├── .github └── FUNDING.yml ├── .gitignore ├── ChangeLog ├── LICENSE ├── README.org ├── moom-font.el ├── moom-transient.el └── moom.el /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: takaxp # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: takaxp # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | README.html 2 | index.html 3 | *.elc 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2021-03-24 Takaaki ISHIKAWA 2 | 3 | * moom-font.el: version 1.6.0 4 | - no changes 5 | 6 | * moom.el: version 1.6.0 7 | - [breaking change] moom-change-frame-width-max is obsoleted 8 | - [breaking change] moom-change-frame-height-max has been removed 9 | - [improve] management of cycle height 10 | - [new] keybindings for moom-fill-width and moom-fill-height 11 | - [new] moom-command-history-length 12 | - [new feature] Undo 13 | 14 | 2021-03-06 Takaaki ISHIKAWA 15 | 16 | * moom-font.el: version 1.5.0 17 | - no changes 18 | 19 | * moom.el: version 1.5.0 20 | - [breaking change] moom-multi-monitors-support is t as default 21 | - [new] moom-use-font-module 22 | - [new] moom-update-user-margin 23 | - [new] moom-cycle-monitors 24 | - [improve] moom-check-user-margin 25 | - [improve] Support Windows 10 and dual monitors 26 | - [improve] Management of local margins in Windows 10 27 | - moom-fill-screen 28 | - moom-fill-width 29 | - moom-fill-height 30 | - [new feature] disable font module by configuration 31 | 32 | 2021-02-11 Takaaki ISHIKAWA 33 | 34 | * moom-font.el: version 1.4.0 35 | - Count up just to sync the version of moom.el 36 | 37 | * moom.el: version 1.4.0 38 | - [breaking change] moom-screen-margin is obsoleted 39 | - [new] moom-change-frame-width-max 40 | - [new] moom-change-frame-height-max 41 | - [new] moom-before-setup-hook 42 | - [new] moom-user-margin 43 | - [new] moom-print-monitors 44 | - [new] moom-jump-to-monitor 45 | - [improve] Disable some hooks when restoring the last status 46 | - [improve] User friendly format to show frame status in mini buffer 47 | - [improve] Keep the current buffer when deleting a window 48 | - [new feature] Support Linux (GTK) and Windows 49 | - [new feature] Support multi monitors on macOS and Windows 10 50 | 51 | 2020-05-31 Takaaki ISHIKAWA 52 | 53 | * moom-font.el: version 1.3.0 54 | - [improve] Detecting fonts with moom-font--extract-family-name 55 | - [improve] moom-font-ja and moom-font-ascii support scale option 56 | 57 | * moom.el: version 1.3.0 58 | - [breaking change] moom-font-init-size is now internal 59 | - [improve] Prevent writing moom status to message buffer 60 | - [improve] Frame will stay in display region when resizing 61 | - [new] moom-fill-height 62 | - [new] moom-split-window 63 | - [new] moom-delete-windows 64 | - [new] moom-split-window-hook 65 | - [new] moom-delete-window-hook 66 | - [new feature] Fit frame to vertical or horizontal center line 67 | - [new] moom-move-frame-to-centerline-from-left 68 | - [new] moom-move-frame-to-centerline-from-right 69 | - [new] moom-move-frame-to-centerline-from-top 70 | - [new] moom-move-frame-to-centerline-from-bottom 71 | - [new feature] Centering for some commands 72 | - moom-command-with-centering controls which command can centering 73 | - [new feature] Support line-number-mode 74 | - moom-display-line-numbers-width controls the default digit 75 | - [update] moom-cycle-frame-height 76 | 77 | 2018-05-18 Takaaki ISHIKAWA 78 | 79 | * moom-font.el: version 1.2.0 80 | - [breaking change] Remove moom-font-ja variable, switched to a function 81 | - [breaking change] Remove moom-font-ascii variable, switched to a function 82 | - [new feature] Support auto detection of the default fonts 83 | - [new] moom-font-ja (as a function) 84 | - [new] moom-font-ascii (as a function) 85 | 86 | * moom.el: version 1.2.0 87 | - [new feature] Support setting of screen margins by moom-screen-margin 88 | - [improve] Calculating frame columns and height lines 89 | - [improve] Calculating frame width and height in pixels 90 | - [improve] Centering frame in Linux and Windows 91 | 92 | 2018-05-06 Takaaki ISHIKAWA 93 | 94 | * moom-font.el: version 1.1.0 95 | - [new] moom-font-table 96 | - [new] moom-font--extract-family-name 97 | - [new] moom-font-print-name-at-point 98 | - [update] moom-font-ja 99 | 100 | * moom.el: version 1.1.0 101 | - [new] moom-fill-band-options 102 | - [new] moom-scaling-gradient 103 | - [new] moom-generate-font-table 104 | - [new] moom-recommended-keybindings 105 | - [update] moom-fill-band 106 | - [update] moom-move-frame-to-center 107 | - [update] moom-print-status 108 | - [update] moom-toggle-font-module 109 | 110 | 2018-04-23 Takaaki ISHIKAWA 111 | 112 | * moom-font.el: version 1.0.0 113 | 114 | * moom.el: version 1.0.0 115 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | #+title: Moom - A Moom port to GNU Emacs 2 | #+startup: showall 3 | 4 | [[https://melpa.org/#/moom][file:https://melpa.org/packages/moom-badge.svg]] 5 | 6 | /Make your dominant hand FREE from your mouse/ :) 7 | 8 | * Setup 9 | 10 | After installing =moom.el= and =moom-font.el= (optional), activate =moom= by =(moom-mode 1)= in your =init.el=. This module requires [[https://www.gnu.org/software/emacs/][GNU Emacs]] *25.1 or later*. 11 | 12 | #+begin_src emacs-lisp 13 | (with-eval-after-load "moom" 14 | ;; add settings here ... 15 | ;; (setq moom-use-font-module nil) 16 | (moom-mode 1)) 17 | #+end_src 18 | 19 | or 20 | 21 | #+begin_src emacs-lisp 22 | (when (require 'moom nil t) 23 | ;; add settings here ... 24 | ;; (setq moom-use-font-module nil) 25 | (moom-mode 1)) 26 | #+end_src 27 | 28 | If you don't want to change font size when resizing frame size, please configure ~moom-use-font-module~ before activating =moom-mode= by ~(moom-mode 1)~. 29 | 30 | #+begin_quote 31 | [!NOTE] 32 | =moom= can display a command list supported by =transient.el=. See [[https://github.com/takaxp/moom?tab=readme-ov-file#transientel-support][transient.el support]] section. 33 | #+end_quote 34 | 35 | * A set of commands to control frame position and size by keyboard 36 | 37 | #+caption: demo for moving and zooming, frame maximized 38 | [[https://github.com/takaxp/contents/blob/master/moom/demo1.gif]] 39 | 40 | Note - This module has basically been tested on macOS High Sierra, Catalina, BigSur, and [[https://www.apple.com/jp/macos/][Monterey]] with combinations of two Full HD (1920x1080) monitors and one 4K monitor. Additionally, tested in Windows 10 and Linux (Ubuntu 20.04 with Emacs 26.3, CentOS 8.2, and openSUSE 15.1) with GTK, but they may still have some issues. 41 | 42 | ** Move 43 | 44 | - moom-move-frame 45 | 46 | *** Horizontal shift 47 | 48 | - moom-move-frame-left 49 | - moom-move-frame-right 50 | 51 | *** Centering 52 | 53 | - moom-move-frame-to-center 54 | - moom-move-frame-to-vertical-center 55 | - moom-move-frame-to-horizontal-center 56 | 57 | ** Fit 58 | 59 | *** edge 60 | 61 | - moom-move-frame-to-edge-top 62 | - moom-move-frame-to-edge-left 63 | - moom-move-frame-to-edge-right 64 | - moom-move-frame-to-edge-bottom 65 | 66 | *** center line 67 | 68 | - moom-move-frame-to-centerline-from-top 69 | - moom-move-frame-to-centerline-from-left 70 | - moom-move-frame-to-centerline-from-right 71 | - moom-move-frame-to-centerline-from-bottom 72 | 73 | ** Expand 74 | 75 | These functions will not change font size in a frame. 76 | 77 | - moom-change-frame-width-single 78 | - moom-change-frame-width-double 79 | - moom-change-frame-width-half-again 80 | - moom-change-frame-width 81 | - moom-change-frame-height 82 | - moom-cycle-frame-height 83 | - moom-change-frame-width-max (moom-fill-width) 84 | - moom-change-frame-height-max (moom-fill-height) 85 | 86 | *** split and delete window 87 | 88 | - moom-split-window 89 | - moom-delete-windows 90 | 91 | ** Fill screen 92 | 93 | These functions normally change font size in a frame. But the behavior can be changed by =M-x moom-toggle-font-module=. 94 | 95 | - moom-fill-screen 96 | - moom-fill-band 97 | - moom-fill-top 98 | - moom-fill-bottom 99 | - moom-fill-left 100 | - moom-fill-right 101 | - moom-fill-top-left 102 | - moom-fill-top-right 103 | - moom-fill-bottom-left 104 | - moom-fill-bottom-right 105 | 106 | Note - If you find any problems around font settings when resizing the Emacs frame, you can easily disable the feature in =moom-font.el=. Just change =moom-use-font-module= to nil in your init.el. =M-x moom-toggle-font-module= can also control if the font module is utilized or not. 107 | 108 | #+begin_src emacs-lisp 109 | (with-eval-after-load "moom" 110 | (setq moom-use-font-module nil)) 111 | #+end_src 112 | 113 | ** Other functions 114 | 115 | - moom-reset 116 | - moom-undo 117 | - moom-update-height-steps 118 | - moom-check-user-margin 119 | - moom-update-user-margin 120 | - moom-identify-current-monitor 121 | - moom-print-monitors 122 | - moom-jump-to-monitor 123 | - moom-cycle-monitors 124 | - moom-restore-last-status 125 | - moom-toggle-font-module 126 | - moom-toggle-frame-maximized 127 | - moom-cycle-line-spacing 128 | - moom-reset-line-spacing 129 | - moom-generate-font-table 130 | - moom-print-status 131 | - moom-version 132 | 133 | (obsoleted) 134 | - moom-screen-margin (was replaced with moom-check-user-margin) 135 | 136 | *** How to setup screen margins 137 | 138 | For macOS users, the default margin is =(23 0 0 0)=. And for other system types, it is also automatically configured using combination of =frame-monitor-geometry= and =frame-monitor-workarea= when =moom-mode= is activated. But the actual work area is probably depends on user environment. Therefore, =moom.el= provides a capability that you can control the actual active region on your screen by setting =moom-user-margin= in init.el. 139 | 140 | #+begin_src emacs-lisp 141 | (setq moom-user-margin '(50 50 50 50)) ;; {top, bottom, left, right} 142 | (moom-mode 1) 143 | #+end_src 144 | 145 | Each value means a margin from the ~top~, ~bottom~, ~left~, and ~right~ edge of your screen. If you want to test some combinations of the margins, then =M-x moom-check-user-margin= could be helpful since it provides an interactive way to check the actual region on a screen and save the tested value for the Emacs session. 146 | 147 | It is also useful to use =moom-update-user-margin= directly by putting new margin or interactively. Note that =moom-check-user-margin= internally calls =moom-update-user-margin=. 148 | 149 | #+begin_src emacs-lisp 150 | (moom-update-user-margin '(50 50 50 50)) ;; {top, bottom, left, right} 151 | #+end_src 152 | 153 | The =moom-check-user-margin= and =moom-update-user-margin= will change =moom-user-margin= in an Emacs session, however, the updated margins will NOT be saved as a permanent value, so please configure the margins in your init.el explicitly for the next session. 154 | 155 | * Extension to integrate font resizing 156 | 157 | No need to load =moom-font.el= explicitly. If the package is installed in your system, then it will be activated automatically. The package is basically provided for the users who rely on Japanese fonts. And if you will never user the font module without deleting =moom-font.el=, please configure =moom-use-font-module= to nil before activating =moom-mode= by =(moom-mode 1)=. 158 | 159 | #+caption: demo for increasing and decreasing fonts, frame maximized 160 | [[https://github.com/takaxp/contents/blob/master/moom/demo2.gif]] 161 | 162 | ** Setting 163 | 164 | Font names for ASCII and Japanese font are now automatically identified without user action when =moom-mode= is activated. But =moom-font-ascii-scale= and =moom-font-ja-scale= should be configured still manually according to your environment. If you don't satisfy the automatically configured setting for ASCII and Japanese font, then please set these parameters manually by functions of =moom-font-ascii= or =moom-font-ja=. 165 | 166 | The default values for =moom-font-ascii-scale= and =moom-font-ja-scale= are =1.0= and =1.2= respectably. The scaling factors for each font are integrated into =face-font-rescale-alist= properly. 167 | 168 | If you don't know which fonts are used in Emacs frame, you can easily check them by ~M-x moom-font-print-name-at-point~ or ~M-x describe-char~ on a character. 169 | 170 | The following text is an example message when you type ~M-x moom-font-print-name-at-point~. 171 | 172 | #+begin_src txt 173 | [moom-font] It’s "Menlo". Call ‘moom-font-ja’ or ‘moom-font-ascii’ with "Menlo". 174 | #+end_src 175 | 176 | After you identify the font names in a buffer, then please configure them as follows: 177 | 178 | #+begin_src emacs-lisp 179 | (with-eval-after-load "moom-font" 180 | (setq moom-font-ascii-scale 1.0) 181 | (setq moom-font-ja-scale 1.2) 182 | (moom-font-ascii "Menlo") ;; Ricty Diminished, Inconsolata 183 | (moom-font-ja "Migu 2M")) ;; Hiragino Maru Gothic Pro 184 | #+end_src 185 | 186 | Normally, ASCII and Japanese fonts will be updated when resizing fonts. But if you provide an optional argument to =moom-font-ascii= or =moom-font-ja=, the given font is immediately applied and reflected in each buffer. See the following example setting. 187 | 188 | #+begin_src emacs-lisp 189 | (with-eval-after-load "moom-font" 190 | (moom-font-ascii "Menlo" '(:immediate t)) 191 | (moom-font-ja "Migu 2M" '(:immediate t))) 192 | #+end_src 193 | 194 | When you find the column exceeds 80 when the frame is maximized, then configure =moom-scaling-gradient= properly. It depends on ASCII font type. For instance, ~1.66~ (default) for Menlo, Monaco, ~2.0~ for Inconsolata, MS Gothic, and TakaoGothic. Please see the following section. 195 | 196 | *** Font table 197 | 198 | You can also use =M-x moom-generate-font-table= to identify appropriate values of =moom-scaling-gradient=, and additionally =moom-font-table=. After calling =moom-generate-font-table=, the current buffer will be changed to the ~*moom-font*~ buffer. Please follow the instructions described in that buffer. 199 | 200 | Here is an example. ~Monaco~ is used for ASCII font and ~Migu 2M~ is used for Japanese font in these images. The upper image shows a gap between strings in ASCII and Japanese at the first line, the font table is not defined in this case. On the other hand, the lower image shows no gap since the font table is utilized to identify the correct size of font. You can freely customize the font table in you init.el for your convenience. 201 | 202 | #+caption: Without font table (Monaco: 13pt 8px) 203 | [[https://github.com/takaxp/contents/blob/master/moom/monaco-13pt8px.png]] 204 | 205 | #+caption: With font table (Monaco: 14pt 8px) 206 | [[https://github.com/takaxp/contents/blob/master/moom/monaco-14pt8px.png]] 207 | 208 | ** Resize font 209 | 210 | - moom-font-increase 211 | - moom-font-decrease 212 | - moom-font-resize 213 | - moom-font-size-reset 214 | 215 | ** Font setting 216 | 217 | - moom-font-ja 218 | - moom-font-ascii 219 | 220 | ** Other functions 221 | 222 | - moom-font-print-name-at-point 223 | 224 | * User variables 225 | ** moom.el 226 | 227 | #+caption: User variables in moom.el 228 | | | default | type | 229 | |--------------------------------------+------------------------------------+---------| 230 | | moom-move-frame-pixel-offset | '(0 . 0) | sexp | 231 | | moom-min-frame-height | 16 | integer | 232 | | moom-init-line-spacing | line-spacing | float | 233 | | moom-min-line-spacing | 0.1 | float | 234 | | moom-max-line-spacing | 0.8 | float | 235 | | moom-frame-width-single | 80 | integer | 236 | | moom-frame-width-double | 163 | integer | 237 | | moom-horizontal-shifts | '(200 200) | choice | 238 | | moom-fill-band-options | '(:direction vertical :range 50.0) | plist | 239 | | moom-scaling-gradient | 1.66 | float | 240 | | moom-moom-display-line-numbers-width | 6 | integer | 241 | | moom-command-with-centering | '(split delete) | list | 242 | | moom-user-margin | '(0 0 0 0) | list | 243 | | moom-use-font-module | t | boolean | 244 | | moom-command-history-length | 100 | integer | 245 | | moom-verbose | nil | boolean | 246 | | moom-lighter | Moom | string | 247 | 248 | *** moom-command-with-centering 249 | 250 | The following commands will centerize the frame position in display if =moom-command-with-centering= includes the corresponding values. If you specify =nil= then no commands will centerize the frame. 251 | 252 | | Value | Command | 253 | |------------+------------------------------------| 254 | | split | moom-split-window | 255 | | delete | moom-delete-windows | 256 | | single | moom-change-frame-width-single | 257 | | double | moom-change-frame-width-double | 258 | | half-again | moom-change-frame-width-half-again | 259 | 260 | ** moom-font.el 261 | 262 | #+caption: User variables in moom-font.el 263 | | | default | type | 264 | |-----------------------+---------+---------------------------------| 265 | | moom-font-ja-scale | 1.2 | float | 266 | | moom-font-ascii-scale | 1.0 | float | 267 | | moom-font-table | nil | (repeat (list integer integer)) | 268 | | moom-font-verbose | nil | boolean | 269 | 270 | Note - *(breaking changes at v1.2.1)* ~moom-font-init-size~ was hidden. The size is now automatically detected. If you want to use customized variable, please use =moom-font-ascii= with ~:size~ option like =(moom-font-ascii "Inconsolata" :size 14)=. 271 | 272 | Note - *(breaking changes at v1.2.0)* Variables of ~moom-font-ascii~ and ~moom-font-ja~ were hidden so that font settings could be controlled conveniently by utility functions. Please utilize each function of the same name to setup fonts. 273 | 274 | ** moom-transient.el 275 | 276 | #+caption: User variables in moom-transient.el 277 | | | default | type | 278 | |--------------------------------+---------+---------| 279 | | moom-transient-dispatch-sticky | t | boolean | 280 | 281 | * Example keybindings 282 | ** Overview 283 | 284 | In general, =Cmd-= is used to switch windows, which is not limited to Emacs.app. So it is natural to concentrate all keybindings associated to control frame position and size into the left side of your keyboard with pressing =Cmd=. The following example keybindings are basically designed in that manner. 285 | 286 | #+caption: Assgined keys 287 | [[https://github.com/takaxp/contents/blob/master/moom/layout.png]] 288 | 289 | You can use =moom-recommended-keybindings= to set keybindings for each API in a bundle. The function require a list argument or =all=. The list can contain multiple API types. When the argument is =(move fit expand fill font reset undo)= , it is identical to =all=. 290 | 291 | #+begin_src emacs-lisp 292 | (with-eval-after-load "moom" 293 | (moom-recommended-keybindings '(move fit expand fill font reset undo))) ;; 'all 294 | #+end_src 295 | 296 | Note: If you don't want to rely on using function key to execute a moom command, then add a =wof= option for =moom-recommended-keybindings= as follows: 297 | 298 | #+begin_src emacs-lisp 299 | (with-eval-after-load "moom" 300 | (moom-recommended-keybindings '(all wof))) ;; wof: WithOut Function key 301 | #+end_src 302 | 303 | | command | without wof | with wof | 304 | |--------------------------------+-------------+-----------| 305 | | moom-move-frame-to-edge-left | M- | C-c e l | 306 | | moom-move-frame-to-edge-right | M- | C-c e r | 307 | | moom-move-frame-to-edge-top | | C-c e t | 308 | | moom-move-frame-to-edge-bottom | S- | C-c e b | 309 | | moom-cycle-frame-height | | C-2 | 310 | | moom-toggle-frame-maximized | M- | C-c f f x | 311 | 312 | ** Move 313 | 314 | [[https://github.com/takaxp/contents/blob/master/moom/shifts.gif]] [[https://github.com/takaxp/contents/blob/master/moom/move-right.gif]] [[https://github.com/takaxp/contents/blob/master/moom/center.gif]] 315 | 316 | #+begin_src emacs-lisp 317 | (with-eval-after-load "moom" 318 | (define-key moom-mode-map (kbd "M-0") 'moom-move-frame) ;; to top left corner 319 | (define-key moom-mode-map (kbd "M-1") 'moom-move-frame-left) 320 | (define-key moom-mode-map (kbd "M-2") 'moom-move-frame-to-center) 321 | (define-key moom-mode-map (kbd "M-3") 'moom-move-frame-right)) 322 | #+end_src 323 | 324 | ** Fit 325 | 326 | [[https://github.com/takaxp/contents/blob/master/moom/edges.gif]] [[https://github.com/takaxp/contents/blob/master/moom/corners.gif]] 327 | 328 | #+begin_src emacs-lisp 329 | (with-eval-after-load "moom" 330 | (define-key moom-mode-map (kbd "M-") 'moom-move-frame-to-edge-left) 331 | (define-key moom-mode-map (kbd "M-") 'moom-move-frame-to-edge-right) 332 | (define-key moom-mode-map (kbd "") 'moom-move-frame-to-edge-top) 333 | (define-key moom-mode-map (kbd "S-") 'moom-move-frame-to-edge-bottom)) 334 | #+end_src 335 | 336 | Additionally, move onto the center line. 337 | 338 | [[https://github.com/takaxp/contents/blob/master/moom/centerline.gif]] 339 | 340 | #+begin_src emacs-lisp 341 | (with-eval-after-load "moom" 342 | (define-key moom-mode-map (kbd "C-c f c l") 'moom-move-frame-to-centerline-from-left) 343 | (define-key moom-mode-map (kbd "C-c f c r") 'moom-move-frame-to-centerline-from-right) 344 | (define-key moom-mode-map (kbd "C-c f c t") 'moom-move-frame-to-centerline-from-top) 345 | (define-key moom-mode-map (kbd "C-c f c b") 'moom-move-frame-to-centerline-from-bottom)) 346 | #+end_src 347 | 348 | ** Expand 349 | [[https://github.com/takaxp/contents/blob/master/moom/cycle-height.gif]] [[https://github.com/takaxp/contents/blob/master/moom/expand.gif]] 350 | 351 | #+begin_src emacs-lisp 352 | (with-eval-after-load "moom" 353 | (define-key moom-mode-map (kbd "") 'moom-cycle-frame-height) 354 | (define-key moom-mode-map (kbd "C-c f s") 'moom-change-frame-width-single) 355 | (define-key moom-mode-map (kbd "C-c f d") 'moom-change-frame-width-double) 356 | (define-key moom-mode-map (kbd "C-c f a") 'moom-change-frame-width-half-again) 357 | (define-key moom-mode-map (kbd "C-c f S") 'moom-split-window) 358 | (define-key moom-mode-map (kbd "C-c f D") 'moom-delete-windows) 359 | (define-key moom-mode-map (kbd "C-c f w") 'moom-change-frame-width-max) 360 | (define-key moom-mode-map (kbd "C-c f h") 'moom-change-frame-height-max)) 361 | #+end_src 362 | 363 | ** Fill 364 | :PROPERTIES: 365 | :ID: 4FF1C514-E9BD-4A98-91B4-916578FB697D 366 | :END: 367 | 368 | [[https://github.com/takaxp/contents/blob/master/moom/fill.gif]] [[https://github.com/takaxp/contents/blob/master/moom/quarters.gif]] 369 | 370 | #+begin_src emacs-lisp 371 | (with-eval-after-load "moom" 372 | (define-key moom-mode-map (kbd "C-c f f t") 'moom-fill-top) 373 | (define-key moom-mode-map (kbd "C-c f f b") 'moom-fill-bottom) 374 | (define-key moom-mode-map (kbd "C-c f f l") 'moom-fill-left) 375 | (define-key moom-mode-map (kbd "C-c f f r") 'moom-fill-right) 376 | (define-key moom-mode-map (kbd "C-c f f 1") 'moom-fill-top-left) 377 | (define-key moom-mode-map (kbd "C-c f f 2") 'moom-fill-top-right) 378 | (define-key moom-mode-map (kbd "C-c f f 3") 'moom-fill-bottom-left) 379 | (define-key moom-mode-map (kbd "C-c f f 4") 'moom-fill-bottom-right) 380 | (define-key moom-mode-map (kbd "C-c f f m") 'moom-fill-band) 381 | ;; (define-key moom-mode-map (kbd "C-c f f w") 'moom-fill-width) 382 | ;; (define-key moom-mode-map (kbd "C-c f f h") 'moom-fill-height) 383 | ) 384 | #+end_src 385 | 386 | ** Fill (screen by toggle) 387 | 388 | [[https://github.com/takaxp/contents/blob/master/moom/fill-screen.gif]] 389 | 390 | #+begin_src emacs-lisp 391 | (with-eval-after-load "moom" 392 | (define-key moom-mode-map (kbd "M-") 'moom-toggle-frame-maximized)) 393 | #+end_src 394 | 395 | Note: When maximizing a frame, =moom-fill-screen= is called internally. 396 | 397 | ** Reset, resize, and undo 398 | *** Reset Frame size, position, and font size 399 | 400 | #+begin_src emacs-lisp 401 | (with-eval-after-load "moom" 402 | (define-key moom-mode-map (kbd "C-c C-0") 'moom-reset)) 403 | #+end_src 404 | 405 | *** Undo command history 406 | 407 | =moom= stores command history. The maximum numbers of the history is limited by =moom-command-history-length=. The default value is 1000. 408 | 409 | #+begin_src emacs-lisp 410 | (with-eval-after-load "moom" 411 | (define-key moom-mode-map (kbd "C-c C-/") 'moom-undo)) 412 | #+end_src 413 | 414 | *** Font size (require moom-font.el) 415 | 416 | #+begin_src emacs-lisp 417 | (with-eval-after-load "moom" 418 | (define-key moom-mode-map (kbd "C--") 'moom-font-decrease) 419 | (define-key moom-mode-map (kbd "C-=") 'moom-font-increase) 420 | (define-key moom-mode-map (kbd "C-0") 'moom-font-size-reset) 421 | (define-key moom-mode-map (kbd "C-_") 'text-scale-decrease) ;; built-in for ascii 422 | (define-key moom-mode-map (kbd "C-+") 'text-scale-increase) ;; built-in for ascii 423 | 424 | ;; Recommended for stable presentation during font size increasing 425 | (add-hook 'moom-font-after-resize-hook #'moom-move-frame-to-edge-top)) 426 | #+end_src 427 | 428 | * transient.el support 429 | :PROPERTIES: 430 | :ID: 3D063E56-C322-4214-B600-733D3B9225B1 431 | :END: 432 | 433 | =moom-transient.el= provides a dispatcher to select a moom command listed in a popup menu. To use =moom-transient.el=, please put the following code (below the figure) to your init.el. The keybind =(C-c o)= should be changed for your environment. The module depends on [[https://github.com/magit/transient][transient.el]], so please install it first. 434 | 435 | #+caption: A dispatcher to select a moom command powered by transient.el 436 | [[https://github.com/takaxp/contents/blob/master/moom/transient.png]] 437 | 438 | #+begin_src emacs-lisp 439 | (with-eval-after-load "moom" 440 | (when (require 'moom-transient nil t) 441 | (moom-transient-hide-cursor) ;; if needed 442 | (define-key moom-mode-map (kbd "C-c o") #'moom-transient-dispatch))) 443 | #+end_src 444 | 445 | The dispatcher (=moom-transient-dispatch=) keeps the menu window after a command is executed as default. If you like to hide the dispatcher each time, then please configure =moom-transient-dispatch-sticky=. 446 | 447 | * Collaboration with other packages 448 | ** Org mode (org-agenda) 449 | 450 | Expand the frame width temporarily during org-agenda is active. 451 | 452 | [[https://github.com/takaxp/contents/blob/master/moom/org-agenda.gif]] 453 | 454 | #+begin_src emacs-lisp 455 | (with-eval-after-load "moom" 456 | (with-eval-after-load "org" 457 | (add-hook 'org-agenda-mode-hook #'moom-change-frame-width-half-again) 458 | (defun advice:org-agenda--quit (&optional _bury) 459 | (moom-change-frame-width)) 460 | (advice-add 'org-agenda--quit :after #'advice:org-agenda--quit))) 461 | #+end_src 462 | 463 | ** Org mode (org-tree-slide) 464 | :PROPERTIES: 465 | :ID: 14AA17BD-897D-460F-A1E6-585E864830C2 466 | :END: 467 | 468 | Entering quickly to the frame maximized presentation with [[https://github.com/takaxp/org-tree-slide][org-tree-slide.el]]. No additional settings are required except activating moom-mode by =(moom-mode 1)=. Just =M-x moom-toggle-frame-maximized=. The font is automatically scaled to be maintained the frame width at 80 even if you use Japanese font. 469 | 470 | [[https://github.com/takaxp/contents/blob/master/moom/org-tree-slide.gif]] 471 | 472 | ** Org mode 473 | 474 | Note - /Under consideration, but you can try./ 475 | 476 | Run =org-redisplay-inline-images= after font resizing to synchronize the image width and font size automatically. 477 | 478 | #+begin_src emacs-lisp 479 | (with-eval-after-load "moom" 480 | (with-eval-after-load "org" 481 | (add-hook 'moom-font-after-resize-hook #'org-redisplay-inline-images))) 482 | #+end_src 483 | 484 | * Hooks 485 | 486 | - moom-before-fill-screen-hook 487 | - moom-after-fill-screen-hook 488 | - moom-resize-frame-height-hook 489 | - moom-split-window-hook 490 | - moom-delete-window-hook 491 | - moom-before-setup-hook 492 | - moom-after-select-monitor-hook 493 | - moom-font-before-resize-hook (in moom-font.el) 494 | - moom-font-after-resize-hook (in moom-font.el) 495 | 496 | * Acknowledgment 497 | 498 | This package is highly inspired from [[https://manytricks.com/moom/]["Moom"]] released by [[https://manytricks.com/][Many Tricks]]. Moom stands for "Mo"ve and zo"om". Cool! 499 | 500 | If you like and need the capabilities of changing window position and size by keyboard at the OS level, buy [[https://manytricks.com/moom/][Moom]] now! 501 | 502 | ** Keycastr 503 | 504 | For writing README, [[https://github.com/keycastr/keycastr][keycastr]] was utilized to capture keystrokes of each command. Thanks! but ~Shift+F1~ was recorded as ~?~. Haha... :p 505 | 506 | * Related packages 507 | 508 | 1) [[https://www.emacswiki.org/emacs/frame-cmds.el][frame-cmds.el]] 509 | - This package provides many fundamental APIs to control frame and window. If you want to control them more specifically and precisely, you may want to try this nice package. But the license is not open and not distributed through MELPA. 510 | 2) [[https://github.com/zonuexe/emacs-presentation-mode][presentation.el]] 511 | - It is highly recommended to try this vital package to scale and restore text size easily for nice viewing when you present your source code rendered in the Emacs buffers. Find more details at the above repository. 512 | -------------------------------------------------------------------------------- /moom-font.el: -------------------------------------------------------------------------------- 1 | ;;; moom-font.el --- A module for resizing Japanese fonts for Moom -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2017-2025 Takaaki ISHIKAWA 4 | 5 | ;; Author: Takaaki ISHIKAWA 6 | ;; Keywords: frames, faces, convenience 7 | ;; Version: 1.4.3 8 | ;; Maintainer: Takaaki ISHIKAWA 9 | ;; URL: https://github.com/takaxp/Moom 10 | ;; Twitter: @takaxp 11 | 12 | ;; This program is free software: you can redistribute it and/or modify 13 | ;; it under the terms of the GNU General Public License as published by 14 | ;; the Free Software Foundation; either version 3 of the License, or 15 | ;; (at your option) any later version. 16 | 17 | ;; This program is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with GNU Emacs; see the file COPYING. If not, write to the 24 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 25 | ;; Boston, MA 02110-1301, USA. 26 | 27 | ;;; Commentary: 28 | 29 | ;; This package is an additional module for Moom.el 30 | 31 | ;;; Change Log: 32 | 33 | ;;; Code: 34 | (eval-when-compile 35 | (require 'cl-lib)) 36 | 37 | (defcustom moom-font-ja-scale 1.2 38 | "The default value to scale JP fonts." 39 | :type 'float 40 | :group 'moom) 41 | 42 | (defcustom moom-font-ascii-scale 1.0 43 | "The default value to scale ASCII fonts." 44 | :type 'float 45 | :group 'moom) 46 | 47 | (defcustom moom-font-table nil 48 | "Font table." 49 | :type '(repeat (list (integer :tag "Font size in point") 50 | (integer :tag "Font width in pixels"))) 51 | :group 'moom) 52 | 53 | (defcustom moom-font-verbose nil 54 | "Show responses from `moom`." 55 | :type 'boolean 56 | :group 'moom) 57 | 58 | (defcustom moom-font-before-resize-hook nil 59 | "Hook runs before resizing font size." 60 | :type 'hook 61 | :group 'moom) 62 | 63 | (defcustom moom-font-after-resize-hook nil 64 | "Hook runs after resizing font size." 65 | :type 'hook 66 | :group 'moom) 67 | 68 | (defvar moom-font--init-size 12 69 | "The default value to set font size.") 70 | (defvar moom-font--size moom-font--init-size 71 | "Current font size.") 72 | (defvar moom-font--pause nil) 73 | (defvar moom-font--ascii nil) 74 | (defvar moom-font--ja nil) 75 | 76 | (defun moom-font--update-rescale-alist (key value) 77 | "Update `face-font-rescale-alist'. 78 | If KEY exists in `face-font-rescale-alist', delete it before updating the list. 79 | VALUE is a new value to re-scale the font in KEY." 80 | (setq face-font-rescale-alist 81 | (delete (assoc key face-font-rescale-alist) face-font-rescale-alist)) 82 | (add-to-list 'face-font-rescale-alist `(,key . ,value))) 83 | 84 | (defun moom-font--change-size (&optional arg) 85 | "Core function to change font size. 86 | If `ARG' is nil, the default size is used." 87 | (unless moom-font--pause 88 | (when arg 89 | (setq moom-font--size arg)) 90 | (moom-font--update-rescale-alist 91 | (concat ".*" moom-font--ja ".*") moom-font-ja-scale) 92 | (moom-font--update-rescale-alist 93 | (concat ".*" moom-font--ascii ".*") moom-font-ascii-scale) 94 | (let ((spec (font-spec :family moom-font--ja 95 | :size moom-font--size))) 96 | (set-fontset-font nil 'japanese-jisx0208 spec) 97 | (set-fontset-font nil 'katakana-jisx0201 spec) 98 | (set-fontset-font nil 'japanese-jisx0212 spec) 99 | (set-fontset-font nil '(#x0080 . #x024F) spec) 100 | (set-fontset-font nil '(#x0370 . #x03FF) spec) 101 | (set-fontset-font nil 'mule-unicode-0100-24ff spec)) 102 | (set-fontset-font nil 'ascii 103 | (font-spec :family moom-font--ascii 104 | :size moom-font--size)))) 105 | 106 | (defun moom-font--extract-font-size (xlfd) 107 | "Try to identify the font size. 108 | Return an integer value extracted from XLFD if possible, otherwise return nil." 109 | (when (stringp xlfd) 110 | (let ((size 111 | (string-to-number 112 | (if (string-match 113 | "^-[^-]+-[^-]+-[^-]+-[^-]+-[^-]+-[^-]+-\\([^-]+\\)-.*$" xlfd) 114 | (match-string 1 xlfd) "0")))) 115 | (if (> size 0) size nil)))) 116 | 117 | (defun moom-font--extract-family-name (xlfd) 118 | "Try to identify the font name. 119 | Return a font name extracted from XLFD if possible, otherwise return nil." 120 | (when (stringp xlfd) 121 | (let* ((name (when (string-match "^-[^-]+-\\([^-]+\\)-.*$" xlfd) 122 | (match-string 1 xlfd)))) 123 | (if (and name (x-list-fonts name)) name nil)))) 124 | 125 | (defun moom-font--find-size (width table) 126 | "Return font size associated with WIDTH by looking up the TABLE." 127 | (when table 128 | (car (rassoc (list width) table)))) 129 | 130 | (defun moom-font--find-width (size table) 131 | "Return font width associated with SIZE by looking up the TABLE." 132 | (when table 133 | (cdr (assoc size table)))) 134 | 135 | (defun moom-font--generate-font-table (&optional begin end) 136 | "Generate a font table. 137 | If BEGIN is nil, use 5 as the default value. 138 | If END is nil, use 50 as the default value." 139 | (let ((moom-font-table nil)) 140 | (cl-loop 141 | for pt from (or begin 5) to (or end 50) 142 | do 143 | (moom-font-resize pt) 144 | (push (list moom-font--size (frame-char-width)) moom-font-table)) 145 | (let ((buffer "*moom-font*")) 146 | (with-current-buffer (get-buffer-create buffer) 147 | (erase-buffer) 148 | (insert ";; 1. M-x eval-buffer\n") 149 | (insert ";; 2. Paste the following configurations into your init.el.\n") 150 | (insert "(with-eval-after-load \"moom-font\"\n") 151 | (insert (format " (setq moom-scaling-gradient (/ (float %d) %d))\n" 152 | (nth 0 (car moom-font-table)) 153 | (nth 1 (car moom-font-table)))) 154 | (insert (format " (setq moom-font-table (quote %s)))" moom-font-table)) 155 | (goto-char 0) 156 | (switch-to-buffer buffer))))) 157 | 158 | (defun moom-font--font-exists-p (font-family) 159 | "Check given FONT-FAMILY exists." 160 | (when window-system 161 | (let ((result (and (fboundp 'x-list-fonts) 162 | (x-list-fonts font-family)))) 163 | (if result 164 | (when moom-font-verbose 165 | (message "[moom-font] \"%s\" is available." font-family)) 166 | (warn "[moom-font] \"%s\" is NOT installed in your system." 167 | font-family)) 168 | result))) 169 | 170 | ;;;###autoload 171 | (defun moom-font-ascii (font &optional plist) 172 | "Set ASCII font family by given FONT. 173 | If PLIST is non-nil and it has immediate property, 174 | given FONT is immediately applied." 175 | (when (moom-font--font-exists-p font) 176 | (setq moom-font--ascii font) 177 | (let ((font-size (plist-get plist :size))) 178 | (when font-size 179 | (setq moom-font--size font-size))) 180 | (let ((rescale (plist-get plist :scale))) 181 | (when rescale 182 | (setq moom-font-ascii-scale rescale))) 183 | (when (plist-get plist :immediate) 184 | (run-hooks 'moom-font-before-resize-hook) 185 | (moom-font--change-size) 186 | (run-hooks 'moom-font-after-resize-hook)))) 187 | 188 | ;;;###autoload 189 | (defun moom-font-ja (font &optional plist) 190 | "Set Japanese font family by given FONT. 191 | If PLIST is non-nil and it has immediate property, 192 | given FONT is immediately applied." 193 | (when (moom-font--font-exists-p font) 194 | (setq moom-font--ja font) 195 | (let ((rescale (plist-get plist :scale))) 196 | (when rescale 197 | (setq moom-font-ja-scale rescale))) 198 | (when (plist-get plist :immediate) 199 | (moom-font--change-size)))) 200 | 201 | ;;;###autoload 202 | (defun moom-font-resize (&optional n width) 203 | "Resize font. 204 | `frame-width' will be updated accordingly. 205 | Optional argument N specifies the target font size. 206 | If WIDTH is non-nil, ensure an appropriate font size so that 207 | the actual pixel width will not exceed the WIDTH." 208 | ;;(interactive "nSize: ") 209 | (interactive (list 210 | (read-number 211 | "Size: " moom-font--size))) 212 | (run-hooks 'moom-font-before-resize-hook) 213 | (unless moom-font--pause 214 | (moom-font--change-size 215 | (setq moom-font--size (or n moom-font--init-size))) 216 | (when (and width 217 | (< width (frame-pixel-width))) 218 | (when moom-font-verbose 219 | (message "[moom-font] Font size is changed from %s to %s." 220 | moom-font--size (1- moom-font--size))) 221 | (moom-font--change-size 222 | (setq moom-font--size (1- moom-font--size)))) 223 | (when moom-font-verbose 224 | (message "[moom-font] %s" moom-font--size))) 225 | (run-hooks 'moom-font-after-resize-hook)) 226 | 227 | ;;;###autoload 228 | (defun moom-font-size-reset () 229 | "Reset font to the initial size." 230 | (interactive) 231 | (run-hooks 'moom-font-before-resize-hook) 232 | (moom-font--change-size 233 | (setq moom-font--size moom-font--init-size)) 234 | (when moom-font-verbose 235 | (message "[moom-font] %s" moom-font--size)) 236 | (run-hooks 'moom-font-after-resize-hook)) 237 | 238 | ;;;###autoload 239 | (defun moom-font-increase (&optional inc) 240 | "Increase font size. 241 | Optional argument INC specifies an increasing step." 242 | (interactive) 243 | (run-hooks 'moom-font-before-resize-hook) 244 | (unless moom-font--pause 245 | (setq moom-font--size 246 | (+ moom-font--size 247 | (if (and (integerp inc) (> inc 0)) 248 | inc 1))) 249 | (moom-font--change-size moom-font--size) 250 | (when moom-font-verbose 251 | (message "[moom-font] +%d: %s" 252 | (if (integerp inc) inc 1) moom-font--size))) 253 | (run-hooks 'moom-font-after-resize-hook)) 254 | 255 | ;;;###autoload 256 | (defun moom-font-decrease (&optional dec) 257 | "Decrease font size. 258 | Optional argument DEC specifies a decreasing step." 259 | (interactive) 260 | (run-hooks 'moom-font-before-resize-hook) 261 | (unless moom-font--pause 262 | (setq moom-font--size 263 | (- moom-font--size 264 | (if (and (integerp dec) 265 | (> dec 0) 266 | (> moom-font--size dec)) 267 | dec 1))) 268 | (when (< moom-font--size 1) 269 | (setq moom-font--size 1)) 270 | (when (and moom-font-verbose 271 | (> moom-font--size 0)) 272 | (message "[moom-font] -%d: %s" 273 | (if (integerp dec) dec 1) moom-font--size)) 274 | (moom-font--change-size moom-font--size)) 275 | (run-hooks 'moom-font-after-resize-hook)) 276 | 277 | ;;;###autoload 278 | (defun moom-font-print-name-at-point () 279 | "Print font family name at point." 280 | (interactive) 281 | (if (eq (point) (point-max)) 282 | (message "[moom-font] Not on a character. Move cursor, and try again.") 283 | (let* ((xlfd-name (font-xlfd-name (font-at (point)))) 284 | (family-name (moom-font--extract-family-name xlfd-name))) 285 | (if family-name 286 | (message 287 | "[moom-font] It's \"%s\", %s[pt].\n[moom-font] Call `moom-font-ja' or `moom-font-ascii' with \"%s\"." 288 | family-name moom-font--size family-name) 289 | (message 290 | "[moom-font] Failed to detect the font family name from \"%s\"." 291 | xlfd-name))))) 292 | 293 | ;; init 294 | (when (and window-system 295 | (fboundp 'x-list-fonts)) 296 | (let* ((default-font (face-font 'default nil ?A)) 297 | (size 298 | (moom-font--extract-font-size default-font)) 299 | (ja-font 300 | (moom-font--extract-family-name (face-font 'default nil ?あ))) 301 | (ascii-font 302 | (moom-font--extract-family-name default-font))) 303 | (when size 304 | (setq moom-font--size 305 | (setq moom-font--init-size size))) 306 | ;; Apply font if found. Otherwise, use the default ASCII or Japanese font. 307 | (if ja-font 308 | (moom-font-ja ja-font) 309 | (cond ((memq window-system '(ns mac)) 310 | (moom-font-ja "Osaka")) 311 | ((eq window-system 'w32) 312 | (moom-font-ja "MS ゴシック" '(:size 1.0))) 313 | ((eq window-system 'x) 314 | (moom-font-ja "TakaoGothic" '(:size 1.0))))) 315 | (if ascii-font 316 | (moom-font-ascii ascii-font) 317 | (cond ((memq window-system '(ns mac)) 318 | (moom-font-ascii "Monaco")) 319 | ((eq window-system 'w32) 320 | (moom-font-ascii "MS ゴシック")) 321 | ((eq window-system 'x) 322 | (moom-font-ascii "TakaoGothic")))))) 323 | 324 | (provide 'moom-font) 325 | 326 | ;;; moom-font.el ends here 327 | -------------------------------------------------------------------------------- /moom-transient.el: -------------------------------------------------------------------------------- 1 | ;;; moom-transient.el --- Moom command dispatcher by transient -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2022-2025 Takaaki ISHIKAWA 4 | 5 | ;; Author: Takaaki ISHIKAWA 6 | ;; Keywords: frames, faces, convenience 7 | ;; Version: 0.9.8 8 | ;; Maintainer: Takaaki ISHIKAWA 9 | ;; URL: https://github.com/takaxp/Moom 10 | ;; Package-Requires: ((emacs "25.1") (transient "0.3.7")) 11 | ;; Twitter: @takaxp 12 | 13 | ;; This program is free software: you can redistribute it and/or modify 14 | ;; it under the terms of the GNU General Public License as published by 15 | ;; the Free Software Foundation; either version 3 of the License, or 16 | ;; (at your option) any later version. 17 | 18 | ;; This program is distributed in the hope that it will be useful, 19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | ;; GNU General Public License for more details. 22 | 23 | ;; You should have received a copy of the GNU General Public License 24 | ;; along with GNU Emacs; see the file COPYING. If not, write to the 25 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 26 | ;; Boston, MA 02110-1301, USA. 27 | 28 | ;;; Commentary: 29 | 30 | ;; This package provides an example of moom command dispatcher powered 31 | ;; by transient.el (see https://github.com/magit/transient). 32 | ;; 33 | ;; To use this package, put the following code to your init.el. 34 | ;; (with-eval-after-load "moom" 35 | ;; (when (require 'moom-transient nil t) 36 | ;; (moom-transient-hide-cursor) ;; if needed 37 | ;; (define-key moom-mode-map (kbd "C-c o") #'moom-transient-dispatch))) 38 | 39 | ;;; Change Log: 40 | 41 | ;;; Code: 42 | 43 | (require 'moom) 44 | (require 'transient) 45 | 46 | (defcustom moom-transient-dispatch-sticky t 47 | "If Non-nil, keep showing the dispatcher right after executing a command. 48 | This option is used in `moom-transient-dispatch'." 49 | :type 'boolean 50 | :group 'moom) 51 | 52 | (defvar moom-transient--last-command nil) 53 | (defun moom-transient--dispatch-description () 54 | "Update description about executed command." 55 | (let ((prompt "[moom] Last Command: ") 56 | (command (symbol-name this-command))) 57 | (if (eq 0 (string-match "^moom-" command)) 58 | (setq moom-transient--last-command 59 | (format "%s%s" 60 | (propertize prompt 'face 'font-lock-type-face) 61 | (propertize command 'face 'bold))) 62 | moom-transient--last-command))) 63 | 64 | (defun moom-transient--insert-groups () 65 | "Enable to shrink a frame horizontally." 66 | (setq window-size-fixed nil)) 67 | (advice-add 'transient--insert-groups :after #'moom-transient--insert-groups) 68 | 69 | (defun moom-transient--hide-cursor (f) 70 | "An advice to F for hiding cursor in transient buffer." 71 | (let ((transient-enable-popup-navigation nil)) 72 | (funcall f))) 73 | 74 | (defun moom-transient--do-stay () 75 | "Return a status for 'transient-suffix." 76 | (if moom-transient-dispatch-sticky 'transient--do-stay nil)) 77 | 78 | (defun moom-transient--font-module-status () 79 | "Return whether `moom-module' is activating or not." 80 | (format "%s" (if moom--font-module-p 81 | (propertize "on" 'face 'font-lock-type-face) 82 | (propertize "off" 'face 'font-lock-warning-face)))) 83 | 84 | (defun moom-transient--font-module-status-description () 85 | "Update description on whether `moom-font' is activating or not." 86 | (format "%s%s%s" 87 | (propertize "Fill (font resizing: " 'face 'transient-heading) 88 | (moom-transient--font-module-status) 89 | (propertize ")" 'face 'transient-heading))) 90 | 91 | (defun moom-transient--font-api-status-description () 92 | "Update description on whether font api is available." 93 | (format "%s%s" 94 | (propertize "Font " 'face 'transient-heading) 95 | (if moom--font-module-p 96 | "" 97 | (concat 98 | (propertize "(" 'face 'transient-heading) 99 | (propertize "disabled" 'face 'font-lock-warning-face) 100 | (propertize ")" 'face 'transient-heading))))) 101 | 102 | ;;;###autoload (autoload 'moom-transient-dispatch "moom-transient" nil t) 103 | (transient-define-prefix moom-transient-dispatch () 104 | "Command list of `moom'." 105 | :transient-suffix 'moom-transient--do-stay 106 | [:description 107 | moom-transient--dispatch-description 108 | ["Move" 109 | ("0" "top-left" moom-move-frame) 110 | ("1" "left" moom-move-frame-left) 111 | ("2" "center" moom-move-frame-to-center) 112 | ("3" "right" moom-move-frame-right) 113 | ("4" "center (hol)" moom-move-frame-to-horizontal-center) 114 | ("5" "center (ver)" moom-move-frame-to-vertical-center)] 115 | ["Expand" 116 | ("s" "single" moom-change-frame-width-single) 117 | ("d" "double" moom-change-frame-width-double) 118 | ("a" "3/2" moom-change-frame-width-half-again) 119 | ("w" "width (full)" moom-fill-width) 120 | ("h" "height (full)" moom-fill-height) 121 | ("H" "height (cycle)" moom-cycle-frame-height)] 122 | ["Fit (edge)" 123 | ("e l" "edge left" moom-move-frame-to-edge-left) 124 | ("e r" "edge right" moom-move-frame-to-edge-right) 125 | ("e t" "edge top" moom-move-frame-to-edge-top) 126 | ("e b" "edge bottom" moom-move-frame-to-edge-bottom)] 127 | ["Fit (center)" 128 | ("c l" "center left" moom-move-frame-to-centerline-from-left) 129 | ("c r" "center right" moom-move-frame-to-centerline-from-right) 130 | ("c t" "center top" moom-move-frame-to-centerline-from-top) 131 | ("c b" "center bottom" moom-move-frame-to-centerline-from-bottom)]] 132 | [:description 133 | moom-transient--font-module-status-description 134 | [("f 1" "top-left" moom-fill-top-left) 135 | ("f 2" "top-right" moom-fill-top-right) 136 | ("f 3" "bottom-left" moom-fill-bottom-left) 137 | ("f 4" "bottom-right" moom-fill-bottom-right)] 138 | [("f l" "left" moom-fill-left) 139 | ("f r" "right" moom-fill-right) 140 | ("f t" "top" moom-fill-top) 141 | ("f b" "bottom" moom-fill-bottom)] 142 | [("f s" "screen" moom-fill-screen) 143 | ("f m" "band" moom-fill-band) 144 | "" 145 | ("F" "toggle font resizing" moom-transient-toggle-font-module)]] 146 | [["Monitors" 147 | ;; ("m j" "monitor jump" moom-jump-to-monitor) 148 | ("m c" "monitor cycle" moom-cycle-monitors) 149 | ("m p" "monitor print" moom-print-monitors)] 150 | ["Window" 151 | ("S" "split" moom-split-window) 152 | ("D" "delete" moom-delete-windows)] 153 | [:description 154 | moom-transient--font-api-status-description 155 | :if (lambda () moom--font-module-p) 156 | ("=" "increase" moom-font-increase) 157 | ("-" "decrease" moom-font-decrease) 158 | ("R" "reset" moom-font-size-reset)] 159 | ["Utilities" 160 | ("r" "reset" moom-reset) 161 | ("u" "undo" moom-undo) 162 | ("p" "print" moom-print-status)] 163 | ["" 164 | ("C" "config" moom-transient-config) 165 | ("v" "version" moom-transient-version) 166 | ("q" "quit" transient-quit-all)]]) 167 | 168 | ;;;###autoload (autoload 'moom-transient-config "moom-transient" nil t) 169 | (transient-define-prefix moom-transient-config () 170 | "Command list of `moom' configuration." 171 | ["[moom] Configuration" 172 | [("t" "generate font table" moom-generate-font-table) 173 | ("c" "check margin" moom-check-user-margin) 174 | ("p" "print font name" moom-font-print-name-at-point) 175 | ("D" "dispatch" moom-transient-dispatch) 176 | ("q" "quit" transient-quit-all)]]) 177 | 178 | ;;;###autoload 179 | (defun moom-transient-toggle-font-module () 180 | "Call `moom-toggle-font-module' with `moom-transient-dispatch'." 181 | (interactive) 182 | (moom-toggle-font-module) 183 | (call-interactively 'moom-transient-dispatch)) 184 | 185 | ;;;###autoload 186 | (defun moom-transient-hide-cursor () 187 | "Hide cursor in transient buffer." 188 | (advice-add 'moom-transient-config :around #'moom-transient--hide-cursor) 189 | (advice-add 'moom-transient-dispatch :around #'moom-transient--hide-cursor)) 190 | 191 | ;;;###autoload 192 | (defun moom-transient-version () 193 | "Printing version of `moom' and `moom-transient'." 194 | (interactive) 195 | (let ((alpha "0.9.8")) 196 | (message "%s" (concat (moom-version) "\n" "[Moom-transient] v" alpha)))) 197 | 198 | (provide 'moom-transient) 199 | 200 | ;;; moom-transient.el ends here 201 | -------------------------------------------------------------------------------- /moom.el: -------------------------------------------------------------------------------- 1 | ;;; moom.el --- Commands to control frame position and size -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2017-2023 Takaaki ISHIKAWA 4 | 5 | ;; Author: Takaaki ISHIKAWA 6 | ;; Keywords: frames, faces, convenience 7 | ;; Version: 1.6.9 8 | ;; Maintainer: Takaaki ISHIKAWA 9 | ;; URL: https://github.com/takaxp/Moom 10 | ;; Package-Requires: ((emacs "25.1")) 11 | ;; Twitter: @takaxp 12 | 13 | ;; This program is free software: you can redistribute it and/or modify 14 | ;; it under the terms of the GNU General Public License as published by 15 | ;; the Free Software Foundation; either version 3 of the License, or 16 | ;; (at your option) any later version. 17 | 18 | ;; This program is distributed in the hope that it will be useful, 19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | ;; GNU General Public License for more details. 22 | 23 | ;; You should have received a copy of the GNU General Public License 24 | ;; along with GNU Emacs; see the file COPYING. If not, write to the 25 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 26 | ;; Boston, MA 02110-1301, USA. 27 | 28 | ;;; Commentary: 29 | 30 | ;; This package provides a set of commands to control frame position and size. 31 | ;; The font size in buffers will be changed with synchronization of the updated 32 | ;; frame geometry so that the frame width could be maintained at 80 as default. 33 | ;; 34 | ;; Now make your dominant hand FREE from your mouse by Moom. 35 | ;; 36 | ;; Install: 37 | ;; - Get moom.el and moom-font.el from MELPA or GitHub. 38 | ;; 39 | ;; Setup: 40 | ;; - After installing, activate Moom by (moom-mode 1) in your init.el. 41 | ;; 42 | ;; Keybindings: 43 | ;; - The moom-mode-map is available. 44 | ;; - To see more details and examples, go https://github.com/takaxp/moom. 45 | ;; 46 | 47 | ;;; Change Log: 48 | 49 | ;;; Code: 50 | 51 | (eval-when-compile 52 | (require 'cl-lib) 53 | (require 'moom-font nil t)) 54 | 55 | (defgroup moom nil 56 | "Commands to control frame position and size." 57 | :group 'convenience) 58 | 59 | (defcustom moom-move-frame-pixel-offset '(0 . 0) 60 | "Offset of the center position." 61 | :type 'sexp 62 | :group 'moom) 63 | 64 | (defcustom moom-min-frame-height 16 65 | "The minimum height." 66 | :type 'integer 67 | :group 'moom) 68 | 69 | (defcustom moom-init-line-spacing line-spacing 70 | "The default value to set ‘line-spacing’." 71 | :type 'float 72 | :group 'moom) 73 | 74 | (defcustom moom-min-line-spacing 0.1 75 | "The minimum value for line spacing." 76 | :type 'float 77 | :group 'moom) 78 | 79 | (defcustom moom-max-line-spacing 0.8 80 | "The maximum value for line spacing." 81 | :type 'float 82 | :group 'moom) 83 | 84 | (defcustom moom-frame-width-single 80 85 | "The width of the current frame as the default value." 86 | :type 'integer 87 | :group 'moom) 88 | 89 | (defcustom moom-frame-width-double (+ (* 2 moom-frame-width-single) 3) 90 | "The width of the current frame (double size)." 91 | :type 'integer 92 | :group 'moom) 93 | 94 | (defcustom moom-horizontal-shifts '(200 200) 95 | "Distance to move the frame horizontally." 96 | :type '(choice (integer :tag "Common value for left and right") 97 | (list (integer :tag "Value for left") 98 | (integer :tag "Value for right"))) 99 | :group 'moom) 100 | 101 | (defcustom moom-fill-band-options '(:direction vertical :range 50.0) 102 | "Band direction and range to fill screen. 103 | If DIRECTION is horizontal, the frame height is limited based on RANGE. 104 | If it is vertical, then the frame width will be limited based on RANGE. 105 | If the type of RANGE is float, range is calculated in percent. 106 | Note that even if DIRECTION is vertical and RANGE is 100.0, the screen 107 | may not be covered entirely because this package prioritize keeping 108 | the column at `moom-frame-width-single'. Instead, if the value is integer, 109 | the screen will be covered precisely by the specified value in pixels. 110 | :direction symbol, horizontal or vertical 111 | :range float(%) or integer(px)." 112 | :type 'plist 113 | :group 'moom) 114 | 115 | (defcustom moom-scaling-gradient (/ 5.0 3) 116 | "Gradient factor between font size and actual font pixel width. 117 | This parameter is used to calculate the font pixel width when resizing 118 | the frame width to keep the column 80. It depends on Font. 119 | For instance, 120 | 1.66 or (5.0/3.0) : Menlo, Monaco 121 | 2.00 or (5.0/2.5) : Inconsolata 122 | ." 123 | :type 'float 124 | :group 'moom) 125 | 126 | (defcustom moom-display-line-numbers-width 6 127 | "Width to expand the frame for function `global-display-line-numbers-mode'. 128 | For function `display-line-numbers-mode', 129 | - set this variable to 0, and also 130 | - set `moom-frame-width-single' more than 80 (e.g. 86)" 131 | :group 'moom 132 | :type 'integer) 133 | 134 | (defcustom moom-command-with-centering '(split delete) 135 | "List of flags. 136 | It specifies whether centerize the frame after changing the frame width." 137 | :type '(repeat 138 | (choice 139 | (const :tag "Split window" :value split) 140 | (const :tag "Delete windows" :value delete) 141 | (const :tag "Change frame width single" :value single) 142 | (const :tag "Change frame width double" :value double) 143 | (const :tag "Change frame width half again" :value half-again))) 144 | :group 'moom) 145 | 146 | (defcustom moom-user-margin '(0 0 0 0) 147 | "User specified margin to adjust to the local environment." 148 | :type '(list (integer :tag "Top margin") 149 | (integer :tag "Bottom margin") 150 | (integer :tag "Left margin") 151 | (integer :tag "Right margin")) 152 | :group 'moom) 153 | 154 | (defcustom moom-use-font-module t 155 | "If nil, font module will not integrated even if the module is available. 156 | Configure this variable before activating moom mode. 157 | `moom-toggle-font-module' could be also useful." 158 | :type 'boolean 159 | :group 'moom) 160 | 161 | (defcustom moom-command-history-length 100 162 | "Number of commands to remember in history." 163 | :type 'integer 164 | :group 'moom) 165 | 166 | (defcustom moom-verbose nil 167 | "Show responses from \"moom\"." 168 | :type 'boolean 169 | :group 'moom) 170 | 171 | (defcustom moom-lighter "Moom" 172 | "Package name in mode line." 173 | :type 'string 174 | :group 'moom) 175 | 176 | (defcustom moom-before-fill-screen-hook nil 177 | "Hook runs before changing to frame maximized." 178 | :type 'hook 179 | :group 'moom) 180 | 181 | (defcustom moom-after-fill-screen-hook nil 182 | "Hook runs after changing to frame maximized." 183 | :type 'hook 184 | :group 'moom) 185 | 186 | (defcustom moom-resize-frame-height-hook nil 187 | "Hook runs after resizing the frame height." 188 | :type 'hook 189 | :group 'moom) 190 | 191 | (defcustom moom-split-window-hook nil 192 | "Hook runs after splitting window horizontally." 193 | :type 'hook 194 | :group 'moom) 195 | 196 | (defcustom moom-delete-window-hook nil 197 | "Hook runs after deleting window horizontally." 198 | :type 'hook 199 | :group 'moom) 200 | 201 | (defcustom moom-before-setup-hook nil 202 | "Hook runs before enabling this package." 203 | :type 'hook 204 | :group 'moom) 205 | 206 | (defcustom moom-after-reset-hook nil 207 | "Hook runs after reset of internal parameters." 208 | :type 'hook 209 | :group 'moom) 210 | 211 | (defcustom moom-after-select-monitor-hook nil 212 | "Hook runs after selecting and jumping to a monitor." 213 | :type 'hook 214 | :group 'moom) 215 | 216 | (defvar moom-mode-map 217 | (let ((map (make-sparse-keymap))) 218 | ;; No keybindings are configured as default. It's open for users. 219 | map) 220 | "The keymap for `moom'.") 221 | 222 | (defvar moom--init-status nil) 223 | (defvar moom--internal-border-width 0) 224 | (defvar moom--font-module-p (require 'moom-font nil t)) 225 | (defvar moom--frame-width 80) 226 | (defvar moom--height-list nil) 227 | (defvar moom--height-steps 4) 228 | (defvar moom--last-status nil) 229 | (defvar moom--maximized nil) 230 | (defvar moom--screen-margin nil) 231 | (defvar moom--fill-minimum-range 256) 232 | (defvar moom--frame-resize-pixelwise nil) 233 | (defvar moom--virtual-grid nil) 234 | (defvar moom--screen-grid nil) 235 | (defvar moom--print-status t) 236 | (defvar moom--common-margin '(0 0 0 0)) 237 | (defvar moom--pos-options '(:grid nil :bound nil)) ;; {screen,virtual}, {nil,t} 238 | (defvar moom--local-margin (cond ((eq window-system 'w32) '(0 9 -16 16)) 239 | ((eq window-system 'x) '(-19 0 0 0)) 240 | (t '(0 0 0 0)))) 241 | (defvar moom--autoreset-hooks '(menu-bar-mode-hook 242 | tool-bar-mode-hook tab-bar-mode-hook 243 | horizontal-scroll-bar-mode-hook 244 | scroll-bar-mode-hook)) 245 | (defvar moom--last-monitor nil) 246 | (defvar moom--display-border '(0 0)) 247 | (defvar moom--command-history nil) 248 | (defvar moom--non-interactive-history nil) 249 | 250 | (defun moom--setup () 251 | "Init function." 252 | (run-hooks 'moom-before-setup-hook) 253 | (setq moom--font-module-p (when moom-use-font-module 254 | (boundp 'moom-font--pause))) 255 | (setq moom-font--pause (not moom--font-module-p)) 256 | (moom-identify-current-monitor) 257 | (unless moom--virtual-grid 258 | (setq moom--virtual-grid (moom--virtual-grid))) 259 | (unless moom--screen-grid 260 | (setq moom--screen-grid (moom--screen-grid))) 261 | (setq moom--internal-border-width 262 | (alist-get 'internal-border-width (frame-geometry))) 263 | (unless (eq (setq moom--frame-width moom-frame-width-single) 80) 264 | (set-frame-width nil moom--frame-width)) 265 | (moom--make-frame-height-list) 266 | (moom--save-last-status) 267 | (setq moom--init-status moom--last-status) 268 | (setq moom--frame-resize-pixelwise frame-resize-pixelwise 269 | frame-resize-pixelwise t) 270 | ;; JP-font module 271 | (when moom--font-module-p 272 | (add-hook 'moom-font-after-resize-hook #'moom--make-frame-height-list) 273 | (add-hook 'moom-font-after-resize-hook #'moom--stay-in-region)) 274 | ;; display-line-numbers-mode 275 | (when (fboundp 'global-display-line-numbers-mode) 276 | (add-hook 'global-display-line-numbers-mode-hook 277 | #'moom--update-frame-display-line-numbers)) 278 | (mapcar (lambda (hook) (add-hook hook #'moom-reset)) 279 | moom--autoreset-hooks)) 280 | 281 | (defun moom--abort () 282 | "Abort." 283 | (moom-reset-line-spacing) 284 | (moom-reset) 285 | (setq frame-resize-pixelwise moom--frame-resize-pixelwise) 286 | (setq moom--screen-margin nil 287 | moom--virtual-grid nil 288 | moom--screen-grid nil) 289 | (when (fboundp 'global-display-line-numbers-mode) 290 | (remove-hook 'global-display-line-numbers-mode-hook 291 | #'moom--update-frame-display-line-numbers)) 292 | (mapcar (lambda (hook) (remove-hook hook #'moom-reset)) 293 | moom--autoreset-hooks)) 294 | 295 | (defun moom--reload () 296 | "Reload." 297 | (moom--abort) 298 | (moom--setup)) 299 | 300 | (defun moom--lighter () 301 | "Lighter." 302 | (when moom-lighter 303 | (concat " " moom-lighter))) 304 | 305 | (defun moom--frame-internal-width () 306 | "Width of internal objects. 307 | Including fringes and border." 308 | (if window-system 309 | (let ((fp (frame-parameters))) 310 | (+ (alist-get 'right-fringe fp) 311 | (alist-get 'left-fringe fp) 312 | (if (get-scroll-bar-mode) 313 | (alist-get 'scroll-bar-width fp) 314 | 0) 315 | (* 2 moom--internal-border-width))) 316 | 0)) ;; TODO check this by terminal 317 | 318 | (defun moom--internal-border-height () 319 | "Height of internal border within `frame-pixel-height'." 320 | 0) 321 | 322 | (defun moom--frame-internal-height () 323 | "Height of internal objects. 324 | Including title-bar, menu-bar, offset depends on window system, and border." 325 | (if window-system 326 | (let ((geometry (frame-geometry))) 327 | (+ (cdr (alist-get 'title-bar-size geometry)) 328 | (cdr (alist-get 'tool-bar-size geometry)) 329 | (if (memq window-system '(x w32)) 330 | (cdr (alist-get 'menu-bar-size geometry)) 0) 331 | (moom--internal-border-height))) 332 | 0)) ;; TODO check this by terminal 333 | 334 | (defun moom--frame-pixel-width () 335 | "Return frame width in pixels." 336 | (let ((edges (frame-edges))) 337 | (- (nth 2 edges) 338 | (nth 0 edges)))) 339 | 340 | (defun moom--frame-pixel-height () 341 | "Return frame height in pixels." 342 | (let ((edges (frame-edges))) 343 | (- (nth 3 edges) 344 | (nth 1 edges)))) 345 | 346 | (defun moom--max-frame-pixel-width () 347 | "Return the maximum width on pixel base." 348 | (- (display-pixel-width) 349 | (moom--frame-internal-width) 350 | (nth 2 moom--screen-margin) 351 | (nth 3 moom--screen-margin))) 352 | 353 | (defun moom--max-frame-pixel-height () 354 | "Return the maximum height on pixel base." 355 | (- (display-pixel-height) 356 | (moom--frame-internal-height) 357 | (nth 0 moom--screen-margin) 358 | (nth 1 moom--screen-margin))) 359 | 360 | (defun moom--max-half-frame-pixel-height () 361 | "Return the half of maximum height on pixel base." 362 | (floor (/ (- (display-pixel-height) 363 | (nth 0 moom--screen-margin) 364 | (nth 1 moom--screen-margin) 365 | (* 2 (moom--frame-internal-height))) 366 | 2.0))) 367 | 368 | (defun moom--frame-width () 369 | "Return frame width." 370 | (/ (- (moom--frame-pixel-width) 371 | (moom--frame-internal-width)) 372 | (frame-char-width))) 373 | 374 | (defun moom--frame-height () 375 | "Return frame height." 376 | (/ (- (moom--frame-pixel-height) 377 | (moom--internal-border-height)) 378 | (frame-char-height))) 379 | 380 | (defun moom--max-frame-width () 381 | "Return the maximum width based on screen size." 382 | (floor (/ (moom--max-frame-pixel-width) 383 | (frame-char-width)))) 384 | 385 | (defun moom--max-frame-height () 386 | "Return the maximum height based on screen size." 387 | (floor (/ (moom--max-frame-pixel-height) 388 | (frame-char-height)))) 389 | 390 | (defun moom--min-frame-height () 391 | "Return the minimum height of frame." 392 | moom-min-frame-height) 393 | 394 | (defun moom--make-frame-height-list () 395 | "Create an internal ring to change frame height." 396 | (let ((max-height (moom--max-frame-height)) 397 | (min-height (moom--min-frame-height)) 398 | (steps moom--height-steps) 399 | (heights nil)) 400 | (while (> (setq steps (1- steps)) 0) 401 | (cl-pushnew (max min-height 402 | (/ (* steps max-height) moom--height-steps)) 403 | heights)) 404 | (cl-pushnew (max min-height max-height) heights) 405 | (setq moom--height-list (copy-sequence heights)) 406 | ;; Skip the current height 407 | (when (eq (car moom--height-list) 408 | (moom--frame-height)) 409 | (moom--cycle-frame-height-list)))) 410 | 411 | (defun moom--cycle-frame-height-list () 412 | "Rotate `moom--height-list'." 413 | (setq moom--height-list 414 | (append (cdr moom--height-list) 415 | (list (car moom--height-list))))) 416 | 417 | (defun moom--font-size (pixel-width) 418 | "Return an appropriate font-size based on PIXEL-WIDTH. 419 | If `moom-font-table' is non-nil, the returned value will be more precisely 420 | calculated." 421 | (let* ((font-width (/ (float (- pixel-width (moom--frame-internal-width))) 422 | moom-frame-width-single)) 423 | (scaled-width (/ font-width 424 | (if moom--font-module-p 425 | moom-font-ascii-scale 1.0))) 426 | (font-size (when moom--font-module-p 427 | (moom-font--find-size 428 | (floor scaled-width) moom-font-table)))) 429 | (if font-size font-size 430 | (floor (* (if (< scaled-width 1) 1 scaled-width) 431 | moom-scaling-gradient))))) 432 | 433 | (defun moom--font-resize (font-size &optional pixel-width) 434 | "Resize font. 435 | Resize the current font to FONT-SIZE. 436 | If PIXEL-WIDTH is non-nil, ensure an appropriate font size so that 437 | the actual pixel width will not exceed the WIDTH." 438 | (when moom--font-module-p 439 | (set-frame-width nil moom-frame-width-single) 440 | (moom-font-resize font-size pixel-width))) 441 | 442 | (defun moom--fullscreen-font-size () 443 | "Return the maximum font-size for full screen." 444 | (if window-system 445 | (moom--font-size (+ (moom--max-frame-pixel-width) 446 | (moom--frame-internal-width))) 447 | 12)) ;; FIXME, use face-attribute 448 | 449 | (defun moom--virtual-grid () 450 | "Alignment for pointing frame left and top position on `set-frame-position'." 451 | (cond ((eq window-system 'w32) '(-16 0)) 452 | ((and (eq window-system 'x) 453 | (version< emacs-version "26.0")) '(0 27)) 454 | ((memq window-system '(ns mac)) '(0 0)) 455 | ((eq window-system 'x) '(10 8)) 456 | (t '(0 0)))) 457 | 458 | (defun moom--screen-grid () 459 | "Alignment of frame left and top position on monitor." 460 | (cond ((eq window-system 'w32) '(8 0)) 461 | ((and (eq window-system 'x) 462 | (version< emacs-version "26.0")) '(10 -19)) 463 | ((memq window-system '(ns mac)) '(0 0)) 464 | ((eq window-system 'x) '(0 0)) 465 | (t '(0 0)))) 466 | 467 | (defun moom--frame-left () 468 | "Return outer left position." 469 | (let ((left (frame-parameter nil 'left))) 470 | (+ (if (listp left) (nth 1 left) left) 471 | (nth 0 moom--virtual-grid) 472 | (nth 0 moom--screen-grid)))) 473 | 474 | (defun moom--frame-top () 475 | "Return outer top position." 476 | (let ((top (frame-parameter nil 'top))) 477 | (+ (if (listp top) (nth 1 top) top) 478 | (nth 1 moom--virtual-grid) 479 | (nth 1 moom--screen-grid)))) 480 | 481 | (defun moom--pos-x (posx &optional options) 482 | "Return aligned POSX for `set-frame-position'. 483 | OPTIONS controls grid and bound. See `moom--pos-options'." 484 | (when (listp posx) 485 | (setq posx (nth 1 posx))) 486 | (setq posx (- posx (nth 0 moom--screen-grid))) 487 | (when (eq window-system 'w32) 488 | (setq posx (+ posx 16))) ;; FIXME 489 | (when (or (plist-get options :bound) 490 | (not (memq window-system '(ns mac w32)))) ;; TODO: support others if possible 491 | (let ((bounds-left (- (nth 0 moom--last-monitor) 492 | (nth 0 moom--screen-grid))) 493 | (bounds-right (+ (nth 0 moom--last-monitor) 494 | (nth 2 moom--last-monitor) 495 | (- (moom--frame-pixel-width))))) 496 | (setq posx (cond ((< posx bounds-left) bounds-left) 497 | ((> posx bounds-right) bounds-right) 498 | (t posx))))) 499 | (unless (plist-get options :grid) 500 | (setq options (if (eq window-system 'ns) 501 | '(:grid screen) '(:grid virtual)))) 502 | (cond ((eq (plist-get options :grid) 'virtual) 503 | (let ((pw (- (nth 0 moom--display-border) 504 | (moom--frame-pixel-width)))) 505 | (if (< posx 0) 506 | (- posx (+ pw (nth 0 moom--virtual-grid))) 507 | posx))) 508 | ((eq (plist-get options :grid) 'screen) 509 | posx) 510 | (t 511 | posx))) 512 | 513 | (defun moom--pos-y (posy &optional options) 514 | "Return aligned POSY for `set-frame-position'. 515 | OPTIONS controls grid and bound. See `moom--pos-options'." 516 | (when (listp posy) 517 | (setq posy (nth 1 posy))) 518 | (setq posy (- posy (nth 1 moom--screen-grid))) 519 | (when (or (plist-get options :bound) 520 | (not (memq window-system '(ns mac w32)))) ;; TODO: support others if possible 521 | (let ((bounds-top (- (nth 1 moom--last-monitor) 522 | (nth 1 moom--screen-grid))) 523 | (bounds-bottom (+ (nth 1 moom--last-monitor) 524 | (nth 3 moom--last-monitor) 525 | (- (moom--frame-pixel-height))))) 526 | (setq posy (cond ((< posy bounds-top) bounds-top) 527 | ((> posy bounds-bottom) bounds-bottom) 528 | (t posy))))) 529 | (unless (plist-get options :grid) 530 | (setq options (if (eq window-system 'ns) 531 | '(:grid screen) '(:grid virtual)))) 532 | (cond ((eq (plist-get options :grid) 'virtual) 533 | (let ((ph (- (nth 1 moom--display-border) 534 | (moom--frame-pixel-height)))) 535 | (if (< posy 0) 536 | (- posy (+ ph (nth 1 moom--virtual-grid))) 537 | posy))) 538 | ((eq (plist-get options :grid) 'screen) 539 | posy) 540 | (t 541 | posy))) 542 | 543 | (defun moom--horizontal-center () 544 | "Horizontal center position." 545 | (+ (nth 2 moom--screen-margin) 546 | (floor (/ (+ (moom--max-frame-pixel-width) 547 | (moom--frame-internal-width)) 548 | 2.0)))) 549 | 550 | (defun moom--vertical-center () 551 | "Vertical center position." 552 | (+ (nth 0 moom--screen-margin) 553 | (floor (/ (+ (moom--max-frame-pixel-height) 554 | (moom--frame-internal-height)) 555 | 2.0)))) 556 | 557 | (defun moom--horizontal-center-pos () 558 | "Left edge position when centering." 559 | (+ (car moom-move-frame-pixel-offset) 560 | (moom--horizontal-center) 561 | (let ((scroll (frame-parameter nil 'scroll-bar-width))) 562 | (if (and (> scroll 0) (get-scroll-bar-mode)) ;; TBD 563 | scroll 564 | (frame-parameter nil 'left-fringe))) 565 | (- (/ (+ (moom--frame-pixel-width) 566 | (moom--frame-internal-width) 567 | (- (moom--internal-border-height))) 568 | 2)))) 569 | 570 | (defun moom--vertical-center-pos () 571 | "Top edge position when centering." 572 | (+ (cdr moom-move-frame-pixel-offset) 573 | (moom--vertical-center) 574 | (- (/ (+ (moom--frame-pixel-height) 575 | (moom--frame-internal-height) 576 | (- (moom--internal-border-height))) 577 | 2)))) 578 | 579 | (defun moom--save-last-status () 580 | "Store the last frame position, size, and font-size." 581 | (setq moom--last-status 582 | `(("font-size" . ,(if moom--font-module-p moom-font--size nil)) 583 | ("left" . ,(moom--pos-x (moom--frame-left))) 584 | ("top" . ,(moom--frame-top)) 585 | ("width" . ,(moom--frame-width)) 586 | ("height" . ,(moom--frame-height)) 587 | ("pixel-width" . ,(moom--frame-pixel-width)) 588 | ("pixel-height" . ,(moom--frame-pixel-height))))) 589 | 590 | (defun moom--fill-display (area) 591 | "Move the frame to AREA. 592 | Font size will be changed appropriately. 593 | AREA would be \=top, \=bottom, \=left, \=right, \=topl, \=topr, 594 | \=botl, and \=botr." 595 | (let* ((align-width (+ (moom--max-frame-pixel-width) 596 | (moom--frame-internal-width))) 597 | (pixel-width 598 | (- (floor (/ align-width 2.0)) 599 | (moom--frame-internal-width))) 600 | (pixel-height (moom--max-half-frame-pixel-height)) 601 | (pos-x (nth 2 moom--screen-margin)) 602 | (pos-y (nth 0 moom--screen-margin))) 603 | ;; Region 604 | (cond ((memq area '(top bottom)) 605 | (setq pixel-width (moom--max-frame-pixel-width))) 606 | ((memq area '(left right)) 607 | (setq pixel-height (moom--max-frame-pixel-height)) 608 | (setq align-width (floor (/ align-width 2.0)))) 609 | ((memq area '(topl topr botl botr)) 610 | (setq align-width (floor (/ align-width 2.0)))) 611 | (nil t)) 612 | ;; Font size 613 | (let ((moom-font-before-resize-hook nil) 614 | (moom-font-after-resize-hook nil)) 615 | (moom--font-resize (moom--font-size align-width) align-width)) 616 | ;; Position 617 | (when (memq area '(right topr botr)) 618 | (setq pos-x (moom--horizontal-center))) 619 | (when (memq area '(bottom botl botr)) 620 | (setq pos-y (moom--vertical-center))) 621 | (when (memq area '(top bottom left right topl topr botl botr)) 622 | (let ((flag (memq window-system '(ns mac w32)))) 623 | (unless flag 624 | (set-frame-size nil pixel-width pixel-height t)) 625 | (when (and (not moom--font-module-p) 626 | (eq window-system 'w32)) 627 | (set-frame-width nil moom-frame-width-single)) ;; FIXME 628 | (set-frame-position nil 629 | (moom--pos-x pos-x) 630 | (moom--pos-y pos-y)) 631 | (when flag 632 | (set-frame-size nil pixel-width pixel-height t))))) 633 | (moom--make-frame-height-list) 634 | (moom-print-status)) 635 | 636 | (defun moom--shift-amount (direction) 637 | "Extract shift amount from `moom-horizontal-shifts' based on DIRECTION." 638 | (let ((index (cond ((eq direction 'left) 0) 639 | ((eq direction 'right) 1) 640 | (t 0)))) 641 | (cond ((integerp moom-horizontal-shifts) 642 | moom-horizontal-shifts) 643 | ((listp moom-horizontal-shifts) 644 | (nth index moom-horizontal-shifts)) 645 | (t 646 | (error (format "%s is wrong value." moom-horizontal-shifts)))))) 647 | 648 | (defun moom--frame-monitor-attribute (attribute &optional frame x y) 649 | "Return the value of ATTRIBUTE on FRAME's monitor. 650 | 651 | If X and Y are both numbers, then ignore the value of FRAME; the 652 | monitor is determined to be the physical monitor that contains 653 | the pixel coordinate (X, Y). 654 | 655 | Taken from frame.el in 26.1 to support previous Emacs versions, 25.1 or later." 656 | (if (and (numberp x) 657 | (numberp y)) 658 | (cl-loop for monitor in (display-monitor-attributes-list) 659 | for geometry = (alist-get 'geometry monitor) 660 | for min-x = (pop geometry) 661 | for min-y = (pop geometry) 662 | for max-x = (+ min-x (pop geometry)) 663 | for max-y = (+ min-y (car geometry)) 664 | when (and (<= min-x x) 665 | (< x max-x) 666 | (<= min-y y) 667 | (< y max-y)) 668 | return (alist-get attribute monitor)) 669 | (alist-get attribute (frame-monitor-attributes frame)))) 670 | 671 | (defun moom--frame-monitor-geometry (&optional frame x y) 672 | "Return the geometry of FRAME's monitor. 673 | 674 | If X and Y are both numbers, then ignore the value of FRAME; the 675 | monitor is determined to be the physical monitor that contains 676 | the pixel coordinate (X, Y). 677 | 678 | Taken from frame.el in 26.1 to support previous Emacs versions, 25.1 or later." 679 | (moom--frame-monitor-attribute 'geometry frame x y)) 680 | 681 | (defun moom--frame-monitor-workarea (&optional frame x y) 682 | "Return the workarea of FRAME's monitor. 683 | 684 | If X and Y are both numbers, then ignore the value of FRAME; the 685 | monitor is determined to be the physical monitor that contains 686 | the pixel coordinate (X, Y). 687 | 688 | Taken from frame.el in 26.1 to support previous Emacs versions, 25.1 or later." 689 | (moom--frame-monitor-attribute 'workarea frame x y)) 690 | 691 | (defun moom--default-screen-margin () 692 | "Calculate default screen margins." 693 | (let ((geometry (moom--frame-monitor-geometry)) 694 | (workarea (moom--frame-monitor-workarea))) 695 | (setq moom--screen-margin 696 | (list (- (nth 1 workarea) (nth 1 geometry)) 697 | (- (+ (nth 1 geometry) (nth 3 geometry)) 698 | (+ (nth 1 workarea) (nth 3 workarea))) 699 | (- (nth 0 workarea) (nth 0 geometry)) 700 | (- (+ (nth 0 geometry) (nth 2 geometry)) 701 | (+ (nth 0 workarea) (nth 2 workarea))))) 702 | ;; Update 703 | (moom--merge-screen-margin moom--local-margin))) 704 | 705 | (defun moom--merge-screen-margin (margin) 706 | "Add MARGIN to `moom--screen-margin'." 707 | (setq moom--screen-margin 708 | (list (+ (nth 0 margin) (nth 0 moom--screen-margin)) 709 | (+ (nth 1 margin) (nth 1 moom--screen-margin)) 710 | (+ (nth 2 margin) (nth 2 moom--screen-margin)) 711 | (+ (nth 3 margin) (nth 3 moom--screen-margin))))) 712 | 713 | (defun moom--update-frame-display-line-numbers () 714 | "Expand frame width by `moom-display-line-numbers-width'. 715 | This feature is available when function `global-display-line-numbers-mode' 716 | is utilized." 717 | (if (numberp moom-display-line-numbers-width) 718 | (unless (eq moom-display-line-numbers-width 0) 719 | (let ((flag (if global-display-line-numbers-mode 1 -1))) 720 | (setq moom-frame-width-single 721 | (+ moom-frame-width-single 722 | (* flag moom-display-line-numbers-width))) 723 | (setq moom-frame-width-double 724 | (+ (* 2 moom-frame-width-single) 3)) 725 | (set-frame-width nil 726 | (+ (frame-width) 727 | (* flag moom-display-line-numbers-width))))) 728 | (user-error "Unexpected value of `moom-display-line-numbers-width'")) 729 | (moom-print-status)) 730 | 731 | (defun moom--centerize-p (arg) 732 | "Return nil when `ARG' is not listed in `moom-command-with-centering'." 733 | (memq arg (if (listp moom-command-with-centering) 734 | moom-command-with-centering 735 | (list moom-command-with-centering)))) 736 | 737 | (defun moom--stay-in-region (&optional target-width) 738 | "Shift the frame to try to keep the frame staying in the display. 739 | The frame width may be specified with TARGET-WIDTH." 740 | (let ((shift (- (+ (* (frame-char-width) (or target-width 741 | (moom--frame-width))) 742 | (moom--frame-internal-width) 743 | (moom--pos-x (moom--frame-left))) 744 | (- (display-pixel-width) 745 | (nth 3 moom--screen-margin))))) 746 | ;; Left side border 747 | (when (< (moom--pos-x (moom--frame-left)) shift) 748 | (setq shift (moom--pos-x (moom--frame-left)))) 749 | ;; Right side border 750 | (when (> shift 0) 751 | (moom-move-frame-left shift)))) 752 | 753 | (defun moom--update-display-border () 754 | "Update right and bottom border for negative coordinate value on windows-nt." 755 | (let ((dma-list (display-monitor-attributes-list)) 756 | (rb 0) 757 | (lb 0)) 758 | (dotimes (i (length dma-list)) 759 | (let ((gm (alist-get 'geometry (nth i dma-list)))) 760 | (when (< (nth 0 gm) 0) 761 | (setq rb (nth 0 gm))) 762 | (when (< (nth 1 gm) 0) 763 | (setq lb (nth 1 gm))))) 764 | (setq moom--display-border 765 | (list (+ (display-pixel-width) rb) 766 | (+ (display-pixel-height) lb))))) 767 | 768 | (defun moom--current-monitor-id () 769 | "Provide id of the current monitor." 770 | (let ((dma-list (display-monitor-attributes-list)) 771 | (id 0)) 772 | (dotimes (i (length dma-list)) 773 | (when (equal (alist-get 'geometry (nth i dma-list)) moom--last-monitor) 774 | (setq id i))) 775 | id)) 776 | 777 | (defun moom--read-user-margin () 778 | "Read new user margin." 779 | (mapcar #'string-to-number 780 | (split-string 781 | (read-string "New user margin: " 782 | (mapconcat #'identity (mapcar 783 | #'number-to-string 784 | moom-user-margin) " "))))) 785 | 786 | (defun moom--add-command-history (status) 787 | "Add the last STATUS to `moom--command-history' for undo feature." 788 | (unless (equal status (car moom--command-history)) 789 | (push status moom--command-history) 790 | (when (> (length moom--command-history) moom-command-history-length) 791 | (nbutlast moom--command-history)))) 792 | 793 | ;;;###autoload 794 | (defun moom-undo (&optional index) 795 | "Undo. 796 | If INDEX is non-nil, revert to the provided id of history." 797 | (interactive) 798 | (unless index 799 | (setq index 0)) 800 | (if (and (numberp index) 801 | (> (length moom--command-history) index)) 802 | (let ((previous (nth index moom--command-history))) 803 | (moom-restore-last-status previous) 804 | (setq moom--command-history (nthcdr (1+ index) moom--command-history)) 805 | (when moom-verbose 806 | (message "[moom] %s undo available" (length moom--command-history)))) 807 | (message "[moom] No further undo"))) 808 | 809 | ;;;###autoload 810 | (defun moom-identify-current-monitor (&optional shift) 811 | "Update `moom--screen-margin' to identify and focus on the current monitor. 812 | SHIFT can control the margin, if needed. 813 | If SHIFT is nil, `moom--common-margin' will be applied." 814 | (interactive) 815 | (let ((geometry (moom--frame-monitor-geometry)) 816 | (workarea (moom--frame-monitor-workarea))) 817 | (if (not (> (length (display-monitor-attributes-list)) 1)) 818 | (setq moom--screen-margin (moom--default-screen-margin)) 819 | (setq moom--screen-margin 820 | (let ((shift (or shift moom--common-margin))) 821 | (list (+ (nth 1 workarea) 822 | (nth 0 shift)) 823 | (+ (- (display-pixel-height) 824 | (nth 1 workarea) 825 | (nth 3 workarea)) 826 | (nth 1 shift)) 827 | (+ (nth 0 workarea) 828 | (nth 2 shift)) 829 | (+ (- (display-pixel-width) 830 | (nth 0 workarea) 831 | (nth 2 workarea)) 832 | (nth 3 shift))))) 833 | (moom--merge-screen-margin moom--local-margin)) 834 | (moom--merge-screen-margin moom-user-margin) 835 | (moom--update-display-border) 836 | (unless (equal moom--last-monitor geometry) 837 | (setq moom--last-monitor geometry) 838 | (when moom-verbose 839 | (message "[Moom] The current monitor has been changed to %s" geometry)) 840 | (moom--make-frame-height-list))) 841 | (when (eq window-system 'mac) ;; To avoid visual error 842 | (redraw-frame))) 843 | 844 | ;;;###autoload 845 | (defun moom-print-monitors () 846 | "Print available monitors with index number. 847 | `moom-jump-to-monitor' could be useful to jump to a monitor." 848 | (interactive) 849 | (let ((dma-list (display-monitor-attributes-list)) 850 | (msg nil)) 851 | (dotimes (i (length dma-list)) 852 | (let ((gm (alist-get 'geometry (nth i dma-list)))) 853 | (push (format "[%s] W:%04s H:%04s (%05s,%05s) %s" 854 | i (nth 2 gm) (nth 3 gm) (nth 0 gm) (nth 1 gm) 855 | (if (equal gm moom--last-monitor) "" "")) msg))) 856 | (when moom-verbose 857 | (message "%s" (mapconcat 'concat (reverse msg) "\n"))))) 858 | 859 | ;;;###autoload 860 | (defun moom-jump-to-monitor (id) 861 | "Jump to a monitor by specifying ID." 862 | (interactive (list 863 | (read-number 864 | "Target monitor: " (moom--current-monitor-id)))) 865 | (let ((dma-list (display-monitor-attributes-list))) 866 | (if (< id (length dma-list)) 867 | (let ((workarea (alist-get 'workarea (nth id dma-list)))) 868 | (set-frame-position nil (nth 0 workarea) (nth 1 workarea)) 869 | (when (memq window-system '(x)) 870 | (sleep-for 0.2)) ;; FIXME 871 | (moom-identify-current-monitor) 872 | (run-hooks 'moom-after-select-monitor-hook)) 873 | (user-error "Target index shall be less than %s" id (length dma-list))))) 874 | 875 | ;;;###autoload 876 | (defun moom-cycle-monitors () 877 | "Cycle monitors. 878 | `moom-after-select-monitor-hook' could be useful to add some additional 879 | actions when selecting a monitor." 880 | (interactive) 881 | (let ((dma-list (display-monitor-attributes-list))) 882 | (moom-jump-to-monitor 883 | (let ((v (1+ (moom--current-monitor-id)))) 884 | (if (equal v (length dma-list)) 0 v)))) 885 | (moom-print-monitors)) 886 | 887 | ;;;###autoload 888 | (defun moom-fill-screen () 889 | "Expand frame width and height to fill screen. 890 | The font size in buffers will be increased so that the frame width could be 891 | maintained at 80. The top left corner of the frame is moved to that of screen. 892 | `moom-before-fill-screen-hook' and `moom-after-fill-screen-hook' can be 893 | used to add additional actions." 894 | (interactive) 895 | (let ((last (moom--save-last-status))) 896 | (run-hooks 'moom-before-fill-screen-hook) 897 | (moom--font-resize (moom--fullscreen-font-size) 898 | (+ (moom--max-frame-pixel-width) 899 | (moom--frame-internal-width))) 900 | (set-frame-position nil 901 | (moom--pos-x (nth 2 moom--screen-margin)) 902 | (moom--pos-y (nth 0 moom--screen-margin))) 903 | (set-frame-size nil 904 | (moom--max-frame-pixel-width) 905 | (moom--max-frame-pixel-height) t) 906 | (moom-print-status) 907 | (run-hooks 'moom-after-fill-screen-hook) 908 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 909 | (moom--add-command-history last)))) 910 | 911 | ;;;###autoload 912 | (defun moom-toggle-frame-maximized () 913 | "Toggle frame maximized. 914 | No information is stored for undo." 915 | (interactive) 916 | (let ((moom--print-status nil)) 917 | (if moom--maximized 918 | (progn 919 | (moom-restore-last-status moom--maximized) 920 | (setq moom--maximized nil)) 921 | (setq moom--maximized (moom--save-last-status)) 922 | (moom-fill-screen))) 923 | (moom-print-status)) 924 | 925 | ;;;###autoload 926 | (defun moom-fill-top () 927 | "Fill upper half of screen." 928 | (interactive) 929 | (let ((last (moom--save-last-status))) 930 | (moom--fill-display 'top) 931 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 932 | (moom--add-command-history last)))) 933 | 934 | ;;;###autoload 935 | (defun moom-fill-bottom () 936 | "Fill lower half of screen." 937 | (interactive) 938 | (let ((last (moom--save-last-status))) 939 | (moom--fill-display 'bottom) 940 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 941 | (moom--add-command-history last)))) 942 | 943 | ;;;###autoload 944 | (defun moom-fill-left () 945 | "Fill left half of screen." 946 | (interactive) 947 | (let ((last (moom--save-last-status))) 948 | (moom--fill-display 'left) 949 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 950 | (moom--add-command-history last)))) 951 | 952 | ;;;###autoload 953 | (defun moom-fill-right () 954 | "Fill right half of screen." 955 | (interactive) 956 | (let ((last (moom--save-last-status))) 957 | (moom--fill-display 'right) 958 | (when (eq window-system 'w32) 959 | (moom-move-frame-to-edge-right)) 960 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 961 | (moom--add-command-history last)))) 962 | 963 | ;;;###autoload 964 | (defun moom-fill-top-left () 965 | "Fill top left quarter of screen." 966 | (interactive) 967 | (let ((last (moom--save-last-status))) 968 | (moom--fill-display 'topl) 969 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 970 | (moom--add-command-history last)))) 971 | 972 | ;;;###autoload 973 | (defun moom-fill-top-right () 974 | "Fill top right quarter of screen." 975 | (interactive) 976 | (let ((last (moom--save-last-status))) 977 | (moom--fill-display 'topr) 978 | (when (eq window-system 'w32) 979 | (moom-move-frame-to-edge-right)) 980 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 981 | (moom--add-command-history last)))) 982 | 983 | ;;;###autoload 984 | (defun moom-fill-bottom-left () 985 | "Fill bottom left quarter of screen." 986 | (interactive) 987 | (let ((last (moom--save-last-status))) 988 | (moom--fill-display 'botl) 989 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 990 | (moom--add-command-history last)))) 991 | 992 | ;;;###autoload 993 | (defun moom-fill-bottom-right () 994 | "Fill bottom right quarter of screen." 995 | (interactive) 996 | (let ((last (moom--save-last-status))) 997 | (moom--fill-display 'botr) 998 | (when (eq window-system 'w32) 999 | (moom-move-frame-to-edge-right)) 1000 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1001 | (moom--add-command-history last)))) 1002 | 1003 | ;;;###autoload 1004 | (defun moom-fill-band (&optional plist) 1005 | "Fill screen by band region. 1006 | If PLIST is nil, `moom-fill-band-options' is applied." 1007 | (interactive) 1008 | (let ((last (moom--save-last-status))) 1009 | (let* ((moom--print-status nil) 1010 | (values (or plist moom-fill-band-options)) 1011 | (direction (plist-get values :direction)) 1012 | (range (plist-get values :range)) 1013 | (band-pixel-width nil) 1014 | (band-pixel-height nil)) 1015 | (cond ((memq direction '(vertical nil)) 1016 | (setq band-pixel-width 1017 | (if (floatp range) 1018 | (floor (/ (* range (+ (moom--max-frame-pixel-width) 1019 | (moom--frame-internal-width))) 1020 | 100.0)) 1021 | range)) 1022 | (when (< band-pixel-width moom--fill-minimum-range) 1023 | (setq band-pixel-width moom--fill-minimum-range) 1024 | (warn "Range was changed since given value is too small.")) 1025 | (moom--font-resize 1026 | (moom--font-size band-pixel-width) band-pixel-width) 1027 | ;; Update band-pixel-width for `set-frame-size' 1028 | (setq band-pixel-width 1029 | (- (if (and moom--font-module-p 1030 | (floatp range)) 1031 | (moom--frame-pixel-width) 1032 | band-pixel-width) 1033 | (moom--frame-internal-width))) 1034 | (setq band-pixel-height (moom--max-frame-pixel-height))) 1035 | ((eq direction 'horizontal) 1036 | (setq band-pixel-height 1037 | (- (if (floatp range) 1038 | (floor (/ (* (+ (moom--max-frame-pixel-height) 1039 | (moom--frame-internal-height)) 1040 | range) 1041 | 100.0)) 1042 | range) 1043 | (moom--frame-internal-height))) 1044 | (moom--font-resize (moom--fullscreen-font-size) 1045 | (+ (moom--max-frame-pixel-width) 1046 | (moom--frame-internal-width))) 1047 | (setq band-pixel-width (moom--max-frame-pixel-width)))) 1048 | (when (and band-pixel-width 1049 | band-pixel-height) 1050 | (set-frame-size nil band-pixel-width band-pixel-height t) 1051 | (moom-move-frame-to-center) 1052 | (moom--make-frame-height-list))) 1053 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1054 | (moom--add-command-history last))) 1055 | (moom-print-status)) 1056 | 1057 | ;;;###autoload 1058 | (defun moom-cycle-line-spacing () 1059 | "Change `line-spacing’ value between a range." 1060 | (interactive) 1061 | (if (< line-spacing moom-max-line-spacing) 1062 | (setq line-spacing (+ line-spacing 0.1)) 1063 | (setq line-spacing moom-min-line-spacing)) 1064 | (when moom-verbose 1065 | (message "[Moom] %.1f" line-spacing))) 1066 | 1067 | ;;;###autoload 1068 | (defun moom-reset-line-spacing () 1069 | "Reset to the defaut value for line spacing." 1070 | (interactive) 1071 | (setq line-spacing moom-init-line-spacing) 1072 | (when (and moom-verbose 1073 | line-spacing) 1074 | (message "[Moom] %.1f" line-spacing))) 1075 | 1076 | ;;;###autoload 1077 | (defun moom-move-frame-right (&optional pixel) 1078 | "PIXEL move the current frame to right." 1079 | (interactive) 1080 | (moom-identify-current-monitor) 1081 | (let ((last (moom--save-last-status))) 1082 | (let* ((pos-x (moom--frame-left)) 1083 | (pos-y (moom--frame-top)) 1084 | (new-pos-x (+ pos-x (or pixel 1085 | (moom--shift-amount 'right))))) 1086 | (when (>= new-pos-x (- (display-pixel-width) 1087 | (nth 3 moom--screen-margin))) 1088 | (setq new-pos-x (- new-pos-x 1089 | (display-pixel-width) 1090 | (moom--frame-pixel-width) 1091 | (- (moom--shift-amount 'right))))) 1092 | (set-frame-position nil 1093 | (moom--pos-x new-pos-x) 1094 | (moom--pos-y pos-y))) 1095 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1096 | (moom--add-command-history last))) 1097 | (moom-print-status)) 1098 | 1099 | ;;;###autoload 1100 | (defun moom-move-frame-left (&optional pixel) 1101 | "PIXEL move the current frame to left." 1102 | (interactive) 1103 | (moom-identify-current-monitor) 1104 | (let ((last (moom--save-last-status))) 1105 | (let* ((pos-x (moom--frame-left)) 1106 | (pos-y (moom--frame-top)) 1107 | (new-pos-x (- pos-x (or pixel 1108 | (moom--shift-amount 'left))))) 1109 | (when (<= new-pos-x (- (nth 2 moom--screen-margin) 1110 | (moom--frame-pixel-width))) 1111 | (setq new-pos-x (+ new-pos-x 1112 | (display-pixel-width) 1113 | (moom--frame-pixel-width) 1114 | (- (moom--shift-amount 'left))))) 1115 | (set-frame-position nil 1116 | (moom--pos-x new-pos-x) 1117 | (moom--pos-y pos-y))) 1118 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1119 | (moom--add-command-history last))) 1120 | (moom-print-status)) 1121 | 1122 | ;;;###autoload 1123 | (defun moom-move-frame-to-horizontal-center () 1124 | "Move the current frame to the horizontal center of the screen." 1125 | (interactive) 1126 | (let ((last (moom--save-last-status))) 1127 | (set-frame-position nil 1128 | (moom--pos-x (moom--horizontal-center-pos) '(:bound t)) 1129 | (moom--pos-y (moom--frame-top) '(:bound t))) 1130 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1131 | (moom--add-command-history last))) 1132 | (moom-print-status)) 1133 | 1134 | ;;;###autoload 1135 | (defun moom-move-frame-to-vertical-center () 1136 | "Move the current frame to the vertical center of the screen." 1137 | (interactive) 1138 | (let ((last (moom--save-last-status))) 1139 | (set-frame-position nil 1140 | (moom--pos-x (moom--frame-left) '(:bound t)) 1141 | (moom--pos-y (moom--vertical-center-pos) '(:bound t))) 1142 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1143 | (moom--add-command-history last))) 1144 | (moom-print-status)) 1145 | 1146 | ;;;###autoload 1147 | (defun moom-move-frame-to-edge-top () 1148 | "Move the current frame to the top of the screen. 1149 | If you find the frame is NOT moved to the top exactly, 1150 | please configure the margins by variable `moom-user-margin'." 1151 | (interactive) 1152 | (let ((last (moom--save-last-status))) 1153 | (set-frame-position nil 1154 | (moom--pos-x (moom--frame-left) '(:bound t)) 1155 | (moom--pos-y (nth 0 moom--screen-margin) '(:bound t))) 1156 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1157 | (moom--add-command-history last))) 1158 | (moom-print-status)) 1159 | 1160 | ;;;###autoload 1161 | (defun moom-move-frame-to-edge-bottom () 1162 | "Move the current frame to the top of the screen. 1163 | If you find the frame is NOT moved to the bottom exactly, 1164 | please configure the margins by variable `moom-user-margin'." 1165 | (interactive) 1166 | (let ((last (moom--save-last-status))) 1167 | (set-frame-position nil 1168 | (moom--pos-x (moom--frame-left) '(:bound t)) 1169 | (moom--pos-y 1170 | (- (display-pixel-height) 1171 | (moom--frame-pixel-height) 1172 | (moom--frame-internal-height) 1173 | (- (moom--internal-border-height)) 1174 | (nth 1 moom--screen-margin)) '(:bound t))) 1175 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1176 | (moom--add-command-history last))) 1177 | (moom-print-status)) 1178 | 1179 | ;;;###autoload 1180 | (defun moom-move-frame-to-edge-right () 1181 | "Move the current frame to the right edge of the screen." 1182 | (interactive) 1183 | (let ((last (moom--save-last-status))) 1184 | (set-frame-position nil 1185 | (moom--pos-x (- (display-pixel-width) 1186 | (moom--frame-pixel-width) 1187 | (nth 3 moom--screen-margin)) 1188 | (when (eq window-system 'w32) 1189 | '(:bound t))) ;; FIXME 1190 | (moom--pos-y (moom--frame-top) '(:bound t))) 1191 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1192 | (moom--add-command-history last))) 1193 | (moom-print-status)) 1194 | 1195 | ;;;###autoload 1196 | (defun moom-move-frame-to-edge-left () 1197 | "Move the current frame to the left edge of the screen." 1198 | (interactive) 1199 | (let ((last (moom--save-last-status))) 1200 | (set-frame-position nil 1201 | (moom--pos-x (nth 2 moom--screen-margin)) 1202 | (moom--pos-y (moom--frame-top) '(:bound t))) 1203 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1204 | (moom--add-command-history last))) 1205 | (moom-print-status)) 1206 | 1207 | ;;;###autoload 1208 | (defun moom-move-frame-to-centerline-from-left () 1209 | "Fit frame to vertical line in the middle from left side." 1210 | (interactive) 1211 | (let ((last (moom--save-last-status))) 1212 | (set-frame-position nil 1213 | (- (moom--horizontal-center) (moom--frame-pixel-width)) 1214 | (moom--pos-y (moom--frame-top))) 1215 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1216 | (moom--add-command-history last))) 1217 | (moom-print-status)) 1218 | 1219 | ;;;###autoload 1220 | (defun moom-move-frame-to-centerline-from-right () 1221 | "Fit frame to vertical line in the middle from right side." 1222 | (interactive) 1223 | (let ((last (moom--save-last-status))) 1224 | (set-frame-position nil 1225 | (moom--horizontal-center) 1226 | (moom--pos-y (moom--frame-top))) 1227 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1228 | (moom--add-command-history last))) 1229 | (moom-print-status)) 1230 | 1231 | ;;;###autoload 1232 | (defun moom-move-frame-to-centerline-from-top () 1233 | "Fit frame to horizontal line in the middle from above." 1234 | (interactive) 1235 | (let ((last (moom--save-last-status))) 1236 | (set-frame-position nil 1237 | (moom--pos-x (moom--frame-left)) 1238 | (moom--pos-y (- (moom--vertical-center) 1239 | (moom--frame-internal-height) 1240 | (moom--frame-pixel-height)))) 1241 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1242 | (moom--add-command-history last))) 1243 | (moom-print-status)) 1244 | 1245 | ;;;###autoload 1246 | (defun moom-move-frame-to-centerline-from-bottom () 1247 | "Fit frame to horizontal line in the middle from below." 1248 | (interactive) 1249 | (let ((last (moom--save-last-status))) 1250 | (set-frame-position nil 1251 | (moom--pos-x (moom--frame-left)) 1252 | (moom--pos-y (moom--vertical-center))) 1253 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1254 | (moom--add-command-history last))) 1255 | (moom-print-status)) 1256 | 1257 | ;;;###autoload 1258 | (defun moom-move-frame-to-center () 1259 | "Move the current frame to the center of the screen." 1260 | (interactive) 1261 | (let ((last (moom--save-last-status))) 1262 | (set-frame-position nil 1263 | (moom--pos-x (moom--horizontal-center-pos)) 1264 | (moom--pos-y (moom--vertical-center-pos) '(:bound t))) 1265 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1266 | (moom--add-command-history last))) 1267 | (moom-print-status)) 1268 | 1269 | ;;;###autoload 1270 | (defun moom-move-frame (&optional arg) 1271 | "Move the frame to somewhere (default: left top of workarea). 1272 | When ARG is a list like \=(10 10), move the frame to the position. 1273 | When ARG is a single number like 10, shift the frame horizontally +10 pixel. 1274 | When ARG is nil, then move to the default position (i.e. left top of workarea)." 1275 | (interactive) 1276 | (let ((last (moom--save-last-status))) 1277 | (let ((pos-x (nth 2 moom--screen-margin)) 1278 | (pos-y (nth 0 moom--screen-margin))) 1279 | (when (eq window-system 'w32) 1280 | (setq pos-x (+ pos-x (nth 0 moom--screen-grid))) 1281 | (setq pos-y (+ pos-y (nth 1 moom--screen-grid)))) 1282 | (cond ((not arg) t) ;; left top of workarea by '(pos-x, pos-y) 1283 | ((numberp arg) ;; horizontal shift 1284 | (setq pos-x (+ pos-x arg)) 1285 | (setq pos-y (moom--frame-top))) 1286 | ((listp arg) ;; move to '(x, y) 1287 | (setq pos-x (+ pos-x (nth 0 arg))) 1288 | (setq pos-y (+ pos-y (nth 1 arg))))) 1289 | (if (eq window-system 'w32) 1290 | (modify-frame-parameters 1291 | nil `((left . (+ ,pos-x)) (top . (+ ,pos-y)))) 1292 | (unless (and (eq pos-x (moom--frame-left)) 1293 | (eq pos-y (moom--frame-top))) 1294 | (set-frame-position nil (moom--pos-x pos-x) (moom--pos-y pos-y))))) 1295 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1296 | (moom--add-command-history last))) 1297 | (moom-print-status)) 1298 | 1299 | ;;;###autoload 1300 | (defun moom-cycle-frame-height () 1301 | "Change frame height and update the internal ring. 1302 | If you find the frame is NOT changed as expected, 1303 | please configure the margins by variable `moom-user-margin'. 1304 | No information is stored for undo." 1305 | (interactive) 1306 | (unless moom--height-list 1307 | (moom--make-frame-height-list)) 1308 | (let ((height (car moom--height-list))) 1309 | ;; Skip the current height 1310 | (when (equal height (moom--frame-height)) 1311 | (moom--cycle-frame-height-list) 1312 | (setq height (car moom--height-list))) 1313 | ;; Align to center or bottom line 1314 | (cond ((equal height (moom--max-frame-height)) 1315 | (moom-change-frame-height (moom--max-frame-pixel-height) t)) 1316 | ((equal height (/ (moom--max-frame-height) 2)) 1317 | (moom-change-frame-height (moom--max-half-frame-pixel-height) t)) 1318 | (t (moom-change-frame-height height)))) 1319 | (moom--cycle-frame-height-list) 1320 | (run-hooks 'moom-resize-frame-height-hook)) 1321 | 1322 | ;;;###autoload 1323 | (defun moom-fill-height () 1324 | "Expand frame height to fill screen vertically without changing frame width." 1325 | (interactive) 1326 | (let ((last (moom--save-last-status))) 1327 | (moom-move-frame-to-edge-top) 1328 | (moom-change-frame-height (moom--max-frame-pixel-height) t) 1329 | (moom--make-frame-height-list) 1330 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1331 | (moom--add-command-history last)))) 1332 | (defalias 'moom-change-frame-height-max 'moom-fill-height) 1333 | 1334 | ;;;###autoload 1335 | (defun moom-change-frame-height (&optional frame-height pixelwise) 1336 | "Change the hight of the current frame. 1337 | Argument FRAME-HEIGHT specifies new frame height. 1338 | If PIXELWISE is non-nil, the frame height will be changed by pixel value." 1339 | (interactive 1340 | (list (read-number "New Height: " (moom--frame-height)))) 1341 | (let ((last (moom--save-last-status))) 1342 | (when (not frame-height) 1343 | (setq frame-height moom-min-frame-height)) 1344 | (if pixelwise 1345 | (set-frame-height nil frame-height nil pixelwise) 1346 | (let ((min-height (moom--min-frame-height)) 1347 | (max-height (moom--max-frame-height))) 1348 | (when (> frame-height max-height) 1349 | (setq frame-height max-height) 1350 | (when moom-verbose 1351 | (message "[Moom] Force set the height %s." frame-height))) 1352 | (when (< frame-height min-height) 1353 | (setq frame-height min-height) 1354 | (when moom-verbose 1355 | (message "[Moom] Force set the height %s." frame-height))) 1356 | (set-frame-height nil (floor frame-height)))) 1357 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1358 | (moom--add-command-history last))) 1359 | (moom-print-status)) 1360 | 1361 | ;;;###autoload 1362 | (defun moom-change-frame-width (&optional frame-width pixelwise) 1363 | "Change the frame width by the FRAME-WIDTH argument. 1364 | This function does not effect font size. 1365 | If FRAME-WIDTH is nil, `moom-frame-width-single' will be used. 1366 | If PIXELWISE is non-nil, the frame width will be changed by pixel value. 1367 | In that case, variable `moom--frame-width' will keep the same value." 1368 | (interactive 1369 | (list (read-number "New Width: " (moom--frame-width)))) 1370 | (let ((last (moom--save-last-status))) 1371 | (unless frame-width 1372 | (setq frame-width moom-frame-width-single)) 1373 | (if pixelwise 1374 | (set-frame-width nil frame-width nil pixelwise) 1375 | (set-frame-width nil frame-width) 1376 | (setq moom--frame-width frame-width)) 1377 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1378 | (moom--add-command-history last))) 1379 | (moom-print-status)) 1380 | 1381 | ;;;###autoload 1382 | (defun moom-change-frame-width-single () 1383 | "Change the frame width to single. 1384 | This function does not effect font size." 1385 | (interactive) 1386 | (let ((last (moom--save-last-status))) 1387 | (moom-change-frame-width) 1388 | (when (moom--centerize-p 'single) 1389 | (moom-move-frame-to-horizontal-center)) 1390 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1391 | (moom--add-command-history last)))) 1392 | 1393 | ;;;###autoload 1394 | (defun moom-change-frame-width-double () 1395 | "Change the frame width to double. 1396 | This function does not effect font size." 1397 | (interactive) 1398 | (let ((last (moom--save-last-status))) 1399 | (moom-change-frame-width moom-frame-width-double) 1400 | (if (moom--centerize-p 'double) 1401 | (moom-move-frame-to-horizontal-center) 1402 | (moom--stay-in-region)) 1403 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1404 | (moom--add-command-history last)))) 1405 | 1406 | ;;;###autoload 1407 | (defun moom-change-frame-width-half-again () 1408 | "Change the frame width to half as large again as single width. 1409 | This function does not effect font size." 1410 | (interactive) 1411 | (let ((last (moom--save-last-status))) 1412 | (moom-change-frame-width (floor (* 1.5 moom-frame-width-single))) 1413 | (if (moom--centerize-p 'half-again) 1414 | (moom-move-frame-to-horizontal-center) 1415 | (moom--stay-in-region)) 1416 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1417 | (moom--add-command-history last)))) 1418 | 1419 | ;;;###autoload 1420 | (defun moom-fill-width () 1421 | "Change the frame width to fill display horizontally. 1422 | This function does not effect font size." 1423 | (interactive) 1424 | (let ((last (moom--save-last-status))) 1425 | (moom-move-frame-to-edge-left) 1426 | (moom-change-frame-width (moom--max-frame-pixel-width) t) 1427 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1428 | (moom--add-command-history last)))) 1429 | (defalias 'moom-change-frame-width-max 'moom-fill-width) 1430 | 1431 | ;;;###autoload 1432 | (defun moom-delete-windows () 1433 | "Delete all window and make frame width single. 1434 | No information is stored for undo." 1435 | (interactive) 1436 | (let ((buffer (buffer-name)) 1437 | (p (point))) 1438 | (delete-other-windows) 1439 | (switch-to-buffer buffer) 1440 | (goto-char p)) 1441 | (moom-change-frame-width) 1442 | (when (moom--centerize-p 'delete) 1443 | (moom-move-frame-to-horizontal-center)) 1444 | (run-hooks 'moom-delete-window-hook)) 1445 | 1446 | ;;;###autoload 1447 | (defun moom-split-window () 1448 | "Split window and make frame width double. 1449 | No information is stored for undo." 1450 | (interactive) 1451 | (moom-change-frame-width moom-frame-width-double) 1452 | (if (moom--centerize-p 'split) 1453 | (moom-move-frame-to-horizontal-center) 1454 | (moom--stay-in-region)) 1455 | (split-window-right) 1456 | (run-hooks 'moom-split-window-hook)) 1457 | 1458 | ;;;###autoload 1459 | (defun moom-reset () 1460 | "Reset associated parameters." 1461 | (interactive) 1462 | (let ((moom--font-module-p (require 'moom-font nil t))) 1463 | (setq moom--maximized nil) 1464 | (setq moom--command-history nil) 1465 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1466 | (moom--add-command-history (moom--save-last-status))) 1467 | (moom-restore-last-status moom--init-status) 1468 | (moom-identify-current-monitor) 1469 | (when (or moom--non-interactive-history (called-interactively-p 'any)) 1470 | (run-hooks 'moom-after-reset-hook)))) 1471 | 1472 | ;;;###autoload 1473 | (defun moom-update-height-steps (arg) 1474 | "Change number of step of the height ring by ARG. 1475 | The default step is 4." 1476 | (when (and (integerp arg) 1477 | (> arg 1)) 1478 | (setq moom--height-steps arg) 1479 | (moom--make-frame-height-list))) 1480 | 1481 | ;;;###autoload 1482 | (defun moom-screen-margin (margins &optional fill) 1483 | "Change top, bottom, left, and right margin by provided MARGINS. 1484 | MARGINS shall be a list consists of 4 integer variables like \=(23 0 0 0). 1485 | If FILL is non-nil, the frame will cover the screen with given margins." 1486 | (when (and (listp margins) 1487 | (eq (length margins) 4)) 1488 | (setq moom--screen-margin margins) 1489 | (moom-reset) 1490 | (when fill 1491 | (moom-toggle-frame-maximized))) 1492 | (warn "`moom-screen-margin' is obsolated since 2020-10-01")) 1493 | 1494 | (make-obsolete 'moom-screen-margin 'moom-check-user-margin "2020-10-01") 1495 | 1496 | ;;;###autoload 1497 | (defun moom-update-user-margin (margin) 1498 | "Update variable `moom-user-margin' and apply it to internal margin. 1499 | MARGIN is a list with 4 integers in order of {top, down, left, right}." 1500 | (interactive (list (moom--read-user-margin))) 1501 | (if (not (eq 4 (length margin))) 1502 | (user-error "[moom] Format error...%s" margin) 1503 | (setq moom-user-margin margin) 1504 | (moom-identify-current-monitor) 1505 | (moom--make-frame-height-list) 1506 | (message "[moom] `moom-user-margin' is updated to %s." moom-user-margin))) 1507 | 1508 | ;;;###autoload 1509 | (defun moom-check-user-margin (margin) 1510 | "Change top, bottom, left, and right margin by provided MARGINS. 1511 | MARGIN shall be a list consists of 4 integer variables like \=(10 10 20 20)." 1512 | (interactive (list (moom--read-user-margin))) 1513 | (let ((last (moom--save-last-status)) 1514 | (sm moom--screen-margin)) 1515 | (when (eq 4 (length margin)) 1516 | (let ((moom-user-margin margin)) 1517 | (moom-reset) 1518 | (moom-move-frame) 1519 | (moom-fill-screen)) 1520 | (if (y-or-n-p "[moom] Update `moom-user-margin' for this session? ") 1521 | (moom-update-user-margin margin) 1522 | (message "[moom] Abort.") 1523 | (setq moom--screen-margin sm)) 1524 | (moom-restore-last-status last)))) 1525 | 1526 | ;;;###autoload 1527 | (defun moom-restore-last-status (&optional status) 1528 | "Restore the last frame position, size, and font-size. 1529 | STATUS is a list consists of font size, frame position, frame region, 1530 | and pixel-region." 1531 | (interactive) 1532 | (when status 1533 | (setq moom--last-status status)) 1534 | (let ((moom-font-before-resize-hook nil) 1535 | (moom-font-after-resize-hook nil)) 1536 | (moom--font-resize (cdr (assoc "font-size" moom--last-status)) nil)) 1537 | (set-frame-position nil 1538 | (cdr (assoc "left" moom--last-status)) 1539 | (cdr (assoc "top" moom--last-status))) 1540 | (set-frame-size nil 1541 | (cdr (assoc "width" moom--last-status)) 1542 | (cdr (assoc "height" moom--last-status))) 1543 | (set-frame-size nil 1544 | (- (cdr (assoc "pixel-width" moom--last-status)) 1545 | (moom--frame-internal-width)) 1546 | (+ (- (cdr (assoc "pixel-height" moom--last-status)) 1547 | (moom--internal-border-height))) 1548 | t) 1549 | (when moom--screen-margin 1550 | (moom--make-frame-height-list)) 1551 | (moom-print-status)) 1552 | 1553 | ;;;###autoload 1554 | (defun moom-toggle-font-module () 1555 | "Toggle `moom--font-module-p'. 1556 | When `moom--font-module-p' is nil, font size is fixed except for `moom-reset' 1557 | even if \"moom-font.el\" is loaded." 1558 | (interactive) 1559 | (if (require 'moom-font nil t) 1560 | (progn 1561 | (setq moom--font-module-p (not moom--font-module-p)) 1562 | (setq moom-font--pause (not moom--font-module-p)) 1563 | (if moom--font-module-p 1564 | (add-hook 'moom-font-after-resize-hook 1565 | #'moom--make-frame-height-list) 1566 | (remove-hook 'moom-font-after-resize-hook 1567 | #'moom--make-frame-height-list)) 1568 | (when moom-verbose 1569 | (message 1570 | (concat "[Moom] Using font module ... " 1571 | (if moom--font-module-p "ON" "OFF"))))) 1572 | (when moom-verbose 1573 | (message "[Moom] moom-font.el is NOT installed.")))) 1574 | 1575 | ;;;###autoload 1576 | (defun moom-generate-font-table () 1577 | "Generate a font table. 1578 | The last frame position and size will be restored." 1579 | (interactive) 1580 | (if (not (fboundp 'moom-font--generate-font-table)) 1581 | (warn "moom-font.el is NOT installed.") 1582 | (let* ((moom--font-module-p (boundp 'moom-font--pause)) 1583 | (moom-font--pause (not moom--font-module-p)) 1584 | (last (moom--save-last-status))) 1585 | (moom-font--generate-font-table) 1586 | (moom-restore-last-status last)))) 1587 | 1588 | ;;;###autoload 1589 | (defun moom-recommended-keybindings (options) 1590 | "Apply pre defined keybindings. 1591 | OPTIONS is a list of moom API types. If you want to set all recommemded 1592 | keybindings, put the following code in your init.el. 1593 | (with-eval-after-load \"moom\" 1594 | (moom-recommended-keybindings \='all)) 1595 | =\'all is identical to =\'(move fit expand fill font reset undo). 1596 | If OPTIONS includes =\'wof, then each binding is configured not to use fn key. 1597 | If you give only =\'(reset) as the argument, then \\[moom-reset] is activated. 1598 | The keybindings will be assigned only when Emacs runs in GUI." 1599 | (when window-system 1600 | (unless (listp options) 1601 | (setq options (list options))) 1602 | (when (memq 'all options) 1603 | (if (memq 'wof options) 1604 | (setq options '(move fit expand fill font reset undo wof)) 1605 | (setq options '(move fit expand fill font reset undo)))) 1606 | (when (memq 'move options) 1607 | (define-key moom-mode-map (kbd "M-0") 'moom-move-frame) 1608 | (define-key moom-mode-map (kbd "M-1") 'moom-move-frame-left) 1609 | (define-key moom-mode-map (kbd "M-2") 'moom-move-frame-to-center) 1610 | (define-key moom-mode-map (kbd "M-3") 'moom-move-frame-right)) 1611 | (when (memq 'fit options) 1612 | (cond 1613 | ((memq 'wof options) 1614 | (define-key moom-mode-map (kbd "C-c e l") 'moom-move-frame-to-edge-left) 1615 | (define-key moom-mode-map (kbd "C-c e r") 1616 | 'moom-move-frame-to-edge-right) 1617 | (define-key moom-mode-map (kbd "C-c e t") 'moom-move-frame-to-edge-top) 1618 | (define-key moom-mode-map (kbd "C-c e b") 1619 | 'moom-move-frame-to-edge-bottom)) 1620 | (t 1621 | (define-key moom-mode-map (kbd "M-") 'moom-move-frame-to-edge-left) 1622 | (define-key moom-mode-map (kbd "M-") 'moom-move-frame-to-edge-right) 1623 | (define-key moom-mode-map (kbd "") 'moom-move-frame-to-edge-top) 1624 | (define-key moom-mode-map (kbd "S-") 1625 | 'moom-move-frame-to-edge-bottom))) 1626 | (define-key moom-mode-map (kbd "C-c f c l") 1627 | 'moom-move-frame-to-centerline-from-left) 1628 | (define-key moom-mode-map (kbd "C-c f c r") 1629 | 'moom-move-frame-to-centerline-from-right) 1630 | (define-key moom-mode-map (kbd "C-c f c t") 1631 | 'moom-move-frame-to-centerline-from-top) 1632 | (define-key moom-mode-map (kbd "C-c f c b") 1633 | 'moom-move-frame-to-centerline-from-bottom)) 1634 | (when (memq 'expand options) 1635 | (cond ((memq 'wof options) 1636 | (define-key moom-mode-map (kbd "C-2") 'moom-cycle-frame-height)) 1637 | (t 1638 | (define-key moom-mode-map (kbd "") 'moom-cycle-frame-height))) 1639 | (define-key moom-mode-map (kbd "C-c f s") 'moom-change-frame-width-single) 1640 | (define-key moom-mode-map (kbd "C-c f d") 'moom-change-frame-width-double) 1641 | (define-key moom-mode-map (kbd "C-c f S") 'moom-delete-windows) 1642 | (define-key moom-mode-map (kbd "C-c f D") 'moom-split-window) 1643 | (define-key moom-mode-map (kbd "C-c f w") 'moom-change-frame-width-max) 1644 | (define-key moom-mode-map (kbd "C-c f h") 'moom-change-frame-height-max) 1645 | (define-key moom-mode-map (kbd "C-c f a") 1646 | 'moom-change-frame-width-half-again)) 1647 | (when (memq 'fill options) 1648 | (define-key moom-mode-map (kbd "C-c f f t") 'moom-fill-top) 1649 | (define-key moom-mode-map (kbd "C-c f f b") 'moom-fill-bottom) 1650 | (define-key moom-mode-map (kbd "C-c f f l") 'moom-fill-left) 1651 | (define-key moom-mode-map (kbd "C-c f f r") 'moom-fill-right) 1652 | (define-key moom-mode-map (kbd "C-c f f 1") 'moom-fill-top-left) 1653 | (define-key moom-mode-map (kbd "C-c f f 2") 'moom-fill-top-right) 1654 | (define-key moom-mode-map (kbd "C-c f f 3") 'moom-fill-bottom-left) 1655 | (define-key moom-mode-map (kbd "C-c f f 4") 'moom-fill-bottom-right) 1656 | (define-key moom-mode-map (kbd "C-c f f m") 'moom-fill-band) 1657 | (define-key moom-mode-map (kbd "C-c f f w") 'moom-fill-width) ;; will be deleted 1658 | (define-key moom-mode-map (kbd "C-c f f h") 'moom-fill-height) ;; will be deleted 1659 | (cond ((memq 'wof options) 1660 | (define-key moom-mode-map (kbd "C-c f f x") 1661 | 'moom-toggle-frame-maximized)) 1662 | (t 1663 | (define-key moom-mode-map (kbd "M-") 1664 | 'moom-toggle-frame-maximized)))) 1665 | (when (memq 'font options) 1666 | (define-key moom-mode-map (kbd "C--") 'moom-font-decrease) 1667 | (define-key moom-mode-map (kbd "C-=") 'moom-font-increase) 1668 | (define-key moom-mode-map (kbd "C-0") 'moom-font-size-reset)) 1669 | (when (memq 'reset options) 1670 | (define-key moom-mode-map (kbd "C-c C-0") 'moom-reset)) 1671 | (when (memq 'undo options) 1672 | (define-key moom-mode-map (kbd "C-c C-/") 'moom-undo)) 1673 | (when (and moom-verbose 1674 | options) 1675 | (message "[Moom] Key defined for APIs of %s." options)))) 1676 | 1677 | ;;;###autoload 1678 | (defun moom-print-status () 1679 | "Print font size, frame size and origin in mini buffer." 1680 | (interactive) 1681 | (when (and moom-verbose 1682 | moom--print-status) 1683 | ;; (message "--- print!") 1684 | (let ((message-log-max nil) 1685 | (fc-width (frame-char-width)) 1686 | (fp-width (moom--frame-pixel-width)) 1687 | (fp-height (moom--frame-pixel-height))) 1688 | (message 1689 | (format 1690 | "[Moom] Font: %spt(%dpx) | Frame: c(%d, %d) p(%d, %d) | Origin: (%s, %s)" 1691 | (if moom--font-module-p moom-font--size "**") 1692 | fc-width 1693 | (/ (- fp-width (moom--frame-internal-width)) fc-width) 1694 | (/ (- fp-height (moom--internal-border-height)) (frame-char-height)) 1695 | fp-width 1696 | fp-height 1697 | (- (moom--frame-left) (nth 2 moom--local-margin)) 1698 | (- (moom--frame-top) (nth 0 moom--local-margin))))))) 1699 | 1700 | ;;;###autoload 1701 | (defun moom-version () 1702 | "The release version of Moom." 1703 | (interactive) 1704 | (let ((moom-release "1.6.9")) 1705 | (message "[Moom] v%s" moom-release))) 1706 | 1707 | ;;;###autoload 1708 | (define-minor-mode moom-mode 1709 | "Toggle the minor mode `moom-mode'. 1710 | This mode provides a set of commands to control frame position and size. 1711 | The font size in buffers will be changed with synchronization of the updated 1712 | frame geometry so that the frame width could be maintained at 80. 1713 | 1714 | No keybindings are configured as default but recommended keybindings are 1715 | implemented in `moom-mode', thus user setting is very easy. 1716 | You just use `moom-recommended-keybindings' to apply the recommended 1717 | keybindings. 1718 | 1719 | To see more details and examples, please visit https://github.com/takaxp/moom." 1720 | :init-value nil 1721 | :lighter (:eval (moom--lighter)) 1722 | :keymap moom-mode-map 1723 | :global t 1724 | :require 'moom 1725 | :group 'moom 1726 | (when window-system 1727 | (if moom-mode 1728 | (moom--setup) 1729 | (moom--abort)))) 1730 | 1731 | (provide 'moom) 1732 | 1733 | ;;; moom.el ends here 1734 | --------------------------------------------------------------------------------