diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c0f894b5f473d9832dd7cbfa780c2fa194316b94..0000000000000000000000000000000000000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -todo.org \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 7ba573f7787e25484827eab032553b4797ff53e6..0000000000000000000000000000000000000000 --- a/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - sniem Copyright (C) 2021 SpringHan - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/README.org b/README.org deleted file mode 100644 index ebdfb4603b00a2a8cc631b383bcd98bca02c385e..0000000000000000000000000000000000000000 --- a/README.org +++ /dev/null @@ -1,209 +0,0 @@ -* Sniem - [[file:README_CN.org][中文文档]] -** Screenshot - [[file:screenshot.png]] -** Dependences - - ~s~ - - ~dash~ -** Installation - #+begin_src emacs-lisp - (use-package - sniem - :load-path "path/to/sniem" - :init (global-sniem-mode t) - :config - (sniem-set-keyboard-layout 'qwerty)) - #+end_src -** What is sniem - Sniem means Simple United Editing Method,it's a new editing method for Emacs. -** Features - - ~last-point~ - - ~last-point~ is a thing that through all motions and most of operations. Like its name, when execute any motions, the last position will be set to ~last-point~. - - - ~leader-key~ - - Sniem has leader key,the key of leader map can be set by ~(sniem-leader-set-key)~. And you can use ~(sniem-set-leader-key)~ to set the key of leader. - #+begin_src emacs-lisp - (sniem-leader-set-key - "d" 'sniem-digit-argument-or-fn - "D" 'dired) - (sniem-set-leader-key ",") - #+end_src - - - Modes - - Sniem has 3 modes. - - ~NORMAL~: This mode is the default mode for the editing buffers. - - You can use ~(sniem-normal-set-key)~ to set keys for normal mode. Its usage is same as ~(sniem-leader-set-key)~. - - - ~INSERT~: This mode will be used when you executed ~sniem-insert~ in ~NORMAL~ mode. It's used to edit. In this mode, there's only one binding for ~sniem~, that is ~~ which will make you exit ~INSERT~ mode back to ~NORMAL~ mode. - - - ~MOTION~: This mode is used in special modes, there's only has one binding for ~sniem~, that is ~~ which can let you use leader keys. - - - ~EXPAND~: This mode is used to expand region more comfortablely. - - You can use ~(sniem-expand-set-key)~ to set keys for normal mode. Its usage is same as ~(sniem-leader-set-key)~. - - | Key | Function | - | ~RET~ | Call the object-catch function | - | ~r~ | Repeat the object-catch | - | ~p~ | Catch the parent pair of the content selected | - | ~b~ | Catch pair by its prefix char | - | ~B~ | Catch the parent pair of the content selected by its prefix char | - | ~o~ | Catch ~()~ pair | - | ~O~ | Catch parent ~()~ pair for the content selected | - | ~s~ | Catch ~[]~ pair | - | ~S~ | Catch parent ~[]~ pair for the content selected | - | ~c~ | Catch ~{}~ pair | - | ~C~ | Catch parent ~{}~ pair for the content selected | - | ~q~ | Catch ~''~ pair | - | ~Q~ | Catch parent ~''~ pair for the content selected | - | ~d~ | Catch ~""~ pair | - | ~D~ | Catch parent ~""~ pair for the content selected | - | ~a~ | Catch ~<>~ pair | - | ~A~ | Catch parent ~<>~ pair for the content selected | - | ~/~ | Reverse the direction of catch | - | Other alpha keys | Quit expand mode and goto NORMAL mode | - - - Keyboard layout - - Sniem provides supports for the mainly 4 layouts,you can use ~(sniem-set-keyboard-layout)~ to set. - #+begin_src emacs-lisp - (sniem-set-keyboard-layout 'qwerty) - (sniem-set-keyboard-layout 'colemak) - (sniem-set-keyboard-layout 'dvorak) - (sniem-set-keyboard-layout 'dvp) ;For Dvorak Programmer - #+end_src - After you set the keyboard layout, Sniem will set the default keys in ~NORMAL~ mode accroding to your layout, then create the cheatsheet. - - - Keypad - - Sniem provides the Keypad function, After you execute the Keypad, When you press: , is ~C-~ , . is ~M-~ , / is ~C-M-~ . After you press ~~, it will reture the next key itself which you press. - - - middle-keyboard-digit-argument-or-function - - This function is defaultly bound on ~~. After you execute it, the middle keys of the keyboard can be instead of numbers and ~-~, the record will be over after you pressed ~~. You can also use the keys in the table to do the special operations: - | Key | Function | - | , | Repeat object-catch | - | . | Mark the content at point or a region | - | SPC | Execute function in motion-hint | - | / | Reverse the direction of object-catch | - | p | Add, change or delete the pair of region | - | < | Jump to prev comment mark | - | > | Jump to next comment mark | - | m | Insert new comment mark | -** Some special operations - - Motions - - - ~(sniem-goto-prev)~ & ~(sniem-goto-next)~ - - Use ~middle-keyboard~ to get the lines to forward or backward, then execute it. - - - ~(sniem-next-word)~ & ~(sniem-prev-word)~ - - Normally, goto the next or previous word. If there is a content selected, goto the next or previous content same as it. - - - ~(sniem-goto-last-point)~ - - Normally, goto the ~last-point~. If the ~sniem-mark-content~ is exists, goto the ~mark-content~. - - - Editing operations - - - operation-about-last-point - - Most of the editing operations is related to ~last-point~ (Without ~(sniem-paste)~). - - You can press ~p~ after the operations to execute it with ~last-point~. - - ~(sniem-lock-unlock-last-point)~ - Lock or unlock the ~last-point~. When it is locked, it will display in the buffer. - - - operation-in-region - - All of the operations which are end with ~-in-region~ will edit the area from the forward point of the start of region to the backward point of the end of the region. - - - ~object-catch~ - - Sniem provides functions to get the object smartly: ~object-catch~. - - ~~ - - Get the closest pair to cursor. - - - ~~ - - Get the parent pair of the selected pair. - - - ~~ - - Input the char of the pair, then get the closest to cursor. - - - ~~ - - Input the char of the pair, then get the parent of the selected pair. - - - ~(~ & ~[~ & ~{~ - - Quickly get the pair. - - - ~(sniem-paste)~ - - Defaultly, press ~p~ to enter the interface of the ~sniem-paste~. Then you can use ~n~ & ~p~ to flip. You can paste the first content when you press ~p~ in the first page. - ~[1-9]~ to select the content. - - - ~(sniem-macro)~ - - Sniem provides some great kmacro functions. - - Basic - - ~q~ for record, ~e~ for execution, ~n~ to name the last kmacro. - - - Advance - - - When you record after selecting some lines, the kmacro will be executed to all the lines you selected after recording. - - If you record after selecting content in the same line, the content will be recorded. Then you can execute ~(sniem-next-word)~ or ~(sniem-prev-word)~ to goto the next or previous content same as it. Execute ~(keyboard-quit)~ can cancel the content record. - - - sniem-mark-jump - - sniem-mark-jump provides two motions. They are ~(sniem-mark-jump-next)~ & ~(sniem-mark-jump-prev)~. - Normally, execute them can goto the next or previous comment mark. But if you use them with ~digit-argument~, they'll find the next or previous comment mark with type which is the number you input of the mark type alist. -** Custom - - ~sniem-center-message~ & ~sniem-mark-message~ & ~sniem-delete-message~ & ~sniem-change-message~ & ~sniem-yank-message~ & ~sniem-macro-message~ - - Theses variables are the help message for their operations. If you don't want them, you can execute this function: - #+begin_src emacs-lisp - (setq sniem-center-message nil - sniem-mark-message nil - sniem-delete-message nil - sniem-change-message nil - sniem-yank-message nil - sniem-macro-message nil) - #+end_src - - - ~sniem-xxx-mode-cursor~ - - The ~xxx~ can be: ~normal~, ~insert~, ~motion~. - - - ~sniem-motion-hint-sit-time~ - - This is the sit time for motion hint. Default is ~1~. - - - State Hint - - If you use [[https://github.com/manateelazycat/awesome-tray][awesome-tray]], sniem will automaticly set ~(sniem-state)~ to the alist, so you can use it. - Otherwise, you can set the state hint accroding to your modeline. - - If you use the default modeline, you can try this: - #+begin_src emacs-lisp - (setq-default mode-line-format (append '((:eval (sniem-state))) mode-line-format)) - (force-mode-line-update) - #+end_src - - - sniem-mark-jump - - - ~sniem-mark-jump-author-name~ - - This is the author name for the comment mark. - - - ~sniem-mark-jump-author-name-enable~ - - This variable is the status of the author name's enablement. diff --git a/README_CN.org b/README_CN.org deleted file mode 100644 index fffe1de566c4fcc887f76876f073de7ab5516b72..0000000000000000000000000000000000000000 --- a/README_CN.org +++ /dev/null @@ -1,213 +0,0 @@ -* Sniem - [[file:README.org][English Doc]] -** 截图 - [[file:screenshot.png]] -** 依赖 - - ~s~ - - ~dash~ -** 安装 - #+begin_src emacs-lisp - (use-package - sniem - :load-path "path/to/sniem" - :init (global-sniem-mode t) - :config - (sniem-set-keyboard-layout 'qwerty)) - #+end_src -** 什么是 sniem - Sniem 全称 Simple United Editing Method,是一款新的编辑模式 -** 特性 - - ~last-point~ - - ~last-point~ 是 sniem 中贯穿所有动作和几乎所有操作的概念,如其名,当执行任意动作时,一般情况下执行前的那个位置会被设置为 ~last-point~ - - - ~leader-key~ - - Sniem 自带 leader key,leader map 的按键可通过 ~(sniem-leader-set-key)~ 来设置。也可通过 ~(sniem-set-leader-key)~ 来设置 leader 的按键。 - #+begin_src emacs-lisp - (sniem-leader-set-key - "d" 'sniem-digit-argument-or-fn - "D" 'dired) - (sniem-set-leader-key ",") - #+end_src - - - Modes - - Sniem 有以下几个模式 - - ~NORMAL~ - - 一般情况下的模式,此模式下绑定了许多按键,可通过 ~(sniem-cheatsheet)~ 或者 ~?~ 键来查看绑定的按键。可通过 ~(sniem-normal-set-key)~ 来绑定按键,用法与 ~(sniem-leader-set-key)~ 相同。 - - - ~INSERT~ - - 此模式下 ~~ (可通过 ~(sniem-set-quit-insert-key)~ 设置) 按键会被绑定为 ~(sniem-quit-insert)~ 以退出此模式 ,其它按键都是 ~global-map~ 里的按键 - - - ~MOTION~ - - 与 ~INSERT~ 模式相同,除了 ~~ 键被绑定为 leader,其它按键都是原本的按键。(原来的空格键被绑定为了 ~ ~) - - - ~EXPAND~ - - 这个模式使扩展选中区域更舒适。 - - 可通过 ~(sniem-expand-set-key)~ 来绑定按键,用法与 ~(sniem-leader-set-key)~ 相同。 - - | Key | Function | - | ~RET~ | 调用 object-catch | - | ~r~ | 重复上一次的 object-catch | - | ~p~ | 抓取当前选中内容的父级 pair | - | ~b~ | 获取 pair 通过其前缀字符 | - | ~B~ | 获取当前选中内容的父级 pair 通过其前缀字符 | - | ~o~ | 获取 ~()~ pair | - | ~O~ | 获取当前选中内容的父级 ~()~ pair | - | ~s~ | 获取 ~[]~ pair | - | ~S~ | 获取当前选中内容的父级 ~[]~ pair | - | ~c~ | 获取 ~{}~ pair | - | ~C~ | 获取当前选中内容的父级 ~{}~ pair | - | ~q~ | 获取 ~''~ pair | - | ~Q~ | 获取当前选中内容的父级 ~''~ pair | - | ~d~ | 获取 ~""~ pair | - | ~D~ | 获取当前选中内容的父级 ~""~ pair | - | ~a~ | 获取 ~<>~ pair | - | ~A~ | 获取当前选中内容的父级 ~<>~ pair | - | ~/~ | 反转抓取的方向 | - | 其它字母、负号按键 | 切换到 NORMAL 模式 | - - - Keyboard layout - - Sniem 针对目前主流的四种键盘布局提供了支持,可通过 ~(sniem-set-keyboard-layout)~ 来设置 - #+begin_src emacs-lisp - (sniem-set-keyboard-layout 'qwerty) - (sniem-set-keyboard-layout 'colemak) - (sniem-set-keyboard-layout 'dvorak) - (sniem-set-keyboard-layout 'dvp) ;For Dvorak Programmer - #+end_src - 在设置了键盘布局之后,Sniem 会根据键盘布局来设置 ~NORMAL~ 模式下的默认按键,并生成当前布局的 cheatsheet - - - Keypad - - Sniem 提供 Keypad 支持,进入 Keypad 之后: , 为 ~C-~ , . 为 ~M-~ , / 为 ~C-M-~ ;按下空格再按上面这几个键,则是它们本身。 - - - middle-keyboard-digit-argument-or-function - - 此功能默认绑定在 ~~ 键上。执行后,可通过键盘中间的键来分别代替数字键和减号,回车即录入完毕;也可按下以下键来进行特殊操作: - | Key | function | - | , | 重复 object-catch | - | . | 标记当前光标下内容或区域 | - | SPC | 执行 motion-hint | - | / | 反转 object-catch 方向 | - | p | 添加,更改或删除当前选中内容的 pair | - | < | 跳转到下一个 comment mark | - | > | 跳转到上一个 comment mark | - | m | 插入新的 comment mark | -** 一些特殊操作 - - - 移动 - - - ~(sniem-goto-prev)~ & ~(sniem-goto-next)~ - 使用 ~middle-keyboard~ 来获取前进或后退的行数,并执行 - - - ~(sniem-next-word)~ & ~(sniem-prev-word)~ - 一般情况下,跳转到下一个词或者上一个词。如果有内容被选中,则跳转到下一个或上一个与选中内容相同的位置 - - - ~(sniem-goto-last-point)~ - 一般情况下,跳转到 ~last-point~ 的位置。如果有内容被记录,则跳转到其第一个字符。 - - - 编辑操作 - - - operation-about-last-point - - Sniem 中几乎所有编辑操作都与 ~last-point~ 有关 (除了 ~(sniem-paste)~) - - 上述的编辑操作只需按下 ~p~ 即可进行与 ~last-point~ 有关的操作 - - ~(sniem-lock-unlock-last-point)~ - 将 ~last-point~ 锁定或者解除锁定,此时任何移动都不会改变其值。如果被锁定了,会在当前 buffer 显示出来。 - - - operation-in-region - - 所有以 ~-in-region~ 为结尾的操作,都是在 region 中对其开头的后一个位置到结尾的前一个位置进行编辑 - - - ~object-catch~ - - Sniem 提供了一个智能获取 object 的功能, ~object-catch~ 。此源于本人用 ~evil~ 的时候写的一个插件: ~evil-wildfire~ 。 - - ~~ - - 按下此键即可选取离光标最近的 pair - - - ~~ - - 按下此键会选取当前选中的 pair 的父级 pair - - - ~~ - - 按下此键后,输入所需 pair ,然后即可选取离光标最近的 pair - - - ~~ - - 按下此键后,输入所需 pair ,然后会选取当前所选的父级 pair - - - ~(~ & ~[~ & ~{~ - - 可用于快速选取指定 pair - - - ~(sniem-paste)~ - - Sniem 的粘贴有些许不同,默认按下 ~p~ 键后进入粘贴面板,随后可用 ~n~ & ~p~ 进行翻页,如果在第一页按下 ~p~ ,则粘贴第一个结果。 - 可用数字键对内容进行选择 - - - ~(sniem-macro)~ - - Sniem 为键盘宏提供了一些不错的功能。 - - 基本功能 - - ~q~ 录制, ~e~ 执行, ~n~ 为最后一个宏命名 - - - 进阶功能 - - - 在选中多行的情况下录制,在录制完之后会对所选的每一行执行一遍 - - 在选中同行的内容后录制,在录制完之后会记录下内容,此时执行 ~(sniem-next-word)~ 或者 ~(sniem-prev-word)~ 即跳转到此内容,按下 ~C-g~ 可取消内容锁定 - - - sniem-mark-jump - - sniem-mark-jump 提供了两个 motions,即 ~(sniem-mark-jump-next)~ & ~(sniem-mark-jump-prev)~ 。 - 一般情况下,执行它们会跳转到上一个或者下一个 comment mark。但如果你使用了 ~digit-argument~ ,它们将跳转到上一个或下一个指定类型的 comment mark,此类型是以你所使用的 ~digit-argument~ 为索引向类型列表里获取到的结果。 -** 自定义 - - ~sniem-center-message~ & ~sniem-mark-message~ & ~sniem-delete-message~ & ~sniem-change-message~ & ~sniem-yank-message~ & ~sniem-macro-message~ - - 这些变量是其操作的帮助信息。如果你不想要它们,可以执行一下语句: - #+begin_src emacs-lisp - (setq sniem-center-message nil - sniem-mark-message nil - sniem-delete-message nil - sniem-change-message nil - sniem-yank-message nil - sniem-macro-message nil) - #+end_src - - - ~sniem-xxx-mode-cursor~ - - ~xxx~ 可以是: ~normal~, ~insert~, ~motion~ - - - ~sniem-motion-hint-sit-time~ - - 这是动作提示的显示时间,默认为 ~1~ - - - 模式提示 - - 如果你使用 [[https://github.com/manateelazycat/awesome-tray][awesome-tray]], sniem 将自动把 ~(sniem-state)~ 添加到指定列表,供你使用。 - 或者,你可以根据你的 modeline 来设置模式提醒。 - - 如果你使用的是默认的 modeline, 你可以尝试以下方案: - #+begin_src emacs-lisp - (setq-default mode-line-format (append '((:eval (sniem-state))) mode-line-format)) - (force-mode-line-update) - #+end_src - - - sniem-mark-jump - - - ~sniem-mark-jump-author-name~ - - 这是 comment mark 中的人名。 - - - ~sniem-mark-jump-author-name-enable~ - - 这是当前人名的启用状态。 diff --git a/screenshot.png b/screenshot.png deleted file mode 100644 index cf1c6ea295d3b44af3887aad09a7fd2e013c87c8..0000000000000000000000000000000000000000 Binary files a/screenshot.png and /dev/null differ diff --git a/sniem-cheatsheet.el b/sniem-cheatsheet.el deleted file mode 100644 index 229c9fcb79adeff425365cd5350451b64545d35b..0000000000000000000000000000000000000000 --- a/sniem-cheatsheet.el +++ /dev/null @@ -1,332 +0,0 @@ -;;; sniem-cheatsheet.el --- Simple united editing method -*- lexical-binding: t -*- - -;; Author: SpringHan -;; Maintainer: SpringHan - -;; This file is not part of GNU Emacs - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; For a full copy of the GNU General Public License -;; see . - - -;;; Commentary: - -;; Simple united editing method. - -;;; Code: - -(require 's) -(require 'dash) -(require 'sniem-var) - -(defconst sniem-cheatsheet-layout-qwerty - " Cheatsheet For Qwerty - -┏━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━┓ -┃ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ DEL ┃ -┃ [~]| [!]| [@]| [#]| [$]| [%]| [^]| [&]| [*]| [(]| [)]| [_]| [+]| ┃ -┠─┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┤ [DEL]┃ -┃ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ ┃ -┃ [`]| [1]| [2]| [3]| [4]| [5]| [6]| [7]| [8]| [9]| [0]| [-]| [=]| ┃ -┠─────────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────────┨ -┃ TAB │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ { │ } │ | ┃ -┃ | [Q]| [W]| [E]| [R]| [T]| [Y]| [U]| [I]| [O]| [P]| [{]| [}]| [|]┃ -┃ ├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┨ -┃ │ q │ w │ e │ r │ t │ y │ u │ i │ o │ p │ [ │ ] │ \\ ┃ -┃ | [q]| [w]| [e]| [r]| [t]| [y]| [u]| [i]| [o]| [p]| [[]| []]| [\\]┃ -┠─────────────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─────────┨ -┃ │ A │ S │ D │ F │ G │ H │ J │ K │ L │ : │ \" │ RET ┃ -┃ | [A]| [S]| [D]| [F]| [G]| [H]| [J]| [K]| [L]| [:]| [\"]│ ┃ -┃ ├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┤ [RET]┃ -┃ │ a │ s │ d │ f │ g │ h │ j │ k │ l │ ; │ ' │ ┃ -┃ | [a]| [s]| [d]| [f]| [g]| [h]| [j]| [k]| [l]| [;]| [']| ┃ -┠───────────────┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────────────────┨ -┃ │ Z │ X │ C │ V │ B │ N │ M │ < │ > │ ? │ ┃ -┃ | [Z]| [X]| [C]| [V]| [B]| [N]| [M]| [<]| [>]| [?]| ┃ -┃ ├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┤ ┃ -┃ │ z │ x │ c │ v │ b │ n │ m │ , │ . │ / │ ┃ -┃ | [z]| [x]| [c]| [v]| [b]| [n]| [m]| [,]| [.]| [/]| ┃ -┗━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━╅─────────┴─────────┴─────────┴─────────╆━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━┛ - ┃ SPC ┃ - ┃ [SPC]┃ - ┃ ┃ - ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ -" ) - -(defconst sniem-cheatsheet-layout-dvp - " Cheatsheet For Programmer Dvorak - -┏━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━┓ -┃ ~ │ % │ 7 │ 5 │ 3 │ 1 │ 9 │ 0 │ 2 │ 4 │ 6 │ 8 │ ` │ DEL ┃ -┃ [~]│ [%]│ [7]│ [5]│ [3]│ [1]│ [9]│ [0]│ [2]│ [4]│ [6]│ [8]│ [`]│ ┃ -┠─┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┤ [DEL]┃ -┃ $ │ & │ [ │ { │ } │ ( │ = │ * │ ) │ + │ ] │ ! │ # │ ┃ -┃ [$]│ [&]│ [[]│ [{]│ [}]│ [(]│ [=]│ [*]│ [)]│ [+]│ []]│ [!]│ [#]│ ┃ -┠─────────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────────┨ -┃ TAB │ : │ < │ > │ P │ Y │ F │ G │ C │ R │ L │ ? │ ^ │ | ┃ -┃ │ [:]│ [<]│ [>]│ [P]│ [Y]│ [F]│ [G]│ [C]│ [R]│ [L]│ [?]│ [^]│ [|]┃ -┃ ├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┨ -┃ │ ; │ , │ . │ p │ y │ f │ g │ c │ r │ l │ / │ @ │ \\ ┃ -┃ │ [;]│ [,]│ [.]│ [p]│ [y]│ [f]│ [g]│ [c]│ [r]│ [l]│ [/]│ [@]│ [\\]┃ -┠─────────────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─────────┨ -┃ │ A │ O │ E │ U │ I │ D │ H │ T │ N │ S │ _ │ RET ┃ -┃ │ [A]│ [O]│ [E]│ [U]│ [I]│ [D]│ [H]│ [T]│ [N]│ [S]│ [_]│ ┃ -┃ ├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┤ [RET]┃ -┃ │ a │ o │ e │ u │ i │ d │ h │ t │ n │ s │ - │ ┃ -┃ │ [a]│ [o]│ [e]│ [u]│ [i]│ [d]│ [h]│ [t]│ [n]│ [s]│ [-]│ ┃ -┠───────────────┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────────────────┨ -┃ │ \" │ Q │ J │ K │ X │ B │ M │ W │ V │ Z │ ┃ -┃ │ [\"]│ [Q]│ [J]│ [K]│ [X]│ [B]│ [M]│ [W]│ [V]│ [Z]│ ┃ -┃ ├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┤ ┃ -┃ │ ' │ q │ j │ k │ x │ b │ m │ w │ v │ z │ ┃ -┃ │ [']│ [q]│ [j]│ [k]│ [x]│ [b]│ [m]│ [w]│ [v]│ [z]│ ┃ -┗━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━╅─────────┴─────────┴─────────┴─────────╆━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━┛ - ┃ SPC ┃ - ┃ [SPC]┃ - ┃ ┃ - ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ -") - -(defconst sniem-cheatsheet-layout-dvorak - " Cheatsheet For Dvorak Simplified - -┏━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━┓ -┃ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ { │ } │ DEL ┃ -┃ [~]| [!]| [@]| [#]| [$]| [%]| [^]| [&]| [*]| [(]| [)]| [{]| [}]| ┃ -┠─┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┤ [DEL]┃ -┃ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ [ │ ] │ ┃ -┃ [`]| [1]| [2]| [3]| [4]| [5]| [6]| [7]| [8]| [9]| [0]| [[]| []]| ┃ -┠─────────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────────┨ -┃ TAB │ \" │ < │ > │ P │ Y │ F │ G │ C │ R │ L │ ? │ + │ | ┃ -┃ │ [\"]│ [<]│ [>]│ [P]│ [Y]│ [F]│ [G]│ [C]│ [R]│ [L]│ [?]│ [+]│ [|]┃ -┃ ├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┨ -┃ │ ' │ , │ . │ p │ y │ f │ g │ c │ r │ l │ / │ = │ \\ ┃ -┃ │ [']│ [,]│ [.]│ [p]│ [y]│ [f]│ [g]│ [c]│ [r]│ [l]│ [/]│ [=]│ [\\]┃ -┠─────────────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─────────┨ -┃ │ A │ O │ E │ U │ I │ D │ H │ T │ N │ S │ _ │ RET ┃ -┃ │ [A]│ [O]│ [E]│ [U]│ [I]│ [D]│ [H]│ [T]│ [N]│ [S]│ [_]│ ┃ -┃ ├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┤ [RET]┃ -┃ │ a │ o │ e │ u │ i │ d │ h │ t │ n │ s │ - │ ┃ -┃ │ [a]│ [o]│ [e]│ [u]│ [i]│ [d]│ [h]│ [t]│ [n]│ [s]│ [-]│ ┃ -┠───────────────┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────────────────┨ -┃ │ : │ Q │ J │ K │ X │ B │ M │ W │ V │ Z │ ┃ -┃ │ [:]│ [Q]│ [J]│ [K]│ [X]│ [B]│ [M]│ [W]│ [V]│ [Z]│ ┃ -┃ ├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┤ ┃ -┃ │ ; │ q │ j │ k │ x │ b │ m │ w │ v │ z │ ┃ -┃ │ [;]│ [q]│ [j]│ [k]│ [x]│ [b]│ [m]│ [w]│ [v]│ [z]│ ┃ -┗━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━╅─────────┴─────────┴─────────┴─────────╆━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━┛ - ┃ SPC ┃ - ┃ [SPC]┃ - ┃ ┃ - ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ -") - -(defconst sniem-cheatsheet-layout-colemak - " Cheatsheet For Colemak - -┏━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━┓ -┃ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ DEL ┃ -┃ [~]| [!]| [@]| [#]| [$]| [%]| [^]| [&]| [*]| [(]| [)]| [_]| [+]| ┃ -┠─┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┤ [DEL]┃ -┃ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ ┃ -┃ [`]| [1]| [2]| [3]| [4]| [5]| [6]| [7]| [8]| [9]| [0]| [-]| [=]| ┃ -┠─────────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────┴───┬─────────┨ -┃ TAB │ Q │ W │ F │ P │ G │ J │ L │ U │ Y │ : │ { │ } │ | ┃ -┃ | [Q]| [W]| [F]| [P]| [G]| [J]| [L]| [U]| [Y]| [:]| [{]| [}]| [|]┃ -┃ ├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┨ -┃ │ q │ w │ f │ p │ g │ j │ l │ u │ y │ ; │ [ │ ] │ \\ ┃ -┃ | [q]| [w]| [f]| [p]| [g]| [j]| [l]| [u]| [y]| [;]| [[]| []]| [\\]┃ -┠─────────────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─────────┨ -┃ │ A │ R │ S │ T │ D │ H │ N │ E │ I │ O │ \" │ RET ┃ -┃ | [A]| [R]| [S]| [T]| [D]| [H]| [N]| [E]| [I]| [O]| [\"]│ ┃ -┃ ├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┤ [RET]┃ -┃ │ a │ r │ s │ t │ d │ h │ n │ e │ i │ o │ ' │ ┃ -┃ | [a]| [r]| [s]| [t]| [d]| [h]| [n]| [e]| [i]| [o]| [']| ┃ -┠───────────────┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────┬───┴─────────────────┨ -┃ │ Z │ X │ C │ V │ B │ K │ M │ < │ > │ ? │ ┃ -┃ | [Z]| [X]| [C]| [V]| [B]| [K]| [M]| [<]| [>]| [?]| ┃ -┃ ├┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┼┄┄┄┄┄┄┄┄┄┤ ┃ -┃ │ z │ x │ c │ v │ b │ k │ m │ , │ . │ / │ ┃ -┃ | [z]| [x]| [c]| [v]| [b]| [k]| [m]| [,]| [.]| [/]| ┃ -┗━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━╅─────────┴─────────┴─────────┴─────────╆━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━┛ - ┃ SPC ┃ - ┃ [SPC]┃ - ┃ ┃ - ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ -" ) - -(defconst sniem-cheatsheet-keys - '("a" "A" "b" "B" "c" "C" "d" "D" "e" "E" "f" "F" "g" "G" "h" "H" "i" "I" "j" "J" - "k" "K" "l" "L" "m" "M" "n" "N" "o" "O" "p" "P" "q" "Q" "r" "R" "s" "S" "t" "T" - "u" "U" "v" "V" "w" "W" "x" "X" "y" "Y" "z" "Z" "0" "1" "2" "3" "4" "5" "6" "7" - "8" "9" "!" "@" "" "$" "%" "^" "&" "*" "" "~" "-" "_" "=" "+" "," "<" "." ">" - "/" "?" "(" ")" "[" "]" "{" "}" "\\" "|" ";" ":" "'" "\"" "#" "`" "SPC" "RET" "DEL")) - -(defcustom sniem-cheatsheet-special-key-space - '(("" . " ") - (" " . " ") - (" " . " ")) - "The space for special key." - :type 'list - :group 'sniem) - -(defcustom sniem-cheatsheet-special-key-width - '(("" . 13) - (" " . 17) - (" " . 39)) - "The space for special key." - :type 'list - :group 'sniem) - -(defcustom sniem-cheatsheet-short-commands - '((sniem-forward-char . "→") - (sniem-backward-char . "←") - (sniem-5-forward-char . "5*→") - (sniem-5-backward-char . "←*5") - (sniem-next-line . "↓") - (sniem-prev-line . "↑") - (sniem-5-next-line . "↓*5") - (sniem-5-prev-line . "↑*5") - (digit-argument . "num-arg") - (sniem-digit-argument-or-fn . "num-arg-middle-keyboard-with-functions") - (sniem-beginning-of-line . "line-beg") - (sniem-end-of-line . "line-end") - (sniem-first-line . "1st line") - (sniem-goto-line . "goto-line") - (sniem-next-word . "word →") - (sniem-prev-word . "word ←") - (sniem-next-symbol . "symbol→") - (sniem-prev-symbol . "symbol←") - (sniem-beg-of-mark . "mark-beg") - (sniem-end-of-mark . "mark-end") - (sniem-lock-unlock-last-point . "lock-LP") - (sniem-goto-last-point . "goto-LP") - (sniem-move-last-point . "move-LP-p") - (sniem-goto-next . "lines ↓") - (sniem-goto-prev . "lines ↑") - (sniem-find-forward . "find →") - (sniem-find-backward . "find ←") - (sniem-up-down-case . "↑/↓ case") - (save-buffers-kill-terminal . "exit") - (sniem-yank-in-region . "Y [mark]") - (sniem-delete-in-region . "D [mark]") - (sniem-change-in-region . "C [mark]") - (sniem-paste-in-region . "P [mark]") - (sniem-keyboard-quit . "quit") - (sniem-append-line . "A-line") - (sniem-insert-line . "I-line") - (sniem-delete-char . "D-char") - (sniem-scroll-up-command . "page ↓") - (sniem-scroll-down-command . "page ↑") - (sniem-object-catch-round . "OC-(") - (sniem-object-catch-square . "OC-[") - (sniem-object-catch-curly . "OC-{") - (sniem-replace-char . "R-char") - (sniem-replace-word . "R-word") - (eval-last-sexp . "eval") - (save-buffer . "save") - (execute-extended-command . "M-x") - (sniem-open-line . "new-line↓") - (sniem-open-line-previous . "new-line↑") - (sniem-cheatsheet . "cheatpage")) - "The short commands." - :type 'list - :group 'sniem) - -(defun sniem-cheatsheet () - "Switch to the cheatsheet buffer and insert the cheatsheet." - (interactive) - (if (null sniem-keyboard-layout) - (user-error "[Sniem]: You should set `sniem-keyboard-layout' first!") - (let ((cheatsheet-layout (pcase sniem-keyboard-layout - ('dvp sniem-cheatsheet-layout-dvp) - ('dvorak sniem-cheatsheet-layout-dvorak) - ('colemak sniem-cheatsheet-layout-colemak) - ('qwerty sniem-cheatsheet-layout-qwerty)))) - (-> (propertize cheatsheet-layout 'face 'font-lock-comment-face) - (sniem-cheatsheet--replace) - (sniem-cheatsheet--show-cheatsheet))))) - -(defun sniem-cheatsheet--show-cheatsheet (cs) - "Show the cheatsheet. -Argument CS is the cheatsheet of current keyboard." - (with-current-buffer (get-buffer-create "*Sniem Cheatsheet*") - (setq-local buffer-read-only nil) - (erase-buffer) - (insert cs) - (insert "\nNOTE:\n" - (propertize "[mark]" 'face 'font-lock-constant-face) - " means the operation will edit the regions' content. You can mark a content, " - "then use operations with [mark] sign to edit them.\n" - (propertize "LP" 'face 'font-lock-constant-face) - " means the last-point, all of the sniem motions and most of the operations will use it.") - (text-mode) - (toggle-truncate-lines t) - (display-line-numbers-mode -1) - (line-number-mode -1) - (setq-local buffer-read-only t)) - (switch-to-buffer "*Sniem Cheatsheet*") - (goto-char (point-min))) - -(defun sniem-cheatsheet--replace (cs) - "Replace the keys in the cheatsheet. -Argument CS is the cheatsheet of current keyboard." - (-reduce-from - (lambda (cs key) - (let* ((ckey (kbd key)) - (cmd (key-binding ckey)) - tmp) - (if (and cmd (or (keymapp cmd) (symbolp cmd))) - (let ((case-fold-search nil)) - (s-replace - (format (if (setq tmp (alist-get ckey sniem-cheatsheet-special-key-space nil nil 'equal)) - (concat tmp "[%s]") - " [%s]") - key) - (if (and (keymapp cmd) (equal cmd sniem-leader-keymap)) - " leader" - (sniem-cheatsheet--command cmd ckey)) - cs)) - cs))) - cs sniem-cheatsheet-keys)) - -(defun sniem-cheatsheet--command (cmd key) - "Replace the command to short. -Argument CMD is the command. -Argument KEY is the key of command." - (let ((scmd (or (alist-get cmd sniem-cheatsheet-short-commands) - (s-replace "sniem-" "" (symbol-name cmd)))) - (sp-cmd-space (when (sniem-cheatsheet--special-key-p cmd key) - (alist-get key sniem-cheatsheet-special-key-width nil nil 'equal)))) - (when scmd - (when (string= "undefined" scmd) - (setq scmd "")) - (if (<= (length scmd) (or sp-cmd-space 9)) - (-> (->> (or sp-cmd-space 9) - (number-to-string) - (concat "% ")) - (concat "s") - (format scmd)) - (s-truncate (or sp-cmd-space 9) scmd))))) - -(defun sniem-cheatsheet--special-key-p (cmd key) - "Check if the KEY for CMD is included in `sniem-cheatsheet-special-key-space'." - (catch 'p - (mapc `(lambda (k) - (when (and (equal ,key k) (eq (key-binding k) ',cmd)) - (throw 'p k))) - '(" " " " "")))) - -(provide 'sniem-cheatsheet) - -;;; sniem-cheatsheet.el ends here diff --git a/sniem-common.el b/sniem-common.el deleted file mode 100644 index 46cfb11b452960173039da504783782c3e020309..0000000000000000000000000000000000000000 --- a/sniem-common.el +++ /dev/null @@ -1,147 +0,0 @@ -;;; sniem-common.el --- Simple united editing method -*- lexical-binding: t -*- - -;; Author: SpringHan -;; Maintainer: SpringHan - -;; This file is not part of GNU Emacs - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; For a full copy of the GNU General Public License -;; see . - - -;;; Commentary: - -;; Simple united editing method - -;;; Code: - -(require 'sniem-var) - -(defun sniem-current-mode () - "Get current mode." - (cond (sniem-normal-mode 'normal) - (sniem-insert-mode 'insert) - (sniem-motion-mode 'motion) - (sniem-expand-mode 'expand) - (t nil))) - -(defun sniem-change-mode (mode) - "Change editing MODE." - (unless (eq (sniem-current-mode) mode) - (pcase mode - ('normal (sniem-normal-mode t)) - ('insert (sniem-insert-mode t)) - ('motion (sniem-motion-mode t)) - ('expand (sniem-expand-mode t))) - (sniem-cursor-change))) - -(defun sniem-lock-unlock-last-point (&optional lock) - "LOCK or unlock `sniem-last-point'." - (interactive) - (setq-local sniem-last-point-locked (if (and (null lock) sniem-last-point-locked) - nil - t)) - (sniem-show-last-point (not sniem-last-point-locked)) - (message "[Sniem]: Last point %s." (if sniem-last-point-locked - "locked" - "unlocked"))) - -(defun sniem-object-catch--get-second-char (prefix) - "Get the second char by the PREFIX." - (catch 'second-char - (dolist (char-cons sniem-object-catch-global-symbol-alist) - (when (string= prefix (car char-cons)) - (throw 'second-char (cdr-safe char-cons)))))) - -(defun sniem-motion-hint (motion) - "Hint after MOTION." - (let (overlay point) - (when sniem-motion-hint-overlays - (mapc #'delete-overlay sniem-motion-hint-overlays) - (setq sniem-motion-hint-overlays nil)) - (save-mark-and-excursion - (catch 'stop - (dotimes (i 10) - (call-interactively motion) - (if (and point (= (point) point)) - (throw 'stop nil) - (setq overlay (make-overlay (point) (1+ (point)))) - (overlay-put overlay 'display (format "%s%s" - (propertize (number-to-string (1+ i)) - 'face 'sniem-motion-hint-face) - (pcase (following-char) - ((pred (= 10)) "\n") - ((pred (= 9)) "\t") - (_ "")))) - (setq point (point)) - (push overlay sniem-motion-hint-overlays))))) - (sit-for sniem-motion-hint-sit-time) - (mapc #'delete-overlay sniem-motion-hint-overlays) - (setq sniem-motion-hint-overlays nil) - (setq-local sniem-motion-hint-motion motion))) - -(defun sniem-move-with-hint-num (num) - "Move with NUM to eval the last `sniem-motion-hint-motion'." - (interactive "P") - (dotimes (_ num) - (funcall-interactively sniem-motion-hint-motion)) - (sniem-motion-hint sniem-motion-hint-motion)) - -(defun sniem-digit-argument-get (&optional msg) - "A function which make you can use the middle of the keyboard. -Instead of the num keyboard. -Optional argument MSG is the message which will be outputed." - (interactive) - (let ((number "") - (arg "") - fn) - (while (not (string= number "over")) - (setq number (sniem-digit-argument-read-char)) - (unless (string= number "over") - (cond ((string= number "delete") - (setq arg (substring arg 0 -1))) - ((setq fn (sniem-digit-argument-fn-get number)) - (setq number "over")) - (t (setq arg (concat arg number))))) - (message "%s%s" (if msg - msg - "C-u ") - arg)) - (setq arg (if (string-empty-p arg) - nil - (string-to-number arg))) - (if fn - (if arg - `(funcall-interactively ',fn ,arg) - `(call-interactively ',fn)) - arg))) - -(defun sniem-object-catch-lisp-mode-p () - "Check if the current major mode belongs to Lisp mode." - (string-match-p "\\(?:.*\\)lisp\\(?:.*\\)" (symbol-name major-mode))) - -(defun sniem--mems (ele list) - "Like memq, but use `string-equal'. -Argument ELE is the element to check. -Argument LIST is the list to check." - (let (result) - (catch 'stop - (dolist (item list) - (when (string-equal item ele) - (setq result t) - (throw 'stop nil)))) - result)) - -(provide 'sniem-common) - -;;; sniem-common.el ends here diff --git a/sniem-expand-region.el b/sniem-expand-region.el deleted file mode 100644 index 6ec052e8319ea10d63ab1e83129cbe3aac6c9523..0000000000000000000000000000000000000000 --- a/sniem-expand-region.el +++ /dev/null @@ -1,47 +0,0 @@ -;;; sniem-expand-region.el --- Simple united editing method -*- lexical-binding: t -*- - -;; Author: SpringHan -;; Maintainer: SpringHan - -;; This file is not part of GNU Emacs - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; For a full copy of the GNU General Public License -;; see . - - -;;; Commentary: - -;; Simple united editing method. - -;;; Code: - -(require 'sniem-var) - -(defvar sniem-expand-region-message "[s] for symbol, [w] for word:" - "The message hint for `sniem-expand-region'.") - -(defun sniem-expand-region-string (type) - "Expand string region with it's TYPE." - (interactive (list (read-char sniem-expand-region-message))) - (let* ((thing (pcase type - (115 'symbol) - (119 'word) - (_ (user-error "[Sniem]: The %s type is error!" type)))) - (points (bounds-of-thing-at-point thing))) - (when points - (goto-char (car points)) - (push-mark (cdr points) t t)))) - -(provide 'sniem-expand-region) - -;;; sniem-expand-region.el ends here diff --git a/sniem-macro.el b/sniem-macro.el deleted file mode 100644 index 46fa78a3120926ce0f986ebd17376673636b1c9b..0000000000000000000000000000000000000000 --- a/sniem-macro.el +++ /dev/null @@ -1,54 +0,0 @@ -;;; sniem-macro.el --- Simple united editing method -*- lexical-binding: t -*- - -;; Author: SpringHan -;; Maintainer: SpringHan - -;; This file is not part of GNU Emacs - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; For a full copy of the GNU General Public License -;; see . - - -;;; Commentary: - -;; Simple united editing method. - -;;; Code: - -(defmacro sniem-define-motion (name arg docstring &rest body) - "Define motion for sniem. -Argument NAME is the name of motion. -Argument ARG is the arg of motion. -Argument DOCSTRING is the docstring. -Optional argument BODY is the main body of motion function." - (declare (indent defun) - (doc-string 3) - (debug (&define name lambda-lsit - [&optional stringp] - [&optional ("interactive" [&rest form])] - def-body))) - (let ((inter (if (eq (car-safe (car-safe `,body)) 'interactive) - (pop `,body) - '(interactive)))) - (unless (memq '&optional `,arg) - (setq `,arg (append `,arg '(&optional)))) - `(defun ,name (,@arg non-point-set) - ,docstring - ,inter - (unless (or sniem-last-point-locked non-point-set) - (setq-local sniem-last-point (point))) - ,@body))) - -(provide 'sniem-macro) - -;;; sniem-macro.el ends here diff --git a/sniem-mark-jump.el b/sniem-mark-jump.el deleted file mode 100644 index a2fee8ce64d2e7fe64a2e5a8b040f21b6f453bfa..0000000000000000000000000000000000000000 --- a/sniem-mark-jump.el +++ /dev/null @@ -1,182 +0,0 @@ -;;; sniem-mark-jump.el --- Simple united editing method -*- lexical-binding: t -*- - -;; Author: SpringHan -;; Maintainer: SpringHan - -;; This file is not part of GNU Emacs - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; For a full copy of the GNU General Public License -;; see . - - -;;; Commentary: - -;; Simple united editing method. - -;;; Code: - -(require 'sniem-common) -(require 'sniem-operation) - -(defcustom sniem-mark-jump-items - '("TODO" "BUG" "NOTE") - "The faces for `sniem-mark-jump'." - :type 'list - :group 'sniem) - -(defcustom sniem-mark-jump-author-name nil - "The default name for mark." - :type 'string - :group 'sniem) - -(defcustom sniem-mark-jump-author-name-enable nil - "If enable the author name." - :type 'boolean - :group 'sniem) - -(defcustom sniem-mark-jump-regexp nil - "The regexp for mark." - :type 'string - :group 'sniem) - -(defun sniem-mark-jump-insert (type &optional name) - "Insert the mark with TYPE. -Optional argument NAME means enable the name." - (interactive (list (completing-read "Enter the type: " - sniem-mark-jump-items))) - (unless (eq (face-at-point) 'font-lock-comment-face) - (if (and (eolp) - (not (looking-back "^[\s\t]*" (line-beginning-position) t))) - (insert (if (not (memq (char-before) '(?\t ?\s))) - " " - "") - comment-start) - (unless (= (line-beginning-position) (line-end-position)) - (sniem-open-line-previous)) - (insert (if (sniem-object-catch-lisp-mode-p) - (concat comment-start comment-start) - comment-start)))) - (insert (if (string= " " (substring comment-start -1)) - "" - " ") - type - (if (or name sniem-mark-jump-author-name-enable) - (format "(%s): " (sniem-mark-jump--get-author-name)) - ": ")) - (when comment-end - (save-mark-and-excursion - (insert comment-end))) - (sniem-change-mode 'insert)) - -(defun sniem-mark-jump-insert-with-name (&optional name) - "`sniem-mark-jump-insert' with NAME." - (interactive "P") - (if name - (funcall #'sniem-mark-jump-insert - (completing-read "Enter the type: " sniem-mark-jump-items) t) - (call-interactively #'sniem-mark-jump-insert))) - -(sniem-define-motion sniem-mark-jump-next (&optional type) - "Jump next." - (interactive "P") - (when type - (setq type (sniem-mark-jump--get-type type))) - (sniem-mark-jump--jump t type)) - -(sniem-define-motion sniem-mark-jump-prev (&optional type) - "Jump previous." - (interactive "P") - (when type - (setq type (sniem-mark-jump--get-type type))) - (sniem-mark-jump--jump nil type)) - -(defun sniem-mark-jump--get-type (num) - "Get type by NUM." - (nth (1- num) sniem-mark-jump-items)) - -(defun sniem-mark-jump--jump (next &optional type) - "Jump to NEXT/previous item. -Optional argument TYPE is the type of comment mark." - (let ((search-command (if next - 're-search-forward - 're-search-backward)) - (point (point)) - (case-fold-search nil) - (tmp t)) - (when (sniem-mark-jump--comment-face-p) - (sniem-mark-jump--escape-comment (when next t))) - (catch 'stop - (while tmp - (if type - (setq tmp (funcall search-command (concat "\\(" comment-start "*\\)" "\\(?:.*\\)" type "\\(?:.*\\)") nil t)) - (setq tmp (funcall search-command (concat "\\(" comment-start "*\\)" sniem-mark-jump-regexp) nil t))) - (when (and tmp (numberp tmp)) - (goto-char (comment-beginning)) - (throw 'stop t))) - (message "[Sniem]: The mark can not be found.") - (goto-char point)))) - -(defun sniem-mark-jump--escape-comment (forward) - "Escape current comment. -Argument FORWARD means search forward." - (let ((motion (if forward - 'forward-char - 'backward-char))) - (while (sniem-mark-jump--comment-face-p) - (funcall motion)))) - -(defun sniem-mark-jump--comment-face-p () - "Check if the content at point has the comment face." - (let ((face-list (get-text-property (point) 'face))) - (when face-list - (or (and (symbolp face-list) - (or (eq face-list 'font-lock-comment-face) - (eq face-list 'font-lock-comment-delimiter-face))) - (and (listp face-list) (memq 'font-lock-comment-face face-list)))))) - -(defun sniem-mark-jump--get-author-name () - "Get the author's name." - (if sniem-mark-jump-author-name - sniem-mark-jump-author-name - (unless sniem-mark-jump-author-name-enable - (setq-local sniem-mark-jump-author-name-enable t)) - (read-string "Enter your name: "))) - -(defun sniem-mark-jump-reset-regexp () - "Reset the regexp." - (setq sniem-mark-jump-regexp - (concat "\\(?:.*\\)\\(" - (mapconcat #'sniem-mark-jump--self sniem-mark-jump-items "\\|") - "\\)\\(?:.*\\)"))) - -(defun sniem-mark-jump--self (arg) - "Return ARG itself." - arg) - -(sniem-mark-jump-reset-regexp) - -;;; For user -(defun sniem-mark-jump-set-items (way item) - "Set `sniem-mark-jump-items'. -The WAY includes: -:add - Add a new ITEM. -:delete - Delete a item." - (pcase way - (:add (unless (sniem--mems item sniem-mark-jump-items) - (setq sniem-mark-jump-items (append sniem-mark-jump-items (list item))))) - (:delete (setq sniem-mark-jump-items (delete item sniem-mark-jump-items)))) - (sniem-mark-jump-reset-regexp)) - -(provide 'sniem-mark-jump) - -;;; sniem-mark-jump.el ends here diff --git a/sniem-object-catch.el b/sniem-object-catch.el deleted file mode 100644 index d37384a2b37edbd774724532a426e7fd0b48d954..0000000000000000000000000000000000000000 --- a/sniem-object-catch.el +++ /dev/null @@ -1,395 +0,0 @@ -;;; sniem-object-catch.el --- Simple united editing method -*- lexical-binding: t -*- - -;; Author: SpringHan -;; Maintainer: SpringHan - -;; This file is not part of GNU Emacs - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; For a full copy of the GNU General Public License -;; see . - - -;;; Commentary: - -;; Simple united editing method - -;;; Code: - -(require 'sniem-var) -(require 'sniem-common) -(require 'sniem-macro) - -(defgroup sniem-object-catch nil - "The group of `sniem-object-catch'." - :group 'sniem) - -(defcustom sniem-object-catch-global-symbol-alist - '(("\"" . "\"") - ("'" . "'") - ("[" . "]") - ("<" . ">") - ("(" . ")") - ("{" . "}")) - "The global symbol alist." - :type 'list - :group 'sniem-object-catch) - -(defcustom sniem-object-catch-last-points nil - "The last point cons." - :type 'cons - :group 'sniem-object-catch) - -(defcustom sniem-object-catch-action nil - "The action info for the last catch." - :type 'cons - :group 'sniem-object-catch) - -(defcustom sniem-object-catch-forward-p nil - "The direction for catch." - :type 'symbol - :group 'sniem-object-catch) - -(defcustom sniem-object-catch-prefix-string-p nil - "If the prefix is string." - :type 'boolean - :group 'sniem-object-catch) - -(sniem-define-motion sniem-object-catch (&optional char parent) - "Catch region." - (interactive) - (let ((point (point))) - (while (not (eq 'no (ignore-errors (sniem-object-catch--get char parent)))) - (if (bobp) - (progn - (goto-char point) - (when sniem-object-catch-last-points - (push-mark (cdr sniem-object-catch-last-points) t t)) - (user-error "[Sniem-Object-Catch]: Can't get more item!")) - (backward-char))) - (when sniem-object-catch-prefix-string-p - (setq-local sniem-object-catch-prefix-string-p nil)))) - -(defun sniem-object-catch--get (char parent) - "Get the object. -Argument CHAR is the prefix of pair. -Argument PARENT means get the parent pair of the content selected." - (let ((move (if sniem-object-catch-forward-p - 'forward-char - 'backward-char)) - prefix-point second-char second-point tmp go-on) - (save-mark-and-excursion - (when (region-active-p) - (funcall move)) - ;; Get the `prefix-point' - (if char - (setq prefix-point - (catch 'point-stop - (while t - (if (and (string= - char - (setq tmp - (buffer-substring-no-properties (point) (1+ (point))))) - (sniem-object-catch-prefix-normal-p)) - (throw 'point-stop (point)) - (if (or (bobp) (eobp)) - (throw 'point-stop nil) - (funcall move)))))) - (setq prefix-point - (catch 'point-stop - (while t - (if (and (sniem-object-catch--get-second-char - (setq tmp (buffer-substring-no-properties (point) (1+ (point))))) - (sniem-object-catch-prefix-normal-p)) - (progn - (setq char tmp) - (throw 'point-stop (point))) - (if (or (bobp) (eobp)) - (throw 'point-stop nil) - (funcall move))))))) - (cond ((and (nth 3 (syntax-ppss prefix-point)) - (/= (following-char) 34)) - (setq-local sniem-object-catch-prefix-string-p t)) - ((and sniem-object-catch-prefix-string-p - (null (nth 3 (syntax-ppss prefix-point)))) - (setq-local sniem-object-catch-prefix-string-p nil))) - (if (not char) - (message "[Sniem-Object-Catch]: Can not find a symbol in alist.") - (setq second-char (sniem-object-catch--get-second-char char)) - (if (and (not (string= char second-char)) - (if (and (bobp) - (= (point) prefix-point)) - (ignore-errors (= (char-before) 92)) - (= (char-before) 92))) - (setq go-on t) - (setq second-point (if (string= char second-char) - (if (or (and (not (nth 3 (syntax-ppss))) - (nth 8 (syntax-ppss))) - (sniem-object-catch--face-around-eq)) - (sniem-object-catch-format-pointc char) - (sniem-object-catch-format-point2 char prefix-point)) - (sniem-object-catch-format-point char second-char)))) - (when (consp second-point) - (setq prefix-point (car second-point) - second-point (cdr second-point))) - (if (and parent sniem-object-catch-last-points - (> (cdr sniem-object-catch-last-points) second-point) - (< prefix-point (car sniem-object-catch-last-points))) - (setq go-on t) - (setq-local sniem-object-catch-last-points (cons prefix-point second-point))))) - (goto-char prefix-point) - (push-mark second-point t t) - (setq-local sniem-object-catch-action `(,char . ,parent)) - (unless go-on - (setq go-on 'no)) - go-on)) - -(defun sniem-object-catch-by-char (char) - "Catch region by CHAR." - (interactive (list (char-to-string (read-char)))) - (if (sniem-object-catch--get-second-char char) - (sniem-object-catch char) - (message "[Sniem-Object-Catch]: %s is not defined in the symbol alist." char))) - -(defun sniem-object-catch-char () - "Catch region by the last char." - (interactive) - (let ((pair (sniem-object-catch--get-last-char))) - (sniem-object-catch pair nil))) - -(defun sniem-object-catch-parent () - "Catch region for its parent." - (interactive) - (let ((pair (sniem-object-catch--get-last-char))) - (sniem-object-catch pair t))) - -(defun sniem-object-catch--get-last-char () - "Get the last char." - (pcase last-input-event - ((or 41 79 111) "(") - ((or 83 93 115) "[") - ((or 67 125 99) "{") - ((or 39 113 81) "'") - ((or 34 100 68) "\"") - ((or 60 97 65) "<") - (_ nil))) - -(defun sniem-object-catch-parent-by-char (char) - "Catch region for its parent by CHAR." - (interactive (list (char-to-string (read-char)))) - (if (sniem-object-catch--get-second-char char) - (sniem-object-catch char t) - (message "[Sniem-Object-Catch]: %s is not defined in the symbol alist." char))) - -(defun sniem-object-catch-repeat () - "Repeat the last catch." - (interactive) - (when sniem-object-catch-action - (sniem-object-catch (car sniem-object-catch-action) (cdr sniem-object-catch-action)))) - -(defun sniem-object-catch-direction-reverse (&optional forward) - "Reverse the catch direction. -Optional argument FORWARD means change the direction to forward." - (interactive) - (setq-local sniem-object-catch-forward-p - (if (or forward (null sniem-object-catch-forward-p)) - t - nil)) - (message "[Sniem]: The object-catch-direction now is %s." - (if sniem-object-catch-forward-p - "forward" - "backward"))) - -(defun sniem-object-catch-format-point (prefix second-char) - "Format point with the PREFIX. -Argument SECOND-CHAR is the end char of the pair." - (let ((times 1) - tmp) - (forward-char) - (while (/= times 0) - (setq tmp (buffer-substring-no-properties (point) (1+ (point)))) - (cond ((and (string= tmp prefix) (not (string= prefix second-char)) - (or (and sniem-object-catch-prefix-string-p - (nth 3 (syntax-ppss))) - (and (null sniem-object-catch-prefix-string-p) - (null (nth 3 (syntax-ppss))))) - (not (= (char-before) 92))) - (setq times (1+ times))) - ((and (string= tmp second-char) (> times 0) - (not (= (char-before) 92)) - (or (and sniem-object-catch-prefix-string-p - (nth 3 (syntax-ppss))) - (and (null sniem-object-catch-prefix-string-p) - (null (nth 3 (syntax-ppss)))))) - (setq times (1- times)))) - (forward-char)) - (point))) - -(defun sniem-object-catch-format-point2 (pair prefix-point) - "Format point for the PAIR with same char. -Argument PREFIX-POINT is the prefix point." - (let ((region-forward-p (when (and (region-active-p) sniem-object-catch-forward-p) - (prog1 (cons (region-beginning) (region-end)) - (deactivate-mark)))) - (face-eq-p (lambda (face1) - (let ((face2 (get-text-property (point) 'face))) - (ignore-errors - (or (eq face1 face2) - (memq face1 face2) - (memq face2 face1)))))) - prefix-face second-point) - (save-mark-and-excursion - (goto-char prefix-point) - (setq prefix-face (face-at-point)) - (cond ((progn - (backward-char) - (funcall face-eq-p prefix-face)) - (setq second-point (sniem-object-catch-format-point1 pair prefix-point) - prefix-point (sniem-object-catch-format-point1 pair prefix-point t t))) - - ((progn - (forward-char 2) - (funcall face-eq-p prefix-face)) ; NOTE: This expression in here maybe have bug. - (setq prefix-point (sniem-object-catch-format-point1 pair prefix-point nil t) - second-point (sniem-object-catch-format-point1 pair (point) t)))) - (when region-forward-p - (goto-char (car region-forward-p)) - (push-mark (cdr region-forward-p))) - (cons prefix-point (1+ second-point))))) - -(defun sniem-object-catch-format-point1 (pair point &optional search prefix) - "Format the POINT for char. -Argument PAIR is the pair." - (save-mark-and-excursion - (goto-char point) - (let ((search-command (if prefix - 'search-backward - 'search-forward))) - (when search - (setq point (progn - (funcall search-command pair) - (unless prefix (backward-char)) - (point)))) - (when (sniem-object-catch-backslash-p) - (setq point (progn - (forward-char) - (point))) - (while (progn - (setq point (funcall search-command pair)) - (sniem-object-catch-backslash-p))))) - point)) - -(defun sniem-object-catch-format-pointc (char) - "Format the CHAR has same char in comment." - (let (balone falone) - (setq balone (sniem-object-catch--while-check-format char)) - (setq falone (sniem-object-catch--while-check-format char t)) - (if balone - (cons balone (1+ (point))) - (1+ falone)))) - -(defun sniem-object-catch--while-check-format (char &optional forward) - "Check the pair which has same CHAR in a while with the direction. -When the FORWARD is non-nil, the direction is forward. -Otherwise it's backward." - (let ((command (if forward - 'forward-char - 'backward-char)) - current-char alone another-point) - (save-mark-and-excursion - (while (and (not (sniem-object-catch--border forward)) - (or (funcall command) t) - (or (nth 8 (syntax-ppss)) - (ignore-errors - (= (char-before) 10)) - (sniem-object-catch--face-around-eq))) - (when (and (not (sniem-object-catch-backslash-p)) - (ignore-errors - (setq current-char - (buffer-substring-no-properties (point) (1+ (point))))) - (string= char current-char)) - (cond ((null another-point) - (setq another-point (point))) - (alone (setq alone nil)) - (t (setq alone t)))))) - (when (not alone) - another-point))) - -(defun sniem-object-catch--border (forward) - "Check if it's border now. -FORWARD means now it's forward direction." - (if forward - (eobp) - (bobp))) - -(defun sniem-object-catch--face-around-eq () - "Check if the faces around the point are equal." - (let ((face (face-at-point)) - lface rface) - (save-mark-and-excursion - (setq lface (progn - (ignore-errors (backward-char)) - (face-at-point)) - rface (progn - (ignore-errors (forward-char)) - (face-at-point)))) - (and (eq face lface) - (eq face rface)))) - -(defun sniem-object-catch--symbol-exists-p (symbol) - "Check if the SYMBOL is exists." - (catch 'exists - (let ((index 0)) - (dolist (symbol-cons sniem-object-catch-global-symbol-alist) - (when (string= symbol (car symbol-cons)) - (throw 'exists index)) - (setq index (1+ index)))))) - -(defun sniem-object-catch-prefix-normal-p () - "Check if the current major mode belongs to Lisp mode. -The current char is not quote and the char before prefix is not backslash." - (not (or (and (= 39 (following-char)) (sniem-object-catch-lisp-mode-p)) - (sniem-object-catch-backslash-p)))) - -(defun sniem-object-catch-backslash-p () - "Check if the char before current point is \\." - (unless (bobp) - (and (= 92 (char-before)) - (not (save-mark-and-excursion - (backward-char) - (if (bobp) - t - (= 92 (char-before)))))))) - -(defmacro sniem-object-catch-mode-defalist (modename &rest alist) - "Define ALIST for major mode. -Argument MODENAME if the mode name." - (declare (indent 1)) - `(let ((sym-alist sniem-object-catch-global-symbol-alist) - tmp) - (dolist (list ',alist) - (if (setq tmp (sniem-object-catch--symbol-exists-p (car list))) - (setf (cdr (nth tmp sym-alist)) (cdr list)) - (add-to-list 'sym-alist list))) - (add-hook (intern (concat (symbol-name ',modename) "-hook")) - `(lambda () (setq-local sniem-object-catch-global-symbol-alist - ',sym-alist))))) - -(add-hook 'deactivate-mark-hook #'(lambda () - (when sniem-object-catch-last-points - (setq-local sniem-object-catch-last-points nil)) - (when sniem-object-catch-prefix-string-p - (setq-local sniem-object-catch-prefix-string-p nil)))) - -(provide 'sniem-object-catch) - -;;; sniem-object-catch.el ends here diff --git a/sniem-operation.el b/sniem-operation.el deleted file mode 100644 index 3ce8af93ad15c3c13607f4633cbfa8f24a997e61..0000000000000000000000000000000000000000 --- a/sniem-operation.el +++ /dev/null @@ -1,692 +0,0 @@ -;;; sniem-operation.el --- Simple united editing method -*- lexical-binding: t -*- - -;; Author: SpringHan -;; Maintainer: SpringHan - -;; This file is not part of GNU Emacs - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; For a full copy of the GNU General Public License -;; see . - - -;;; Commentary: - -;; Simple united editing method - -;;; Code: - -(require 'sniem-var) -(require 'sniem-macro) -(require 'sniem-common) - -(defun sniem-insert () - "Insert at the current point or the beginning of mark region." - (interactive) - (unless (eq (sniem-current-mode) 'insert) - (when (region-active-p) - (goto-char (region-beginning)) - (deactivate-mark)) - (sniem-change-mode 'insert))) - -(defun sniem-insert-line () - "Insert at the beginning of line." - (interactive) - (if (region-active-p) - (goto-char (1+ (region-beginning))) - (back-to-indentation)) - (sniem-insert)) - -(defun sniem-append () - "Append at the next point or the end of mark region." - (interactive) - (if (region-active-p) - (progn - (goto-char (region-end)) - (deactivate-mark)) - (forward-char)) - (sniem-insert)) - -(defun sniem-append-line () - "Append at the end of line." - (interactive) - (if (region-active-p) - (progn - (goto-char (1- (region-end))) - (deactivate-mark)) - (end-of-line)) - (sniem-insert)) - -(defun sniem--open-line (&optional above) - "Open new line for other function. -Optional argument ABOVE is t, it will open line above." - (when above - (sniem-prev-line nil t)) - (sniem-end-of-line t) - (insert "\n")) - -(defun sniem-open-line () - "Open new line." - (interactive) - (sniem--open-line) - (indent-according-to-mode) - (sniem-insert)) - -(defun sniem-open-line-previous () - "Open new line." - (interactive) - (if (bobp) - (progn - (beginning-of-line) - (insert "\n") - (goto-char (point-min))) - (sniem--open-line t)) - (indent-according-to-mode) - (sniem-insert)) - -(defun sniem-center (action) - "Center ACTION for sniem." - (interactive (list (read-char sniem-center-message))) - (pcase action - (122 (recenter nil t)) - (116 (recenter-top-bottom 0)) - (98 (recenter-top-bottom -1)))) - -(defun sniem-mark (type) - "Mark the object with action TYPE." - (interactive (list (read-char sniem-mark-message))) - (pcase type - (108 - (beginning-of-line) - (push-mark (point) t t) - (end-of-line) - (setq-local sniem-mark-line t)) - (112 - (push-mark sniem-last-point t t) - (when sniem-last-point-locked - (sniem-lock-unlock-last-point))) - (109 (push-mark (point) t t)) - (102 (mark-defun)) - (98 (mark-whole-buffer)) - (_ (sniem-expand-region-string type)))) - -;;; Hook for mark -(add-hook 'deactivate-mark-hook #'(lambda () - (when sniem-mark-line - (setq-local sniem-mark-line nil)))) - -(defun sniem-up-down-case () - "Up or down case." - (interactive) - (if (region-active-p) - (let ((contents (buffer-substring-no-properties (region-beginning) - (region-end)))) - (delete-region (region-beginning) (region-end)) - (dolist (char (string-to-list contents)) - (insert-char (if (eq (upcase char) char) - (downcase char) - (upcase char))))) - (let ((char (following-char))) - (delete-char 1) - (insert-char (if (eq (upcase char) char) - (downcase char) - (upcase char)))))) - -(defun sniem-replace-char (char) - "Replace the CHAR under cursor." - (interactive "c") - (delete-char 1) - (insert-char char) - (sniem-backward-char nil t)) - -(defun sniem-replace-word () - "Replace the word under cursor." - (interactive) - (let* ((word (thing-at-point 'word t)) - (replaced (read-string "Enter the new word: " word)) - (word-points (bounds-of-thing-at-point 'word))) - (delete-region (car word-points) (cdr word-points)) - (insert replaced))) - -(defun sniem-delete-char () - "Delete the char under cursor." - (interactive) - (if (eolp) - (delete-char -1) - (unless (or (= (following-char) 32) - (= (following-char) 10)) - (kill-ring-save (point) (1+ (point)))) - (delete-char 1))) - -(defun sniem-delete (action) - "Delete ACTION." - (interactive (list (if sniem-delete-edit - (progn - (setq-local sniem-delete-edit nil) - 112) - (if (region-active-p) - t - (read-char sniem-delete-message))))) - (pcase action - ((pred symbolp) (sniem-delete-region (region-beginning) (region-end))) - (100 (if (= (line-beginning-position) (line-end-position)) - (progn - (if (bobp) - (delete-char 1) - (delete-char -1)) - (forward-line)) - (sniem-delete-region (line-beginning-position) - (if (= (line-end-position) (point-max)) - (line-end-position) - (1+ (line-end-position))))) - (when (eobp) - (beginning-of-line))) - (68 (sniem-delete-region (line-beginning-position) (line-end-position))) - (112 (sniem-delete-region sniem-last-point (point)) - (when sniem-last-point-locked - (sniem-lock-unlock-last-point))) - (101 (setq-local sniem-delete-edit t) - (sniem-lock-unlock-last-point t)))) - -(defun sniem-delete-in-region () - "Delete in region." - (interactive) - (when (region-active-p) - (when (= (point) (region-beginning)) - (sniem-end-of-mark)) - (push-mark (1+ (region-beginning)) t t) - (goto-char (1- (region-end))) - (sniem-delete t))) - -(defun sniem-delete-region (start end) - "Like `delete-region', but it will eval `kill-ring-save' to copy the region. -Argument START is the start point of the region. -Argument END is the end point of the region." - (kill-ring-save start end) - (delete-region start end)) - -(defun sniem-change (action) - "Change contents. -Argument ACTION is the action of change." - (interactive (list (if sniem-change-edit - (progn - (setq-local sniem-change-edit nil) - 112) - (if (region-active-p) - t - (read-char sniem-change-message))))) - (pcase action - ((pred symbolp) (sniem-delete t) (sniem-insert)) - (99 (sniem-delete 68) (indent-according-to-mode) (sniem-insert)) - (112 (sniem-delete 112) (sniem-insert)) - (101 (setq-local sniem-change-edit t) - (sniem-lock-unlock-last-point t)))) - -(defun sniem-change-in-region () - "Change in region." - (interactive) - (when (region-active-p) - (when (= (point) (region-beginning)) - (sniem-end-of-mark)) - (push-mark (1+ (region-beginning)) t t) - (goto-char (1- (region-end))) - (sniem-change t))) - -(defun sniem-yank (action) - "Yank ACTION." - (interactive (list (if (region-active-p) - t - (read-char sniem-yank-message)))) - (pcase action - ((pred symbolp) (kill-ring-save (region-beginning) (region-end))) - (121 (kill-ring-save (line-beginning-position) - (if (= (point-max) (line-end-position)) - (line-end-position) - (1+ (line-end-position))))) - (112 (kill-ring-save sniem-last-point (point)) - (when sniem-last-point-locked - (sniem-lock-unlock-last-point))))) - -(defun sniem-yank-in-region () - "Yank in region." - (interactive) - (when (region-active-p) - (kill-ring-save (1+ (region-beginning)) (1- (region-end))))) - -(defun sniem-paste (&optional n) - "Paste the N content in `kill-ring'." - (interactive "P") - (let ((i 0) - (regionp (when (region-active-p) - (cons (region-beginning) (region-end))))) - (unless n - (when - (catch 'n - (while (= 0 - (string-to-number - (char-to-string - (setq n (read-char (format "%s:%d%s" - (sniem-paste--output-contents i) - (1+ (/ i 9)) - (propertize "[n]: next page, [p]: prev page or 1, [1-9]: insert content, [q]: cancel" - 'face 'font-lock-comment-face))))))) - (pcase n - (110 (setq i (+ i 9))) - (112 (if (>= i 9) - (setq i (- i 9)) - (throw 'n t))) - (113 (keyboard-quit))))) - (setq n 49))) - (setq n (string-to-number (char-to-string n))) - (when regionp - (goto-char (cdr regionp)) - (push-mark (car regionp) t t) - (sniem-delete t)) - (insert (nth (if regionp - (+ n i) - (1- (+ n i))) - kill-ring)))) - -(defun sniem-paste--output-contents (n) - "Output contents for `sniem-paste'. -Argument N is the page of the contents." - (let (content c tmp) - (dotimes (i 9) - (setq c (format "%d: %s" - (1+ i) - (nth (+ i n) kill-ring)) - content (concat content - (progn - (when (setq tmp (sniem-paste--include-ln-p c)) - (setq c tmp)) - (while (> (length c) (frame-width)) - (setq c (concat (substring c 0 (1- (- (length c) (frame-width)))) "..."))) - c) - "\n"))) - content)) - -(defun sniem-paste--include-ln-p (string) - "Check if there has \n in STRING." - (let ((string-list (string-to-list string)) - tmp) - (when (memq 10 string-list) - (setq tmp (delete 10 string-list))) - (when tmp - (eval `(string ,@tmp))))) - -(defun sniem-paste-in-region () - "Paste the `kill-ring' content in region." - (interactive) - (when (region-active-p) - (when (= (region-beginning) (point)) - (sniem-end-of-mark)) - (push-mark (1+ (region-beginning)) t t) - (goto-char (1- (region-end))) - (sniem-paste))) - -(defun sniem-join () - "Change LINE to one line." - (interactive) - (let ((last-point (point))) - (if (bolp) - (if (save-mark-and-excursion - (forward-line -1) - (= (line-beginning-position) (line-end-position))) - (forward-line -1) - (backward-char)) - (backward-char) - (unless (or (= 10 (following-char)) - (= 32 (following-char))) - (user-error "[Sniem]: The current position doesn't need join!"))) - (while (or (= 10 (following-char)) - (= 32 (following-char))) - (backward-char)) - (forward-char) - (push-mark last-point t t))) - -(defun sniem-macro (action) - "Macro ACTION." - (interactive (list (unless defining-kbd-macro - (read-char sniem-macro-message)))) - (if defining-kbd-macro - (progn - (end-kbd-macro) - ;; If the `sniem-kmacro-range' is exists, call the macro to the lines - (when sniem-kmacro-range - (let ((region-beg - (save-mark-and-excursion - (sniem-goto-line (car sniem-kmacro-range) t) - (line-beginning-position))) - (region-end - (save-mark-and-excursion - (sniem-goto-line (cdr sniem-kmacro-range) t) - (when (= (line-beginning-position) (line-end-position)) - (forward-line)) - (line-end-position)))) - (apply-macro-to-region-lines region-beg region-end) - (setq-local sniem-kmacro-range nil)))) - - (when (region-active-p) - (if (= action 113) - (if (= (line-number-at-pos (region-beginning)) - (line-number-at-pos (region-end))) - (setq-local sniem-kmacro-mark-content - (buffer-substring-no-properties (region-beginning) (region-end))) - (setq-local sniem-kmacro-range - (cons (1+ (line-number-at-pos (region-beginning))) - (line-number-at-pos (region-end)))) - (deactivate-mark) - (goto-char (region-beginning))) - (setq-local sniem-kmacro-mark-content - (buffer-substring-no-properties (region-beginning) (region-end))))) - (pcase action - (113 (call-interactively #'start-kbd-macro)) - (101 (call-last-kbd-macro)) - (110 (call-interactively #'name-last-kbd-macro))))) - -(advice-add 'keyboard-quit :before - (lambda () - (when sniem-kmacro-mark-content - (setq-local sniem-kmacro-mark-content nil)))) - -(defun sniem-pair (prefix &optional add) - "Modify the region's pair. -Argument PREFIX is the prefix of the pair." - (interactive (list (let ((var (read-char))) - (if (= var 97) - (list (read-char) t) - var)))) - (when (cdr-safe prefix) - (setq add t - prefix (car prefix))) - (let ((second (unless (= 32 prefix) - (sniem-object-catch--get-second-char (char-to-string prefix)))) - (prefix-point (region-beginning)) - (second-point (region-end)) - (prefix-char (buffer-substring-no-properties (region-beginning) (1+ (region-beginning))))) - (if (and (null second) - (/= prefix 32)) - (user-error "[Sniem]: The pair is not exists in `sniem-object-catch-global-symbol-alist'!") - (save-mark-and-excursion - (goto-char prefix-point) - (when (and (null add) - (sniem-pair--pair-p prefix-char)) - (delete-char 1)) - (unless (= prefix 32) - (insert prefix)) - (goto-char (if (= prefix 32) - (1- second-point) - second-point)) - (if (and (null add) - (sniem-pair--pair-p prefix-char)) - (delete-char -1) - (forward-char)) - (unless (= prefix 32) - (insert second)))))) - -(defun sniem-pair--pair-p (char-string) - "Check if the CHAR belongs to pair. -Argument CHAR-STRING is the string to compair." - (let ((alpha-list '("a" "A" "b" "B" "c" "C" "d" "D" "e" "E" "f" "F" "g" "G" - "h" "H" "i" "I" "j" "J" "k" "K" "l" "L" "m" "M" "n" "N" - "o" "O" "p" "P" "q" "Q" "r" "R" "s" "S" "t" "T" "u" "U" - "v" "V" "w" "W" "x" "X" "y" "Y" "z" "Z" "0" "1" "2" "3" - "4" "5" "6" "7" "8" "9"))) - ;; Write like this because `memq' and others can not work well. - (not (sniem--mems char-string alpha-list)))) - -;;; Motions - -(sniem-define-motion sniem-beginning-of-line () - "Beginning of line." - (beginning-of-line)) - -(sniem-define-motion sniem-end-of-line () - "End of line." - (end-of-line)) - -(sniem-define-motion sniem-forward-char (&optional n) - "Forward char." - (interactive "P") - (setq n (or n 1)) - (catch 'end - (while (/= n 0) - (if (eolp) - (throw 'end t) - (forward-char) - (setq n (1- n)))))) - -(sniem-define-motion sniem-5-forward-char () - "Eval `sniem-forward-char' 5 times." - (sniem-forward-char 5 t)) - -(sniem-define-motion sniem-backward-char (&optional n) - "Backward char." - (interactive "P") - (setq n (or n 1)) - (catch 'beg - (while (/= n 0) - (if (bolp) - (throw 'beg t) - (backward-char) - (setq n (1- n)))))) - -(sniem-define-motion sniem-5-backward-char () - "Eval `sniem-backward-char' 5 times." - (sniem-backward-char 5 t)) - -(sniem-define-motion sniem-prev-line (&optional n) - "Previous line." - (interactive "P") - (setq n (or n 1)) - (unless (bobp) - (line-move (- 0 n))) - (when (and (region-active-p) sniem-mark-line) - (if (= (region-beginning) (point)) - (beginning-of-line) - (end-of-line)))) - -(sniem-define-motion sniem-5-prev-line () - "Eval `sniem-prev-line' 5 times." - (sniem-prev-line 5 t)) - -(sniem-define-motion sniem-next-line (&optional n) - "Next line." - (interactive "P") - (setq n (or n 1)) - (unless (eobp) - (line-move n)) - (when (and (region-active-p) sniem-mark-line) - (if (= (region-beginning) (point)) - (beginning-of-line) - (end-of-line)))) - -(sniem-define-motion sniem-5-next-line () - "Eval `sniem-next-line' 5 times." - (sniem-next-line 5 t)) - -(sniem-define-motion sniem-first-line () - "Goto beginning of buffer." - (goto-char (point-min)) - (when (and (region-active-p) sniem-mark-line) - (end-of-line))) - -(sniem-define-motion sniem-goto-line (&optional n) - "Goto line with N." - (interactive "P") - (if (null n) - (with-no-warnings (end-of-buffer)) - (goto-char (point-min)) - (forward-line (1- n))) - (when (and (region-active-p) sniem-mark-line) - (end-of-line))) - -(sniem-define-motion sniem-scroll-up-command (&optional n) - "Scroll up." - (interactive "P") - (scroll-up-command n) - (when (and (region-active-p) sniem-mark-line) - (end-of-line))) - -(sniem-define-motion sniem-scroll-down-command (&optional n) - "Scroll down." - (interactive "P") - (scroll-down-command n) - (when (and (region-active-p) sniem-mark-line) - (end-of-line))) - -(sniem-define-motion sniem-find-forward (&optional n c no-hint) - "Find CHAR forward." - (interactive "P") - (let ((char (if c - c - (read-char)))) - (if n - (dotimes (_ n) - (sniem-find char 'forward)) - (sniem-find char 'forward)) - (when (region-active-p) - (sniem-forward-char nil t)) - (unless no-hint - (sniem-motion-hint `(lambda () (interactive) - (sniem-find-forward nil ,char t t)))))) - -(sniem-define-motion sniem-find-backward (&optional n c no-hint) - "Find CHAR backward." - (interactive "P") - (let ((char (if c - c - (read-char)))) - (if n - (dotimes (_ n) - (sniem-find char 'backward)) - (sniem-find char 'backward)) - (unless no-hint - (sniem-motion-hint `(lambda () (interactive) - (sniem-find-backward nil ,char t t)))))) - -(defun sniem-find (char direct) - "Find CHAR. -Argument DIRECT is the direction for find." - (let ((current-point (point)) - (way (pcase direct - ('forward 'sniem-forward-char) - ('backward 'sniem-backward-char) - (_ (user-error "[Sniem]: The direction for finding is error!"))))) - (funcall way nil t) - (while (not (or (eolp) (bolp) (eq (following-char) char))) - (funcall way nil t)) - (when (/= char (following-char)) - (goto-char current-point)))) - -(sniem-define-motion sniem-next-word (&optional n no-hint word) - "Move to next word. If the region is active, goto the next word which is same as it." - (interactive "P") - (if (or (region-active-p) word sniem-kmacro-mark-content) - (let ((word (cond (word word) - (sniem-kmacro-mark-content - (prog1 sniem-kmacro-mark-content - (setq-local sniem-kmacro-mark-content nil))) - (t (buffer-substring-no-properties (region-beginning) - (region-end)))))) - (when (= (point) (region-beginning)) - (goto-char (region-end))) - (deactivate-mark) - (ignore-errors (search-forward word)) - (push-mark (- (point) (length word)) t t)) - (forward-word n)) - (unless no-hint - (sniem-motion-hint `(lambda () (interactive) - (sniem-next-word ,n t ,word t))))) - -(sniem-define-motion sniem-prev-word (&optional n no-hint word) - "Move to prev word. If the region is active, goto the prev word which is same as it." - (interactive "P") - (if (or (region-active-p) word sniem-kmacro-mark-content) - (let ((word (cond (word word) - (sniem-kmacro-mark-content - (prog1 sniem-kmacro-mark-content - (setq-local sniem-kmacro-mark-content nil))) - (t (buffer-substring-no-properties (region-beginning) - (region-end)))))) - (when (= (point) (region-end)) - (goto-char (region-beginning))) - (deactivate-mark) - (ignore-errors (search-backward word)) - (push-mark (point) t t) - (goto-char (+ (point) (length word)))) - (backward-word n)) - (unless no-hint - (sniem-motion-hint `(lambda () (interactive) - (sniem-prev-word ,n t ,word t))))) - -(sniem-define-motion sniem-next-symbol (&optional n) - "Move to next symbol." - (interactive "P") - (unless n - (setq n 1)) - (forward-symbol n) - (sniem-motion-hint `(lambda () (interactive) - (forward-symbol ,n)))) - -(sniem-define-motion sniem-prev-symbol (&optional n) - "Move to previous symbol." - (interactive "P") - (unless n - (setq n 1)) - (forward-symbol (- 0 n)) - (sniem-motion-hint `(lambda () (interactive) - (forward-symbol (- 0 ,n))))) - -(sniem-define-motion sniem-beg-of-mark () - "Goto the beginning of mark." - (when (region-active-p) - (let ((end-point (region-end))) - (goto-char (region-beginning)) - (push-mark end-point t t)))) - -(sniem-define-motion sniem-end-of-mark () - "Goto the end of mark." - (when (region-active-p) - (let ((beg-point (region-beginning))) - (goto-char (region-end)) - (push-mark beg-point t t)))) - -(sniem-define-motion sniem-goto-prev () - "Goto prev lines with `sniem-digit-argument-get'." - (sniem-prev-line (sniem-digit-argument-get "Move up: ") t) - (when (and (region-active-p) sniem-mark-line) - (end-of-line))) - -(sniem-define-motion sniem-goto-next () - "Goto next lines with `sniem-digit-argument-get'." - (sniem-next-line (sniem-digit-argument-get "Move down: ") t) - (when (and (region-active-p) sniem-mark-line) - (end-of-line))) - -(defun sniem-goto-last-point (&optional type non-point-set) - "Goto `sniem-last-point'. -Optional argument TYPE is the type of the point to go. -Optional argument NON-POINT-SET means not change the last-point." - (interactive "P") - (let ((current-point (point))) - (if type - (goto-char sniem-last-point) - (goto-char (if sniem-mark-content-overlay - (overlay-start sniem-mark-content-overlay) - sniem-last-point))) - (unless (or sniem-last-point-locked non-point-set) - (setq-local sniem-last-point current-point)))) - -(provide 'sniem-operation) - -;;; sniem-operation.el ends here diff --git a/sniem-var.el b/sniem-var.el deleted file mode 100644 index 7d225322fba050e482c59e958f84d1e5e2a8d795..0000000000000000000000000000000000000000 --- a/sniem-var.el +++ /dev/null @@ -1,286 +0,0 @@ -;;; sniem-var.el --- Simple united editing method -*- lexical-binding: t -*- - -;; Author: SpringHan -;; Maintainer: SpringHan - -;; This file is not part of GNU Emacs - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; For a full copy of the GNU General Public License -;; see . - - -;;; Commentary: - -;; Simple united editing method. - -;;; Code: - -(defcustom sniem-space-command nil - "The command binded on SPC." - :type 'symbol - :group 'sniem) - -(defcustom sniem-mode-keymap - (let ((map (make-sparse-keymap))) - map) - "Mode keymap for sniem." - :type 'keymap - :group 'sniem) - -(defcustom sniem-last-point nil - "The last point." - :type 'number - :group 'sniem) - -(defcustom sniem-last-point-overlay nil - "The overlay for last point." - :type 'overlay - :group 'sniem) - -(defcustom sniem-last-point-locked nil - "If the `sniem-last-point' is locked." - :type 'boolean - :group 'sniem) - -(defcustom sniem-keyboard-layout nil - "User's keyboard layout." - :type 'symbol - :group 'sniem) - -(defcustom sniem-motion-hint-overlays nil - "The list of all the motion hint overlays." - :type 'list - :group 'sniem) - -(defcustom sniem-motion-hint-sit-time 1 - "The time for motion hint sit." - :type 'number - :group 'sniem) - -(defcustom sniem-kmacro-range nil - "The range for kmacro." - :type 'cons - :group 'sniem) - -(defcustom sniem-kmacro-mark-content nil - "The content which was marked by kmacro." - :type 'string - :group 'sniem) - -(defcustom sniem-mark-line nil - "If in the mark line status." - :type 'boolean - :group 'sniem) - -(defcustom sniem-delete-edit nil - "If it's in delete edit." - :type 'boolean - :group 'sniem) - -(defcustom sniem-change-edit nil - "If it's in change edit." - :type 'boolean - :group 'sniem) - -(defvar sniem-normal-mode-cursor t - "Cursor type for normal mode.") - -(defvar sniem-insert-mode-cursor 'bar - "Cursor type for insert mode.") - -(defvar sniem-motion-mode-cursor t - "Cursor type for motion mode.") - -(defvar sniem-insert-quit-key "" - "The `sniem-quit-insert' key.") - -(defcustom sniem-leader-keymap - (let ((map (make-sparse-keymap))) - (define-key map "x" 'sniem-keypad) - (define-key map "m" 'sniem-keypad) - (define-key map "b" 'sniem-keypad) - (define-key map "v" 'sniem-keypad) - (define-key map "c" 'sniem-keypad) - (define-key map "d" 'sniem-digit-argument) - (define-key map (kbd "SPC") 'sniem-execute-space-command) - map) - "Leader keymap." - :type 'keymap - :group 'sniem) - -(defcustom sniem-normal-state-keymap - (let ((map (make-sparse-keymap))) - (suppress-keymap map t) - (define-key map "a" 'sniem-append) - (define-key map "A" 'sniem-append-line) - (define-key map "o" 'sniem-open-line) - (define-key map "O" 'sniem-open-line-previous) - (define-key map "s" 'eval-last-sexp) - (define-key map "S" 'save-buffer) - (define-key map "r" 'sniem-replace-char) - (define-key map "R" 'sniem-replace-word) - (define-key map "z" 'sniem-center) - (define-key map "x" 'sniem-delete-char) - (define-key map "X" 'execute-extended-command) - (define-key map "c" 'sniem-change) - (define-key map "C" 'sniem-change-in-region) - (define-key map "d" 'sniem-delete) - (define-key map "D" 'sniem-delete-in-region) - (define-key map "b" 'sniem-beginning-of-line) - (define-key map "B" 'sniem-end-of-line) - (define-key map "m" 'sniem-mark) - (define-key map "M" 'sniem-expand-enter-or-quit) - (define-key map "/" 'isearch-forward) - (define-key map "w" 'sniem-next-word) - (define-key map "W" 'sniem-prev-word) - (define-key map "f" 'sniem-find-forward) - (define-key map "F" 'sniem-find-backward) - (define-key map "p" 'sniem-paste) - (define-key map "P" 'sniem-paste-in-region) - (define-key map "g" 'sniem-first-line) - (define-key map "G" 'sniem-goto-line) - (define-key map "y" 'sniem-yank) - (define-key map "Y" 'sniem-yank-in-region) - (define-key map "v" 'sniem-scroll-up-command) - (define-key map "V" 'sniem-scroll-down-command) - (define-key map "q" 'sniem-macro) - (define-key map "Q" 'save-buffers-kill-terminal) - (define-key map ";" 'sniem-keyboard-quit) - (define-key map "'" 'sniem-end-of-mark) - (define-key map "\"" 'sniem-beg-of-mark) - (define-key map "<" 'sniem-goto-prev) - (define-key map ">" 'sniem-goto-next) - (define-key map "`" 'sniem-up-down-case) - (define-key map "1" 'digit-argument) - (define-key map "2" 'digit-argument) - (define-key map "3" 'digit-argument) - (define-key map "4" 'digit-argument) - (define-key map "5" 'digit-argument) - (define-key map "6" 'digit-argument) - (define-key map "7" 'digit-argument) - (define-key map "8" 'digit-argument) - (define-key map "9" 'digit-argument) - (define-key map "0" 'digit-argument) - (define-key map "-" 'kill-current-buffer) - (define-key map "_" 'kill-buffer-and-window) - (define-key map "." 'sniem-move-last-point) - (define-key map "?" 'sniem-cheatsheet) - (define-key map (kbd "SPC") 'sniem-digit-argument-or-fn) - (define-key map (kbd "RET") 'sniem-expand-with-catch) - (define-key map (kbd "(") 'sniem-object-catch-char) - (define-key map (kbd "[") 'sniem-object-catch-char) - (define-key map (kbd "{") 'sniem-object-catch-char) - (define-key map (kbd ")") 'sniem-object-catch-parent) - (define-key map (kbd "]") 'sniem-object-catch-parent) - (define-key map (kbd "}") 'sniem-object-catch-parent) - (define-key map (kbd "") 'sniem-object-catch-parent-by-char) - (define-key map (kbd "C-") 'sniem-object-catch-by-char) - (define-key map (kbd "M-") 'sniem-object-catch-parent) - (define-key map (kbd "DEL") 'sniem-backward-char) - map) - "Normal mode keymap." - :type 'keymap - :group 'sniem) - -(defcustom sniem-insert-state-keymap - (let ((map (make-sparse-keymap))) - (define-key map (kbd "") 'sniem-quit-insert) - map) - "Insert mode keymap." - :type 'keymap - :group 'sniem) - -(defcustom sniem-motion-state-keymap - (let ((map (make-sparse-keymap))) - (define-key map (kbd "SPC") sniem-leader-keymap) - map) - "Motion mode keymap." - :type 'keymap - :group 'sniem) - -(defcustom sniem-expand-state-keymap - (let ((map (make-sparse-keymap))) - (define-key map [remap self-insert-command] 'sniem-expand-enter-or-quit) - (define-key map (kbd "RET") 'sniem-object-catch) - (define-key map "p" 'sniem-object-catch-parent) - (define-key map "r" 'sniem-object-catch-repeat) - (define-key map "b" 'sniem-object-catch-by-char) - (define-key map "B" 'sniem-object-catch-parent-by-char) - (define-key map "s" 'sniem-object-catch-char) - (define-key map "S" 'sniem-object-catch-parent) - (define-key map "o" 'sniem-object-catch-char) - (define-key map "O" 'sniem-object-catch-parent) - (define-key map "c" 'sniem-object-catch-char) - (define-key map "C" 'sniem-object-catch-parent) - (define-key map "q" 'sniem-object-catch-char) - (define-key map "Q" 'sniem-object-catch-parent) - (define-key map "a" 'sniem-object-catch-char) - (define-key map "A" 'sniem-object-catch-parent) - (define-key map "/" 'sniem-object-catch-direction-reverse) - map) - "Expand mode keymap." - :type 'keymap - :group 'sniem) - -(defcustom sniem-motion-hint-motion nil - "The last hint motion." - :type 'symbol - :group 'sniem) - -(defcustom sniem-mark-content-overlay nil - "The mark content overlay." - :type 'overlay - :group 'sniem) - -(defvar sniem-normal-mode-alist - '(fundamental-mode text-mode prog-mode conf-mode cider-repl-mode - json-mode wdired-mode deft-mode pass-view-mode telega-chat-mode - restclient-mode help-mode deadgrep-edit-mode mix-mode authinfo-mode) - "The alist of major modes that make sniem open normal mode.") - -(defvar sniem-insert-mode-alist '(shell-mode eshell-mode vterm-mode inferior-emacs-lisp-mode erc-mode term-mode) - "The alist of major modes that make sniem open insert mode.") - -(defvar sniem-input-method-closed nil - "If the input method was closed when user changed to normal state.") - -(defvar sniem-close-mode-alist nil - "The modes alist for close sniem.") - -(defvar sniem-center-message "[z] for center, [t] for top, [b] for buttom:" - "The message for `sniem-center'.") - -(defvar sniem-mark-message "[m] for normal, [p] for From last point, [l] for line:" - "The message for `sniem-mark'.") - -(defvar sniem-delete-message "[d] for line, [p] for From last point, [D] for Clear line contents:" - "The message for `sniem-delete'.") - -(defvar sniem-change-message "[c] for line, [p] for From last point:" - "The message for `sniem-delete'.") - -(defvar sniem-yank-message "[y] for line, [p] for From last point:" - "The message for `sniem-yank'.") - -(defvar sniem-macro-message "[q] for record, [e] for Eval last kbd macro, [n] for Name for it:" - "The message for `sniem-macro'.") - -(defface sniem-motion-hint-face - `((t (:foreground ,(frame-parameter nil 'background-color) - :background ,(frame-parameter nil 'foreground-color)))) - "The face for motion hint." - :group 'sniem) - -(provide 'sniem-var) - -;;; sniem-var.el ends here diff --git a/sniem.el b/sniem.el deleted file mode 100644 index b075b622952153468bdf8107db5a37741541d7d0..0000000000000000000000000000000000000000 --- a/sniem.el +++ /dev/null @@ -1,433 +0,0 @@ -;;; sniem.el --- Simple united editing method -*- lexical-binding: t -*- - -;; Author: SpringHan -;; Maintainer: SpringHan -;; Version: 1.0 -;; Package-Requires: ((emacs "26.1") (s "2.12.0") (dash "1.12.0")) -;; Homepage: https://github.com/SpringHan/sniem.git -;; Keywords: convenience, united-editing-method - - -;; This file is not part of GNU Emacs - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; For a full copy of the GNU General Public License -;; see . - - -;;; Commentary: - -;; Simple united editing method. - -;;; Code: - -(require 's) -(require 'dash) - -(defgroup sniem nil - "The group for sniem." - :group 'applications) - -(require 'sniem-var) -(require 'sniem-macro) -(require 'sniem-operation) - - -(define-minor-mode sniem-mode - "Simple united editing method mode." - nil nil sniem-mode-keymap - (if sniem-mode - (sniem--enable) - (sniem--disable))) - -;;;###autoload -(define-globalized-minor-mode global-sniem-mode - sniem-mode sniem-initialize) - -(define-minor-mode sniem-normal-mode - "Normal mode for sniem." - nil nil sniem-normal-state-keymap - (when sniem-normal-mode - (sniem-normal-mode-init))) - -(define-minor-mode sniem-insert-mode - "Insert mode for sniem." - nil nil sniem-insert-state-keymap - (when sniem-insert-mode - (sniem-insert-mode-init))) - -(define-minor-mode sniem-motion-mode - "Motion mode for sniem." - nil nil sniem-motion-state-keymap - (when sniem-motion-mode - (sniem-motion-mode-init))) - -(define-minor-mode sniem-expand-mode - "Expand mode for sniem." - nil nil sniem-expand-state-keymap - (when sniem-expand-mode - (sniem-expand-mode-init))) - -(defun sniem-normal-mode-init () - "Normal mode init." - (sniem-insert-mode -1) - (sniem-motion-mode -1) - (sniem-expand-mode -1) - (when current-input-method - (toggle-input-method) - (setq-local sniem-input-method-closed t))) - -(defun sniem-insert-mode-init () - "Insert mode init." - (sniem-normal-mode -1) - (sniem-motion-mode -1) - (sniem-expand-mode -1) - (when sniem-input-method-closed - (toggle-input-method) - (setq-local sniem-input-method-closed nil))) - -(defun sniem-motion-mode-init () - "Motion mode init." - (sniem-normal-mode -1) - (sniem-insert-mode -1) - (sniem-expand-mode -1)) - -(defun sniem-expand-mode-init () - "Expand mode init." - (sniem-normal-mode -1) - (sniem-insert-mode -1) - (sniem-motion-mode -1)) - -(defun sniem--enable () - "Unable sniem." - (unless (apply #'derived-mode-p sniem-close-mode-alist) - (unless sniem-space-command - (setq-local sniem-space-command (key-binding (kbd "SPC")))) - (cond ((apply #'derived-mode-p sniem-normal-mode-alist) - (sniem-change-mode 'normal)) - ((apply #'derived-mode-p sniem-insert-mode-alist) - (sniem-change-mode 'insert)) - (t (sniem-change-mode 'motion))) - (add-to-list 'emulation-mode-map-alists 'sniem-normal-state-keymap))) - -(defun sniem--disable () - "Disable sniem." - (sniem-normal-mode -1) - (sniem-insert-mode -1) - (sniem-motion-mode -1)) - -;;; Interactive functions - -(defun sniem-expand-with-catch () - "Enter expand mode with object catch." - (interactive) - (sniem-object-catch) - (sniem-expand-mode t)) - -(defun sniem-expand-enter-or-quit () - "Quit expand mode." - (interactive) - (if sniem-expand-mode - (sniem-change-mode 'normal) - (sniem-change-mode 'expand))) - -(defun sniem-execute-space-command () - "Execute space command." - (interactive) - (call-interactively sniem-space-command)) - -(defun sniem-quit-insert () - "Quit insert mode." - (interactive) - (sniem-change-mode 'normal)) - -(defun sniem-keypad () - "Execute the keypad command." - (interactive) - (let ((key (pcase last-input-event - (120 "C-x ") (109 "M-") (98 "C-M-") (118 "C-"))) - tmp) - (when (null key) - (setq key (concat "C-" (char-to-string last-input-event) " "))) - - (message key) - (catch 'stop - (while (setq tmp (read-char)) - (if (= tmp 127) - (setq key (substring key 0 -2)) - (when (= tmp 59) - (keyboard-quit)) - (setq key (concat key - (cond ((= tmp 32) (concat (char-to-string (read-char)) " ")) - ((= tmp 44) "C-") - ((= tmp 46) "M-") - ((= tmp 47) "C-M-") - (t (concat (char-to-string tmp) " ")))))) - (message key) - (when (commandp (setq tmp (key-binding (read-kbd-macro (substring key 0 -1))))) - (throw 'stop nil)))) - (call-interactively tmp))) - -(defun sniem-move-last-point () - "Move the last point to current point." - (interactive) - (setq-local sniem-last-point (point)) - (sniem-lock-unlock-last-point)) - -(defun sniem-keyboard-quit () - "Like `keyboard-quit'. -But when it's recording kmacro and there're region, deactivate mark." - (interactive) - (if (and (region-active-p) defining-kbd-macro) - (deactivate-mark) - (keyboard-quit))) - -;;; Functional functions - -(defun sniem-initialize () - "Initialize sniem." - (unless (minibufferp) - (sniem-mode t))) - -(defun sniem--ele-exists-p (ele list) - "Check if ELE is belong to the LIST." - (catch 'exists - (dolist (item list) - (when (equal ele item) - (throw 'exists t))))) - -(defun sniem-cursor-change () - "Change cursor type." - (setq-local cursor-type (pcase (sniem-current-mode) - ('normal sniem-normal-mode-cursor) - ('insert sniem-insert-mode-cursor) - ('motion sniem-motion-mode-cursor) - (_ cursor-type)))) - -(defun sniem-set-leader-key (key) - "Set the leader KEY for normal mode." - (define-key sniem-normal-state-keymap (kbd key) sniem-leader-keymap)) - -(defun sniem-leader-set-key (&rest keys) - "Bind key to leader keymap. - -\(fn KEY FUNC...) -Optional argument KEYS are the keys you want to add." - (let (key func) - (while keys - (setq key (pop keys) - func (pop keys)) - (define-key sniem-leader-keymap (kbd key) func)))) - -(defun sniem-normal-set-key (&rest keys) - "Bind key to normal mode keymap. - -\(fn KEY FUNC...) -Optional argument KEYS are the keys you want to add." - (let (key func) - (while keys - (setq key (pop keys) - func (pop keys)) - (define-key sniem-normal-state-keymap (kbd key) func)))) - -(defun sniem-expand-set-key (&rest keys) - "Bind key to expand mode keymap. - -\(fn KEY FUNC...) -Optional argument KEYS are the keys you want to add." - (let (key func) - (while keys - (setq key (pop keys) - func (pop keys)) - (define-key sniem-expand-state-keymap (kbd key) func)))) - -(defun sniem-set-keyboard-layout (layout) - "Set the keyboard layout, then you can use the default keymap for your layout. - -LAYOUT can be qwerty, colemak or dvorak." - (cond - ((eq layout 'qwerty) - (sniem-normal-set-key - "e" 'sniem-join - "u" 'undo - "k" 'sniem-prev-line - "K" 'sniem-5-prev-line - "j" 'sniem-next-line - "J" 'sniem-5-next-line - "i" 'sniem-insert - "I" 'sniem-insert-line - "h" 'sniem-backward-char - "H" 'sniem-5-backward-char - "l" 'sniem-forward-char - "L" 'sniem-5-forward-char - "n" 'sniem-lock-unlock-last-point - "N" 'sniem-goto-last-point - "t" 'sniem-next-symbol - "T" 'sniem-prev-symbol) - (setq sniem-keyboard-layout 'qwerty)) - ((eq layout 'colemak) - (sniem-normal-set-key - "j" 'sniem-join - "l" 'undo - "u" 'sniem-prev-line - "U" 'sniem-5-prev-line - "e" 'sniem-next-line - "E" 'sniem-5-next-line - "h" 'sniem-insert - "H" 'sniem-insert-line - "n" 'sniem-backward-char - "N" 'sniem-5-backward-char - "i" 'sniem-forward-char - "I" 'sniem-5-forward-char - "k" 'sniem-lock-unlock-last-point - "K" 'sniem-goto-last-point - "t" 'sniem-next-symbol - "T" 'sniem-prev-symbol) - (setq sniem-keyboard-layout 'colemak)) - ((or (eq layout 'dvorak) - (eq layout 'dvp)) - (sniem-normal-set-key - "j" 'sniem-join - "u" 'undo - "e" 'sniem-prev-line - "E" 'sniem-5-prev-line - "n" 'sniem-next-line - "N" 'sniem-5-next-line - "i" 'sniem-insert - "I" 'sniem-insert-line - "h" 'sniem-backward-char - "H" 'sniem-5-backward-char - "t" 'sniem-forward-char - "T" 'sniem-5-forward-char - "k" 'sniem-lock-unlock-last-point - "K" 'sniem-goto-last-point - "l" 'sniem-next-symbol - "L" 'sniem-prev-symbol) - (setq sniem-keyboard-layout (if (eq layout 'dvp) - 'dvp - 'dvorak))) - (t (user-error "[Sniem]: The %s layout is not supplied!" layout)))) - -(defun sniem-digit-argument-or-fn (arg) - "The digit argument function. -Argument ARG is the `digit-argument' result." - (interactive (list (sniem-digit-argument-get))) - (if (listp arg) - (eval arg) - (prefix-command-preserve-state) - (setq prefix-arg arg) - (universal-argument--mode))) - -(defun sniem-digit-argument-fn-get (string) - "Read the fn for `sniem-digit-argument-or-fn'. -Argument STRING is the string get from the input." - (pcase string - ("." 'sniem-mark-content) - (" " 'sniem-move-with-hint-num) - ("/" 'sniem-object-catch-direction-reverse) - ("," 'sniem-object-catch-repeat) - ("p" 'sniem-pair) - ("m" 'sniem-mark-jump-insert-with-name) - ("<" 'sniem-mark-jump-prev) - (">" 'sniem-mark-jump-next))) - -(defun sniem-digit-argument-read-char () - "Read char for `sniem-digit-argument'." - (pcase sniem-keyboard-layout - ('colemak - (pcase (read-char) - (97 "1") (114 "2") (115 "3") (116 "4") (100 "5") - (104 "6") (110 "7") (101 "8") (105 "9") (111 "0") - (39 "-") (13 "over") (127 "delete") (59 (keyboard-quit)) - (x (char-to-string x)))) - ('qwerty - (pcase (read-char) - (97 "1") (115 "2") (100 "3") (102 "4") (103 "5") - (104 "6") (106 "7") (107 "8") (108 "9") (59 "0") - (39 "-") (13 "over") (127 "delete") (59 (keyboard-quit)) - (x (char-to-string x)))) - ('dvorak - (pcase (read-char) - (97 "1") (111 "2") (101 "3") (117 "4") (105 "5") - (100 "6") (104 "7") (116 "8") (110 "9") (115 "0") - (45 "-") (13 "over") (127 "delete") (59 (keyboard-quit)) - (x (char-to-string x)))))) - -(defun sniem-mark-content (&optional mark) - "Mark/unmark the content. -Optional Argument MARK means mark forcibly." - (interactive "P") - (let ((mark-content (lambda () - (if (region-active-p) - (progn - (setq-local sniem-mark-content-overlay - (make-overlay (region-beginning) (region-end))) - (deactivate-mark)) - (setq-local sniem-mark-content-overlay - (make-overlay (point) (1+ (point))))) - (overlay-put sniem-mark-content-overlay 'face 'region)))) - (when (overlayp sniem-mark-content-overlay) - (delete-overlay sniem-mark-content-overlay)) - (if (or (null sniem-mark-content-overlay) mark) - (funcall mark-content) - (setq-local sniem-mark-content-overlay nil)))) - -(defun sniem-show-last-point (&optional hide) - "Show the last point. -Optional argument HIDE is t, the last point will be show." - (let ((cursor-color - `((t (:foreground ,(frame-parameter nil 'background-color)) - :background ,(frame-parameter nil 'cursor-color))))) - (if (or sniem-last-point-overlay hide) - (progn - (delete-overlay sniem-last-point-overlay) - (setq-local sniem-last-point-overlay nil)) - (setq-local sniem-last-point-overlay - (make-overlay sniem-last-point (1+ sniem-last-point) (current-buffer) t t)) - (overlay-put sniem-last-point-overlay 'face cursor-color)))) - -(defun sniem-set-quit-insert-key (key) - "Set the `sniem-quit-insert' KEY." - (define-key sniem-insert-state-keymap (kbd sniem-insert-quit-key) 'nil) - (define-key sniem-insert-state-keymap (kbd key) 'sniem-quit-insert) - (setq sniem-insert-quit-key key)) - -;;; Initialize -(sniem-set-leader-key ",") - -(require 'sniem-object-catch) -(require 'sniem-cheatsheet) -(require 'sniem-mark-jump) -(require 'sniem-expand-region) - -;;; Third-Party Settings -(advice-add 'wdired-change-to-wdired-mode :after #'sniem-normal-mode) -(advice-add 'wdired-change-to-dired-mode :after #'sniem-motion-mode) - -;;; State info print support -(defun sniem-state () - "The function to show the current sniem state." - (pcase (sniem-current-mode) - ('normal (format "[N:%s%s%s]" - (if sniem-object-catch-forward-p ">" "<") - (if sniem-last-point-locked ":l" "") - (if sniem-mark-content-overlay ":M" ""))) - ('insert "[I]") - ('motion "[M]") - ('expand (format "[E:%s]" - (if sniem-object-catch-forward-p ">" "<"))))) -(when (featurep 'awesome-tray) - (add-to-list 'awesome-tray-module-alist '("sniem-state" . (sniem-state awesome-tray-module-evil-face)))) - -(provide 'sniem) - -;;; sniem.el ends here