commit for merge

This commit is contained in:
Ivan Malison 2013-04-10 15:43:11 -07:00
parent eef55f7c0f
commit 903ab9e2d7
24 changed files with 21731 additions and 30 deletions

2
.gitignore vendored
View File

@ -5,3 +5,5 @@ eproject.lst
.smex-items .smex-items
places places
backups backups
eshell
url

View File

@ -18,7 +18,7 @@
[(0 4 1) [(0 4 1)
nil "Major mode for CoffeeScript files" tar]) nil "Major mode for CoffeeScript files" tar])
(company . (company .
[(0 6 2) [(0 6 7)
nil "Modular in-buffer completion framework" tar]) nil "Modular in-buffer completion framework" tar])
(csv-mode . (csv-mode .
[(1 1) [(1 1)
@ -47,6 +47,9 @@
(eldoc-eval . (eldoc-eval .
[(0 1) [(0 1)
nil "Enable eldoc support when minibuffer is in use." single]) nil "Enable eldoc support when minibuffer is in use." single])
(enwc .
[(1 0)
nil "The Emacs Network Client" tar])
(epoch-view . (epoch-view .
[(0 0 1) [(0 0 1)
nil "Minor mode to visualize epoch timestamps" single]) nil "Minor mode to visualize epoch timestamps" single])
@ -54,7 +57,7 @@
[(1 1) [(1 1)
nil "Parse and browse f90 interfaces" single]) nil "Parse and browse f90 interfaces" single])
(ggtags . (ggtags .
[(0 6 2) [(0 6 3)
nil "GNU Global source code tagging system" single]) nil "GNU Global source code tagging system" single])
(heap . (heap .
[(0 3) [(0 3)
@ -70,9 +73,12 @@
((emacs ((emacs
(24 1))) (24 1)))
"Improved JavaScript editing mode" single]) "Improved JavaScript editing mode" single])
(jumpc .
[(2 0)
nil "jump to previous insertion points" single])
(lex . (lex .
[(1 0) [(1 1)
nil "Lexical analyser construction" single]) nil "Lexical analyser construction" tar])
(lmc . (lmc .
[(1 1) [(1 1)
nil "Little Man Computer in Elisp" single]) nil "Little Man Computer in Elisp" single])
@ -107,7 +113,7 @@
[(0 8) [(0 8)
nil "OAuth 2.0 Authorization Protocol" single]) nil "OAuth 2.0 Authorization Protocol" single])
(org . (org .
[(20130318) [(20130408)
nil "Outline-based notes management and organizer" tar]) nil "Outline-based notes management and organizer" tar])
(quarter-plane . (quarter-plane .
[(0 1) [(0 1)

File diff suppressed because one or more lines are too long

674
elpa/evil-1.0.1/COPYING Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
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.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 <http://www.gnu.org/licenses/>.
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:
<program> Copyright (C) <year> <name of author>
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
<http://www.gnu.org/licenses/>.
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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -0,0 +1,26 @@
;;; evil-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads nil "evil-core" "evil-core.el" (20836 47458))
;;; Generated autoloads from evil-core.el
(autoload 'evil-mode "evil" "Toggle evil in all buffers" t)
;;;***
;;;### (autoloads nil nil ("evil-commands.el" "evil-common.el" "evil-digraphs.el"
;;;;;; "evil-ex.el" "evil-integration.el" "evil-macros.el" "evil-maps.el"
;;;;;; "evil-pkg.el" "evil-repeat.el" "evil-search.el" "evil-states.el"
;;;;;; "evil-types.el" "evil-vars.el" "evil.el") (20836 47458 860825))
;;;***
(provide 'evil-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; evil-autoloads.el ends here

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1082
elpa/evil-1.0.1/evil-core.el Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1044
elpa/evil-1.0.1/evil-ex.el Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,288 @@
;;; evil-integration.el --- Integrate Evil with other modules
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.0.1
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
(require 'evil-maps)
(require 'evil-core)
;;; Code:
;;; Evilize some commands
(mapc #'(lambda (cmd)
(evil-set-command-property cmd :keep-visual t)
(evil-declare-not-repeat cmd))
'(digit-argument
negative-argument
universal-argument
universal-argument-minus
universal-argument-more
universal-argument-other-key))
(mapc #'evil-declare-not-repeat
'(what-cursor-position))
(mapc #'evil-declare-change-repeat
'(dabbrev-expand
hippie-expand))
(mapc #'evil-declare-abort-repeat
'(balance-windows
eval-expression
execute-extended-command
exit-minibuffer
compile
delete-window
delete-other-windows
find-file-at-point
ffap-other-window
recompile
save-buffer
split-window
split-window-horizontally
split-window-vertically))
(evil-set-type #'previous-line 'line)
(evil-set-type #'next-line 'line)
(dolist (cmd '(keyboard-quit keyboard-escape-quit))
(evil-set-command-property cmd :suppress-operator t))
;;; Mouse
(evil-declare-insert-at-point-repeat 'mouse-yank-primary)
(evil-declare-insert-at-point-repeat 'mouse-yank-secondary)
;;; key-binding
;; disable evil-esc-mode during a call to key-binding
(defadvice key-binding (around evil activate)
(let (evil-esc-mode)
ad-do-it))
;; disable evil-esc-mode during the read of a key-sequence
;; TODO: should we handle the special ESC-delay, too?
(defadvice read-key-sequence (around evil activate)
(let (evil-esc-mode)
ad-do-it))
;; disable evil-esc-mode during the read of a key-sequence
;; TODO: should we handle the special ESC-delay, too?
(defadvice read-key-sequence-vector (around evil activate)
(let (evil-esc-mode)
ad-do-it))
;; Calling `keyboard-quit' should cancel repeat
(defadvice keyboard-quit (before evil activate)
(when (fboundp 'evil-repeat-abort)
(evil-repeat-abort)))
;; etags-select
;; FIXME: probably etags-select should be recomended in docs
(eval-after-load 'etags-select
'(progn
(define-key evil-motion-state-map "g]" 'etags-select-find-tag-at-point)))
;;; Buffer-menu
(evil-add-hjkl-bindings Buffer-menu-mode-map 'motion)
;; dictionary.el
(evil-add-hjkl-bindings dictionary-mode-map 'motion
"?" 'dictionary-help ; "h"
"C-o" 'dictionary-previous) ; "l"
;;; Dired
(eval-after-load 'dired
'(progn
;; use the standard Dired bindings as a base
(evil-make-overriding-map dired-mode-map 'normal t)
(evil-add-hjkl-bindings dired-mode-map 'normal
"J" 'dired-goto-file ; "j"
"K" 'dired-do-kill-lines ; "k"
"r" 'dired-do-redisplay ; "l"
";" (lookup-key dired-mode-map ":")))) ; ":d", ":v", ":s", ":e"
(eval-after-load 'wdired
'(progn
(add-hook 'wdired-mode-hook #'evil-change-to-initial-state)
(defadvice wdired-change-to-dired-mode (after evil activate)
(evil-change-to-initial-state nil t))))
;;; ELP
(eval-after-load 'elp
'(defadvice elp-results (after evil activate)
(evil-motion-state)))
;;; ERT
(evil-add-hjkl-bindings ert-results-mode-map 'motion)
;;; Info
(evil-add-hjkl-bindings Info-mode-map 'motion
"0" 'evil-digit-argument-or-evil-beginning-of-line
(kbd "\M-h") 'Info-help ; "h"
"\C-t" 'Info-history-back ; "l"
"\C-o" 'Info-history-back
" " 'Info-scroll-up
"\C-]" 'Info-follow-nearest-node
(kbd "DEL") 'Info-scroll-down)
;;; Parentheses
(defadvice show-paren-function (around evil)
"Match parentheses in Normal state."
(if (if (memq 'not evil-highlight-closing-paren-at-point-states)
(memq evil-state evil-highlight-closing-paren-at-point-states)
(not (memq evil-state evil-highlight-closing-paren-at-point-states)))
ad-do-it
(let ((pos (point)) syntax narrow)
(setq pos
(catch 'end
(dotimes (var (1+ (* 2 evil-show-paren-range)))
(if (zerop (mod var 2))
(setq pos (+ pos var))
(setq pos (- pos var)))
(setq syntax (syntax-class (syntax-after pos)))
(cond
((eq syntax 4)
(setq narrow pos)
(throw 'end pos))
((eq syntax 5)
(throw 'end (1+ pos)))))))
(if pos
(save-excursion
(goto-char pos)
(save-restriction
(when narrow
(narrow-to-region narrow (point-max)))
ad-do-it))
;; prevent the preceding pair from being highlighted
(when (overlayp show-paren-overlay)
(delete-overlay show-paren-overlay))
(when (overlayp show-paren-overlay-1)
(delete-overlay show-paren-overlay-1))))))
;;; Speedbar
(evil-add-hjkl-bindings speedbar-key-map 'motion
"h" 'backward-char
"j" 'speedbar-next
"k" 'speedbar-prev
"l" 'forward-char
"i" 'speedbar-item-info
"r" 'speedbar-refresh
"u" 'speedbar-up-directory
"o" 'speedbar-toggle-line-expansion
(kbd "RET") 'speedbar-edit-line)
;; Ibuffer
(eval-after-load 'ibuffer
'(progn
(evil-make-overriding-map ibuffer-mode-map 'normal t)
(evil-define-key 'normal ibuffer-mode-map
"j" 'evil-next-line
"k" 'evil-previous-line
"RET" 'ibuffer-visit-buffer)))
;;; Undo tree visualizer
(defadvice undo-tree-visualize (after evil activate)
"Initialize Evil in the visualization buffer."
(when evil-local-mode
(evil-initialize-state)))
(when (boundp 'undo-tree-visualizer-map)
(define-key undo-tree-visualizer-map [remap evil-backward-char]
'undo-tree-visualize-switch-branch-left)
(define-key undo-tree-visualizer-map [remap evil-forward-char]
'undo-tree-visualize-switch-branch-right)
(define-key undo-tree-visualizer-map [remap evil-next-line]
'undo-tree-visualize-redo)
(define-key undo-tree-visualizer-map [remap evil-previous-line]
'undo-tree-visualize-undo))
;;; Auto-complete
(eval-after-load 'auto-complete
'(progn
(evil-add-command-properties 'ac-complete :repeat 'evil-ac-repeat)
(evil-add-command-properties 'ac-expand :repeat 'evil-ac-repeat)
(evil-add-command-properties 'ac-next :repeat 'ignore)
(evil-add-command-properties 'ac-previous :repeat 'ignore)
(defvar evil-ac-prefix-len nil
"The length of the prefix of the current item to be completed.")
(defun evil-ac-repeat (flag)
"Record the changes for auto-completion."
(cond
((eq flag 'pre)
(setq evil-ac-prefix-len (length ac-prefix))
(evil-repeat-start-record-changes))
((eq flag 'post)
;; Add change to remove the prefix
(evil-repeat-record-change (- evil-ac-prefix-len)
""
evil-ac-prefix-len)
;; Add change to insert the full completed text
(evil-repeat-record-change
(- evil-ac-prefix-len)
(buffer-substring-no-properties (- evil-repeat-pos
evil-ac-prefix-len)
(point))
0)
;; Finish repeation
(evil-repeat-finish-record-changes))))))
;; Eval last sexp
(defadvice preceding-sexp (around evil activate)
"In normal-state, last sexp ends at point."
(if (evil-normal-state-p)
(save-excursion
(unless (or (eobp) (eolp)) (forward-char))
ad-do-it)
ad-do-it))
(defadvice pp-last-sexp (around evil activate)
"In normal-state, last sexp ends at point."
(if (evil-normal-state-p)
(save-excursion
(unless (or (eobp) (eolp)) (forward-char))
ad-do-it)
ad-do-it))
;; Show key
(defadvice quail-show-key (around evil activate)
"Temporarily go to Emacs state"
(evil-with-state emacs ad-do-it))
(defadvice describe-char (around evil activate)
"Temporarily go to Emacs state"
(evil-with-state emacs ad-do-it))
(provide 'evil-integration)
;;; evil-integration.el ends here

View File

@ -0,0 +1,751 @@
;;; evil-macros.el --- Macros
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.0.1
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
(require 'evil-common)
(require 'evil-states)
(require 'evil-repeat)
;;; Code:
(declare-function evil-ex-p "evil-ex")
(defun evil-motion-range (motion &optional count type)
"Execute a motion and return the buffer positions.
The return value is a list (BEG END TYPE)."
(let ((opoint (point))
(omark (mark t))
(omactive (and (boundp 'mark-active) mark-active))
(obuffer (current-buffer))
(evil-motion-marker (move-marker (make-marker) (point)))
range)
(evil-with-transient-mark-mode
(evil-narrow-to-field
(unwind-protect
(let ((current-prefix-arg count)
;; Store type in global variable `evil-this-type'.
;; If necessary, motions can change their type
;; during execution by setting this variable.
(evil-this-type
(or type (evil-type motion 'exclusive))))
(condition-case err
(let ((repeat-type (evil-repeat-type motion t)))
(if (functionp repeat-type)
(funcall repeat-type 'pre))
(unless (with-local-quit
(setq range (call-interactively motion))
t)
(evil-repeat-abort)
(setq quit-flag t))
(if (functionp repeat-type)
(funcall repeat-type 'post)))
(error (prog1 nil
(evil-repeat-abort)
(setq evil-this-type 'exclusive
evil-write-echo-area t)
(message (error-message-string err)))))
(cond
;; the motion returned a range
((evil-range-p range))
;; the motion made a Visual selection
((evil-visual-state-p)
(setq range (evil-visual-range)))
;; the motion made an active region
((region-active-p)
(setq range (evil-range (region-beginning)
(region-end)
evil-this-type)))
;; default: range from previous position to current
(t
(setq range (evil-expand-range
(evil-normalize evil-motion-marker
(point)
evil-this-type)))))
(unless (or (null type) (eq (evil-type range) type))
(evil-set-type range type)
(evil-expand-range range))
(evil-set-range-properties range nil)
range)
;; restore point and mark like `save-excursion',
;; but only if the motion hasn't disabled the operator
(unless evil-inhibit-operator
(set-buffer obuffer)
(evil-move-mark omark)
(goto-char opoint))
;; delete marker so it doesn't slow down editing
(move-marker evil-motion-marker nil))))))
(defmacro evil-define-motion (motion args &rest body)
"Define an motion command MOTION.
\(fn MOTION (COUNT ARGS...) DOC [[KEY VALUE]...] BODY...)"
(declare (indent defun)
(debug (&define name lambda-list
[&optional stringp]
[&rest keywordp sexp]
[&optional ("interactive" [&rest form])]
def-body)))
(let (arg doc interactive key keys type)
(when args
(setq args `(&optional ,@(delq '&optional args))
;; the count is either numerical or nil
interactive '("<c>")))
;; collect docstring
(when (and (> (length body) 1)
(or (eq (car-safe (car-safe body)) 'format)
(stringp (car-safe body))))
(setq doc (pop body)))
;; collect keywords
(setq keys (plist-put keys :repeat 'motion))
(while (keywordp (car-safe body))
(setq key (pop body)
arg (pop body)
keys (plist-put keys key arg)))
;; collect `interactive' specification
(when (eq (car-safe (car-safe body)) 'interactive)
(setq interactive (cdr (pop body))))
;; macro expansion
`(progn
;; refresh echo area in Eldoc mode
(when ',motion
(eval-after-load 'eldoc
'(eldoc-add-command ',motion)))
(evil-define-command ,motion (,@args)
,@(when doc `(,doc)) ; avoid nil before `interactive'
,@keys
:keep-visual t
(interactive ,@interactive)
,@body))))
(defmacro evil-define-union-move (name args &rest moves)
"Create a movement function named NAME.
The function moves to the nearest object boundary defined by one
of the movement function in MOVES, which is a list where each
element has the form \(FUNC PARAMS... COUNT).
COUNT is a variable which is bound to 1 or -1, depending on the
direction. In each iteration, the function calls each move in
isolation and settles for the nearest position. If unable to move
further, the return value is the number of iterations that could
not be performed.
\(fn NAME (COUNT) MOVES...)"
(declare (indent defun)
(debug (&define name lambda-list
[&optional stringp]
def-body)))
(let* ((var (or (car-safe args) 'var))
(doc (when (stringp (car-safe moves))
(pop moves)))
(moves (mapcar #'(lambda (move)
`(save-excursion
;; don't include failing moves
(when (zerop ,move)
(point))))
moves)))
`(evil-define-motion ,name (count)
,@(when doc `(,doc))
(evil-motion-loop (,var (or count 1))
(if (> ,var 0)
(evil-goto-min ,@moves)
(evil-goto-max ,@moves))))))
(defmacro evil-narrow-to-line (&rest body)
"Narrow BODY to the current line.
BODY will signal the errors \"Beginning of line\" or \"End of line\"
upon reaching the beginning or end of the current line.
\(fn [[KEY VAL]...] BODY...)"
(declare (indent defun)
(debug t))
`(let* ((range (evil-expand (point) (point) 'line))
(beg (evil-range-beginning range))
(end (evil-range-end range))
(min (point-min))
(max (point-max)))
(when (save-excursion (goto-char end) (bolp))
(setq end (max beg (1- end))))
;; don't include the newline in Normal state
(when (and evil-move-cursor-back
(not (evil-visual-state-p))
(not (evil-operator-state-p)))
(setq end (max beg (1- end))))
(evil-with-restriction beg end
(evil-signal-without-movement
(condition-case err
(progn ,@body)
(beginning-of-buffer
(if (= beg min)
(signal (car err) (cdr err))
(error "Beginning of line")))
(end-of-buffer
(if (= end max)
(signal (car err) (cdr err))
(error "End of line"))))))))
;; we don't want line boundaries to trigger the debugger
;; when `debug-on-error' is t
(add-to-list 'debug-ignored-errors "^Beginning of line$")
(add-to-list 'debug-ignored-errors "^End of line$")
(defun evil-eobp (&optional pos)
"Whether point is at end-of-buffer with regard to end-of-line."
(save-excursion
(when pos (goto-char pos))
(cond
((eobp))
;; the rest only pertains to Normal state
((not (evil-normal-state-p))
nil)
;; at the end of the last line
((eolp)
(forward-char)
(eobp))
;; at the last character of the last line
(t
(forward-char)
(cond
((eobp))
((eolp)
(forward-char)
(eobp)))))))
(defun evil-move-beginning (count forward &optional backward)
"Move to the beginning of the COUNT next object.
If COUNT is negative, move to the COUNT previous object.
FORWARD is a function which moves to the end of the object, and
BACKWARD is a function which moves to the beginning.
If one is unspecified, the other is used with a negative argument."
(let* ((count (or count 1))
(backward (or backward
#'(lambda (count)
(funcall forward (- count)))))
(forward (or forward
#'(lambda (count)
(funcall backward (- count)))))
(opoint (point)))
(cond
((< count 0)
(when (bobp)
(signal 'beginning-of-buffer nil))
(unwind-protect
(evil-motion-loop (nil count count)
(funcall backward 1))
(unless (zerop count)
(goto-char (point-min)))))
((> count 0)
(when (evil-eobp)
(signal 'end-of-buffer nil))
;; Do we need to move past the current object?
(when (<= (save-excursion
(funcall forward 1)
(funcall backward 1)
(point))
opoint)
(setq count (1+ count)))
(unwind-protect
(evil-motion-loop (nil count count)
(funcall forward 1))
(if (zerop count)
;; go back to beginning of object
(funcall backward 1)
(goto-char (point-max)))))
(t
count))))
(defun evil-move-end (count forward &optional backward inclusive)
"Move to the end of the COUNT next object.
If COUNT is negative, move to the COUNT previous object.
FORWARD is a function which moves to the end of the object, and
BACKWARD is a function which moves to the beginning.
If one is unspecified, the other is used with a negative argument.
If INCLUSIVE is non-nil, then point is placed at the last character
of the object; otherwise it is placed at the end of the object."
(let* ((count (or count 1))
(backward (or backward
#'(lambda (count)
(funcall forward (- count)))))
(forward (or forward
#'(lambda (count)
(funcall backward (- count)))))
(opoint (point)))
(cond
((< count 0)
(when (bobp)
(signal 'beginning-of-buffer nil))
;; Do we need to move past the current object?
(when (>= (save-excursion
(funcall backward 1)
(funcall forward 1)
(point))
(if inclusive
(1+ opoint)
opoint))
(setq count (1- count)))
(unwind-protect
(evil-motion-loop (nil count count)
(funcall backward 1))
(if (not (zerop count))
(goto-char (point-min))
;; go to end of object
(funcall forward 1)
(when inclusive
(unless (bobp) (backward-char)))
(when (or (evil-normal-state-p)
(evil-motion-state-p))
(evil-adjust-cursor t)))))
((> count 0)
(when (evil-eobp)
(signal 'end-of-buffer nil))
(when inclusive
(forward-char))
(unwind-protect
(evil-motion-loop (nil count count)
(funcall forward 1))
(if (not (zerop count))
(goto-char (point-max))
(when inclusive
(unless (bobp) (backward-char)))
(when (or (evil-normal-state-p)
(evil-motion-state-p))
(evil-adjust-cursor t)))))
(t
count))))
(defmacro evil-define-text-object (object args &rest body)
"Define a text object command OBJECT.
BODY should return a range (BEG END) to the right of point
if COUNT is positive, and to the left of it if negative.
\(fn OBJECT (COUNT) DOC [[KEY VALUE]...] BODY...)"
(declare (indent defun)
(debug (&define name lambda-list
[&optional stringp]
[&rest keywordp sexp]
def-body)))
(let* ((args (delq '&optional args))
(count (or (pop args) 'count))
(args (when args `(&optional ,@args)))
(interactive '((interactive "<c><v>")))
arg doc key keys)
;; collect docstring
(when (stringp (car-safe body))
(setq doc (pop body)))
;; collect keywords
(setq keys (plist-put keys :extend-selection t))
(while (keywordp (car-safe body))
(setq key (pop body)
arg (pop body)
keys (plist-put keys key arg)))
;; interactive
(when (eq (car-safe (car-safe body)) 'interactive)
(setq interactive (list (pop body))))
;; macro expansion
`(evil-define-motion ,object (,count ,@args)
,@(when doc `(,doc))
,@keys
,@interactive
(setq ,count (or ,count 1))
(when (/= ,count 0)
(let ((type (evil-type ',object evil-visual-char))
(extend (evil-get-command-property
',object :extend-selection
',(plist-get keys :extend-selection)))
(dir evil-visual-direction)
mark point range selection)
(cond
;; Visual state: extend the current selection
((and (evil-visual-state-p)
(evil-called-interactively-p))
;; if we are at the beginning of the Visual selection,
;; go to the left (negative COUNT); if at the end,
;; go to the right (positive COUNT)
(setq dir evil-visual-direction
,count (* ,count dir))
(setq range (progn ,@body))
(when (evil-range-p range)
(setq range (evil-expand-range range))
(evil-set-type range (evil-type range type))
(setq range (evil-contract-range range))
;; the beginning is mark and the end is point
;; unless the selection goes the other way
(setq mark (evil-range-beginning range)
point (evil-range-end range)
type (evil-type range))
(when (< dir 0)
(evil-swap mark point))
;; select the union
(evil-visual-make-selection mark point type)))
;; not Visual state: return a pair of buffer positions
(t
(setq range (progn ,@body))
(unless (evil-range-p range)
(setq ,count (- ,count)
range (progn ,@body)))
(when (evil-range-p range)
(setq selection (evil-range (point) (point) type))
(if extend
(setq range (evil-range-union range selection))
(evil-set-type range (evil-type range type)))
;; ensure the range is properly expanded
(evil-contract-range range)
(evil-expand-range range)
(evil-set-range-properties range nil)
range))))))))
(defmacro evil-define-operator (operator args &rest body)
"Define an operator command OPERATOR.
\(fn OPERATOR (BEG END ARGS...) DOC [[KEY VALUE]...] BODY...)"
(declare (indent defun)
(debug (&define name lambda-list
[&optional stringp]
[&rest keywordp sexp]
[&optional ("interactive" [&rest form])]
def-body)))
(let* ((args (delq '&optional args))
(interactive (if (> (length args) 2) '("<R>") '("<r>")))
(args (if (> (length args) 2)
`(,(nth 0 args) ,(nth 1 args)
&optional ,@(nthcdr 2 args))
args))
arg doc key keys visual)
;; collect docstring
(when (and (> (length body) 1)
(or (eq (car-safe (car-safe body)) 'format)
(stringp (car-safe body))))
(setq doc (pop body)))
;; collect keywords
(setq keys (plist-put keys :move-point t))
(while (keywordp (car-safe body))
(setq key (pop body)
arg (pop body))
(cond
((eq key :keep-visual)
(setq visual arg))
(t
(setq keys (plist-put keys key arg)))))
;; collect `interactive' specification
(when (eq (car-safe (car-safe body)) 'interactive)
(setq interactive (cdr-safe (pop body))))
;; transform extended interactive specs
(setq interactive (apply #'evil-interactive-form interactive))
(setq keys (evil-concat-plists keys (cdr-safe interactive))
interactive (car-safe interactive))
;; macro expansion
`(evil-define-command ,operator ,args
,@(when doc `(,doc))
,@keys
:keep-visual t
:suppress-operator t
(interactive
(let* ((evil-operator-range-motion
(when (evil-has-command-property-p ',operator :motion)
;; :motion nil is equivalent to :motion undefined
(or (evil-get-command-property ',operator :motion)
#'undefined)))
(evil-operator-range-type
(evil-get-command-property ',operator :type))
(orig (point))
evil-operator-range-beginning
evil-operator-range-end
evil-inhibit-operator)
(setq evil-inhibit-operator-value nil
evil-this-operator this-command)
(prog1 ,interactive
(setq orig (point)
evil-inhibit-operator-value evil-inhibit-operator)
(if ,visual
(when (evil-visual-state-p)
(evil-visual-expand-region))
(when (or (evil-visual-state-p) (region-active-p))
(setq deactivate-mark t)))
(cond
((evil-visual-state-p)
(evil-visual-rotate 'upper-left))
((evil-get-command-property ',operator :move-point)
(goto-char (or evil-operator-range-beginning orig)))
(t
(goto-char orig))))))
(unwind-protect
(let ((evil-inhibit-operator evil-inhibit-operator-value))
(unless (and evil-inhibit-operator
(evil-called-interactively-p))
,@body))
(setq evil-inhibit-operator-value nil)))))
;; this is used in the `interactive' specification of an operator command
(defun evil-operator-range (&optional return-type)
"Read a motion from the keyboard and return its buffer positions.
The return value is a list (BEG END), or (BEG END TYPE) if
RETURN-TYPE is non-nil."
(let ((motion (or evil-operator-range-motion
(when (evil-ex-p) #'evil-line)))
(type evil-operator-range-type)
(range (evil-range (point) (point)))
command count modifier)
(evil-save-echo-area
(cond
;; Ex mode
((and (evil-ex-p) evil-ex-range)
(setq range evil-ex-range))
;; Visual selection
((and (not (evil-ex-p)) (evil-visual-state-p))
(setq range (evil-visual-range)))
;; active region
((and (not (evil-ex-p)) (region-active-p))
(setq range (evil-range (region-beginning)
(region-end)
(or evil-this-type 'exclusive))))
(t
;; motion
(evil-save-state
(unless motion
(evil-change-state 'operator)
;; Make linewise operator shortcuts. E.g., "d" yields the
;; shortcut "dd", and "g?" yields shortcuts "g??" and "g?g?".
(let ((keys (nth 2 (evil-extract-count (this-command-keys)))))
(setq keys (listify-key-sequence keys))
(dotimes (var (length keys))
(define-key evil-operator-shortcut-map
(vconcat (nthcdr var keys)) 'evil-line)))
;; read motion from keyboard
(setq command (evil-read-motion motion)
motion (nth 0 command)
count (nth 1 command)
type (or type (nth 2 command))))
(cond
((eq motion #'undefined)
(setq range (if return-type '(nil nil nil) '(nil nil))
motion nil))
((or (null motion) ; keyboard-quit
(evil-get-command-property motion :suppress-operator))
(when (fboundp 'evil-repeat-abort)
(evil-repeat-abort))
(setq quit-flag t
motion nil))
(evil-repeat-count
(setq count evil-repeat-count
;; only the first operator's count is overwritten
evil-repeat-count nil))
((or count current-prefix-arg)
;; multiply operator count and motion count together
(setq count
(* (prefix-numeric-value count)
(prefix-numeric-value current-prefix-arg)))))
(when motion
(let ((evil-state 'operator)
mark-active)
;; calculate motion range
(setq range (evil-motion-range
motion
count
type))))
;; update global variables
(setq evil-this-motion motion
evil-this-motion-count count
type (evil-type range type)
evil-this-type type))))
(when (evil-range-p range)
(unless (or (null type) (eq (evil-type range) type))
(evil-contract-range range)
(evil-set-type range type)
(evil-expand-range range))
(evil-set-range-properties range nil)
(unless return-type
(evil-set-type range nil))
(setq evil-operator-range-beginning (evil-range-beginning range)
evil-operator-range-end (evil-range-end range)
evil-operator-range-type (evil-type range)))
range)))
(defmacro evil-define-type (type doc &rest body)
"Define type TYPE.
DOC is a general description and shows up in all docstrings.
It is followed by a list of keywords and functions:
:expand FUNC Expansion function. This function should accept
two positions in the current buffer, BEG and END,
and return a pair of expanded buffer positions.
:contract FUNC The opposite of :expand, optional.
:one-to-one BOOL Whether expansion is one-to-one. This means that
:expand followed by :contract always returns the
original range.
:normalize FUNC Normalization function, optional. This function should
accept two unexpanded positions and adjust them before
expansion. May be used to deal with buffer boundaries.
:string FUNC Description function. This takes two buffer positions
and returns a human-readable string, for example,
\"2 lines\".
If further keywords and functions are specified, they are assumed to
be transformations on buffer positions, like :expand and :contract.
\(fn TYPE DOC [[KEY FUNC]...])"
(declare (indent defun)
(debug (&define name
[&optional stringp]
[&rest [keywordp function-form]])))
(let (args defun-forms func key name plist string sym val)
;; standard values
(setq plist (plist-put plist :one-to-one t))
;; keywords
(while (keywordp (car-safe body))
(setq key (pop body)
val (pop body))
(if (plist-member plist key) ; not a function
(setq plist (plist-put plist key val))
(setq func val
sym (intern (replace-regexp-in-string
"^:" "" (symbol-name key)))
name (intern (format "evil-%s-%s" type sym))
args (car (cdr-safe func))
string (car (cdr (cdr-safe func)))
string (if (stringp string)
(format "%s\n\n" string) "")
plist (plist-put plist key `',name))
(add-to-list
'defun-forms
(cond
((eq key :string)
`(defun ,name (beg end &rest properties)
,(format "Return size of %s from BEG to END \
with PROPERTIES.\n\n%s%s" type string doc)
(let ((beg (evil-normalize-position beg))
(end (evil-normalize-position end))
(type ',type)
plist range)
(when (and beg end)
(save-excursion
(evil-sort beg end)
(unless (plist-get properties :expanded)
(setq range (apply #'evil-expand
beg end type properties)
beg (evil-range-beginning range)
end (evil-range-end range)
type (evil-type range type)
plist (evil-range-properties range))
(setq properties
(evil-concat-plists properties plist)))
(or (apply #',func beg end
(when ,(> (length args) 2)
properties))
""))))))
(t
`(defun ,name (beg end &rest properties)
,(format "Perform %s transformation on %s from BEG to END \
with PROPERTIES.\n\n%s%s" sym type string doc)
(let ((beg (evil-normalize-position beg))
(end (evil-normalize-position end))
(type ',type)
plist range)
(when (and beg end)
(save-excursion
(evil-sort beg end)
(when (memq ,key '(:expand :contract))
(setq properties
(plist-put properties
:expanded
,(eq key :expand))))
(setq range (or (apply #',func beg end
(when ,(> (length args) 2)
properties))
(apply #'evil-range
beg end type properties))
beg (evil-range-beginning range)
end (evil-range-end range)
type (evil-type range type)
plist (evil-range-properties range))
(setq properties
(evil-concat-plists properties plist))
(apply #'evil-range beg end type properties)))))))
t)))
;; :one-to-one requires both or neither of :expand and :contract
(when (plist-get plist :expand)
(setq plist (plist-put plist :one-to-one
(and (plist-get plist :contract)
(plist-get plist :one-to-one)))))
`(progn
(evil-put-property 'evil-type-properties ',type ,@plist)
,@defun-forms
',type)))
(defmacro evil-define-interactive-code (code &rest body)
"Define an interactive code.
PROMPT, if given, is the remainder of the interactive string
up to the next newline. Command properties may be specified
via KEY-VALUE pairs. BODY should evaluate to a list of values.
\(fn CODE (PROMPT) [[KEY VALUE]...] BODY...)"
(declare (indent defun))
(let* ((args (when (and (> (length body) 1)
(listp (car-safe body)))
(pop body)))
(doc (when (stringp (car-safe body)) (pop body)))
func properties)
(while (keywordp (car-safe body))
(setq properties
(append properties (list (pop body) (pop body)))))
(cond
(args
(setq func `(lambda ,args
,@(when doc `(,doc))
,@body)))
((> (length body) 1)
(setq func `(progn ,@body)))
(t
(setq func (car body))))
`(eval-and-compile
(let* ((code ,code)
(entry (assoc code evil-interactive-alist))
(value (cons ',func ',properties)))
(if entry
(setcdr entry value)
(push (cons code value) evil-interactive-alist))
code))))
;;; Highlighting
(when (fboundp 'font-lock-add-keywords)
(font-lock-add-keywords
'emacs-lisp-mode
;; Match all `evil-define-' forms except `evil-define-key'.
;; (In the interests of speed, this expression is incomplete
;; and does not match all three-letter words.)
'(("(\\(evil-\\(?:ex-\\)?define-\
\\(?:[^ k][^ e][^ y]\\|[-[:word:]]\\{4,\\}\\)\\)\
\\>[ \f\t\n\r\v]*\\(\\sw+\\)?"
(1 font-lock-keyword-face)
(2 font-lock-function-name-face nil t))
("(\\(evil-\\(?:delay\\|narrow\\|signal\\|save\\|with\\(?:out\\)?\\)\
\\(?:-[-[:word:]]+\\)?\\)\\>\[ \f\t\n\r\v]+"
1 font-lock-keyword-face)
("(\\(evil-\\(?:[-[:word:]]\\)*loop\\)\\>[ \f\t\n\r\v]+"
1 font-lock-keyword-face))))
(provide 'evil-macros)
;;; evil-macros.el ends here

View File

@ -0,0 +1,464 @@
;;; evil-maps.el --- Default keymaps
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.0.1
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
(require 'evil-states)
(require 'evil-ex)
;;; Code:
;;; Normal state
(define-key evil-normal-state-map "a" 'evil-append)
(define-key evil-normal-state-map "A" 'evil-append-line)
(define-key evil-normal-state-map "c" 'evil-change)
(define-key evil-normal-state-map "C" 'evil-change-line)
(define-key evil-normal-state-map "d" 'evil-delete)
(define-key evil-normal-state-map "D" 'evil-delete-line)
(define-key evil-normal-state-map "i" 'evil-insert)
(define-key evil-normal-state-map "I" 'evil-insert-line)
(define-key evil-normal-state-map "J" 'evil-join)
(define-key evil-normal-state-map "m" 'evil-set-marker)
(define-key evil-normal-state-map "o" 'evil-open-below)
(define-key evil-normal-state-map "O" 'evil-open-above)
(define-key evil-normal-state-map "p" 'evil-paste-after)
(define-key evil-normal-state-map "P" 'evil-paste-before)
(define-key evil-normal-state-map "q" 'evil-record-macro)
(define-key evil-normal-state-map "r" 'evil-replace)
(define-key evil-normal-state-map "R" 'evil-replace-state)
(define-key evil-normal-state-map "s" 'evil-substitute)
(define-key evil-normal-state-map "S" 'evil-change-whole-line)
(define-key evil-normal-state-map "x" 'evil-delete-char)
(define-key evil-normal-state-map "X" 'evil-delete-backward-char)
(define-key evil-normal-state-map "y" 'evil-yank)
(define-key evil-normal-state-map "Y" 'evil-yank-line)
(define-key evil-normal-state-map "&" 'evil-ex-repeat-substitute)
(define-key evil-normal-state-map "g&" 'evil-ex-repeat-global-substitute)
(define-key evil-normal-state-map "g8" 'what-cursor-position)
(define-key evil-normal-state-map "ga" 'what-cursor-position)
(define-key evil-normal-state-map "gi" 'evil-insert-resume)
(define-key evil-normal-state-map "gJ" 'evil-join-whitespace)
(define-key evil-normal-state-map "gq" 'evil-fill-and-move)
(define-key evil-normal-state-map "gw" 'evil-fill)
(define-key evil-normal-state-map "gu" 'evil-downcase)
(define-key evil-normal-state-map "gU" 'evil-upcase)
(define-key evil-normal-state-map "gf" 'find-file-at-point)
(define-key evil-normal-state-map "gF" 'evil-find-file-at-point-with-line)
(define-key evil-normal-state-map "g?" 'evil-rot13)
(define-key evil-normal-state-map "g~" 'evil-invert-case)
(define-key evil-normal-state-map "zo" 'evil-open-fold)
(define-key evil-normal-state-map "zc" 'evil-close-fold)
(define-key evil-normal-state-map "za" 'evil-toggle-fold)
(define-key evil-normal-state-map "zr" 'evil-open-folds)
(define-key evil-normal-state-map "zm" 'evil-close-folds)
(define-key evil-normal-state-map "\C-n" 'evil-paste-pop-next)
(define-key evil-normal-state-map "\C-p" 'evil-paste-pop)
(define-key evil-normal-state-map "\C-t" 'pop-tag-mark)
(define-key evil-normal-state-map (kbd "C-.") 'evil-repeat-pop)
(define-key evil-normal-state-map (kbd "M-.") 'evil-repeat-pop-next)
(define-key evil-normal-state-map "." 'evil-repeat)
(define-key evil-normal-state-map "@" 'evil-execute-macro)
(define-key evil-normal-state-map "\"" 'evil-use-register)
(define-key evil-normal-state-map "~" 'evil-invert-char)
(define-key evil-normal-state-map "=" 'evil-indent)
(define-key evil-normal-state-map "<" 'evil-shift-left)
(define-key evil-normal-state-map ">" 'evil-shift-right)
(define-key evil-normal-state-map "ZZ" 'evil-save-modified-and-close)
(define-key evil-normal-state-map "ZQ" 'evil-quit)
(define-key evil-normal-state-map (kbd "DEL") 'evil-backward-char)
(define-key evil-normal-state-map [escape] 'evil-force-normal-state)
(define-key evil-normal-state-map [remap cua-paste-pop] 'evil-paste-pop)
(define-key evil-normal-state-map [remap yank-pop] 'evil-paste-pop)
;; go to last change
(define-key evil-normal-state-map "g;" 'goto-last-change)
(define-key evil-normal-state-map "g," 'goto-last-change-reverse)
;; undo
(define-key evil-normal-state-map "u" 'undo)
(when (fboundp 'undo-tree-undo)
(define-key evil-normal-state-map "u" 'undo-tree-undo)
(define-key evil-normal-state-map "\C-r" 'undo-tree-redo))
;; window commands
(define-prefix-command 'evil-window-map)
(define-key evil-window-map "b" 'evil-window-bottom-right)
(define-key evil-window-map "c" 'delete-window)
(define-key evil-window-map "h" 'evil-window-left)
(define-key evil-window-map "H" 'evil-window-move-far-left)
(define-key evil-window-map "j" 'evil-window-down)
(define-key evil-window-map "J" 'evil-window-move-very-bottom)
(define-key evil-window-map "k" 'evil-window-up)
(define-key evil-window-map "K" 'evil-window-move-very-top)
(define-key evil-window-map "l" 'evil-window-right)
(define-key evil-window-map "L" 'evil-window-move-far-right)
(define-key evil-window-map "n" 'evil-window-new)
(define-key evil-window-map "o" 'delete-other-windows)
(define-key evil-window-map "p" 'evil-window-mru)
(define-key evil-window-map "r" 'evil-window-rotate-downwards)
(define-key evil-window-map "R" 'evil-window-rotate-upwards)
(define-key evil-window-map "s" 'split-window-vertically)
(define-key evil-window-map "S" 'split-window-vertically)
(define-key evil-window-map "t" 'evil-window-top-left)
(define-key evil-window-map "v" 'split-window-horizontally)
(define-key evil-window-map "w" 'evil-window-next)
(define-key evil-window-map "W" 'evil-window-prev)
(define-key evil-window-map "+" 'evil-window-increase-height)
(define-key evil-window-map "-" 'evil-window-decrease-height)
(define-key evil-window-map "_" 'evil-window-set-height)
(define-key evil-window-map "<" 'evil-window-decrease-width)
(define-key evil-window-map ">" 'evil-window-increase-width)
(define-key evil-window-map "=" 'balance-windows)
(define-key evil-window-map "|" 'evil-window-set-width)
(define-key evil-window-map "\C-b" 'evil-window-bottom-right)
(define-key evil-window-map "\C-c" 'delete-window)
(define-key evil-window-map "\C-H" 'evil-window-move-far-left)
(define-key evil-window-map "\C-h" 'evil-window-left)
(define-key evil-window-map "\C-J" 'evil-window-move-very-bottom)
(define-key evil-window-map "\C-j" 'evil-window-down)
(define-key evil-window-map "\C-K" 'evil-window-move-very-top)
(define-key evil-window-map "\C-k" 'evil-window-up)
(define-key evil-window-map "\C-L" 'evil-window-move-far-right)
(define-key evil-window-map "\C-l" 'evil-window-right)
(define-key evil-window-map "\C-n" 'evil-window-new)
(define-key evil-window-map "\C-o" 'delete-other-windows)
(define-key evil-window-map "\C-p" 'evil-window-mru)
(define-key evil-window-map "\C-r" 'evil-window-rotate-downwards)
(define-key evil-window-map "\C-R" 'evil-window-rotate-upwards)
(define-key evil-window-map "\C-s" 'split-window-vertically)
(define-key evil-window-map "\C-S" 'split-window-vertically)
(define-key evil-window-map "\C-t" 'evil-window-top-left)
(define-key evil-window-map "\C-v" 'split-window-horizontally)
(define-key evil-window-map "\C-w" 'evil-window-next)
(define-key evil-window-map "\C-W" 'evil-window-prev)
(define-key evil-window-map "\C-_" 'evil-window-set-height)
(define-key evil-window-map "\C-f" 'ffap-other-window)
;;; Motion state
;; "0" is a special command when called first
(evil-redirect-digit-argument evil-motion-state-map "0" 'evil-beginning-of-line)
(define-key evil-motion-state-map "1" 'digit-argument)
(define-key evil-motion-state-map "2" 'digit-argument)
(define-key evil-motion-state-map "3" 'digit-argument)
(define-key evil-motion-state-map "4" 'digit-argument)
(define-key evil-motion-state-map "5" 'digit-argument)
(define-key evil-motion-state-map "6" 'digit-argument)
(define-key evil-motion-state-map "7" 'digit-argument)
(define-key evil-motion-state-map "8" 'digit-argument)
(define-key evil-motion-state-map "9" 'digit-argument)
(define-key evil-motion-state-map "b" 'evil-backward-word-begin)
(define-key evil-motion-state-map "B" 'evil-backward-WORD-begin)
(define-key evil-motion-state-map "e" 'evil-forward-word-end)
(define-key evil-motion-state-map "E" 'evil-forward-WORD-end)
(define-key evil-motion-state-map "f" 'evil-find-char)
(define-key evil-motion-state-map "F" 'evil-find-char-backward)
(define-key evil-motion-state-map "G" 'evil-goto-line)
(define-key evil-motion-state-map "h" 'evil-backward-char)
(define-key evil-motion-state-map "H" 'evil-window-top)
(define-key evil-motion-state-map "j" 'evil-next-line)
(define-key evil-motion-state-map "k" 'evil-previous-line)
(define-key evil-motion-state-map "l" 'evil-forward-char)
(define-key evil-motion-state-map " " 'evil-forward-char)
(define-key evil-motion-state-map "K" 'evil-lookup)
(define-key evil-motion-state-map "L" 'evil-window-bottom)
(define-key evil-motion-state-map "M" 'evil-window-middle)
(define-key evil-motion-state-map "n" 'evil-search-next)
(define-key evil-motion-state-map "N" 'evil-search-previous)
(define-key evil-motion-state-map "t" 'evil-find-char-to)
(define-key evil-motion-state-map "T" 'evil-find-char-to-backward)
(define-key evil-motion-state-map "w" 'evil-forward-word-begin)
(define-key evil-motion-state-map "W" 'evil-forward-WORD-begin)
(define-key evil-motion-state-map "gd" 'evil-goto-definition)
(define-key evil-motion-state-map "ge" 'evil-backward-word-end)
(define-key evil-motion-state-map "gE" 'evil-backward-WORD-end)
(define-key evil-motion-state-map "gg" 'evil-goto-first-line)
(define-key evil-motion-state-map "gj" 'evil-next-visual-line)
(define-key evil-motion-state-map "gk" 'evil-previous-visual-line)
(define-key evil-motion-state-map "g0" 'evil-beginning-of-visual-line)
(define-key evil-motion-state-map "g_" 'evil-last-non-blank)
(define-key evil-motion-state-map "g^" 'evil-first-non-blank-of-visual-line)
(define-key evil-motion-state-map "g$" 'evil-end-of-visual-line)
(define-key evil-motion-state-map "g\C-]" 'find-tag)
(define-key evil-motion-state-map "{" 'evil-backward-paragraph)
(define-key evil-motion-state-map "}" 'evil-forward-paragraph)
(define-key evil-motion-state-map "#" 'evil-search-symbol-backward)
(define-key evil-motion-state-map "$" 'evil-end-of-line)
(define-key evil-motion-state-map "%" 'evil-jump-item)
(define-key evil-motion-state-map "`" 'evil-goto-mark)
(define-key evil-motion-state-map "'" 'evil-goto-mark-line)
(define-key evil-motion-state-map "(" 'evil-backward-sentence)
(define-key evil-motion-state-map ")" 'evil-forward-sentence)
(define-key evil-motion-state-map "]]" 'evil-forward-section-begin)
(define-key evil-motion-state-map "][" 'evil-forward-section-end)
(define-key evil-motion-state-map "[[" 'evil-backward-section-begin)
(define-key evil-motion-state-map "[]" 'evil-backward-section-end)
(define-key evil-motion-state-map "[(" 'evil-previous-open-paren)
(define-key evil-motion-state-map "])" 'evil-next-close-paren)
(define-key evil-motion-state-map "[{" 'evil-previous-open-brace)
(define-key evil-motion-state-map "]}" 'evil-next-close-brace)
(define-key evil-motion-state-map "*" 'evil-search-symbol-forward)
(define-key evil-motion-state-map "," 'evil-repeat-find-char-reverse)
(define-key evil-motion-state-map "/" 'evil-search-forward)
(define-key evil-motion-state-map ";" 'evil-repeat-find-char)
(define-key evil-motion-state-map "?" 'evil-search-backward)
(define-key evil-motion-state-map "|" 'evil-goto-column)
(define-key evil-motion-state-map "^" 'evil-first-non-blank)
(define-key evil-motion-state-map "+" 'evil-next-line-first-non-blank)
(define-key evil-motion-state-map "_" 'evil-next-line-1-first-non-blank)
(define-key evil-motion-state-map "-" 'evil-previous-line-first-non-blank)
(define-key evil-motion-state-map "\C-w" 'evil-window-map)
(define-key evil-motion-state-map "\C-]" 'evil-jump-to-tag)
(define-key evil-motion-state-map (kbd "C-b") 'evil-scroll-page-up)
(define-key evil-motion-state-map (kbd "C-d") 'evil-scroll-down)
(define-key evil-motion-state-map (kbd "C-e") 'evil-scroll-line-down)
(define-key evil-motion-state-map (kbd "C-f") 'evil-scroll-page-down)
(define-key evil-motion-state-map (kbd "C-o") 'evil-jump-backward)
(define-key evil-motion-state-map (kbd "C-y") 'evil-scroll-line-up)
(define-key evil-motion-state-map (kbd "RET") 'evil-ret)
(define-key evil-motion-state-map "\\" 'evil-execute-in-emacs-state)
(define-key evil-motion-state-map "z^" 'evil-scroll-top-line-to-bottom)
(define-key evil-motion-state-map "z+" 'evil-scroll-bottom-line-to-top)
(define-key evil-motion-state-map "zt" 'evil-scroll-line-to-top)
;; TODO: z RET has an advanced form taking an count before the RET
;; but this requires again a special state with a single command
;; bound to RET
(define-key evil-motion-state-map (vconcat "z" [return]) "zt^")
(define-key evil-motion-state-map (kbd "z RET") (vconcat "z" [return]))
(define-key evil-motion-state-map "zz" 'evil-scroll-line-to-center)
(define-key evil-motion-state-map "z." "zz^")
(define-key evil-motion-state-map "zb" 'evil-scroll-line-to-bottom)
(define-key evil-motion-state-map "z-" "zb^")
(define-key evil-motion-state-map "v" 'evil-visual-char)
(define-key evil-motion-state-map "V" 'evil-visual-line)
(define-key evil-motion-state-map "\C-v" 'evil-visual-block)
(define-key evil-motion-state-map "gv" 'evil-visual-restore)
(define-key evil-motion-state-map (kbd "C-^") 'evil-buffer)
(define-key evil-motion-state-map [left] 'evil-backward-char)
(define-key evil-motion-state-map [right] 'evil-forward-char)
(define-key evil-motion-state-map [up] 'evil-previous-line)
(define-key evil-motion-state-map [down] 'evil-next-line)
(define-key evil-motion-state-map
(read-kbd-macro evil-toggle-key) 'evil-emacs-state)
;; text objects
(define-key evil-outer-text-objects-map "w" 'evil-a-word)
(define-key evil-outer-text-objects-map "W" 'evil-a-WORD)
(define-key evil-outer-text-objects-map "s" 'evil-a-sentence)
(define-key evil-outer-text-objects-map "p" 'evil-a-paragraph)
(define-key evil-outer-text-objects-map "b" 'evil-a-paren)
(define-key evil-outer-text-objects-map "(" 'evil-a-paren)
(define-key evil-outer-text-objects-map ")" 'evil-a-paren)
(define-key evil-outer-text-objects-map "[" 'evil-a-bracket)
(define-key evil-outer-text-objects-map "]" 'evil-a-bracket)
(define-key evil-outer-text-objects-map "B" 'evil-a-curly)
(define-key evil-outer-text-objects-map "{" 'evil-a-curly)
(define-key evil-outer-text-objects-map "}" 'evil-a-curly)
(define-key evil-outer-text-objects-map "<" 'evil-an-angle)
(define-key evil-outer-text-objects-map ">" 'evil-an-angle)
(define-key evil-outer-text-objects-map "'" 'evil-a-single-quote)
(define-key evil-outer-text-objects-map "\"" 'evil-a-double-quote)
(define-key evil-outer-text-objects-map "`" 'evil-a-back-quote)
(define-key evil-outer-text-objects-map "t" 'evil-a-tag)
(define-key evil-outer-text-objects-map "o" 'evil-a-symbol)
(define-key evil-inner-text-objects-map "w" 'evil-inner-word)
(define-key evil-inner-text-objects-map "W" 'evil-inner-WORD)
(define-key evil-inner-text-objects-map "s" 'evil-inner-sentence)
(define-key evil-inner-text-objects-map "p" 'evil-inner-paragraph)
(define-key evil-inner-text-objects-map "b" 'evil-inner-paren)
(define-key evil-inner-text-objects-map "(" 'evil-inner-paren)
(define-key evil-inner-text-objects-map ")" 'evil-inner-paren)
(define-key evil-inner-text-objects-map "[" 'evil-inner-bracket)
(define-key evil-inner-text-objects-map "]" 'evil-inner-bracket)
(define-key evil-inner-text-objects-map "B" 'evil-inner-curly)
(define-key evil-inner-text-objects-map "{" 'evil-inner-curly)
(define-key evil-inner-text-objects-map "}" 'evil-inner-curly)
(define-key evil-inner-text-objects-map "<" 'evil-inner-angle)
(define-key evil-inner-text-objects-map ">" 'evil-inner-angle)
(define-key evil-inner-text-objects-map "'" 'evil-inner-single-quote)
(define-key evil-inner-text-objects-map "\"" 'evil-inner-double-quote)
(define-key evil-inner-text-objects-map "`" 'evil-inner-back-quote)
(define-key evil-inner-text-objects-map "t" 'evil-inner-tag)
(define-key evil-inner-text-objects-map "o" 'evil-inner-symbol)
(when evil-want-C-i-jump
(define-key evil-motion-state-map (kbd "C-i") 'evil-jump-forward))
(when evil-want-C-u-scroll
(define-key evil-motion-state-map (kbd "C-u") 'evil-scroll-up))
;;; Visual state
(define-key evil-visual-state-map "A" 'evil-append)
(define-key evil-visual-state-map "I" 'evil-insert)
(define-key evil-visual-state-map "o" 'exchange-point-and-mark)
(define-key evil-visual-state-map "O" 'evil-visual-exchange-corners)
(define-key evil-visual-state-map "R" 'evil-change)
(define-key evil-visual-state-map "u" 'evil-downcase)
(define-key evil-visual-state-map "U" 'evil-upcase)
(define-key evil-visual-state-map "a" evil-outer-text-objects-map)
(define-key evil-visual-state-map "i" evil-inner-text-objects-map)
(define-key evil-visual-state-map [remap evil-repeat] 'undefined)
(define-key evil-visual-state-map [escape] 'evil-exit-visual-state)
;;; Operator-Pending state
(define-key evil-operator-state-map "a" evil-outer-text-objects-map)
(define-key evil-operator-state-map "i" evil-inner-text-objects-map)
;; (define-key evil-operator-state-map [escape] 'keyboard-quit)
;;; Insert state
(define-key evil-insert-state-map "\C-k" 'evil-insert-digraph)
(define-key evil-insert-state-map "\C-o" 'evil-execute-in-normal-state)
(define-key evil-insert-state-map "\C-r" 'evil-paste-from-register)
(define-key evil-insert-state-map "\C-y" 'evil-copy-from-above)
(define-key evil-insert-state-map "\C-e" 'evil-copy-from-below)
(define-key evil-insert-state-map "\C-n" 'evil-complete-next)
(define-key evil-insert-state-map "\C-p" 'evil-complete-previous)
(define-key evil-insert-state-map "\C-x\C-n" 'evil-complete-next-line)
(define-key evil-insert-state-map "\C-x\C-p" 'evil-complete-previous-line)
(define-key evil-insert-state-map [remap newline] 'evil-ret)
(define-key evil-insert-state-map [remap newline-and-indent] 'evil-ret)
(define-key evil-insert-state-map [escape] 'evil-normal-state)
(define-key evil-insert-state-map
(read-kbd-macro evil-toggle-key) 'evil-emacs-state)
(if evil-want-C-w-delete
(define-key evil-insert-state-map "\C-w" 'evil-delete-backward-word)
(define-key evil-insert-state-map "\C-w" 'evil-window-map))
;;; Replace state
(define-key evil-replace-state-map (kbd "DEL") 'evil-replace-backspace)
(define-key evil-replace-state-map [escape] 'evil-normal-state)
;;; Emacs state
(define-key evil-emacs-state-map
(read-kbd-macro evil-toggle-key) 'evil-exit-emacs-state)
(when evil-want-C-w-in-emacs-state
(define-key evil-emacs-state-map "\C-w" 'evil-window-map))
;;; Minibuffer
(define-key minibuffer-local-map "\C-p" 'evil-complete-next)
(define-key minibuffer-local-map "\C-n" 'evil-complete-previous)
(define-key minibuffer-local-map "\C-x\C-p" 'evil-complete-next-line)
(define-key minibuffer-local-map "\C-x\C-n" 'evil-complete-previous-line)
;;; Mouse
(define-key evil-motion-state-map [down-mouse-1] 'evil-mouse-drag-region)
(define-key evil-visual-state-map [mouse-2] 'evil-exit-visual-and-repeat)
(define-key evil-normal-state-map [mouse-2] 'mouse-yank-primary)
(define-key evil-insert-state-map [mouse-2] 'mouse-yank-primary)
;; Ex
(define-key evil-motion-state-map ":" 'evil-ex)
(evil-ex-define-cmd "e[dit]" 'evil-edit)
(evil-ex-define-cmd "w[rite]" 'evil-write)
(evil-ex-define-cmd "wa[ll]" 'evil-write-all)
(evil-ex-define-cmd "sav[eas]" 'evil-save)
(evil-ex-define-cmd "r[ead]" 'evil-read)
(evil-ex-define-cmd "b[uffer]" 'evil-buffer)
(evil-ex-define-cmd "bn[ext]" 'evil-next-buffer)
(evil-ex-define-cmd "bp[revious]" 'evil-prev-buffer)
(evil-ex-define-cmd "bN[ext]" "bprevious")
(evil-ex-define-cmd "sb[uffer]" 'evil-split-buffer)
(evil-ex-define-cmd "sbn[ext]" 'evil-split-next-buffer)
(evil-ex-define-cmd "sbp[revious]" 'evil-split-prev-buffer)
(evil-ex-define-cmd "sbN[ext]" "sbprevious")
(evil-ex-define-cmd "buffers" 'evil-show-buffers)
(evil-ex-define-cmd "files" "buffers")
(evil-ex-define-cmd "ls" "buffers")
(evil-ex-define-cmd "c[hange]" 'evil-change)
(evil-ex-define-cmd "d[elete]" 'evil-delete)
(evil-ex-define-cmd "go[to]" 'evil-goto-char)
(evil-ex-define-cmd "j[oin]" 'evil-join)
(evil-ex-define-cmd "le[ft]" 'evil-align-left)
(evil-ex-define-cmd "ri[ght]" 'evil-align-right)
(evil-ex-define-cmd "ce[nter]" 'evil-align-center)
(evil-ex-define-cmd "sp[lit]" 'evil-window-split)
(evil-ex-define-cmd "vs[plit]" 'evil-window-vsplit)
(evil-ex-define-cmd "new" 'evil-window-new)
(evil-ex-define-cmd "vne[w]" 'evil-window-vnew)
(evil-ex-define-cmd "clo[se]" 'delete-window)
(evil-ex-define-cmd "on[ly]" 'delete-other-windows)
(evil-ex-define-cmd "q[uit]" 'evil-quit)
(evil-ex-define-cmd "wq" 'evil-save-and-close)
(evil-ex-define-cmd "quita[ll]" 'evil-quit-all)
(evil-ex-define-cmd "qa[ll]" "quitall")
(evil-ex-define-cmd "wqa[ll]" 'evil-save-and-quit)
(evil-ex-define-cmd "xa[ll]" "wqall")
(evil-ex-define-cmd "x[it]" 'evil-save-modified-and-close)
(evil-ex-define-cmd "exi[t]" 'evil-save-modified-and-close)
(evil-ex-define-cmd "bd[elete]" 'evil-delete-buffer)
(evil-ex-define-cmd "g[lobal]" 'evil-ex-global)
(evil-ex-define-cmd "v[global]" 'evil-ex-global-inverted)
(evil-ex-define-cmd "s[ubstitute]" 'evil-ex-substitute)
(evil-ex-define-cmd "&" 'evil-ex-repeat-substitute)
(evil-ex-define-cmd "&&" 'evil-ex-repeat-substitute-with-flags)
(evil-ex-define-cmd "~" 'evil-ex-repeat-substitute-with-search)
(evil-ex-define-cmd "~&" 'evil-ex-repeat-substitute-with-search-and-flags)
(evil-ex-define-cmd "registers" 'evil-show-registers)
(evil-ex-define-cmd "marks" 'evil-show-marks)
(evil-ex-define-cmd "ju[mps]" 'evil-show-jumps)
(evil-ex-define-cmd "noh[lsearch]" 'evil-ex-nohighlight)
(evil-ex-define-cmd "f[ile]" 'evil-show-file-info)
(evil-ex-define-cmd "<" 'evil-shift-left)
(evil-ex-define-cmd ">" 'evil-shift-right)
(evil-ex-define-cmd "=" 'evil-ex-line-number)
(evil-ex-define-cmd "!" 'evil-shell-command)
(evil-ex-define-cmd "@:" 'evil-ex-repeat)
(evil-ex-define-cmd "set-initial-state" 'evil-ex-set-initial-state)
(when (fboundp 'undo-tree-visualize)
(evil-ex-define-cmd "undol[ist]" 'undo-tree-visualize)
(evil-ex-define-cmd "ul" 'undo-tree-visualize))
;; completion
(define-key evil-ex-search-keymap "\d" #'evil-ex-delete-backward-char)
(define-key evil-ex-completion-map "\d" #'evil-ex-delete-backward-char)
(define-key evil-ex-completion-map "\t" #'evil-ex-run-completion-at-point)
(define-key evil-ex-completion-map [tab] #'evil-ex-run-completion-at-point)
(define-key evil-ex-completion-map "\C-p" #'evil-ex-run-completion-at-point)
(define-key evil-ex-completion-map "\C-n" #'evil-ex-run-completion-at-point)
(define-key evil-ex-completion-map "?" nil)
;; evil-read-key
(define-key evil-read-key-map (kbd "ESC") #'keyboard-quit)
(define-key evil-read-key-map (kbd "C-]") #'keyboard-quit)
(define-key evil-read-key-map (kbd "C-q") #'evil-read-quoted-char)
(define-key evil-read-key-map (kbd "C-v") #'evil-read-quoted-char)
(define-key evil-read-key-map "\r" "\n")
(provide 'evil-maps)
;;; evil-maps.el ends here

View File

@ -0,0 +1,5 @@
(define-package
"evil"
"1.0.1"
"Extensible Vi layer for Emacs."
'((undo-tree "0.5.1")))

View File

@ -0,0 +1,607 @@
;;; evil-repeat.el --- Repeat system
;; Author: Frank Fischer <frank.fischer at mathematik.tu-chemnitz.de>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.0.1
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; A repeat begins when leaving Normal state; it ends when re-entering
;; Normal state. The diagram below shows possible routes between
;; Normal state (N), Insert state (I), Visual state (V),
;; Operator-Pending state (O) and Replace state (R). (Emacs state
;; is an exception: nothing is repeated in that state.)
;; ___
;; / \
;; | R |
;; \___/
;; ^ |
;; | |
;; ___ |___V ___
;; / \ <------- / \ -------> / \
;; | V | | N | | O |
;; \___/ -------> \___/ <------- \___/
;; | | ^ |
;; | | | |
;; | V___| |
;; | / \ |
;; +--------> | I | <--------+
;; \___/
;;
;; The recording of a repeat is started in one of two cases: Either a
;; command is about being executed (in pre-command-hook) or normal
;; state is exited. The recording is stopped whenever a command has
;; being completed and evil is in normal state afterwards. Therefore,
;; a non-inserting command in normal-state is recorded as a single
;; repeat unit. In contrast, if the command leaves normal state and
;; starts insert-state, all commands that are executed until
;; insert-state is left and normal state is reactivated are recorded
;; together in one repeat unit. In other words, a repeat unit consists
;; of all commands that are executed starting and ending in normal
;; state.
;;
;; Not all commands are recored. There are several commands that are
;; completely ignored and other commands that even abort the currently
;; active recording, e.g., commands that change the current buffer.
;;
;; During recording the repeat information is appended to the variable
;; `evil-repeat-info', which is cleared when the recording
;; starts. This accumulated repeat information is put into the
;; `evil-repeat-ring' when the recording is finished. The dot command,
;; `\[evil-repeat]' (`evil-repeat') replays the most recent entry in
;; the ring, preceeding repeats can be replayed using
;; `\[evil-repeat-pop]' (`evil-repeat-pop').
;;
;; Repeat information can be stored in almost arbitrary form. How the
;; repeat information for each single command is recored is determined
;; by the :repeat property of the command. This property has the
;; following interpretation:
;;
;; t record commands by storing the key-sequence that invoked it
;; nil ignore this command completely
;; ignore synonym to nil
;; motion command is recorded by storing the key-sequence but only in
;; insert state, otherwise it is ignored.
;; abort stop recording of repeat information immediately
;; change record commands by storing buffer changes
;; SYMBOL if SYMBOL is contained as key in `evil-repeat-types'
;; call the corresponding (function-)value, otherwise
;; call the function associated with SYMBOL. In both
;; cases the function should take exactly one argument
;; which is either 'pre or 'post depending on whether
;; the function is called before or after the execution
;; of the command.
;;
;; Therefore, using a certain SYMBOL one can write specific repeation
;; functions for each command.
;;
;; Each value of ring `evil-repeat-info', i.e., each single repeat
;; information must be one of the following two possibilities:
;; If element is a sequence, it is regarded as a key-sequence to
;; be repeated. Otherwise the element must be a list
;; (FUNCTION PARAMS ...) which will be called using
;; (apply FUNCTION PARAMS) whenever this repeat is being executed.
;;
;; A user supplied repeat function can use the functions
;; `evil-record-repeat' to append further repeat-information of the
;; form described above to `evil-repeat-info'. See the implementation
;; of `evil-repeat-keystrokes' and `evil-repeat-changes' for examples.
;; Those functions are called in different situations before and after
;; the execution of a command. Each function should take one argument
;; which can be either 'pre, 'post, 'pre-operator or 'post-operator
;; specifying when the repeat function has been called. If the command
;; is a usual command the function is called with 'pre before the
;; command is executed and with 'post after the command has been
;; executed.
;;
;; The repeat information is executed with `evil-execute-repeat-info',
;; which passes key-sequence elements to `execute-kbd-macro' and
;; executes other elements as defined above. A special version is
;; `evil-execute-repeat-info-with-count'. This function works as
;; `evil-execute-repeat-info', but replaces the count of the first
;; command. This is done by parsing the key-sequence, ignoring all
;; calls to `digit-prefix-argument' and `negative-argument', and
;; prepending the count as a string to the vector of the remaining
;; key-sequence.
(require 'evil-states)
;;; Code:
(declare-function evil-visual-state-p "evil-visual")
(declare-function evil-visual-range "evil-visual")
(declare-function evil-visual-char "evil-visual")
(declare-function evil-visual-line "evil-visual")
(declare-function evil-visual-block "evil-visual")
(defsubst evil-repeat-recording-p ()
"Returns non-nil iff a recording is in progress."
(eq evil-recording-repeat t))
(defun evil-repeat-start ()
"Start recording a new repeat into `evil-repeat-info'."
(evil-repeat-reset t)
(evil-repeat-record-buffer)
(when (evil-visual-state-p)
(let* ((range (evil-visual-range))
(beg (evil-range-beginning range))
(end (1- (evil-range-end range)))
(nfwdlines (- (line-number-at-pos end)
(line-number-at-pos beg))))
(evil-repeat-record
(cond
((eq evil-visual-selection 'char)
(list #'evil-repeat-visual-char
nfwdlines
(- end
(if (zerop nfwdlines)
beg
(save-excursion
(goto-char end)
(line-beginning-position))))))
((eq evil-visual-selection 'line)
(list #'evil-repeat-visual-line nfwdlines))
((eq evil-visual-selection 'block)
(list #'evil-repeat-visual-block
nfwdlines
(abs (- (evil-column beg) (evil-column end))))))))))
(defun evil-repeat-stop ()
"Stop recording a repeat.
Update `evil-repeat-ring' with the accumulated changes
in `evil-repeat-info' and clear variables."
(unwind-protect
(when (evil-repeat-recording-p)
(setq evil-repeat-info
(evil-normalize-repeat-info evil-repeat-info))
(when (and evil-repeat-info evil-repeat-ring)
(ring-insert evil-repeat-ring evil-repeat-info)))
(evil-repeat-reset nil)))
(defun evil-repeat-abort ()
"Abort current repeation."
(evil-repeat-reset 'abort))
(defun evil-repeat-reset (flag)
"Clear all repeat recording variables.
Set `evil-recording-repeat' to FLAG."
(setq evil-recording-repeat flag
evil-repeat-info nil
evil-repeat-buffer nil))
(defsubst evil-repeat-record-position (&optional pos)
"Set `evil-repeat-pos' to POS or point."
(setq evil-repeat-pos (or pos (point))))
(defun evil-repeat-record-buffer ()
"Set `evil-repeat-buffer' to the current buffer."
(unless (minibufferp)
(setq evil-repeat-buffer (current-buffer))))
(defmacro evil-save-repeat-info (&rest body)
"Execute BODY, protecting the values of repeat variables."
(declare (indent defun)
(debug t))
`(let (evil-repeat-ring
evil-recording-repeat
evil-recording-current-command
evil-repeat-info
evil-repeat-changes
evil-repeat-pos
evil-repeat-keys
evil-repeat-buffer
this-command
last-command)
,@body))
(defun evil-repeat-different-buffer-p (&optional strict)
"Whether the buffer has changed in a repeat.
If STRICT is non-nil, returns t if the previous buffer
is unknown; otherwise returns t only if the previous
buffer is known and different from the current buffer."
(and (or (buffer-live-p evil-repeat-buffer) strict)
(not (minibufferp))
(not (eq (current-buffer) evil-repeat-buffer))))
(defun evil-repeat-type (command &optional default)
"Return the :repeat property of COMMAND.
If COMMAND doesn't have this property, return DEFAULT."
(when (functionp command) ; ignore keyboard macros
(let* ((type (evil-get-command-property command :repeat default))
(repeat-type (assq type evil-repeat-types)))
(if repeat-type (cdr repeat-type) type))))
(defun evil-repeat-force-abort-p (repeat-type)
"Returns non-nil iff the current command should abort the recording of repeat information."
(or (evil-repeat-different-buffer-p) ; ... buffer changed
(eq repeat-type 'abort) ; ... explicitely forced
(eq evil-recording-repeat 'abort) ; ... already aborted
(evil-emacs-state-p) ; ... in Emacs state
(and (evil-mouse-events-p (this-command-keys)) ; ... mouse events
(eq repeat-type nil))
(minibufferp))) ; ... minibuffer activated
(defun evil-repeat-record (info)
"Add INFO to the end of `evil-repeat-info'."
(when (evil-repeat-recording-p)
(setq evil-repeat-info (nconc evil-repeat-info (list info)))))
;; called from `evil-normal-state-exit-hook'
(defun evil-repeat-start-hook ()
"Record a new repeat when exiting Normal state.
Does not record in Emacs state or if the current command
has :repeat nil."
(when (and (eq (evil-repeat-type this-command t) t)
(not (evil-emacs-state-p)))
(evil-repeat-start)))
;; called from `pre-command-hook'
(defun evil-repeat-pre-hook ()
"Prepare the current command for recording the repeation."
(when evil-local-mode
(let ((repeat-type (evil-repeat-type this-command t)))
(cond
;; abort the repeat
((evil-repeat-force-abort-p repeat-type)
;; We mark the current record as being aborted, because there
;; may be further pre-hooks following before the post-hook is
;; called.
(evil-repeat-abort))
;; ignore those commands completely
((null repeat-type))
;; record command
(t
;; In normal-state or visual state, each command is a single
;; repeation, therefore start a new repeation.
(when (or (evil-normal-state-p)
(evil-visual-state-p))
(evil-repeat-start))
(setq evil-recording-current-command t)
(funcall repeat-type 'pre))))))
(put 'evil-repeat-pre-hook 'permanent-local-hook t)
;; called from `post-command-hook'
(defun evil-repeat-post-hook ()
"Finish recording of repeat-information for the current-command."
(when (and evil-local-mode evil-recording-repeat)
(let ((repeat-type (evil-repeat-type this-command t)))
(cond
;; abort the repeat
((evil-repeat-force-abort-p repeat-type)
;; The command has been aborted but is complete, so just reset
;; the recording state.
(evil-repeat-reset nil))
;; ignore if command should not be recorded or the current
;; command is not being recorded
((or (null repeat-type)
(not evil-recording-current-command)))
;; record command
(t
(funcall repeat-type 'post)
;; In normal state, the repeat sequence is complete, so record it.
(when (evil-normal-state-p)
(evil-repeat-stop)))))
;; done with recording the current command
(setq evil-recording-current-command nil)))
(put 'evil-repeat-post-hook 'permanent-local-hook t)
(defun evil-clear-command-keys ()
"Clear `this-command-keys' and all information about the current command keys.
Calling this function prevents further recording of the keys that
invoked the current command"
(clear-this-command-keys t)
(setq evil-repeat-keys ""))
(defun evil-repeat-keystrokes (flag)
"Repeation recording function for commands that are repeated by keystrokes."
(cond
((eq flag 'pre)
(setq evil-repeat-keys (this-command-keys)))
((eq flag 'post)
(evil-repeat-record (if (zerop (length (this-command-keys)))
evil-repeat-keys
(this-command-keys)))
;; erase commands keys to prevent double recording
(evil-clear-command-keys))))
(defun evil-repeat-motion (flag)
"Repeation for motions. Motions are recorded by keystroke but only in insert state."
(when (memq evil-state '(insert replace))
(evil-repeat-keystrokes flag)))
(defun evil-repeat-changes (flag)
"Repeation recording function for commands that are repeated by buffer changes."
(cond
((eq flag 'pre)
(add-hook 'after-change-functions #'evil-repeat-change-hook nil t)
(evil-repeat-start-record-changes))
((eq flag 'post)
(remove-hook 'after-change-functions #'evil-repeat-change-hook t)
(evil-repeat-finish-record-changes))))
;; called from the `after-change-functions' hook
(defun evil-repeat-change-hook (beg end length)
"Record change information for current command."
(let ((repeat-type (evil-repeat-type this-command t)))
(when (and (evil-repeat-recording-p)
(eq repeat-type 'evil-repeat-changes)
(not (evil-emacs-state-p))
(not (evil-repeat-different-buffer-p t))
evil-state)
(unless (evil-repeat-recording-p)
(evil-repeat-start))
(evil-repeat-record-change (- beg evil-repeat-pos)
(buffer-substring beg end)
length))))
(put 'evil-repeat-change-hook 'permanent-local-hook t)
(defun evil-repeat-record-change (relpos ins ndel)
"Record the current buffer changes during a repeat.
If CHANGE is specified, it is added to `evil-repeat-changes'."
(when (evil-repeat-recording-p)
(setq evil-repeat-changes
(nconc evil-repeat-changes (list (list relpos ins ndel))))))
(defun evil-repeat-start-record-changes ()
"Starts the recording of a new set of buffer changes."
(setq evil-repeat-changes nil)
(evil-repeat-record-position))
(defun evil-repeat-finish-record-changes ()
"Finishes the recording of buffer changes and records them as repeat."
(when (evil-repeat-recording-p)
(evil-repeat-record `(evil-execute-change
,evil-repeat-changes
,(- (point) evil-repeat-pos)))
(setq evil-repeat-changes nil)))
(defun evil-repeat-insert-at-point (flag)
"Repeation recording function for commands that insert text in region.
This records text insertion when a command inserts some text in a
buffer between (point) and (mark)."
(cond
((eq flag 'pre)
(add-hook 'after-change-functions #'evil-repeat-insert-at-point-hook nil t))
((eq flag 'post)
(remove-hook 'after-change-functions #'evil-repeat-insert-at-point-hook t))))
(defun evil-repeat-insert-at-point-hook (beg end length)
(let ((repeat-type (evil-repeat-type this-command t)))
(when (and (evil-repeat-recording-p)
(eq repeat-type 'evil-repeat-insert-at-point)
(not (evil-emacs-state-p))
(not (evil-repeat-different-buffer-p t))
evil-state)
(setq evil-repeat-pos beg)
(evil-repeat-record (list 'insert (buffer-substring beg end))))))
(put 'evil-repeat-insert-at-point-hook 'permanent-local-hook t)
(defun evil-normalize-repeat-info (repeat-info)
"Concatenate consecutive arrays in REPEAT-INFO.
Returns a single array."
(let* ((result (cons nil nil))
(result-last result)
cur cur-last)
(dolist (rep repeat-info)
(cond
((null rep))
((arrayp rep)
(setq rep (listify-key-sequence rep))
(cond
(cur
(setcdr cur-last (cons rep nil))
(setq cur-last (cdr cur-last)))
(t
(setq cur (cons rep nil))
(setq cur-last cur))))
(t
(when cur
(setcdr result-last (cons (apply #'vconcat cur) nil))
(setq result-last (cdr result-last))
(setq cur nil))
(setcdr result-last (cons rep nil))
(setq result-last (cdr result-last)))))
(when cur
(setcdr result-last (cons (apply #'vconcat cur) nil)))
(cdr result)))
(defun evil-repeat-visual-char (nfwdlines nfwdchars)
"Restores a character visual selection.
If the selection is in a single line, the restored visual
selection covers the same number of characters. If the selection
covers several lines, the restored selection covers the same
number of lines and the same number of characters in the last
line as the original selection."
(evil-visual-char)
(when (> nfwdlines 0)
(forward-line nfwdlines))
(forward-char nfwdchars))
(defun evil-repeat-visual-line (nfwdlines)
"Restores a character visual selection.
If the selection is in a single line, the restored visual
selection covers the same number of characters. If the selection
covers several lines, the restored selection covers the same
number of lines and the same number of characters in the last
line as the original selection."
(evil-visual-line)
(forward-line nfwdlines))
(defun evil-repeat-visual-block (nfwdlines nfwdchars)
"Restores a character visual selection.
If the selection is in a single line, the restored visual
selection covers the same number of characters. If the selection
covers several lines, the restored selection covers the same
number of lines and the same number of characters in the last
line as the original selection."
(evil-visual-block)
(let ((col (current-column)))
(forward-line nfwdlines)
(move-to-column (+ col nfwdchars) t)))
(defun evil-execute-change (changes rel-point)
"Executes as list of changes.
CHANGES is a list of triples (REL-BEG INSERT-TEXT NDEL).
REL-BEG is the relative position (to point) where the change
takes place. INSERT-TEXT is the text to be inserted at that
position and NDEL the number of characters to be deleted at that
position before insertion.
REL-POINT is the relative position to point before the changed
where point should be placed after all changes."
(evil-save-repeat-info
(let ((point (point)))
(dolist (change changes)
(goto-char (+ point (nth 0 change)))
(delete-char (nth 2 change))
(insert (nth 1 change)))
(goto-char (+ point rel-point)))))
(defun evil-execute-repeat-info (repeat-info)
"Executes a repeat-information REPEAT-INFO."
(evil-save-repeat-info
(dolist (rep repeat-info)
(cond
((or (arrayp rep) (stringp rep))
(execute-kbd-macro rep))
((consp rep)
(apply (car rep) (cdr rep)))
(t
(error "Unexpected repeat-info: %S" rep))))))
;; TODO: currently we prepend the replacing count before the
;; key-sequence that calls the command. Can we use direct
;; modification of prefix-arg instead? Does it work in
;; conjunction with `execute-kbd-macro'?
(defun evil-execute-repeat-info-with-count (count repeat-info)
"Repeat the repeat-information REPEAT-INFO with the count of
the first command replaced by COUNT. The count is replaced if
and only if COUNT is non-nil."
(evil-save-repeat-info
(cond
;; do nothing (zero repeating)
((and count (zerop count)))
;; replace count
(count
(let ((evil-repeat-count count)
done)
(while (and repeat-info
(arrayp (car repeat-info))
(not done))
(let* ((count-and-cmd (evil-extract-count (pop repeat-info))))
(push (vconcat (number-to-string count)
(nth 2 count-and-cmd)
(nth 3 count-and-cmd))
repeat-info)
(setq done t)))
(evil-execute-repeat-info repeat-info)))
;; repeat with original count
(t
(evil-execute-repeat-info repeat-info)))))
(evil-define-command evil-repeat (count &optional save-point)
"Repeat the last editing command with count replaced by COUNT.
If SAVE-POINT is non-nil, do not move point."
:repeat ignore
:suppress-operator t
(interactive (list current-prefix-arg
(not evil-repeat-move-cursor)))
(cond
((null evil-repeat-ring)
(error "Already executing repeat"))
(save-point
(save-excursion
(evil-repeat count)))
(t
(unwind-protect
(let ((confirm-kill-emacs t)
(kill-buffer-hook
(cons #'(lambda ()
(error "Cannot delete buffer in repeat command"))
kill-buffer-hook))
(undo-pointer buffer-undo-list))
(evil-with-single-undo
(setq evil-last-repeat (list (point) count undo-pointer))
(evil-execute-repeat-info-with-count
count (ring-ref evil-repeat-ring 0))))
(evil-normal-state)))))
;; TODO: the same issue concering disabled undos as for `evil-paste-pop'
(evil-define-command evil-repeat-pop (count &optional save-point)
"Replace the just repeated command with a previously executed command.
Only allowed after `evil-repeat', `evil-repeat-pop' or
`evil-repeat-pop-next'. Uses the same repeat count that
was used for the first repeat.
The COUNT argument inserts the COUNT-th previous kill.
If COUNT is negative, this is a more recent kill."
:repeat nil
:suppress-operator t
(interactive (list (prefix-numeric-value current-prefix-arg)
(not evil-repeat-move-cursor)))
(cond
((not (and (eq last-command #'evil-repeat)
evil-last-repeat))
(error "Previous command was not evil-repeat: %s" last-command))
(save-point
(save-excursion
(evil-repeat-pop count)))
(t
(unless (eq buffer-undo-list (nth 2 evil-last-repeat))
(evil-undo-pop))
(goto-char (car evil-last-repeat))
;; rotate the repeat-ring
(while (> count 0)
(when evil-repeat-ring
(ring-insert-at-beginning evil-repeat-ring
(ring-remove evil-repeat-ring 0)))
(setq count (1- count)))
(while (< count 0)
(when evil-repeat-ring
(ring-insert evil-repeat-ring
(ring-remove evil-repeat-ring)))
(setq count (1+ count)))
(setq this-command #'evil-repeat)
(evil-repeat (cadr evil-last-repeat)))))
(evil-define-command evil-repeat-pop-next (count &optional save-point)
"Same as `evil-repeat-pop', but with negative COUNT."
:repeat nil
:suppress-operator t
(interactive (list (prefix-numeric-value current-prefix-arg)
(not evil-repeat-move-cursor)))
(evil-repeat-pop (- count) save-point))
(defadvice read-key-sequence (before evil activate)
"Record `this-command-keys' before it is reset."
(when (and (evil-repeat-recording-p)
evil-recording-current-command)
(let ((repeat-type (evil-repeat-type this-command t)))
(if (functionp repeat-type)
(funcall repeat-type 'post)))))
(provide 'evil-repeat)
;;; evil-repeat.el ends here

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,865 @@
;;; evil-states.el --- States
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.0.1
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
(require 'evil-core)
;;; Code:
;;; Normal state
(evil-define-state normal
"Normal state.
AKA \"Command\" state."
:tag " <N> "
:enable (motion)
:exit-hook (evil-repeat-start-hook)
(cond
((evil-normal-state-p)
(add-hook 'post-command-hook #'evil-normal-post-command nil t))
(t
(remove-hook 'post-command-hook #'evil-normal-post-command t))))
(defun evil-normal-post-command (&optional command)
"Reset command loop variables in Normal state.
Also prevent point from reaching the end of the line.
If the region is activated, enter Visual state."
(unless (evil-initializing-p)
(setq command (or command this-command))
(when (evil-normal-state-p)
(setq evil-this-type nil
evil-this-operator nil
evil-this-motion nil
evil-this-motion-count nil
evil-inhibit-operator nil
evil-inhibit-operator-value nil)
(unless (memq command '(evil-use-register
digit-argument
negative-argument
universal-argument
universal-argument-minus
universal-argument-more
universal-argument-other-key))
(setq evil-this-register nil))
(evil-adjust-cursor))))
(put 'evil-normal-post-command 'permanent-local-hook t)
;;; Insert state
(evil-define-state insert
"Insert state."
:tag " <I> "
:cursor (bar . 2)
:message "-- INSERT --"
:entry-hook (evil-start-track-last-insertion)
:exit-hook (evil-cleanup-insert-state evil-stop-track-last-insertion)
:input-method t
(cond
((evil-insert-state-p)
(add-hook 'pre-command-hook #'evil-insert-repeat-hook)
(unless evil-want-fine-undo
(evil-start-undo-step t)))
(t
(remove-hook 'pre-command-hook #'evil-insert-repeat-hook)
(setq evil-insert-repeat-info evil-repeat-info)
(evil-set-marker ?^ nil t)
(unless evil-want-fine-undo
(evil-end-undo-step t))
(when evil-move-cursor-back
(when (or (evil-normal-state-p evil-next-state)
(evil-motion-state-p evil-next-state))
(evil-move-cursor-back))))))
(defun evil-insert-repeat-hook ()
"Record insertion keys in `evil-insert-repeat-info'."
(setq evil-insert-repeat-info (last evil-repeat-info))
(remove-hook 'pre-command-hook #'evil-insert-repeat-hook))
(put 'evil-insert-repeat-hook 'permanent-local-hook t)
(defun evil-cleanup-insert-state ()
"Called when Insert state is about to be exited.
Handles the repeat-count of the insertion command."
(when evil-insert-count
(dotimes (i (1- evil-insert-count))
(when evil-insert-lines
(evil-insert-newline-below))
(when (fboundp 'evil-execute-repeat-info)
(evil-execute-repeat-info
(cdr evil-insert-repeat-info)))))
(when evil-insert-vcount
(let ((buffer-invisibility-spec buffer-invisibility-spec))
;; make all lines hidden by hideshow temporarily visible
(when (listp buffer-invisibility-spec)
(setq buffer-invisibility-spec
(evil-filter-list
#'(lambda (x)
(or (eq x 'hs)
(eq (car-safe x) 'hs)))
buffer-invisibility-spec)))
(let ((line (nth 0 evil-insert-vcount))
(col (nth 1 evil-insert-vcount))
(vcount (nth 2 evil-insert-vcount)))
(save-excursion
(dotimes (v (1- vcount))
(goto-char (point-min))
(forward-line (+ line v))
(when (or (not evil-insert-skip-empty-lines)
(not (integerp col))
(save-excursion
(evil-move-end-of-line)
(>= (current-column) col)))
(if (integerp col)
(move-to-column col t)
(funcall col))
(dotimes (i (or evil-insert-count 1))
(when (fboundp 'evil-execute-repeat-info)
(evil-execute-repeat-info
(cdr evil-insert-repeat-info)))))))))))
;;; Visual state
;; Visual selections are implemented in terms of types, and are
;; compatible with the Emacs region. This is achieved by "translating"
;; the region to the selected text right before a command is executed.
;; If the command is a motion, the translation is postponed until a
;; non-motion command is invoked (distinguished by the :keep-visual
;; command property).
;;
;; Visual state activates the region, enabling Transient Mark mode if
;; not already enabled. This is only temporay: if Transient Mark mode
;; was disabled before entering Visual state, it is disabled when
;; exiting Visual state. This allows Visual state to harness the
;; "transient" behavior of many commands without overriding the user's
;; preferences in other states.
(defmacro evil-define-visual-selection (selection doc &rest body)
"Define a Visual selection SELECTION.
Creates a command evil-visual-SELECTION for enabling the selection.
DOC is the function's documentation string. The following keywords
may be specified in BODY:
:message STRING Status message when enabling the selection.
:type TYPE Type to use (defaults to SELECTION).
Following the keywords is optional code which is executed each time
the selection is enabled.
\(fn SELECTION DOC [[KEY VAL]...] BODY...)"
(declare (indent defun)
(debug (&define name stringp
[&rest keywordp sexp]
def-body)))
(let* ((name (intern (format "evil-visual-%s" selection)))
(message (intern (format "%s-message" name)))
(type selection)
arg key string)
;; collect keywords
(while (keywordp (car-safe body))
(setq key (pop body)
arg (pop body))
(cond
((eq key :message)
(setq string arg))
((eq key :type)
(setq type arg))))
;; macro expansion
`(progn
(add-to-list 'evil-visual-alist (cons ',selection ',name))
(defvar ,name ',type ,(format "*%s" doc))
(defvar ,message ,string ,doc)
(evil-define-command ,name (&optional mark point type message)
,@(when doc `(,doc))
:keep-visual t
:repeat nil
(interactive
(list nil nil
(if (and (evil-visual-state-p)
(eq evil-visual-selection ',selection))
'exit ,name) t))
(if (eq type 'exit)
(evil-exit-visual-state)
(setq type (or type ,name)
evil-visual-selection ',selection)
(evil-visual-make-region mark point type message)
,@body))
',selection)))
(evil-define-visual-selection char
"Characterwise selection."
:type inclusive
:message "-- VISUAL --")
(evil-define-visual-selection line
"Linewise selection."
:message "-- VISUAL LINE --")
(evil-define-visual-selection block
"Blockwise selection."
:message "-- VISUAL BLOCK --"
(evil-transient-mark -1)
;; refresh the :corner property
(setq evil-visual-properties
(plist-put evil-visual-properties :corner
(evil-visual-block-corner 'upper-left))))
(evil-define-state visual
"Visual state."
:tag " <V> "
:enable (motion normal)
:message 'evil-visual-message
(cond
((evil-visual-state-p)
(evil-save-transient-mark-mode)
(setq select-active-regions nil)
(cond
((region-active-p)
(if (< (evil-visual-direction) 0)
(evil-visual-select (region-beginning) (region-end)
evil-visual-char
(evil-visual-direction))
(evil-visual-make-selection (mark t) (point)
evil-visual-char))
(evil-visual-highlight))
(t
(evil-visual-make-region (point) (point) evil-visual-char)))
(add-hook 'pre-command-hook #'evil-visual-pre-command nil t)
(add-hook 'post-command-hook #'evil-visual-post-command nil t)
(add-hook 'deactivate-mark-hook #'evil-visual-deactivate-hook nil t))
(t
;; Postpone deactivation of region if next state is Insert.
;; This gives certain insertion commands (auto-pairing characters,
;; for example) an opportunity to access the region.
(if (and (eq evil-next-state 'insert)
(eq evil-visual-selection 'char))
(add-hook 'evil-normal-state-entry-hook
#'evil-visual-deactivate-hook nil t)
(evil-visual-deactivate-hook))
(setq evil-visual-region-expanded nil)
(remove-hook 'pre-command-hook #'evil-visual-pre-command t)
(remove-hook 'post-command-hook #'evil-visual-post-command t)
(remove-hook 'deactivate-mark-hook #'evil-visual-deactivate-hook t)
(evil-visual-highlight -1))))
(defun evil-visual-pre-command (&optional command)
"Run before each COMMAND in Visual state.
Expand the region to the selection unless COMMAND is a motion."
(when (evil-visual-state-p)
(setq command (or command this-command))
(unless (evil-get-command-property command :keep-visual)
(evil-visual-expand-region
;; exclude final newline from linewise selection
;; unless the command has real need of it
(and (eq (evil-visual-type) 'line)
(evil-get-command-property command :exclude-newline))))))
(put 'evil-visual-pre-command 'permanent-local-hook t)
(defun evil-visual-post-command (&optional command)
"Run after each COMMAND in Visual state.
If COMMAND is a motion, refresh the selection;
otherwise exit Visual state."
(when (evil-visual-state-p)
(setq command (or command this-command))
(when evil-visual-x-select-timer
(cancel-timer evil-visual-x-select-timer))
(if (or quit-flag
(eq command #'keyboard-quit)
;; Is `mark-active' nil for an unexpanded region?
deactivate-mark
(and (not evil-visual-region-expanded)
(not (region-active-p))
(not (eq evil-visual-selection 'block))))
(progn
(evil-exit-visual-state)
(evil-adjust-cursor))
(if evil-visual-region-expanded
(evil-visual-contract-region)
(evil-visual-refresh))
(setq evil-visual-x-select-timer
(run-with-idle-timer evil-visual-x-select-timeout nil
#'evil-visual-update-x-selection
(current-buffer)))
(evil-visual-highlight))))
(put 'evil-visual-post-command 'permanent-local-hook t)
(defun evil-visual-update-x-selection (&optional buffer)
"Update the X selection with the current visual region."
(with-current-buffer (or buffer (current-buffer))
(when (and (evil-visual-state-p)
(fboundp 'x-select-text)
(or (not (boundp 'ns-initialized))
(with-no-warnings ns-initialized))
(not (eq evil-visual-selection 'block)))
(x-select-text (buffer-substring-no-properties
evil-visual-beginning
evil-visual-end)))))
(defun evil-visual-activate-hook (&optional command)
"Enable Visual state if the region is activated."
(unless (evil-visual-state-p)
(evil-delay nil
;; the activation may only be momentary, so re-check
;; in `post-command-hook' before entering Visual state
'(unless (or (evil-visual-state-p)
(evil-insert-state-p)
(evil-emacs-state-p))
(when (and (region-active-p)
(not deactivate-mark))
(evil-visual-state)))
'post-command-hook nil t
"evil-activate-visual-state")))
(put 'evil-visual-activate-hook 'permanent-local-hook t)
(defun evil-visual-deactivate-hook (&optional command)
"Deactivate the region and restore Transient Mark mode."
(setq command (or command this-command))
(remove-hook 'deactivate-mark-hook
#'evil-visual-deactivate-hook t)
(remove-hook 'evil-normal-state-entry-hook
#'evil-visual-deactivate-hook t)
(cond
((and (evil-visual-state-p) command
(not (evil-get-command-property command :keep-visual)))
(setq evil-visual-region-expanded nil)
(evil-exit-visual-state))
((not (evil-visual-state-p))
(evil-active-region -1)
(evil-restore-transient-mark-mode))))
(put 'evil-visual-deactivate-hook 'permanent-local-hook t)
(evil-define-command evil-exit-visual-state (&optional later buffer)
"Exit from Visual state to the previous state.
If LATER is non-nil, exit after the current command."
:keep-visual t
:repeat abort
(with-current-buffer (or buffer (current-buffer))
(when (evil-visual-state-p)
(evil-visual-update-x-selection)
(if later
(setq deactivate-mark t)
(when evil-visual-region-expanded
(evil-visual-contract-region))
(evil-change-to-previous-state)))))
(defun evil-visual-message (&optional selection)
"Create an echo area message for SELECTION.
SELECTION is a kind of selection as defined by
`evil-define-visual-selection', such as `char', `line'
or `block'."
(let (message)
(setq selection (or selection evil-visual-selection))
(when selection
(setq message
(symbol-value (intern (format "evil-visual-%s-message"
selection))))
(cond
((functionp message)
(funcall message))
((stringp message)
(evil-echo "%s" message))))))
(defun evil-visual-select (beg end &optional type dir message)
"Create a Visual selection of type TYPE from BEG to END.
Point and mark are positioned so that the resulting selection
has the specified boundaries. If DIR is negative, point precedes mark,
otherwise it succedes it. To specify point and mark directly,
use `evil-visual-make-selection'."
(let* ((range (evil-contract beg end type))
(mark (evil-range-beginning range))
(point (evil-range-end range))
(dir (or dir 1)))
(when (< dir 0)
(evil-swap mark point))
(evil-visual-make-selection mark point type message)))
(defun evil-visual-make-selection (mark point &optional type message)
"Create a Visual selection with point at POINT and mark at MARK.
The boundaries of the selection are inferred from these
and the current TYPE. To specify the boundaries and infer
mark and point, use `evil-visual-select' instead."
(let* ((selection (evil-visual-selection-for-type type))
(func (evil-visual-selection-function selection))
(prev (and (evil-visual-state-p) evil-visual-selection))
(mark (evil-normalize-position mark))
(point (evil-normalize-position point))
(state evil-state))
(unless (evil-visual-state-p)
(evil-visual-state))
(setq evil-visual-selection selection)
(funcall func mark point type
;; signal a message when changing the selection
(when (or (not (evil-visual-state-p state))
(not (eq selection prev)))
message))))
(defun evil-visual-make-region (mark point &optional type message)
"Create an active region from MARK to POINT.
If TYPE is given, also set the Visual type.
If MESSAGE is given, display it in the echo area."
(interactive)
(let* ((point (evil-normalize-position
(or point (point))))
(mark (evil-normalize-position
(or mark
(when (or (evil-visual-state-p)
(region-active-p))
(mark t))
point))))
(unless (evil-visual-state-p)
(evil-visual-state))
(evil-active-region 1)
(setq evil-visual-region-expanded nil)
(evil-visual-refresh mark point type)
(cond
((null evil-echo-state))
((stringp message)
(evil-echo "%s" message))
(message
(cond
((stringp evil-visual-state-message)
(evil-echo "%s" evil-visual-state-message))
((functionp evil-visual-state-message)
(funcall evil-visual-state-message)))))))
(defun evil-visual-expand-region (&optional exclude-newline)
"Expand the region to the Visual selection.
If EXCLUDE-NEWLINE is non-nil and the selection ends with a newline,
exclude that newline from the region."
(when (and (evil-visual-state-p)
(not evil-visual-region-expanded))
(let ((mark evil-visual-beginning)
(point evil-visual-end))
(when (< evil-visual-direction 0)
(evil-swap mark point))
(setq evil-visual-region-expanded t)
(evil-visual-refresh mark point)
(when (and exclude-newline
(save-excursion
(goto-char evil-visual-end)
(and (bolp) (not (bobp)))))
(if (< evil-visual-direction 0)
(evil-move-mark (max point (1- (mark))))
(goto-char (max mark (1- (point)))))))))
(defun evil-visual-contract-region ()
"The inverse of `evil-visual-expand-region'.
Create a Visual selection that expands to the current region."
(evil-visual-refresh)
(setq evil-visual-region-expanded nil)
(evil-visual-refresh evil-visual-mark evil-visual-point))
(defun evil-visual-refresh (&optional mark point type &rest properties)
"Refresh point, mark and Visual variables.
Refreshes `evil-visual-beginning', `evil-visual-end',
`evil-visual-mark', `evil-visual-point', `evil-visual-selection',
`evil-visual-direction', `evil-visual-properties' and `evil-this-type'."
(let* ((point (or point (point)))
(mark (or mark (mark t) point))
(dir (evil-visual-direction))
(type (or type (evil-visual-type evil-visual-selection)
(evil-visual-type)))
range)
(evil-move-mark mark)
(goto-char point)
(setq evil-visual-beginning
(or evil-visual-beginning
(let ((marker (make-marker)))
(move-marker marker (min point mark))))
evil-visual-end
(or evil-visual-end
(let ((marker (make-marker)))
(set-marker-insertion-type marker t)
(move-marker marker (max point mark))))
evil-visual-mark
(or evil-visual-mark
(let ((marker (make-marker)))
(move-marker marker mark)))
evil-visual-point
(or evil-visual-point
(let ((marker (make-marker)))
(move-marker marker point))))
(setq evil-visual-properties
(evil-concat-plists evil-visual-properties properties))
(cond
(evil-visual-region-expanded
(setq type (or (evil-visual-type) type))
(move-marker evil-visual-beginning (min point mark))
(move-marker evil-visual-end (max point mark))
;; if the type is one-to-one, we can safely refresh
;; the unexpanded positions as well
(when (evil-type-property type :one-to-one)
(setq range (apply #'evil-contract point mark type
evil-visual-properties)
mark (evil-range-beginning range)
point (evil-range-end range))
(when (< dir 0)
(evil-swap mark point))
(move-marker evil-visual-mark mark)
(move-marker evil-visual-point point)))
(t
(setq range (apply #'evil-expand point mark type
evil-visual-properties)
type (evil-type range type))
(move-marker evil-visual-beginning (evil-range-beginning range))
(move-marker evil-visual-end (evil-range-end range))
(move-marker evil-visual-mark mark)
(move-marker evil-visual-point point)))
(setq evil-visual-direction dir
evil-this-type type)))
(defun evil-visual-highlight (&optional arg)
"Highlight Visual selection, depending on the Visual type.
With negative ARG, disable highlighting."
(cond
((and (numberp arg) (< arg 1))
(when evil-visual-overlay
(delete-overlay evil-visual-overlay)
(setq evil-visual-overlay nil))
(when evil-visual-block-overlays
(mapc #'delete-overlay evil-visual-block-overlays)
(setq evil-visual-block-overlays nil)))
((eq evil-visual-selection 'block)
(when evil-visual-overlay
(evil-visual-highlight -1))
(evil-visual-highlight-block
evil-visual-beginning
evil-visual-end))
(t
(when evil-visual-block-overlays
(evil-visual-highlight -1))
(if evil-visual-overlay
(move-overlay evil-visual-overlay
evil-visual-beginning evil-visual-end)
(setq evil-visual-overlay
(make-overlay evil-visual-beginning evil-visual-end)))
(overlay-put evil-visual-overlay 'face 'region)
(overlay-put evil-visual-overlay 'priority 99))))
(defun evil-visual-highlight-block (beg end &optional overlays)
"Highlight rectangular region from BEG to END.
Do this by putting an overlay on each line within the rectangle.
Each overlay extends across all the columns of the rectangle.
Reuse overlays where possible to prevent flicker."
(let* ((point (point))
(mark (or (mark t) point))
(overlays (or overlays 'evil-visual-block-overlays))
(old (symbol-value overlays))
(eol-col (and (memq this-command '(next-line previous-line))
(numberp temporary-goal-column)
(1+ (min (round temporary-goal-column)
(1- most-positive-fixnum)))))
beg-col end-col new nlines overlay window-beg window-end)
(save-excursion
;; calculate the rectangular region represented by BEG and END,
;; but put BEG in the upper-left corner and END in the
;; lower-right if not already there
(setq beg-col (evil-column beg)
end-col (evil-column end))
(when (>= beg-col end-col)
(if (= beg-col end-col)
(setq end-col (1+ end-col))
(evil-sort beg-col end-col))
(setq beg (save-excursion
(goto-char beg)
(evil-move-to-column beg-col))
end (save-excursion
(goto-char end)
(evil-move-to-column end-col 1))))
;; update end column with eol-col (extension to eol).
(when (and eol-col (> eol-col end-col))
(setq end-col eol-col))
;; force a redisplay so we can do reliable window
;; BEG/END calculations
(sit-for 0)
(setq window-beg (max (window-start) beg)
window-end (min (window-end) (1+ end))
nlines (count-lines window-beg
(min window-end (point-max))))
;; iterate over those lines of the rectangle which are
;; visible in the currently selected window
(goto-char window-beg)
(dotimes (i nlines)
(let (before after row-beg row-end)
;; beginning of row
(evil-move-to-column beg-col)
(when (< (current-column) beg-col)
;; prepend overlay with virtual spaces if unable to
;; move directly to the first column
(setq before
(propertize
(make-string
(- beg-col (current-column)) ?\ )
'face
(or (get-text-property (1- (point)) 'face)
'default))))
(setq row-beg (point))
;; end of row
(evil-move-to-column end-col)
(when (and (not (eolp))
(< (current-column) end-col))
;; append overlay with virtual spaces if unable to
;; move directly to the last column
(setq after
(propertize
(make-string
(if (= (point) row-beg)
(- end-col beg-col)
(- end-col (current-column)))
?\ ) 'face 'region))
;; place cursor on one of the virtual spaces
(if (= point row-beg)
(put-text-property
0 (min (length after) 1)
'cursor t after)
(put-text-property
(max 0 (1- (length after))) (length after)
'cursor t after)))
(setq row-end (min (point) (line-end-position)))
;; trim old leading overlays
(while (and old
(setq overlay (car old))
(< (overlay-start overlay) row-beg)
(/= (overlay-end overlay) row-end))
(delete-overlay overlay)
(setq old (cdr old)))
;; reuse an overlay if possible, otherwise create one
(cond
((and old (setq overlay (car old))
(or (= (overlay-start overlay) row-beg)
(= (overlay-end overlay) row-end)))
(move-overlay overlay row-beg row-end)
(overlay-put overlay 'before-string before)
(overlay-put overlay 'after-string after)
(setq new (cons overlay new)
old (cdr old)))
(t
(setq overlay (make-overlay row-beg row-end))
(overlay-put overlay 'before-string before)
(overlay-put overlay 'after-string after)
(setq new (cons overlay new)))))
(forward-line 1))
;; display overlays
(dolist (overlay new)
(overlay-put overlay 'face 'region)
(overlay-put overlay 'priority 99))
;; trim old overlays
(dolist (overlay old)
(delete-overlay overlay))
(set overlays (nreverse new)))))
(defun evil-visual-range ()
"Return the Visual selection as a range.
This is a list (BEG END TYPE PROPERTIES...), where BEG is the
beginning of the selection, END is the end of the selection,
TYPE is the selection's type, and PROPERTIES is a property list
of miscellaneous selection attributes."
(apply #'evil-range
evil-visual-beginning evil-visual-end
(evil-visual-type)
:expanded t
evil-visual-properties))
(defun evil-visual-direction ()
"Return direction of Visual selection.
The direction is -1 if point precedes mark and 1 otherwise.
See also the variable `evil-visual-direction', which holds
the direction of the last selection."
(let* ((point (point))
(mark (or (mark t) point)))
(if (< point mark) -1 1)))
(defun evil-visual-type (&optional selection)
"Return the type of the Visual selection.
If SELECTION is specified, return the type of that instead."
(if (and (null selection) (evil-visual-state-p))
(or evil-this-type (evil-visual-type evil-visual-selection))
(setq selection (or selection evil-visual-selection))
(symbol-value (cdr-safe (assq selection evil-visual-alist)))))
(defun evil-visual-goto-end ()
"Go to the last line of the Visual selection.
This position may differ from `evil-visual-end' depending on
the selection type, and is contained in the selection."
(let ((range (evil-contract-range (evil-visual-range))))
(goto-char (evil-range-end range))))
(defun evil-visual-alist ()
"Return an association list from types to selection symbols."
(mapcar #'(lambda (e)
(cons (symbol-value (cdr-safe e)) (cdr-safe e)))
evil-visual-alist))
(defun evil-visual-selection-function (selection)
"Return a selection function for TYPE.
Default to `evil-visual-make-region'."
(or (cdr-safe (assq selection evil-visual-alist))
;; generic selection function
'evil-visual-make-region))
(defun evil-visual-selection-for-type (type)
"Return a Visual selection for TYPE."
(catch 'done
(dolist (selection evil-visual-alist)
(when (eq (symbol-value (cdr selection)) type)
(throw 'done (car selection))))))
(defun evil-visual-block-corner (&optional corner point mark)
"Block corner corresponding to POINT, with MARK in opposite corner.
Depending on POINT and MARK, the return value is `upper-left',
`upper-right', `lower-left' or `lower-right':
upper-left +---+ upper-right
| |
lower-left +---+ lower-right
One-column or one-row blocks are ambiguous. In such cases,
the horizontal or vertical component of CORNER is used.
CORNER defaults to `upper-left'."
(let* ((point (or point (point)))
(mark (or mark (mark t)))
(corner (symbol-name
(or corner
(and (overlayp evil-visual-overlay)
(overlay-get evil-visual-overlay
:corner))
'upper-left)))
(point-col (evil-column point))
(mark-col (evil-column mark))
horizontal vertical)
(cond
((= point-col mark-col)
(setq horizontal
(or (and (string-match "left\\|right" corner)
(match-string 0 corner))
"left")))
((< point-col mark-col)
(setq horizontal "left"))
((> point-col mark-col)
(setq horizontal "right")))
(cond
((= (line-number-at-pos point)
(line-number-at-pos mark))
(setq vertical
(or (and (string-match "upper\\|lower" corner)
(match-string 0 corner))
"upper")))
((< point mark)
(setq vertical "upper"))
((> point mark)
(setq vertical "lower")))
(intern (format "%s-%s" vertical horizontal))))
;;; Operator-Pending state
(evil-define-state operator
"Operator-Pending state."
:tag " <O> "
:cursor evil-half-cursor
:enable (evil-operator-shortcut-map operator motion normal))
(evil-define-keymap evil-operator-shortcut-map
"Keymap for Operator-Pending shortcuts like \"dd\" and \"gqq\"."
:local t
(setq evil-operator-shortcut-map (make-sparse-keymap))
(evil-initialize-local-keymaps))
;; the half-height "Operator-Pending cursor" cannot be specified
;; as a static `cursor-type' value, since its height depends on
;; the current font size
(defun evil-half-cursor ()
"Change cursor to a half-height box.
\(This is really just a thick horizontal bar.)"
(let (height)
;; make `window-line-height' reliable
(redisplay)
(setq height (window-line-height))
(setq height (+ (nth 0 height) (nth 3 height)))
;; cut cursor height in half
(setq height (/ height 2))
(setq cursor-type (cons 'hbar height))
;; ensure the cursor is redisplayed
(force-window-update (selected-window))
(redisplay)))
;;; Replace state
(evil-define-state replace
"Replace state."
:tag " <R> "
:cursor hbar
:message "-- REPLACE --"
(cond
((evil-replace-state-p)
(overwrite-mode 1)
(add-hook 'pre-command-hook #'evil-replace-pre-command nil t))
(t
(overwrite-mode -1)
(remove-hook 'pre-command-hook #'evil-replace-pre-command t)
(when evil-move-cursor-back
(evil-move-cursor-back))))
(setq evil-replace-alist nil))
(defun evil-replace-pre-command ()
"Remember the character under point."
(when (evil-replace-state-p)
(unless (assq (point) evil-replace-alist)
(add-to-list 'evil-replace-alist
(cons (point)
(unless (eolp)
(char-after)))))))
(put 'evil-replace-pre-command 'permanent-local-hook t)
(defun evil-replace-backspace ()
"Restore character under cursor."
(interactive)
(let (char)
(backward-char)
(when (assq (point) evil-replace-alist)
(setq char (cdr (assq (point) evil-replace-alist)))
(save-excursion
(delete-char 1)
(when char
(insert char))))))
;;; Motion state
(evil-define-state motion
"Motion state."
:tag " <M> "
:suppress-keymap t)
;;; Emacs state
(evil-define-state emacs
"Emacs state."
:tag " <E> "
:message "-- EMACS --"
:input-method t
:intercept-esc nil)
(provide 'evil-states)
;;; evil-states.el ends here

View File

@ -0,0 +1,361 @@
;;; evil-types.el --- Type system
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; Version: 1.0.1
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; A type defines a transformation on a pair of buffer positions.
;; Types are used by Visual state (character/line/block selection)
;; and Operator-Pending state (character/line/block motions).
;;
;; The basic transformation is "expansion". For example, the `line'
;; type "expands" a pair of positions to whole lines by moving the
;; first position to the beginning of the line and the last position
;; to the end of the line. That expanded selection is what the rest
;; of Emacs sees and acts on.
;;
;; An optional transformation is "contraction", which is the opposite
;; of expansion. If the transformation is one-to-one, expansion
;; followed by contraction always returns the original range.
;; (The `line' type is not one-to-one, as it may expand multiple
;; positions to the same lines.)
;;
;; Another optional transformation is "normalization", which takes
;; two unexpanded positions and adjusts them before expansion.
;; This is useful for cleaning up "invalid" positions.
;;
;; Types are defined at the end of this file using the macro
;; `evil-define-type'.
(require 'evil-common)
(require 'evil-macros)
;;; Code:
;;; Type definitions
(evil-define-type exclusive
"Return the positions unchanged, with some exceptions.
If the end position is at the beginning of a line, then:
* If the beginning position is at or before the first non-blank
character on the line, return `line' (expanded).
* Otherwise, move the end position to the end of the previous
line and return `inclusive' (expanded)."
:normalize (lambda (beg end)
(cond
((progn
(goto-char end)
(and (/= beg end) (bolp)))
(setq end (max beg (1- end)))
(cond
((progn
(goto-char beg)
(looking-back "^[ \f\t\v]*" (line-beginning-position)))
(evil-expand beg end 'line))
(t
(unless evil-cross-lines
(setq end (max beg (1- end))))
(evil-expand beg end 'inclusive))))
(t
(evil-range beg end))))
:string (lambda (beg end)
(let ((width (- end beg)))
(format "%s character%s" width
(if (= width 1) "" "s")))))
(evil-define-type inclusive
"Include the character under point.
If the end position is at the beginning of a line or the end of a
line and `evil-want-visual-char-semi-exclusive', then:
* If in visual state return `exclusive' (expanded)."
:expand (lambda (beg end)
(if (and evil-want-visual-char-semi-exclusive
(evil-visual-state-p)
(< beg end)
(save-excursion
(goto-char end)
(or (bolp) (eolp))))
(evil-range beg end 'exclusive)
(evil-range beg (1+ end))))
:contract (lambda (beg end)
(evil-range beg (max beg (1- end))))
:normalize (lambda (beg end)
(goto-char end)
(when (eq (char-after) ?\n)
(setq end (max beg (1- end))))
(evil-range beg end))
:string (lambda (beg end)
(let ((width (- end beg)))
(format "%s character%s" width
(if (= width 1) "" "s")))))
(evil-define-type line
"Include whole lines."
:one-to-one nil
:expand (lambda (beg end)
(evil-range
(progn
(goto-char beg)
(min (line-beginning-position)
(progn
;; move to beginning of line as displayed
(evil-move-beginning-of-line)
(line-beginning-position))))
(progn
(goto-char end)
(max (line-beginning-position 2)
(progn
;; move to end of line as displayed
(evil-move-end-of-line)
(line-beginning-position 2))))))
:contract (lambda (beg end)
(evil-range beg (max beg (1- end))))
:string (lambda (beg end)
(let ((height (count-lines beg end)))
(format "%s line%s" height
(if (= height 1) "" "s")))))
(evil-define-type block
"Like `inclusive', but for rectangles:
the last column is included."
:expand (lambda (beg end &rest properties)
(let ((beg-col (evil-column beg))
(end-col (evil-column end))
(corner (plist-get properties :corner)))
;; Since blocks are implemented as a pair of buffer
;; positions, expansion is restricted to what the buffer
;; allows. In the case of a one-column block, there are
;; two ways to expand it (either move the upper corner
;; beyond the lower corner, or the lower beyond the
;; upper), so try out both possibilities when
;; encountering the end of the line.
(cond
((= beg-col end-col)
(goto-char end)
(cond
((eolp)
(goto-char beg)
(if (eolp)
(evil-range beg end)
(evil-range (1+ beg) end)))
((memq corner '(lower-right upper-right right))
(evil-range (1+ beg) end))
(t
(evil-range beg (1+ end)))))
((< beg-col end-col)
(goto-char end)
(if (eolp)
(evil-range beg end)
(evil-range beg (1+ end))))
(t
(goto-char beg)
(if (eolp)
(evil-range beg end)
(evil-range (1+ beg) end))))))
:contract (lambda (beg end)
(let ((beg-col (evil-column beg))
(end-col (evil-column end)))
(if (> beg-col end-col)
(evil-range (1- beg) end)
(evil-range beg (max beg (1- end))))))
:string (lambda (beg end)
(let ((height (count-lines
beg
(progn
(goto-char end)
(if (and (bolp) (not (eobp)))
(1+ end)
end))))
(width (abs (- (evil-column beg)
(evil-column end)))))
(format "%s row%s and %s column%s"
height
(if (= height 1) "" "s")
width
(if (= width 1) "" "s"))))
:rotate (lambda (beg end &rest properties)
"Rotate block according to :corner property.
:corner can be one of `upper-left',``upper-right', `lower-left'
and `lower-right'."
(let ((left (evil-column beg))
(right (evil-column end))
(corner (or (plist-get properties :corner)
'upper-left)))
(evil-sort left right)
(goto-char beg)
(if (memq corner '(upper-right lower-left))
(move-to-column right)
(move-to-column left))
(setq beg (point))
(goto-char end)
(if (memq corner '(upper-right lower-left))
(move-to-column left)
(move-to-column right))
(setq end (point))
(setq properties (plist-put properties
:corner corner))
(apply #'evil-range beg end properties))))
(evil-define-type rectangle
"Like `exclusive', but for rectangles:
the last column is excluded."
:expand (lambda (beg end)
;; select at least one column
(if (= (evil-column beg) (evil-column end))
(evil-expand beg end 'block)
(evil-range beg end 'block))))
;;; Standard interactive codes
(evil-define-interactive-code "*"
"Signal error if the buffer is read-only."
(when buffer-read-only
(signal 'buffer-read-only nil)))
(evil-define-interactive-code "b" (prompt)
"Name of existing buffer."
(list (read-buffer prompt (current-buffer) t)))
(evil-define-interactive-code "c"
"Read character."
(list (read-char)))
(evil-define-interactive-code "p"
"Prefix argument converted to number."
(list (prefix-numeric-value current-prefix-arg)))
(evil-define-interactive-code "P"
"Prefix argument in raw form."
(list current-prefix-arg))
;;; Custom interactive codes
(evil-define-interactive-code "<c>"
"Count."
(list (when current-prefix-arg
(prefix-numeric-value
current-prefix-arg))))
(evil-define-interactive-code "<vc>"
"Count, but only in visual state.
This should be used by an operator taking a count. In normal
state the count should not be handled by the operator but by the
motion that defines the operator's range. In visual state the
range is specified by the visual region and the count is not used
at all. Thus in the case the operator may use the count
directly."
(list (when (and (evil-visual-state-p) current-prefix-arg)
(prefix-numeric-value
current-prefix-arg))))
(evil-define-interactive-code "<C>"
"Character read through `evil-read-key'."
(list (evil-read-key)))
(evil-define-interactive-code "<r>"
"Untyped motion range (BEG END)."
(evil-operator-range))
(evil-define-interactive-code "<R>"
"Typed motion range (BEG END TYPE)."
(evil-operator-range t))
(evil-define-interactive-code "<v>"
"Typed motion range of visual range(BEG END TYPE).
If visual state is inactive then those values are nil."
(if (evil-visual-state-p)
(let ((range (evil-visual-range)))
(list (car range)
(cadr range)
(evil-type range)))
(list nil nil nil)))
(evil-define-interactive-code "<x>"
"Current register."
(list evil-this-register))
(evil-define-interactive-code "<y>"
"Current yank-handler."
(list (evil-yank-handler)))
(evil-define-interactive-code "<a>"
"Ex argument."
:ex-arg t
(list (when (evil-ex-p) evil-ex-argument)))
(evil-define-interactive-code "<f>"
"Ex file argument."
:ex-arg file
(list (when (evil-ex-p) (evil-ex-file-arg))))
(evil-define-interactive-code "<b>"
"Ex buffer argument."
:ex-arg buffer
(list (when (evil-ex-p) evil-ex-argument)))
(evil-define-interactive-code "<sh>"
"Ex shell command argument."
:ex-arg shell
(list (when (evil-ex-p) evil-ex-argument)))
(evil-define-interactive-code "<fsh>"
"Ex file or shell command argument."
:ex-arg file-or-shell
(list (when (evil-ex-p) evil-ex-argument)))
(evil-define-interactive-code "<sym>"
"Ex symbolic argument."
:ex-arg sym
(list (when (and (evil-ex-p) evil-ex-argument)
(intern evil-ex-argument))))
(evil-define-interactive-code "<!>"
"Ex bang argument."
:ex-bang t
(list (when (evil-ex-p) evil-ex-bang)))
(evil-define-interactive-code "</>"
"Ex delimited argument."
(when (evil-ex-p)
(evil-delimited-arguments evil-ex-argument)))
(evil-define-interactive-code "<g/>"
"Ex global argument."
(when (evil-ex-p)
(evil-ex-parse-global evil-ex-argument)))
(evil-define-interactive-code "<s/>"
"Ex substitution argument."
:ex-arg substitution
(when (evil-ex-p)
(evil-ex-get-substitute-info evil-ex-argument)))
(provide 'evil-types)
;;; evil-types.el ends here

1392
elpa/evil-1.0.1/evil-vars.el Normal file

File diff suppressed because it is too large Load Diff

114
elpa/evil-1.0.1/evil.el Normal file
View File

@ -0,0 +1,114 @@
;;; evil.el --- extensible vi layer
;; Author: Vegard Øye <vegard_oye at hotmail.com>
;; Antono Vasiljev <antono.vasiljev at gmail.com>
;; Barry O'Reilly <gundaetiapo at gmail.com>
;; Christoph Lange <langec at web.de>
;; Frank Fischer <frank.fischer at mathematik.tu-chemnitz.de>
;; Frank Terbeck <ft at bewatermyfriend.org>
;; Jonathan Claggett <jclaggett at lonocloud.com>
;; Marian Schubert <maio@netsafe.cz>
;; Michael Markert <markert.michael at googlemail.com>
;; Nikolai Weibull <now at bitwi.se>
;; Sanel Zukan <sanelz at gmail.com>
;; Simon Hafner <hafnersimon at gmail.com>
;; Sune Simonsen <sune.simonsen at jayway.com>
;; Thomas Hisch <thomas at opentech.at>
;; Ulrich Müller <ulm at gentoo.org>
;; Winfred Lu <winfred.lu@gmail.com>
;; Wolfgang Jenkner <wjenkner at inode.at>
;; York Zhao <yzhao at telecor.com>
;; Lintaro Ina <tarao.gnn at gmail.com>
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
;; To get in touch, please use the bug tracker or the
;; mailing list (see below).
;; Created: 2011-03-01
;; Version: 1.0.1
;; Keywords: emulation, vim
;; URL: http://gitorious.org/evil
;; Repository: git://gitorious.org/evil/evil.git
;; EmacsWiki: http://www.emacswiki.org/emacs/Evil
;; Bug tracker: https://bitbucket.org/lyro/evil/issues
;; If you have bug reports, suggestions or patches, please
;; create an issue at the bug tracker (open for everyone).
;; Other discussions (tips, extensions) go to the mailing list.
;; Mailing list: <implementations-list at lists.ourproject.org>
;; Subscribe: http://tinyurl.com/implementations-list
;; Newsgroup: nntp://news.gmane.org/gmane.emacs.vim-emulation
;; Archives: http://dir.gmane.org/gmane.emacs.vim-emulation
;; You don't have to subscribe to post; we usually reply
;; within a few days and CC our replies back to you.
;;
;; This file is NOT part of GNU Emacs.
;;; License:
;; This file is part of Evil.
;;
;; Evil 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.
;;
;; Evil 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 Evil. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Evil is an extensible vi layer for Emacs. It emulates the main
;; features of Vim, and provides facilities for writing custom
;; extensions.
;;
;; Evil lives in a Git repository. To obtain Evil, do
;;
;; git clone git://gitorious.org/evil/evil.git
;;
;; Move Evil to ~/.emacs.d/evil (or somewhere else in the `load-path').
;; Then add the following lines to ~/.emacs:
;;
;; (add-to-list 'load-path "~/.emacs.d/evil")
;; (require 'evil)
;; (evil-mode 1)
;;
;; Evil requires undo-tree.el for linear undo and undo branches:
;;
;; http://www.emacswiki.org/emacs/UndoTree
;;
;; Otherwise, Evil uses regular Emacs undo.
;;
;; Evil requires `goto-last-change' and `goto-last-change-reverse'
;; function for the corresponding motions g; g, as well as the
;; last-change-register `.'. One package providing these functions is
;; goto-chg.el:
;;
;; http://www.emacswiki.org/emacs/GotoChg
;;
;; Without this package the corresponding motions will raise an error.
;;; Code:
(require 'evil-vars)
(require 'evil-common)
(require 'evil-core)
(require 'evil-states)
(require 'evil-repeat)
(require 'evil-macros)
(require 'evil-search)
(require 'evil-ex)
(require 'evil-digraphs)
(require 'evil-types)
(require 'evil-commands)
(require 'evil-maps)
(require 'evil-integration)
(run-hooks 'evil-after-load-hook)
(provide 'evil)
;;; evil.el ends here

View File

@ -0,0 +1,64 @@
;;; undo-tree-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads (global-undo-tree-mode undo-tree-mode) "undo-tree"
;;;;;; "undo-tree.el" (20836 47447))
;;; Generated autoloads from undo-tree.el
(autoload 'undo-tree-mode "undo-tree" "\
Toggle undo-tree mode.
With no argument, this command toggles the mode.
A positive prefix argument turns the mode on.
A negative prefix argument turns it off.
Undo-tree-mode replaces Emacs' standard undo feature with a more
powerful yet easier to use version, that treats the undo history
as what it is: a tree.
The following keys are available in `undo-tree-mode':
\\{undo-tree-map}
Within the undo-tree visualizer, the following keys are available:
\\{undo-tree-visualizer-map}
\(fn &optional ARG)" t nil)
(defvar global-undo-tree-mode nil "\
Non-nil if Global-Undo-Tree mode is enabled.
See the command `global-undo-tree-mode' for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `global-undo-tree-mode'.")
(custom-autoload 'global-undo-tree-mode "undo-tree" nil)
(autoload 'global-undo-tree-mode "undo-tree" "\
Toggle Undo-Tree mode in all buffers.
With prefix ARG, enable Global-Undo-Tree mode if ARG is positive;
otherwise, disable it. If called from Lisp, enable the mode if
ARG is omitted or nil.
Undo-Tree mode is enabled in all buffers where
`turn-on-undo-tree-mode' would do it.
See `undo-tree-mode' for more information on Undo-Tree mode.
\(fn &optional ARG)" t nil)
;;;***
;;;### (autoloads nil nil ("undo-tree-pkg.el") (20836 47447 427512))
;;;***
(provide 'undo-tree-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; undo-tree-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "undo-tree" "0.6.3" "Treat undo history as a tree" (quote nil))

File diff suppressed because it is too large Load Diff

33
init.el
View File

@ -59,17 +59,9 @@
(menu-bar-mode -1) (menu-bar-mode -1)
;; ============================================================================= ;; =============================================================================
;; tmux ;; Flymake
;; ============================================================================= ;; =============================================================================
(defun tmux-copy (&optional b e)
(interactive "r")
(shell-command-on-region b e "cat | tmux loadb -"))
;; ;; =============================================================================
;; ;; Flymake
;; ;; =============================================================================
(require 'flymake) (require 'flymake)
(require 'flymake-cursor) (require 'flymake-cursor)
@ -83,7 +75,7 @@
(add-to-list 'flymake-allowed-file-name-masks '("\\.py\\'" flymake-pylint-init)) (add-to-list 'flymake-allowed-file-name-masks '("\\.py\\'" flymake-pylint-init))
;; Load flymake on non-temp buffers ; Load flymake on non-temp buffers
(add-hook 'python-mode-hook (add-hook 'python-mode-hook
(lambda () (unless (eq buffer-file-name nil) (flymake-mode 1)))) (lambda () (unless (eq buffer-file-name nil) (flymake-mode 1))))
@ -108,8 +100,7 @@
(setq tab-width 4 (setq tab-width 4
indent-tabs-mode t indent-tabs-mode t
python-indent-offset 4)) python-indent-offset 4))
(python-tabs)
(add-hook 'python-mode-hook 'subword-mode)
;; Yelp always uses tabs. ;; Yelp always uses tabs.
(add-hook 'python-mode-hook 'python-tabs) (add-hook 'python-mode-hook 'python-tabs)
@ -124,19 +115,16 @@
(global-set-key (kbd "ESC <down>") (lambda () (interactive) (next-line 5))) (global-set-key (kbd "ESC <down>") (lambda () (interactive) (next-line 5)))
(global-set-key (kbd "ESC <up>") (lambda () (interactive) (previous-line 5))) (global-set-key (kbd "ESC <up>") (lambda () (interactive) (previous-line 5)))
;; Macros
(fset 'ipdb "import ipdb; ipdb.set_trace()")
;; Miscellaneous ;; Miscellaneous
(global-set-key "\C-x\C-b" 'buffer-menu) (global-set-key "\C-x\C-b" 'buffer-menu)
(global-set-key "\C-xw" 'whitespace-mode) (global-set-key "\C-xw" 'whitespace-mode)
(global-set-key "\C-x\C-r" (lambda () (interactive) (revert-buffer t t))) (global-set-key "\C-x\C-r" (lambda () (interactive) (revert-buffer t t)))
(global-set-key "\C-x\C-i" 'increase-left-margin)
(global-set-key "\C-x\C-d" 'decrease-left-margin)
(global-set-key "\C-c\C-c" 'comment-region) (global-set-key "\C-c\C-c" 'comment-region)
(global-set-key (kbd "C-c w") 'tmux-copy)
(global-set-key (kbd "C-x O") (lambda () (interactive) (other-window -1)))
;; Something will occasionally override this binding.
(global-set-key "\C-cg" 'rope-goto-definition)
;; Macros
(fset 'ipdb "import ipdb; ipdb.set_trace()")
;; ============================================================================= ;; =============================================================================
;; ELPA ;; ELPA
@ -158,7 +146,7 @@
;; (package-refresh-contents)) ;; (package-refresh-contents))
;; ;; Add in your own as you wish: ;; ;; Add in your own as you wish:
;; (defvar my-packages '(starter-kit starter-starter-kit-bindings) ;; (defvar my-packages '(starter-kit starter-kit-lisp starter-kit-bindings)
;; "A list of packages to ensure are installed at launch.") ;; "A list of packages to ensure are installed at launch.")
;; (dolist (p my-packages) ;; (dolist (p my-packages)
@ -221,12 +209,11 @@
(load-file "~/.emacs.d/emacs-for-python/epy-init.el") (load-file "~/.emacs.d/emacs-for-python/epy-init.el")
(setq skeleton-pair nil) ;; This breaks pasting from os clipboard (setq skeleton-pair nil) ;; This stuff sucks.
;; ============================================================================= ;; =============================================================================
;; Customize ;; Customize
;; ============================================================================= ;; =============================================================================
(custom-set-variables (custom-set-variables
;; custom-set-variables was added by Custom. ;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.