[emacs] Remove evil
This commit is contained in:
		
							parent
							
								
									d385d419ec
								
							
						
					
					
						commit
						38273737e8
					
				
					 34 changed files with 0 additions and 35112 deletions
				
			
		
							
								
								
									
										1
									
								
								emacs.d/evil/.gitattributes
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								emacs.d/evil/.gitattributes
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
*.el diff=lisp
 | 
			
		||||
							
								
								
									
										14
									
								
								emacs.d/evil/.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										14
									
								
								emacs.d/evil/.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -1,14 +0,0 @@
 | 
			
		|||
*.elc
 | 
			
		||||
*.aux
 | 
			
		||||
*.cp
 | 
			
		||||
*.fn
 | 
			
		||||
*.fns
 | 
			
		||||
*.info
 | 
			
		||||
*.ky
 | 
			
		||||
*.log
 | 
			
		||||
*.pg
 | 
			
		||||
*.toc
 | 
			
		||||
*.tp
 | 
			
		||||
*.vr
 | 
			
		||||
*.vrs
 | 
			
		||||
.depend
 | 
			
		||||
| 
						 | 
				
			
			@ -1,56 +0,0 @@
 | 
			
		|||
* Changes and New Features in Evil
 | 
			
		||||
 | 
			
		||||
** News in 1.0.7
 | 
			
		||||
 | 
			
		||||
   * Fix #319.
 | 
			
		||||
 | 
			
		||||
** News in 1.0.6
 | 
			
		||||
 | 
			
		||||
   * Fix bug induced in emacs trunk due to changed behaviour of
 | 
			
		||||
     `overriding-terminal-local-map` (fixes #309).
 | 
			
		||||
 | 
			
		||||
** News in 1.0.5
 | 
			
		||||
 | 
			
		||||
   * Fix bug in `show-paren-mode` due to variable renaming in latest
 | 
			
		||||
     emacs.
 | 
			
		||||
 | 
			
		||||
   * Fix bug in isearch module due to variable renaming in latest
 | 
			
		||||
     emacs.
 | 
			
		||||
 | 
			
		||||
** News in 1.0.4
 | 
			
		||||
 | 
			
		||||
   * Undo one restriction when <c> argument is read in operator state.
 | 
			
		||||
 | 
			
		||||
** News in 1.0.3
 | 
			
		||||
 | 
			
		||||
   * Fix `evil-delete-backward-word` at first non-blank in a line.
 | 
			
		||||
 | 
			
		||||
** News in 1.0.2
 | 
			
		||||
 | 
			
		||||
   * Fix #290.
 | 
			
		||||
 | 
			
		||||
** News in 1.0.1
 | 
			
		||||
 | 
			
		||||
*** Improvements
 | 
			
		||||
 | 
			
		||||
   * An ELPA package built by =make elpa= contains COPYING file.
 | 
			
		||||
 | 
			
		||||
   * Bind =[tab]= like =\t= in =evil-ex-completion-map=, so that it
 | 
			
		||||
     cannot be overwritten by a =[tab]= binding in the parent keymap
 | 
			
		||||
     =minibuffer-local-completion-map=.
 | 
			
		||||
 | 
			
		||||
   * Improve worst case performance of internal functions
 | 
			
		||||
     =evil-in-string-p=, =evil-string-beginning= and
 | 
			
		||||
     =evil-string-end=. This functions are used, e.g., in certain text
 | 
			
		||||
     objects to detect whether point is within a string.
 | 
			
		||||
 | 
			
		||||
   * Update authors list.
 | 
			
		||||
 | 
			
		||||
*** Fixes
 | 
			
		||||
 | 
			
		||||
   * The interactive code =<state>= is fixed and used correctly in
 | 
			
		||||
     =evil-ex-set-initial-state=.
 | 
			
		||||
 | 
			
		||||
   * =evil-ex-global= always generates a single undo-step.
 | 
			
		||||
 | 
			
		||||
   * Resolved issues: #249, #250, #253 and #257.
 | 
			
		||||
| 
						 | 
				
			
			@ -1,674 +0,0 @@
 | 
			
		|||
                    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>.
 | 
			
		||||
| 
						 | 
				
			
			@ -1,135 +0,0 @@
 | 
			
		|||
SHELL = /bin/sh
 | 
			
		||||
EMACS = emacs
 | 
			
		||||
FILES = $(filter-out evil-tests.el,$(filter-out evil-pkg.el,$(wildcard evil*.el)))
 | 
			
		||||
VERSION := $(shell sed -ne '/define-package/,$$p' evil-pkg.el | sed -ne '/^\s*"[[:digit:]]\+\(\.[[:digit:]]\+\)*"\s*$$/ s/^.*"\(.*\)".*$$/\1/p')
 | 
			
		||||
ELPAPKG = evil-$(VERSION)
 | 
			
		||||
PROFILER =
 | 
			
		||||
DOC = doc
 | 
			
		||||
TAG =
 | 
			
		||||
LIBS = -L lib
 | 
			
		||||
 | 
			
		||||
ELCFILES = $(FILES:.el=.elc)
 | 
			
		||||
 | 
			
		||||
.PHONY: all compile compile-batch info pdf clean tests test emacs term terminal profiler indent elpa version
 | 
			
		||||
 | 
			
		||||
# Byte-compile Evil.
 | 
			
		||||
all: compile
 | 
			
		||||
compile: $(ELCFILES)
 | 
			
		||||
 | 
			
		||||
.depend: $(FILES)
 | 
			
		||||
	@echo Compute dependencies
 | 
			
		||||
	@rm -f .depend
 | 
			
		||||
	@for f in $(FILES); do \
 | 
			
		||||
	    sed -n "s/(require '\(evil-.*\))/$${f}c: \1.elc/p" $$f >> .depend;\
 | 
			
		||||
	done
 | 
			
		||||
 | 
			
		||||
-include .depend
 | 
			
		||||
 | 
			
		||||
$(ELCFILES): %.elc: %.el
 | 
			
		||||
	$(EMACS) --batch -Q -L . $(LIBS) -f batch-byte-compile $<
 | 
			
		||||
 | 
			
		||||
# Byte-compile all files in one batch. This is faster than
 | 
			
		||||
# compiling each file in isolation, but also less stringent.
 | 
			
		||||
compile-batch: clean
 | 
			
		||||
	$(EMACS) --batch -Q -L . $(LIBS) -f batch-byte-compile ${FILES}
 | 
			
		||||
 | 
			
		||||
# Documentation.
 | 
			
		||||
doc: info pdf
 | 
			
		||||
 | 
			
		||||
info: clean
 | 
			
		||||
	cd $(DOC) && makeinfo evil.texi
 | 
			
		||||
 | 
			
		||||
pdf: clean
 | 
			
		||||
	cd $(DOC) && texi2pdf evil.texi
 | 
			
		||||
 | 
			
		||||
# Delete byte-compiled files etc.
 | 
			
		||||
clean:
 | 
			
		||||
	rm -f *~
 | 
			
		||||
	rm -f \#*\#
 | 
			
		||||
	rm -f *.elc
 | 
			
		||||
	rm -f .depend
 | 
			
		||||
	cd $(DOC) && rm -f *.aux *.cp *.fn *.fns *.info *.ky *.log *.pg *.toc *.tp *.vr *.vrs
 | 
			
		||||
 | 
			
		||||
# Run tests.
 | 
			
		||||
# The TAG variable may specify a test tag or a test name:
 | 
			
		||||
#       make test TAG=repeat
 | 
			
		||||
# This will only run tests pertaining to the repeat system.
 | 
			
		||||
test:
 | 
			
		||||
	$(EMACS) -nw -Q -L . $(LIBS) -l evil-tests.el \
 | 
			
		||||
--eval "(evil-tests-initialize '(${TAG}) '(${PROFILER}))"
 | 
			
		||||
 | 
			
		||||
# Byte-compile Evil and run all tests.
 | 
			
		||||
tests: compile
 | 
			
		||||
	$(EMACS) -nw -Q -L . $(LIBS) -l evil-tests.el \
 | 
			
		||||
--eval "(evil-tests-initialize '(${TAG}) '(${PROFILER}))"
 | 
			
		||||
	rm -f *.elc .depend
 | 
			
		||||
 | 
			
		||||
# Load Evil in a fresh instance of Emacs and run all tests.
 | 
			
		||||
emacs:
 | 
			
		||||
	$(EMACS) -Q -L . $(LIBS) -l goto-chg.el -l evil-tests.el \
 | 
			
		||||
--eval "(evil-mode 1)" \
 | 
			
		||||
--eval "(evil-tests-initialize '(${TAG}) '(${PROFILER}) t)" &
 | 
			
		||||
 | 
			
		||||
# Load Evil in a terminal Emacs and run all tests.
 | 
			
		||||
term: terminal
 | 
			
		||||
terminal:
 | 
			
		||||
	$(EMACS) -nw -Q -L . $(LIBS) -l goto-chg.el -l evil-tests.el \
 | 
			
		||||
--eval "(evil-mode 1)" \
 | 
			
		||||
--eval "(evil-tests-initialize '(${TAG}) '(${PROFILER}) t)"
 | 
			
		||||
 | 
			
		||||
# Run all tests with profiler.
 | 
			
		||||
profiler:
 | 
			
		||||
	$(EMACS) --batch -Q -L . $(LIBS) -l goto-chg.el -l evil-tests.el \
 | 
			
		||||
--eval "(evil-tests-initialize '(${TAG}) (or '(${PROFILER}) t))"
 | 
			
		||||
 | 
			
		||||
# Re-indent all Evil code.
 | 
			
		||||
# Loads Evil into memory in order to indent macros properly.
 | 
			
		||||
# Also removes trailing whitespace, tabs and extraneous blank lines.
 | 
			
		||||
indent: clean
 | 
			
		||||
	$(EMACS) --batch --eval '(setq vc-handled-backends nil)' ${FILES} evil-tests.el -Q -L . $(LIBS) -l evil-tests.el \
 | 
			
		||||
--eval "(dolist (buffer (reverse (buffer-list))) \
 | 
			
		||||
(when (buffer-file-name buffer) \
 | 
			
		||||
(set-buffer buffer) \
 | 
			
		||||
(message \"Indenting %s\" (current-buffer)) \
 | 
			
		||||
(setq-default indent-tabs-mode nil) \
 | 
			
		||||
(untabify (point-min) (point-max)) \
 | 
			
		||||
(indent-region (point-min) (point-max)) \
 | 
			
		||||
(delete-trailing-whitespace) \
 | 
			
		||||
(untabify (point-min) (point-max)) \
 | 
			
		||||
(goto-char (point-min)) \
 | 
			
		||||
(while (re-search-forward \"\\n\\\\{3,\\\\}\" nil t) \
 | 
			
		||||
(replace-match \"\\n\\n\")) \
 | 
			
		||||
(when (buffer-modified-p) (save-buffer 0))))"
 | 
			
		||||
 | 
			
		||||
# Create an ELPA package.
 | 
			
		||||
elpa:
 | 
			
		||||
	@echo "Creating ELPA package $(ELPAPKG).tar"
 | 
			
		||||
	@rm -rf ${ELPAPKG}
 | 
			
		||||
	@mkdir ${ELPAPKG}
 | 
			
		||||
	@cp $(FILES) COPYING evil-pkg.el ${ELPAPKG}
 | 
			
		||||
	@tar cf ${ELPAPKG}.tar ${ELPAPKG}
 | 
			
		||||
	@rm -rf ${ELPAPKG}
 | 
			
		||||
 | 
			
		||||
# Change the version using make VERSION=x.y.z
 | 
			
		||||
version:
 | 
			
		||||
	$(EMACS) --batch --eval '(setq vc-handled-backends nil)' ${FILES} evil-tests.el -Q \
 | 
			
		||||
--eval "\
 | 
			
		||||
(progn \
 | 
			
		||||
  (find-file \"evil-vars.el\") \
 | 
			
		||||
  (when (re-search-forward \"^(defconst evil-version \\\"\\\\([-_.[:word:]]*\\\\)\\\"\" nil t) \
 | 
			
		||||
    (replace-match \"${VERSION}\" t t nil 1)) \
 | 
			
		||||
  (find-file \"evil-pkg.el\") \
 | 
			
		||||
  (goto-line 3) \
 | 
			
		||||
  (when (and (string-match-p \"[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+\" \"${VERSION}\") \
 | 
			
		||||
             (re-search-forward \"\\\"\\\\([-_.[:word:]]*\\\\)\\\"\" nil t)) \
 | 
			
		||||
    (replace-match \"${VERSION}\" t t nil 1)) \
 | 
			
		||||
  (dolist (buffer (reverse (buffer-list))) \
 | 
			
		||||
    (when (buffer-file-name buffer) \
 | 
			
		||||
      (set-buffer buffer) \
 | 
			
		||||
      (goto-char (point-min)) \
 | 
			
		||||
      (when (re-search-forward \"^;;[[:space:]]*Version:[[:space:]]*\\\\([-_.[:word:]]*\\\\)\" nil t) \
 | 
			
		||||
        (replace-match \"${VERSION}\" t t nil 1)) \
 | 
			
		||||
      (when (buffer-modified-p) (save-buffer 0))))) \
 | 
			
		||||
"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -1,769 +0,0 @@
 | 
			
		|||
\input texinfo @c -*-texinfo-*-
 | 
			
		||||
@setfilename evil.info
 | 
			
		||||
@documentencoding ISO-8859-1
 | 
			
		||||
@include version.texi
 | 
			
		||||
@settitle Evil-mode manual
 | 
			
		||||
@include macros.texi
 | 
			
		||||
 | 
			
		||||
@copying
 | 
			
		||||
This manual is for Evil (version @value{VERSION} of @value{UPDATED}),
 | 
			
		||||
an extensible vi layer for Emacs.
 | 
			
		||||
 | 
			
		||||
Copyright @copyright{} 2011 @authors{}.
 | 
			
		||||
 | 
			
		||||
@quotation
 | 
			
		||||
Permission is granted to copy, distribute and/or modify this document
 | 
			
		||||
under the terms of the GNU Free Documentation License, Version 1.3
 | 
			
		||||
or any later version published by the Free Software Foundation;
 | 
			
		||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 | 
			
		||||
A copy of the license is included in the section entitled
 | 
			
		||||
``GNU Free Documentation License''.
 | 
			
		||||
@end quotation
 | 
			
		||||
 | 
			
		||||
The Evil team thanks everyone at gmane.emacs.vim-emulation for
 | 
			
		||||
their feedback and contributions.
 | 
			
		||||
@end copying
 | 
			
		||||
 | 
			
		||||
@dircategory Emacs
 | 
			
		||||
@direntry
 | 
			
		||||
* Evil: (evil). Extensible vi layer for Emacs.
 | 
			
		||||
@end direntry
 | 
			
		||||
 | 
			
		||||
@titlepage
 | 
			
		||||
@title Evil
 | 
			
		||||
@subtitle Extensible vi layer for Emacs
 | 
			
		||||
@author @authors{}
 | 
			
		||||
@page
 | 
			
		||||
@insertcopying
 | 
			
		||||
@end titlepage
 | 
			
		||||
 | 
			
		||||
@contents
 | 
			
		||||
 | 
			
		||||
@ifnottex
 | 
			
		||||
@node Top, Overview, (dir), (dir)
 | 
			
		||||
@top Evil
 | 
			
		||||
 | 
			
		||||
This is the manual for Evil, an extensible vi layer for Emacs.
 | 
			
		||||
@end ifnottex
 | 
			
		||||
 | 
			
		||||
@menu
 | 
			
		||||
* Overview::
 | 
			
		||||
* Settings::
 | 
			
		||||
* Keymaps::
 | 
			
		||||
* Hooks::
 | 
			
		||||
* Macros::
 | 
			
		||||
* Other internals::
 | 
			
		||||
* GNU Free Documentation License::
 | 
			
		||||
@end menu
 | 
			
		||||
 | 
			
		||||
@node Overview
 | 
			
		||||
@chapter Overview
 | 
			
		||||
 | 
			
		||||
Evil is an extensible vi layer for Emacs.  It emulates the main features
 | 
			
		||||
of Vim,@footnote{Vim is the most popular version of @dfn{vi}, a modal
 | 
			
		||||
text editor with many implementations.  Vim also adds some functions of
 | 
			
		||||
its own, like Visual selection and text objects.  For more information,
 | 
			
		||||
see: @uref{http://www.vim.org/}} turning Emacs into a modal editor.
 | 
			
		||||
Like Emacs in general, Evil is extensible in Emacs Lisp.
 | 
			
		||||
 | 
			
		||||
@menu
 | 
			
		||||
* Installation::
 | 
			
		||||
* Modes and states::
 | 
			
		||||
@end menu
 | 
			
		||||
 | 
			
		||||
@node Installation
 | 
			
		||||
@section Installation
 | 
			
		||||
 | 
			
		||||
Evil lives in a Git repository.  To download Evil, do:
 | 
			
		||||
 | 
			
		||||
@example
 | 
			
		||||
git clone git://gitorious.org/evil/evil.git
 | 
			
		||||
@end example
 | 
			
		||||
 | 
			
		||||
@noindent Move Evil to @code{~/.emacs.d/evil}.  Then add the following
 | 
			
		||||
lines to @code{~/.emacs}:
 | 
			
		||||
 | 
			
		||||
@lisp
 | 
			
		||||
(add-to-list 'load-path "~/.emacs.d/evil")
 | 
			
		||||
(require 'evil)
 | 
			
		||||
(evil-mode 1)
 | 
			
		||||
@end lisp
 | 
			
		||||
 | 
			
		||||
@noindent Evil requires @code{undo-tree.el} to provide linear undo
 | 
			
		||||
and undo branches.  It is available from
 | 
			
		||||
EmacsWiki.@footnote{@uref{http://www.emacswiki.org/emacs/UndoTree}}
 | 
			
		||||
(A copy of @code{undo-tree.el} is also included in the Git repository.)
 | 
			
		||||
 | 
			
		||||
@node Modes and states
 | 
			
		||||
@section Modes and states
 | 
			
		||||
 | 
			
		||||
The next time Emacs is started, it will come up in @dfn{Normal state},
 | 
			
		||||
denoted by @code{<N>} on the mode line.  This is where the main vi
 | 
			
		||||
bindings are defined.  Note that you can always disable Normal state
 | 
			
		||||
with @kbd{C-z}, which switches to an ``Emacs state'' (denoted by
 | 
			
		||||
@code{<E>}) in which vi keys are completely disabled.  Press @kbd{C-z}
 | 
			
		||||
again to switch back to Normal state.
 | 
			
		||||
 | 
			
		||||
Evil uses the term @dfn{state} for what is called a ``mode'' in vi,
 | 
			
		||||
since ``mode'' already has its own meaning in Emacs.  Evil defines a
 | 
			
		||||
number of states, such as Normal state (@code{<N>}), Insert state
 | 
			
		||||
(@code{<I>}), Visual state (@code{<V>}), Replace state (@code{<R>}),
 | 
			
		||||
Operator-Pending state (@code{<O>}), Motion state (@code{<M>}) and Emacs
 | 
			
		||||
state (@code{<E>}).  Each state has its own keymaps and customization
 | 
			
		||||
variables.
 | 
			
		||||
 | 
			
		||||
Meanwhile, a @dfn{mode} in Emacs is a set of key bindings for editing a
 | 
			
		||||
certain sort of text, like @code{emacs-lisp-mode} for Emacs Lisp.  Modes
 | 
			
		||||
may include custom bindings for Evil states.
 | 
			
		||||
 | 
			
		||||
@node Settings
 | 
			
		||||
@chapter Settings
 | 
			
		||||
 | 
			
		||||
Evil's behavior can be adjusted by setting various variables.
 | 
			
		||||
The current values may be inspected by doing
 | 
			
		||||
@kbd{M-x customize-group RET evil RET}.
 | 
			
		||||
 | 
			
		||||
To change the value of a variable, add a @samp{setq} form to
 | 
			
		||||
@code{~/.emacs}, preferably before Evil is loaded:@footnote{Strictly
 | 
			
		||||
speaking, the order only matters if the variable affects the way Evil is
 | 
			
		||||
loaded.  This is the case with some of the @samp{evil-want-} variables.}
 | 
			
		||||
 | 
			
		||||
@lisp
 | 
			
		||||
(setq evil-shift-width 8)
 | 
			
		||||
;; @r{Load Evil}
 | 
			
		||||
(require 'evil) @r{@dots{}}
 | 
			
		||||
@end lisp
 | 
			
		||||
 | 
			
		||||
@noindent Note that if a variable is buffer-local, you must use
 | 
			
		||||
@samp{setq-default} instead of @samp{setq} to change its global value.
 | 
			
		||||
 | 
			
		||||
@defvar evil-auto-indent
 | 
			
		||||
Whether the current line is indented when entering Insert state.
 | 
			
		||||
If @code{t} (the default), then the line is indented.  If @code{nil},
 | 
			
		||||
then the line is not indented.  Buffer-local.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-shift-width
 | 
			
		||||
The number of columns a line is shifted by the commands
 | 
			
		||||
@kbd{>} and @kbd{<}.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-repeat-move-cursor
 | 
			
		||||
If @code{t} (the default), then repeating a command with @kbd{.} may
 | 
			
		||||
change the position of the cursor.  If @code{nil}, then the original
 | 
			
		||||
position is preserved.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-find-skip-newlines
 | 
			
		||||
If @code{t}, then @kbd{f}, @kbd{F}, @kbd{t} and @kbd{T} may skip over
 | 
			
		||||
newlines to find a character.  If @code{nil} (the default), then they
 | 
			
		||||
are restricted to the current line.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-move-cursor-back
 | 
			
		||||
If @code{t} (the default), then the cursor moves backwards when exiting
 | 
			
		||||
Insert state.  If @code{nil}, then the cursor does not move.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-want-fine-undo
 | 
			
		||||
If @code{t}, then a change-based action like @kbd{cw} may be undone
 | 
			
		||||
in several steps.  If @code{nil} (the default), then it is undone in
 | 
			
		||||
one step.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-regexp-search
 | 
			
		||||
If @code{t} (the default), then @kbd{/} and @kbd{?} use regular
 | 
			
		||||
expressions for searching.  If @code{nil}, they use plain text.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-search-wrap
 | 
			
		||||
If @code{t} (the default), then @kbd{/} and @kbd{?} wrap the search
 | 
			
		||||
around the buffer.  If @code{nil}, then they stop at buffer boundaries.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-flash-delay
 | 
			
		||||
The number of seconds to flash search matches when pressing @kbd{n}
 | 
			
		||||
and @kbd{N}.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-want-C-i-jump
 | 
			
		||||
If @code{t} (the default), then @kbd{C-i} jumps forwards in the jump
 | 
			
		||||
list.  If @code{nil}, then @kbd{C-i} inserts a tab.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-want-C-u-scroll
 | 
			
		||||
If @code{t}, then @kbd{C-u} scrolls the buffer.  If @code{nil} (the
 | 
			
		||||
default), then @kbd{C-u} begins a numeric prefix argument.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@menu
 | 
			
		||||
* The cursor::
 | 
			
		||||
* The initial state::
 | 
			
		||||
@end menu
 | 
			
		||||
 | 
			
		||||
@node The cursor
 | 
			
		||||
@section The cursor
 | 
			
		||||
 | 
			
		||||
A state may change the cursor's appearance.  The cursor settings are
 | 
			
		||||
stored in the variables below, which may contain a cursor type as per
 | 
			
		||||
the @samp{cursor-type} variable, a color string as passed to the
 | 
			
		||||
@samp{set-cursor-color} function, a zero-argument function for changing
 | 
			
		||||
the cursor, or a list of the above.  For example, the following changes
 | 
			
		||||
the cursor in Replace state to a red box:
 | 
			
		||||
 | 
			
		||||
@lisp
 | 
			
		||||
(setq evil-replace-state-cursor '("red" box))
 | 
			
		||||
@end lisp
 | 
			
		||||
 | 
			
		||||
@noindent If the state does not specify a cursor,
 | 
			
		||||
@samp{evil-default-cursor} is used.
 | 
			
		||||
 | 
			
		||||
@defvar evil-default-cursor
 | 
			
		||||
The default cursor.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-normal-state-cursor
 | 
			
		||||
The cursor for Normal state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-insert-state-cursor
 | 
			
		||||
The cursor for Insert state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-visual-state-cursor
 | 
			
		||||
The cursor for Visual state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-replace-state-cursor
 | 
			
		||||
The cursor for Replace state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-operator-state-cursor
 | 
			
		||||
The cursor for Operator-Pending state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-motion-state-cursor
 | 
			
		||||
The cursor for Motion state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-emacs-state-cursor
 | 
			
		||||
The cursor for Emacs state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@node The initial state
 | 
			
		||||
@section The initial state
 | 
			
		||||
 | 
			
		||||
By default, a new buffer comes up in Normal state.  This can be changed
 | 
			
		||||
with the function @samp{evil-set-initial-state}.
 | 
			
		||||
 | 
			
		||||
@defun evil-set-initial-state mode state
 | 
			
		||||
Set the initial state for a buffer in which @var{mode} is active to
 | 
			
		||||
@var{state}.  @var{mode} should be a major mode such as
 | 
			
		||||
@code{text-mode}, although minor modes work as well.
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@node Keymaps
 | 
			
		||||
@chapter Keymaps
 | 
			
		||||
 | 
			
		||||
Evil's key bindings are stored in a number of keymaps.  Each state has a
 | 
			
		||||
@dfn{global keymap}, where the default key bindings for the state are
 | 
			
		||||
stored.  For example, the global keymap for Normal state is
 | 
			
		||||
@samp{evil-normal-state-map}, and the key bindings in this map are seen
 | 
			
		||||
in all buffers that are currently in Normal state.
 | 
			
		||||
 | 
			
		||||
Keymaps are modified with the Emacs function @samp{define-key}:
 | 
			
		||||
 | 
			
		||||
@lisp
 | 
			
		||||
(define-key evil-normal-state-map "w" 'foo)
 | 
			
		||||
@end lisp
 | 
			
		||||
 | 
			
		||||
@noindent This binds the key @kbd{w} to the command @samp{foo}
 | 
			
		||||
in Normal state.  The file @code{evil-maps.el} contains all the
 | 
			
		||||
key bindings.
 | 
			
		||||
 | 
			
		||||
@defvar evil-normal-state-map
 | 
			
		||||
The global keymap for Normal state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-insert-state-map
 | 
			
		||||
The global keymap for Insert state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-visual-state-map
 | 
			
		||||
The global keymap for Visual state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-replace-state-map
 | 
			
		||||
The global keymap for Replace state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-operator-state-map
 | 
			
		||||
The global keymap for Operator-Pending state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-motion-state-map
 | 
			
		||||
The global keymap for Motion state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@noindent Each state also has a @dfn{buffer-local keymap},
 | 
			
		||||
which is specific to the current buffer and has precedence over
 | 
			
		||||
the global keymap.  These maps may be changed from a mode hook.
 | 
			
		||||
 | 
			
		||||
@defvar evil-normal-state-local-map
 | 
			
		||||
Buffer-local keymap for Normal state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-insert-state-local-map
 | 
			
		||||
Buffer-local keymap for Insert state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-visual-state-local-map
 | 
			
		||||
Buffer-local keymap for Visual state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-replace-state-local-map
 | 
			
		||||
Buffer-local keymap for Replace state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-operator-state-local-map
 | 
			
		||||
Buffer-local keymap for Operator-Pending state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-motion-state-local-map
 | 
			
		||||
Buffer-local keymap for Motion state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@menu
 | 
			
		||||
* @samp{evil-define-key}::
 | 
			
		||||
@end menu
 | 
			
		||||
 | 
			
		||||
@node @samp{evil-define-key}
 | 
			
		||||
@section @samp{evil-define-key}
 | 
			
		||||
 | 
			
		||||
Finally, Evil provides the function @samp{evil-define-key} for adding
 | 
			
		||||
state bindings to a regular keymap.
 | 
			
		||||
 | 
			
		||||
@defun evil-define-key state keymap key def
 | 
			
		||||
In @var{keymap}, create a binding from @var{key} to @var{def} in
 | 
			
		||||
@var{state}.  @var{state} is one of @samp{normal}, @samp{insert},
 | 
			
		||||
@samp{visual}, @samp{replace}, @samp{operator} and @samp{motion}.
 | 
			
		||||
The other parameters are like those of @samp{define-key}.
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@noindent @samp{evil-define-key} can be used to augment existing
 | 
			
		||||
modes with state bindings, as well as create packages for custom
 | 
			
		||||
bindings.  For example, the following will create a minor mode
 | 
			
		||||
@code{foo-mode} with Normal state bindings for the keys @kbd{w}
 | 
			
		||||
and @kbd{e}:
 | 
			
		||||
 | 
			
		||||
@lisp
 | 
			
		||||
(define-minor-mode foo-mode
 | 
			
		||||
  "Foo mode."
 | 
			
		||||
  :keymap (make-sparse-keymap))
 | 
			
		||||
 | 
			
		||||
(evil-define-key 'normal foo-mode-map "w" 'bar)
 | 
			
		||||
(evil-define-key 'normal foo-mode-map "e" 'baz)
 | 
			
		||||
@end lisp
 | 
			
		||||
 | 
			
		||||
@noindent This minor mode can then be enabled in any buffers where
 | 
			
		||||
the custom bindings are desired:
 | 
			
		||||
 | 
			
		||||
@lisp
 | 
			
		||||
(add-hook 'text-mode-hook 'foo-mode) ; @r{enable alongside @code{text-mode}}
 | 
			
		||||
@end lisp
 | 
			
		||||
 | 
			
		||||
@noindent If the minor mode is put into its own file @code{foo.el}
 | 
			
		||||
with a @code{(provide 'foo)} statement, it becomes an Emacs package.
 | 
			
		||||
 | 
			
		||||
@node Hooks
 | 
			
		||||
@chapter Hooks
 | 
			
		||||
 | 
			
		||||
A @dfn{hook} is a list of functions to execute.  Hooks are modified with
 | 
			
		||||
the Emacs function @samp{add-hook}.  Evil provides entry and exit hooks
 | 
			
		||||
for all of its states.
 | 
			
		||||
 | 
			
		||||
@defvar evil-normal-state-entry-hook
 | 
			
		||||
Run when entering Normal state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-normal-state-exit-hook
 | 
			
		||||
Run when exiting Normal state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-insert-state-entry-hook
 | 
			
		||||
Run when entering Insert state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-insert-state-exit-hook
 | 
			
		||||
Run when exiting Insert state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-visual-state-entry-hook
 | 
			
		||||
Run when entering Visual state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-visual-state-exit-hook
 | 
			
		||||
Run when exiting Visual state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-replace-state-entry-hook
 | 
			
		||||
Run when entering Replace state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-replace-state-exit-hook
 | 
			
		||||
Run when exiting Replace state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-operator-state-entry-hook
 | 
			
		||||
Run when entering Operator-Pending state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-operator-state-exit-hook
 | 
			
		||||
Run when exiting Operator-Pending state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-motion-state-entry-hook
 | 
			
		||||
Run when entering Motion state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-motion-state-exit-hook
 | 
			
		||||
Run when exiting Motion state.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@noindent When these hooks are run, the variables @samp{evil-next-state}
 | 
			
		||||
and @samp{evil-previous-state} hold information about the states being
 | 
			
		||||
switched to and from.
 | 
			
		||||
 | 
			
		||||
@defvar evil-next-state
 | 
			
		||||
The state being switched to.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@defvar evil-previous-state
 | 
			
		||||
The state being switched from.
 | 
			
		||||
@end defvar
 | 
			
		||||
 | 
			
		||||
@node Macros
 | 
			
		||||
@chapter Macros
 | 
			
		||||
 | 
			
		||||
Evil is implemented in terms of reusable macros.  Package writers can
 | 
			
		||||
use these to define new commands.
 | 
			
		||||
 | 
			
		||||
@menu
 | 
			
		||||
* Motions::
 | 
			
		||||
* Operators::
 | 
			
		||||
* Text objects::
 | 
			
		||||
* Types::
 | 
			
		||||
* States::
 | 
			
		||||
@end menu
 | 
			
		||||
 | 
			
		||||
@node Motions
 | 
			
		||||
@section Motions
 | 
			
		||||
 | 
			
		||||
A @dfn{motion} is a command which moves the cursor, such as @kbd{w} and
 | 
			
		||||
@kbd{e}.  Motions are defined with the macro @samp{evil-define-motion}.
 | 
			
		||||
Motions not defined in this way should be declared with
 | 
			
		||||
@samp{evil-declare-motion}.
 | 
			
		||||
 | 
			
		||||
@defun evil-declare-motion command
 | 
			
		||||
Declare @var{command} to be a motion.  This ensures that it works
 | 
			
		||||
properly in Visual state.
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@defmac evil-define-motion motion (count args@dots{}) doc keyword-args@dots{} body@dots{}
 | 
			
		||||
Define a movement command @var{motion}.  A motion can have any number of
 | 
			
		||||
arguments, but the first argument, if any, has a predefined meaning as
 | 
			
		||||
the @var{count}. It is a positive or negative number, or @code{nil}.
 | 
			
		||||
The argument list is followed by the documentation string @var{doc},
 | 
			
		||||
which is followed by optional keyword arguments:
 | 
			
		||||
 | 
			
		||||
@table @code
 | 
			
		||||
@item :type @var{type}
 | 
			
		||||
The @var{type} determines how the motion works after an operator.  If
 | 
			
		||||
@var{type} is @samp{inclusive}, then the ending position is included in
 | 
			
		||||
the motion range.  If @var{type} is @samp{line}, then the range is
 | 
			
		||||
expanded to linewise positions.  If @var{type} is @samp{block}, then the
 | 
			
		||||
range is blockwise.  The default is @samp{exclusive}, which means that
 | 
			
		||||
the range is used as-is.
 | 
			
		||||
 | 
			
		||||
@item :jump @var{jump}
 | 
			
		||||
If @var{jump} is @code{t}, then the previous position is stored in the
 | 
			
		||||
jump list so it can be restored with @kbd{C-o}.  The default is
 | 
			
		||||
@code{nil}.
 | 
			
		||||
@end table
 | 
			
		||||
 | 
			
		||||
The keyword arguments are followed by the @var{body}, which is where
 | 
			
		||||
the motion's behavior is defined.  For instance:
 | 
			
		||||
 | 
			
		||||
@lisp
 | 
			
		||||
(evil-define-motion foo-forward (count)
 | 
			
		||||
  "Move to the right by COUNT characters."
 | 
			
		||||
  :type inclusive
 | 
			
		||||
  (forward-char (or count 1)))
 | 
			
		||||
@end lisp
 | 
			
		||||
 | 
			
		||||
For more examples, you can view the source code for any command with
 | 
			
		||||
@kbd{C-h k}.  For instance, @samp{evil-goto-line} may be viewed by
 | 
			
		||||
typing @kbd{C-h k G} and following the file link.
 | 
			
		||||
@end defmac
 | 
			
		||||
 | 
			
		||||
@node Operators
 | 
			
		||||
@section Operators
 | 
			
		||||
 | 
			
		||||
An @dfn{operator} is a command which acts on the text moved over by a
 | 
			
		||||
motion, such as @kbd{c}, @kbd{d} and @kbd{y}.  Operators are defined
 | 
			
		||||
with the macro @samp{evil-define-operator}.
 | 
			
		||||
 | 
			
		||||
@defmac evil-define-operator operator (beg end type args@dots{}) doc keyword-args@dots{} body@dots{}
 | 
			
		||||
Define an operator command @var{operator}.  An operator must have at
 | 
			
		||||
least two or three arguments, which have predefined meanings.
 | 
			
		||||
@var{beg} is the beginning position, @var{end} is the ending position,
 | 
			
		||||
and @var{type}, if given, is the type of the motion range.  The argument
 | 
			
		||||
list is followed by the documentation string @var{doc}, which is
 | 
			
		||||
followed by optional keyword arguments:
 | 
			
		||||
 | 
			
		||||
@table @code
 | 
			
		||||
@item :type @var{type}
 | 
			
		||||
Make the input range be a certain @var{type}.  For example, an operator
 | 
			
		||||
which only works with whole lines may set @var{type} to @samp{line}.
 | 
			
		||||
 | 
			
		||||
@item :motion @var{motion}
 | 
			
		||||
Use the motion @var{motion} instead of reading one from the keyboard.
 | 
			
		||||
This does not affect the behavior in Visual state, where the selection
 | 
			
		||||
boundaries are used instead.
 | 
			
		||||
 | 
			
		||||
@item :repeat @var{repeat}
 | 
			
		||||
If @var{repeat} is @code{t} (the default), then @kbd{.} will repeat the
 | 
			
		||||
operator.  If @var{repeat} is @code{nil}, then the operator will not be
 | 
			
		||||
repeated.
 | 
			
		||||
 | 
			
		||||
@item :move-point @var{move-point}
 | 
			
		||||
If @var{move-point} is @code{t} (the default), then the cursor is
 | 
			
		||||
positioned at the beginning of the range.  If @var{move-point} is
 | 
			
		||||
@code{nil}, then the original position is preserved.
 | 
			
		||||
 | 
			
		||||
@item :keep-visual @var{keep-visual}
 | 
			
		||||
If @var{keep-visual} is @code{t}, then the selection is not disabled
 | 
			
		||||
when the operator is run in Visual state; it is up to the operator to do
 | 
			
		||||
this.  The default is @code{nil}, which means that Visual state is
 | 
			
		||||
exited automatically.
 | 
			
		||||
@end table
 | 
			
		||||
 | 
			
		||||
The keyword arguments are followed by the @var{body}, which is where the
 | 
			
		||||
operator's actions on @var{beg} and @var{end} are defined.  For example,
 | 
			
		||||
@samp{evil-rot13}, which is bound to @kbd{g?} and performs ROT13
 | 
			
		||||
encryption on the text, may be defined as:
 | 
			
		||||
 | 
			
		||||
@lisp
 | 
			
		||||
(evil-define-operator evil-rot13 (beg end)
 | 
			
		||||
  "ROT13 encrypt text."
 | 
			
		||||
  (rot13-region beg end))
 | 
			
		||||
@end lisp
 | 
			
		||||
 | 
			
		||||
Pressing @kbd{g?w} will encrypt a word by calling @samp{rot13-region}
 | 
			
		||||
on the text moved over by the @kbd{w} motion.
 | 
			
		||||
@end defmac
 | 
			
		||||
 | 
			
		||||
@node Text objects
 | 
			
		||||
@section Text objects
 | 
			
		||||
 | 
			
		||||
A @dfn{text object} is a special kind of motion which sets a beginning
 | 
			
		||||
position as well as an ending position, such as @kbd{iw} and @kbd{a(}.
 | 
			
		||||
In Visual state, text objects alter both ends of the selection.  Text
 | 
			
		||||
objects are defined with the macro @samp{evil-define-text-object}.
 | 
			
		||||
 | 
			
		||||
@defmac evil-define-text-object object (count args@dots{}) doc keyword-args@dots{} body@dots{}
 | 
			
		||||
Define a text object @var{object}.  The first argument has a predefined
 | 
			
		||||
meaning as the @var{count}: it is a positive or negative number.  The
 | 
			
		||||
argument list is followed by the documentation string @var{doc}, which
 | 
			
		||||
is followed by optional keyword arguments:
 | 
			
		||||
 | 
			
		||||
@table @code
 | 
			
		||||
@item :type @var{type}
 | 
			
		||||
Use the type @var{type} after an operator.  In Visual state, this is the
 | 
			
		||||
type of the selection.
 | 
			
		||||
 | 
			
		||||
@item :extend-selection @var{extend-selection}
 | 
			
		||||
If @var{extend-selection} is @code{t} (the default), then the text
 | 
			
		||||
object always enlarges the current selection.  If @code{nil}, then the
 | 
			
		||||
object replaces the selection.
 | 
			
		||||
@end table
 | 
			
		||||
 | 
			
		||||
The keyword arguments are followed by the @var{body}, which should
 | 
			
		||||
evaluate to a list @code{(@var{beg} @var{end})} of two positions in the
 | 
			
		||||
buffer.  For example, a text object which selects three characters
 | 
			
		||||
following the current position could be defined as:
 | 
			
		||||
 | 
			
		||||
@lisp
 | 
			
		||||
(evil-define-text-object foo (count)
 | 
			
		||||
  "Select three characters."
 | 
			
		||||
  (list (point) (+ (point) 3)))
 | 
			
		||||
@end lisp
 | 
			
		||||
@end defmac
 | 
			
		||||
 | 
			
		||||
@noindent Evil provides several functions which return a list of
 | 
			
		||||
positions, for use in the definition of a text object.  These functions
 | 
			
		||||
follow the rule that a positive @var{count} selects text after the
 | 
			
		||||
current position, while a negative @var{count} selects text before it.
 | 
			
		||||
 | 
			
		||||
@defun evil-inner-object-range count forward backward
 | 
			
		||||
Return a text range @code{(@var{beg} @var{end})} of @var{count}
 | 
			
		||||
``inner'' text objects (e.g., @kbd{iw}, @kbd{is}).  @var{forward} is a
 | 
			
		||||
function which moves to the end of an object, and @var{backward} is a
 | 
			
		||||
function which moves to the beginning.
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@defun evil-an-object-range count forward backward
 | 
			
		||||
Return a text range @code{(@var{beg} @var{end})} of @var{count} text
 | 
			
		||||
objects with whitespace (e.g., @kbd{aw}, @kbd{as}).  @var{forward} is a
 | 
			
		||||
function which moves to the end of an object, and @var{backward} is a
 | 
			
		||||
function which moves to the beginning.
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@defun evil-paren-range count open close &optional exclusive
 | 
			
		||||
Return a text range @code{(@var{beg} @var{end})} of @var{count}
 | 
			
		||||
delimited blocks (e.g., @kbd{i(}, @kbd{a(}). @var{open} and @var{close}
 | 
			
		||||
are characters.  If @var{exclusive} is non-nil, then the delimiters are
 | 
			
		||||
excluded from the range.  This function uses Emacs' syntax table and is
 | 
			
		||||
only applicable for single-character delimiters; use
 | 
			
		||||
@samp{evil-regexp-range} to match multiple characters.
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@defun evil-regexp-range count open close &optional exclusive
 | 
			
		||||
Return a text range @code{(@var{beg} @var{end})} of @var{count}
 | 
			
		||||
delimited blocks (e.g., @kbd{it}, @kbd{at}). @var{open} and @var{close}
 | 
			
		||||
are regular expressions.  If @var{exclusive} is non-nil, then the
 | 
			
		||||
delimiters are excluded from the range.
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@node Types
 | 
			
		||||
@section Types
 | 
			
		||||
 | 
			
		||||
A @dfn{type} is a transformation on a pair of buffer positions.  Evil
 | 
			
		||||
defines the types @samp{exclusive}, @samp{inclusive}, @samp{line} and
 | 
			
		||||
@samp{block}, which are used for motion ranges and Visual selection.
 | 
			
		||||
Types are defined with the macro @samp{evil-define-type}.
 | 
			
		||||
 | 
			
		||||
@defmac evil-define-type type doc keyword-args@dots{}
 | 
			
		||||
Define a type @var{type}, described by the documentation string
 | 
			
		||||
@var{doc}.  Then follows keyword arguments:
 | 
			
		||||
 | 
			
		||||
@table @code
 | 
			
		||||
@item :expand @var{expand}
 | 
			
		||||
A function which takes two buffer positions and returns a list
 | 
			
		||||
@code{(@var{beg} @var{end})} of expanded positions.
 | 
			
		||||
 | 
			
		||||
@item :contract @var{contract}
 | 
			
		||||
A function which takes two expanded buffer positions and returns a list
 | 
			
		||||
@code{(@var{beg} @var{end})} of unexpanded positions.  Optional.
 | 
			
		||||
 | 
			
		||||
@item :normalize @var{normalize}
 | 
			
		||||
A function which takes two unexpanded buffer positions and returns a
 | 
			
		||||
list @code{(@var{beg} @var{end})} of adjusted positions.  Optional.
 | 
			
		||||
 | 
			
		||||
@item :injective @var{injective}
 | 
			
		||||
If @code{t} (the default), then expansion is one-to-one -- i.e.,
 | 
			
		||||
@var{expand} followed by @var{contract} always returns the original
 | 
			
		||||
positions.  If @code{nil}, then several positions may expand to the same
 | 
			
		||||
(for example, the @samp{line} type is one-to-many as it expands to the
 | 
			
		||||
containing lines).
 | 
			
		||||
@end table
 | 
			
		||||
 | 
			
		||||
Further keywords and functions may be specified.  These are understood
 | 
			
		||||
to be transformations on buffer positions, like @var{expand} and
 | 
			
		||||
@var{contract}.
 | 
			
		||||
@end defmac
 | 
			
		||||
 | 
			
		||||
@node States
 | 
			
		||||
@section States
 | 
			
		||||
 | 
			
		||||
States are defined with the macro @samp{evil-define-state}.  The macro
 | 
			
		||||
defines the necessary hooks, keymaps and variables for a state, as well
 | 
			
		||||
as a toggle function @samp{evil-@var{state}-state} for entering the
 | 
			
		||||
state, and a predicate function @samp{evil-@var{state}-state-p} which
 | 
			
		||||
returns @code{t} when the state is active, and @code{nil} otherwise.
 | 
			
		||||
 | 
			
		||||
@defmac evil-define-state state doc keyword-args@dots{} body@dots{}
 | 
			
		||||
Define an Evil state @var{state}, described by the documentation string
 | 
			
		||||
@var{doc}.  Then follows optional keyword arguments:
 | 
			
		||||
 | 
			
		||||
@table @code
 | 
			
		||||
@item :tag @var{tag}
 | 
			
		||||
Mode line indicitor, e.g., @code{"<T>"}.
 | 
			
		||||
@item :message @var{message}
 | 
			
		||||
String shown in the echo area.
 | 
			
		||||
@item :cursor @var{cursor}
 | 
			
		||||
Cursor specification.
 | 
			
		||||
@item :enable @var{enable}
 | 
			
		||||
List of other modes and states to enable.  A state may enable another
 | 
			
		||||
state's keymaps in addition to its own.
 | 
			
		||||
@end table
 | 
			
		||||
 | 
			
		||||
This is followed the @var{body}, which is executed whenever the state is
 | 
			
		||||
enabled or disabled.  The state's predicate function may be used to
 | 
			
		||||
distinguish between the two.
 | 
			
		||||
@end defmac
 | 
			
		||||
 | 
			
		||||
@node Other internals
 | 
			
		||||
@chapter Other internals
 | 
			
		||||
 | 
			
		||||
@menu
 | 
			
		||||
* Command properties::
 | 
			
		||||
@end menu
 | 
			
		||||
 | 
			
		||||
@node Command properties
 | 
			
		||||
@section Command properties
 | 
			
		||||
 | 
			
		||||
Evil defines @dfn{command properties} to store information about
 | 
			
		||||
commands, such as whether they should be repeated.  A command property
 | 
			
		||||
is a @code{@var{:keyword}} with an associated value, e.g., @code{:repeat
 | 
			
		||||
nil}.
 | 
			
		||||
 | 
			
		||||
@defun evil-add-command-properties command &rest properties
 | 
			
		||||
Add @var{properties} to @var{command}.  The properties should be
 | 
			
		||||
specified as a list of keywords and values:
 | 
			
		||||
 | 
			
		||||
@lisp
 | 
			
		||||
(evil-add-command-properties 'my-command :repeat t)
 | 
			
		||||
@end lisp
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@defun evil-set-command-properties command &rest properties
 | 
			
		||||
Like @samp{evil-add-command-properties}, but resets all
 | 
			
		||||
previous properties.
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@defun evil-get-command-property command property
 | 
			
		||||
Return the value of a command property.
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@defmac evil-define-command command (args@dots{}) doc keyword-args@dots{} body@dots{}
 | 
			
		||||
Define a command with command properties @var{keyword-args}.
 | 
			
		||||
@end defmac
 | 
			
		||||
 | 
			
		||||
@noindent For setting repeat properties, Evil provides the
 | 
			
		||||
following functions:
 | 
			
		||||
 | 
			
		||||
@defun evil-declare-repeat command
 | 
			
		||||
Declare @var{command} to be repeatable.
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@defun evil-declare-not-repeat command
 | 
			
		||||
Declare @var{command} to be nonrepeatable.
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@defun evil-declare-change-repeat command
 | 
			
		||||
Declare @var{command} to be repeatable by buffer changes rather than
 | 
			
		||||
keystrokes.
 | 
			
		||||
@end defun
 | 
			
		||||
 | 
			
		||||
@node GNU Free Documentation License
 | 
			
		||||
@appendix GNU Free Documentation License
 | 
			
		||||
@include fdl-1.3.texi
 | 
			
		||||
 | 
			
		||||
@bye
 | 
			
		||||
 | 
			
		||||
@c Local Variables:
 | 
			
		||||
@c mode: texinfo
 | 
			
		||||
@c TeX-master: t
 | 
			
		||||
@c sentence-end-double-space: t
 | 
			
		||||
@c End:
 | 
			
		||||
| 
						 | 
				
			
			@ -1,506 +0,0 @@
 | 
			
		|||
@c The GNU Free Documentation License.
 | 
			
		||||
@center Version 1.3, 3 November 2008
 | 
			
		||||
 | 
			
		||||
@c This file is intended to be included within another document,
 | 
			
		||||
@c hence no sectioning command or @node.
 | 
			
		||||
 | 
			
		||||
@display
 | 
			
		||||
Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
 | 
			
		||||
@uref{http://fsf.org/}
 | 
			
		||||
 | 
			
		||||
Everyone is permitted to copy and distribute verbatim copies
 | 
			
		||||
of this license document, but changing it is not allowed.
 | 
			
		||||
@end display
 | 
			
		||||
 | 
			
		||||
@enumerate 0
 | 
			
		||||
@item
 | 
			
		||||
PREAMBLE
 | 
			
		||||
 | 
			
		||||
The purpose of this License is to make a manual, textbook, or other
 | 
			
		||||
functional and useful document @dfn{free} in the sense of freedom: to
 | 
			
		||||
assure everyone the effective freedom to copy and redistribute it,
 | 
			
		||||
with or without modifying it, either commercially or noncommercially.
 | 
			
		||||
Secondarily, this License preserves for the author and publisher a way
 | 
			
		||||
to get credit for their work, while not being considered responsible
 | 
			
		||||
for modifications made by others.
 | 
			
		||||
 | 
			
		||||
This License is a kind of ``copyleft'', which means that derivative
 | 
			
		||||
works of the document must themselves be free in the same sense.  It
 | 
			
		||||
complements the GNU General Public License, which is a copyleft
 | 
			
		||||
license designed for free software.
 | 
			
		||||
 | 
			
		||||
We have designed this License in order to use it for manuals for free
 | 
			
		||||
software, because free software needs free documentation: a free
 | 
			
		||||
program should come with manuals providing the same freedoms that the
 | 
			
		||||
software does.  But this License is not limited to software manuals;
 | 
			
		||||
it can be used for any textual work, regardless of subject matter or
 | 
			
		||||
whether it is published as a printed book.  We recommend this License
 | 
			
		||||
principally for works whose purpose is instruction or reference.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
APPLICABILITY AND DEFINITIONS
 | 
			
		||||
 | 
			
		||||
This License applies to any manual or other work, in any medium, that
 | 
			
		||||
contains a notice placed by the copyright holder saying it can be
 | 
			
		||||
distributed under the terms of this License.  Such a notice grants a
 | 
			
		||||
world-wide, royalty-free license, unlimited in duration, to use that
 | 
			
		||||
work under the conditions stated herein.  The ``Document'', below,
 | 
			
		||||
refers to any such manual or work.  Any member of the public is a
 | 
			
		||||
licensee, and is addressed as ``you''.  You accept the license if you
 | 
			
		||||
copy, modify or distribute the work in a way requiring permission
 | 
			
		||||
under copyright law.
 | 
			
		||||
 | 
			
		||||
A ``Modified Version'' of the Document means any work containing the
 | 
			
		||||
Document or a portion of it, either copied verbatim, or with
 | 
			
		||||
modifications and/or translated into another language.
 | 
			
		||||
 | 
			
		||||
A ``Secondary Section'' is a named appendix or a front-matter section
 | 
			
		||||
of the Document that deals exclusively with the relationship of the
 | 
			
		||||
publishers or authors of the Document to the Document's overall
 | 
			
		||||
subject (or to related matters) and contains nothing that could fall
 | 
			
		||||
directly within that overall subject.  (Thus, if the Document is in
 | 
			
		||||
part a textbook of mathematics, a Secondary Section may not explain
 | 
			
		||||
any mathematics.)  The relationship could be a matter of historical
 | 
			
		||||
connection with the subject or with related matters, or of legal,
 | 
			
		||||
commercial, philosophical, ethical or political position regarding
 | 
			
		||||
them.
 | 
			
		||||
 | 
			
		||||
The ``Invariant Sections'' are certain Secondary Sections whose titles
 | 
			
		||||
are designated, as being those of Invariant Sections, in the notice
 | 
			
		||||
that says that the Document is released under this License.  If a
 | 
			
		||||
section does not fit the above definition of Secondary then it is not
 | 
			
		||||
allowed to be designated as Invariant.  The Document may contain zero
 | 
			
		||||
Invariant Sections.  If the Document does not identify any Invariant
 | 
			
		||||
Sections then there are none.
 | 
			
		||||
 | 
			
		||||
The ``Cover Texts'' are certain short passages of text that are listed,
 | 
			
		||||
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
 | 
			
		||||
the Document is released under this License.  A Front-Cover Text may
 | 
			
		||||
be at most 5 words, and a Back-Cover Text may be at most 25 words.
 | 
			
		||||
 | 
			
		||||
A ``Transparent'' copy of the Document means a machine-readable copy,
 | 
			
		||||
represented in a format whose specification is available to the
 | 
			
		||||
general public, that is suitable for revising the document
 | 
			
		||||
straightforwardly with generic text editors or (for images composed of
 | 
			
		||||
pixels) generic paint programs or (for drawings) some widely available
 | 
			
		||||
drawing editor, and that is suitable for input to text formatters or
 | 
			
		||||
for automatic translation to a variety of formats suitable for input
 | 
			
		||||
to text formatters.  A copy made in an otherwise Transparent file
 | 
			
		||||
format whose markup, or absence of markup, has been arranged to thwart
 | 
			
		||||
or discourage subsequent modification by readers is not Transparent.
 | 
			
		||||
An image format is not Transparent if used for any substantial amount
 | 
			
		||||
of text.  A copy that is not ``Transparent'' is called ``Opaque''.
 | 
			
		||||
 | 
			
		||||
Examples of suitable formats for Transparent copies include plain
 | 
			
		||||
ASCII without markup, Texinfo input format, La@TeX{} input
 | 
			
		||||
format, SGML or XML using a publicly available
 | 
			
		||||
DTD, and standard-conforming simple HTML,
 | 
			
		||||
PostScript or PDF designed for human modification.  Examples
 | 
			
		||||
of transparent image formats include PNG, XCF and
 | 
			
		||||
JPG.  Opaque formats include proprietary formats that can be
 | 
			
		||||
read and edited only by proprietary word processors, SGML or
 | 
			
		||||
XML for which the DTD and/or processing tools are
 | 
			
		||||
not generally available, and the machine-generated HTML,
 | 
			
		||||
PostScript or PDF produced by some word processors for
 | 
			
		||||
output purposes only.
 | 
			
		||||
 | 
			
		||||
The ``Title Page'' means, for a printed book, the title page itself,
 | 
			
		||||
plus such following pages as are needed to hold, legibly, the material
 | 
			
		||||
this License requires to appear in the title page.  For works in
 | 
			
		||||
formats which do not have any title page as such, ``Title Page'' means
 | 
			
		||||
the text near the most prominent appearance of the work's title,
 | 
			
		||||
preceding the beginning of the body of the text.
 | 
			
		||||
 | 
			
		||||
The ``publisher'' means any person or entity that distributes copies
 | 
			
		||||
of the Document to the public.
 | 
			
		||||
 | 
			
		||||
A section ``Entitled XYZ'' means a named subunit of the Document whose
 | 
			
		||||
title either is precisely XYZ or contains XYZ in parentheses following
 | 
			
		||||
text that translates XYZ in another language.  (Here XYZ stands for a
 | 
			
		||||
specific section name mentioned below, such as ``Acknowledgements'',
 | 
			
		||||
``Dedications'', ``Endorsements'', or ``History''.)  To ``Preserve the Title''
 | 
			
		||||
of such a section when you modify the Document means that it remains a
 | 
			
		||||
section ``Entitled XYZ'' according to this definition.
 | 
			
		||||
 | 
			
		||||
The Document may include Warranty Disclaimers next to the notice which
 | 
			
		||||
states that this License applies to the Document.  These Warranty
 | 
			
		||||
Disclaimers are considered to be included by reference in this
 | 
			
		||||
License, but only as regards disclaiming warranties: any other
 | 
			
		||||
implication that these Warranty Disclaimers may have is void and has
 | 
			
		||||
no effect on the meaning of this License.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
VERBATIM COPYING
 | 
			
		||||
 | 
			
		||||
You may copy and distribute the Document in any medium, either
 | 
			
		||||
commercially or noncommercially, provided that this License, the
 | 
			
		||||
copyright notices, and the license notice saying this License applies
 | 
			
		||||
to the Document are reproduced in all copies, and that you add no other
 | 
			
		||||
conditions whatsoever to those of this License.  You may not use
 | 
			
		||||
technical measures to obstruct or control the reading or further
 | 
			
		||||
copying of the copies you make or distribute.  However, you may accept
 | 
			
		||||
compensation in exchange for copies.  If you distribute a large enough
 | 
			
		||||
number of copies you must also follow the conditions in section 3.
 | 
			
		||||
 | 
			
		||||
You may also lend copies, under the same conditions stated above, and
 | 
			
		||||
you may publicly display copies.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
COPYING IN QUANTITY
 | 
			
		||||
 | 
			
		||||
If you publish printed copies (or copies in media that commonly have
 | 
			
		||||
printed covers) of the Document, numbering more than 100, and the
 | 
			
		||||
Document's license notice requires Cover Texts, you must enclose the
 | 
			
		||||
copies in covers that carry, clearly and legibly, all these Cover
 | 
			
		||||
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
 | 
			
		||||
the back cover.  Both covers must also clearly and legibly identify
 | 
			
		||||
you as the publisher of these copies.  The front cover must present
 | 
			
		||||
the full title with all words of the title equally prominent and
 | 
			
		||||
visible.  You may add other material on the covers in addition.
 | 
			
		||||
Copying with changes limited to the covers, as long as they preserve
 | 
			
		||||
the title of the Document and satisfy these conditions, can be treated
 | 
			
		||||
as verbatim copying in other respects.
 | 
			
		||||
 | 
			
		||||
If the required texts for either cover are too voluminous to fit
 | 
			
		||||
legibly, you should put the first ones listed (as many as fit
 | 
			
		||||
reasonably) on the actual cover, and continue the rest onto adjacent
 | 
			
		||||
pages.
 | 
			
		||||
 | 
			
		||||
If you publish or distribute Opaque copies of the Document numbering
 | 
			
		||||
more than 100, you must either include a machine-readable Transparent
 | 
			
		||||
copy along with each Opaque copy, or state in or with each Opaque copy
 | 
			
		||||
a computer-network location from which the general network-using
 | 
			
		||||
public has access to download using public-standard network protocols
 | 
			
		||||
a complete Transparent copy of the Document, free of added material.
 | 
			
		||||
If you use the latter option, you must take reasonably prudent steps,
 | 
			
		||||
when you begin distribution of Opaque copies in quantity, to ensure
 | 
			
		||||
that this Transparent copy will remain thus accessible at the stated
 | 
			
		||||
location until at least one year after the last time you distribute an
 | 
			
		||||
Opaque copy (directly or through your agents or retailers) of that
 | 
			
		||||
edition to the public.
 | 
			
		||||
 | 
			
		||||
It is requested, but not required, that you contact the authors of the
 | 
			
		||||
Document well before redistributing any large number of copies, to give
 | 
			
		||||
them a chance to provide you with an updated version of the Document.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
MODIFICATIONS
 | 
			
		||||
 | 
			
		||||
You may copy and distribute a Modified Version of the Document under
 | 
			
		||||
the conditions of sections 2 and 3 above, provided that you release
 | 
			
		||||
the Modified Version under precisely this License, with the Modified
 | 
			
		||||
Version filling the role of the Document, thus licensing distribution
 | 
			
		||||
and modification of the Modified Version to whoever possesses a copy
 | 
			
		||||
of it.  In addition, you must do these things in the Modified Version:
 | 
			
		||||
 | 
			
		||||
@enumerate A
 | 
			
		||||
@item
 | 
			
		||||
Use in the Title Page (and on the covers, if any) a title distinct
 | 
			
		||||
from that of the Document, and from those of previous versions
 | 
			
		||||
(which should, if there were any, be listed in the History section
 | 
			
		||||
of the Document).  You may use the same title as a previous version
 | 
			
		||||
if the original publisher of that version gives permission.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
List on the Title Page, as authors, one or more persons or entities
 | 
			
		||||
responsible for authorship of the modifications in the Modified
 | 
			
		||||
Version, together with at least five of the principal authors of the
 | 
			
		||||
Document (all of its principal authors, if it has fewer than five),
 | 
			
		||||
unless they release you from this requirement.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
State on the Title page the name of the publisher of the
 | 
			
		||||
Modified Version, as the publisher.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
Preserve all the copyright notices of the Document.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
Add an appropriate copyright notice for your modifications
 | 
			
		||||
adjacent to the other copyright notices.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
Include, immediately after the copyright notices, a license notice
 | 
			
		||||
giving the public permission to use the Modified Version under the
 | 
			
		||||
terms of this License, in the form shown in the Addendum below.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
Preserve in that license notice the full lists of Invariant Sections
 | 
			
		||||
and required Cover Texts given in the Document's license notice.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
Include an unaltered copy of this License.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
Preserve the section Entitled ``History'', Preserve its Title, and add
 | 
			
		||||
to it an item stating at least the title, year, new authors, and
 | 
			
		||||
publisher of the Modified Version as given on the Title Page.  If
 | 
			
		||||
there is no section Entitled ``History'' in the Document, create one
 | 
			
		||||
stating the title, year, authors, and publisher of the Document as
 | 
			
		||||
given on its Title Page, then add an item describing the Modified
 | 
			
		||||
Version as stated in the previous sentence.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
Preserve the network location, if any, given in the Document for
 | 
			
		||||
public access to a Transparent copy of the Document, and likewise
 | 
			
		||||
the network locations given in the Document for previous versions
 | 
			
		||||
it was based on.  These may be placed in the ``History'' section.
 | 
			
		||||
You may omit a network location for a work that was published at
 | 
			
		||||
least four years before the Document itself, or if the original
 | 
			
		||||
publisher of the version it refers to gives permission.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
 | 
			
		||||
the Title of the section, and preserve in the section all the
 | 
			
		||||
substance and tone of each of the contributor acknowledgements and/or
 | 
			
		||||
dedications given therein.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
Preserve all the Invariant Sections of the Document,
 | 
			
		||||
unaltered in their text and in their titles.  Section numbers
 | 
			
		||||
or the equivalent are not considered part of the section titles.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
Delete any section Entitled ``Endorsements''.  Such a section
 | 
			
		||||
may not be included in the Modified Version.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
Do not retitle any existing section to be Entitled ``Endorsements'' or
 | 
			
		||||
to conflict in title with any Invariant Section.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
Preserve any Warranty Disclaimers.
 | 
			
		||||
@end enumerate
 | 
			
		||||
 | 
			
		||||
If the Modified Version includes new front-matter sections or
 | 
			
		||||
appendices that qualify as Secondary Sections and contain no material
 | 
			
		||||
copied from the Document, you may at your option designate some or all
 | 
			
		||||
of these sections as invariant.  To do this, add their titles to the
 | 
			
		||||
list of Invariant Sections in the Modified Version's license notice.
 | 
			
		||||
These titles must be distinct from any other section titles.
 | 
			
		||||
 | 
			
		||||
You may add a section Entitled ``Endorsements'', provided it contains
 | 
			
		||||
nothing but endorsements of your Modified Version by various
 | 
			
		||||
parties---for example, statements of peer review or that the text has
 | 
			
		||||
been approved by an organization as the authoritative definition of a
 | 
			
		||||
standard.
 | 
			
		||||
 | 
			
		||||
You may add a passage of up to five words as a Front-Cover Text, and a
 | 
			
		||||
passage of up to 25 words as a Back-Cover Text, to the end of the list
 | 
			
		||||
of Cover Texts in the Modified Version.  Only one passage of
 | 
			
		||||
Front-Cover Text and one of Back-Cover Text may be added by (or
 | 
			
		||||
through arrangements made by) any one entity.  If the Document already
 | 
			
		||||
includes a cover text for the same cover, previously added by you or
 | 
			
		||||
by arrangement made by the same entity you are acting on behalf of,
 | 
			
		||||
you may not add another; but you may replace the old one, on explicit
 | 
			
		||||
permission from the previous publisher that added the old one.
 | 
			
		||||
 | 
			
		||||
The author(s) and publisher(s) of the Document do not by this License
 | 
			
		||||
give permission to use their names for publicity for or to assert or
 | 
			
		||||
imply endorsement of any Modified Version.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
COMBINING DOCUMENTS
 | 
			
		||||
 | 
			
		||||
You may combine the Document with other documents released under this
 | 
			
		||||
License, under the terms defined in section 4 above for modified
 | 
			
		||||
versions, provided that you include in the combination all of the
 | 
			
		||||
Invariant Sections of all of the original documents, unmodified, and
 | 
			
		||||
list them all as Invariant Sections of your combined work in its
 | 
			
		||||
license notice, and that you preserve all their Warranty Disclaimers.
 | 
			
		||||
 | 
			
		||||
The combined work need only contain one copy of this License, and
 | 
			
		||||
multiple identical Invariant Sections may be replaced with a single
 | 
			
		||||
copy.  If there are multiple Invariant Sections with the same name but
 | 
			
		||||
different contents, make the title of each such section unique by
 | 
			
		||||
adding at the end of it, in parentheses, the name of the original
 | 
			
		||||
author or publisher of that section if known, or else a unique number.
 | 
			
		||||
Make the same adjustment to the section titles in the list of
 | 
			
		||||
Invariant Sections in the license notice of the combined work.
 | 
			
		||||
 | 
			
		||||
In the combination, you must combine any sections Entitled ``History''
 | 
			
		||||
in the various original documents, forming one section Entitled
 | 
			
		||||
``History''; likewise combine any sections Entitled ``Acknowledgements'',
 | 
			
		||||
and any sections Entitled ``Dedications''.  You must delete all
 | 
			
		||||
sections Entitled ``Endorsements.''
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
COLLECTIONS OF DOCUMENTS
 | 
			
		||||
 | 
			
		||||
You may make a collection consisting of the Document and other documents
 | 
			
		||||
released under this License, and replace the individual copies of this
 | 
			
		||||
License in the various documents with a single copy that is included in
 | 
			
		||||
the collection, provided that you follow the rules of this License for
 | 
			
		||||
verbatim copying of each of the documents in all other respects.
 | 
			
		||||
 | 
			
		||||
You may extract a single document from such a collection, and distribute
 | 
			
		||||
it individually under this License, provided you insert a copy of this
 | 
			
		||||
License into the extracted document, and follow this License in all
 | 
			
		||||
other respects regarding verbatim copying of that document.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
AGGREGATION WITH INDEPENDENT WORKS
 | 
			
		||||
 | 
			
		||||
A compilation of the Document or its derivatives with other separate
 | 
			
		||||
and independent documents or works, in or on a volume of a storage or
 | 
			
		||||
distribution medium, is called an ``aggregate'' if the copyright
 | 
			
		||||
resulting from the compilation is not used to limit the legal rights
 | 
			
		||||
of the compilation's users beyond what the individual works permit.
 | 
			
		||||
When the Document is included in an aggregate, this License does not
 | 
			
		||||
apply to the other works in the aggregate which are not themselves
 | 
			
		||||
derivative works of the Document.
 | 
			
		||||
 | 
			
		||||
If the Cover Text requirement of section 3 is applicable to these
 | 
			
		||||
copies of the Document, then if the Document is less than one half of
 | 
			
		||||
the entire aggregate, the Document's Cover Texts may be placed on
 | 
			
		||||
covers that bracket the Document within the aggregate, or the
 | 
			
		||||
electronic equivalent of covers if the Document is in electronic form.
 | 
			
		||||
Otherwise they must appear on printed covers that bracket the whole
 | 
			
		||||
aggregate.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
TRANSLATION
 | 
			
		||||
 | 
			
		||||
Translation is considered a kind of modification, so you may
 | 
			
		||||
distribute translations of the Document under the terms of section 4.
 | 
			
		||||
Replacing Invariant Sections with translations requires special
 | 
			
		||||
permission from their copyright holders, but you may include
 | 
			
		||||
translations of some or all Invariant Sections in addition to the
 | 
			
		||||
original versions of these Invariant Sections.  You may include a
 | 
			
		||||
translation of this License, and all the license notices in the
 | 
			
		||||
Document, and any Warranty Disclaimers, provided that you also include
 | 
			
		||||
the original English version of this License and the original versions
 | 
			
		||||
of those notices and disclaimers.  In case of a disagreement between
 | 
			
		||||
the translation and the original version of this License or a notice
 | 
			
		||||
or disclaimer, the original version will prevail.
 | 
			
		||||
 | 
			
		||||
If a section in the Document is Entitled ``Acknowledgements'',
 | 
			
		||||
``Dedications'', or ``History'', the requirement (section 4) to Preserve
 | 
			
		||||
its Title (section 1) will typically require changing the actual
 | 
			
		||||
title.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
TERMINATION
 | 
			
		||||
 | 
			
		||||
You may not copy, modify, sublicense, or distribute the Document
 | 
			
		||||
except as expressly provided under this License.  Any attempt
 | 
			
		||||
otherwise to copy, modify, sublicense, or distribute it is void, and
 | 
			
		||||
will automatically terminate your rights under this License.
 | 
			
		||||
 | 
			
		||||
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, receipt of a copy of some or all of the same material does
 | 
			
		||||
not give you any rights to use it.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
FUTURE REVISIONS OF THIS LICENSE
 | 
			
		||||
 | 
			
		||||
The Free Software Foundation may publish new, revised versions
 | 
			
		||||
of the GNU Free Documentation 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.  See
 | 
			
		||||
@uref{http://www.gnu.org/copyleft/}.
 | 
			
		||||
 | 
			
		||||
Each version of the License is given a distinguishing version number.
 | 
			
		||||
If the Document specifies that a particular numbered version of this
 | 
			
		||||
License ``or any later version'' applies to it, you have the option of
 | 
			
		||||
following the terms and conditions either of that specified version or
 | 
			
		||||
of any later version that has been published (not as a draft) by the
 | 
			
		||||
Free Software Foundation.  If the Document does not specify a version
 | 
			
		||||
number of this License, you may choose any version ever published (not
 | 
			
		||||
as a draft) by the Free Software Foundation.  If the Document
 | 
			
		||||
specifies that a proxy can decide which future versions of this
 | 
			
		||||
License can be used, that proxy's public statement of acceptance of a
 | 
			
		||||
version permanently authorizes you to choose that version for the
 | 
			
		||||
Document.
 | 
			
		||||
 | 
			
		||||
@item
 | 
			
		||||
RELICENSING
 | 
			
		||||
 | 
			
		||||
``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any
 | 
			
		||||
World Wide Web server that publishes copyrightable works and also
 | 
			
		||||
provides prominent facilities for anybody to edit those works.  A
 | 
			
		||||
public wiki that anybody can edit is an example of such a server.  A
 | 
			
		||||
``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the
 | 
			
		||||
site means any set of copyrightable works thus published on the MMC
 | 
			
		||||
site.
 | 
			
		||||
 | 
			
		||||
``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0
 | 
			
		||||
license published by Creative Commons Corporation, a not-for-profit
 | 
			
		||||
corporation with a principal place of business in San Francisco,
 | 
			
		||||
California, as well as future copyleft versions of that license
 | 
			
		||||
published by that same organization.
 | 
			
		||||
 | 
			
		||||
``Incorporate'' means to publish or republish a Document, in whole or
 | 
			
		||||
in part, as part of another Document.
 | 
			
		||||
 | 
			
		||||
An MMC is ``eligible for relicensing'' if it is licensed under this
 | 
			
		||||
License, and if all works that were first published under this License
 | 
			
		||||
somewhere other than this MMC, and subsequently incorporated in whole
 | 
			
		||||
or in part into the MMC, (1) had no cover texts or invariant sections,
 | 
			
		||||
and (2) were thus incorporated prior to November 1, 2008.
 | 
			
		||||
 | 
			
		||||
The operator of an MMC Site may republish an MMC contained in the site
 | 
			
		||||
under CC-BY-SA on the same site at any time before August 1, 2009,
 | 
			
		||||
provided the MMC is eligible for relicensing.
 | 
			
		||||
 | 
			
		||||
@end enumerate
 | 
			
		||||
 | 
			
		||||
@page
 | 
			
		||||
@heading ADDENDUM: How to use this License for your documents
 | 
			
		||||
 | 
			
		||||
To use this License in a document you have written, include a copy of
 | 
			
		||||
the License in the document and put the following copyright and
 | 
			
		||||
license notices just after the title page:
 | 
			
		||||
 | 
			
		||||
@smallexample
 | 
			
		||||
@group
 | 
			
		||||
  Copyright (C)  @var{year}  @var{your name}.
 | 
			
		||||
  Permission is granted to copy, distribute and/or modify this document
 | 
			
		||||
  under the terms of the GNU Free Documentation License, Version 1.3
 | 
			
		||||
  or any later version published by the Free Software Foundation;
 | 
			
		||||
  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
 | 
			
		||||
  Texts.  A copy of the license is included in the section entitled ``GNU
 | 
			
		||||
  Free Documentation License''.
 | 
			
		||||
@end group
 | 
			
		||||
@end smallexample
 | 
			
		||||
 | 
			
		||||
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
 | 
			
		||||
replace the ``with@dots{}Texts.'' line with this:
 | 
			
		||||
 | 
			
		||||
@smallexample
 | 
			
		||||
@group
 | 
			
		||||
    with the Invariant Sections being @var{list their titles}, with
 | 
			
		||||
    the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
 | 
			
		||||
    being @var{list}.
 | 
			
		||||
@end group
 | 
			
		||||
@end smallexample
 | 
			
		||||
 | 
			
		||||
If you have Invariant Sections without Cover Texts, or some other
 | 
			
		||||
combination of the three, merge those two alternatives to suit the
 | 
			
		||||
situation.
 | 
			
		||||
 | 
			
		||||
If your document contains nontrivial examples of program code, we
 | 
			
		||||
recommend releasing these examples in parallel under your choice of
 | 
			
		||||
free software license, such as the GNU General Public License,
 | 
			
		||||
to permit their use in free software.
 | 
			
		||||
 | 
			
		||||
@c Local Variables:
 | 
			
		||||
@c ispell-local-pdict: "ispell-dict"
 | 
			
		||||
@c End:
 | 
			
		||||
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 3.2 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 2.1 KiB  | 
| 
						 | 
				
			
			@ -1,110 +0,0 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 | 
			
		||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
 | 
			
		||||
 | 
			
		||||
<svg
 | 
			
		||||
   xmlns:dc="http://purl.org/dc/elements/1.1/"
 | 
			
		||||
   xmlns:cc="http://creativecommons.org/ns#"
 | 
			
		||||
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 | 
			
		||||
   xmlns:svg="http://www.w3.org/2000/svg"
 | 
			
		||||
   xmlns="http://www.w3.org/2000/svg"
 | 
			
		||||
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
 | 
			
		||||
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
 | 
			
		||||
   width="127.82534"
 | 
			
		||||
   height="62.426407"
 | 
			
		||||
   id="svg2"
 | 
			
		||||
   version="1.1"
 | 
			
		||||
   inkscape:version="0.48.0 r9654"
 | 
			
		||||
   sodipodi:docname="evil.svg"
 | 
			
		||||
   inkscape:export-filename="/home/vegard/evil.png"
 | 
			
		||||
   inkscape:export-xdpi="150"
 | 
			
		||||
   inkscape:export-ydpi="150">
 | 
			
		||||
  <defs
 | 
			
		||||
     id="defs4" />
 | 
			
		||||
  <sodipodi:namedview
 | 
			
		||||
     id="base"
 | 
			
		||||
     pagecolor="#ffffff"
 | 
			
		||||
     bordercolor="#666666"
 | 
			
		||||
     borderopacity="1.0"
 | 
			
		||||
     inkscape:pageopacity="0.0"
 | 
			
		||||
     inkscape:pageshadow="2"
 | 
			
		||||
     inkscape:zoom="2.2069466"
 | 
			
		||||
     inkscape:cx="173.13654"
 | 
			
		||||
     inkscape:cy="12.652914"
 | 
			
		||||
     inkscape:document-units="px"
 | 
			
		||||
     inkscape:current-layer="layer1"
 | 
			
		||||
     showgrid="false"
 | 
			
		||||
     inkscape:window-width="1680"
 | 
			
		||||
     inkscape:window-height="998"
 | 
			
		||||
     inkscape:window-x="0"
 | 
			
		||||
     inkscape:window-y="24"
 | 
			
		||||
     inkscape:window-maximized="1"
 | 
			
		||||
     fit-margin-left="10"
 | 
			
		||||
     fit-margin-top="10"
 | 
			
		||||
     fit-margin-right="10"
 | 
			
		||||
     fit-margin-bottom="10"
 | 
			
		||||
     showguides="true"
 | 
			
		||||
     inkscape:guide-bbox="true" />
 | 
			
		||||
  <metadata
 | 
			
		||||
     id="metadata7">
 | 
			
		||||
    <rdf:RDF>
 | 
			
		||||
      <cc:Work
 | 
			
		||||
         rdf:about="">
 | 
			
		||||
        <dc:format>image/svg+xml</dc:format>
 | 
			
		||||
        <dc:type
 | 
			
		||||
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
 | 
			
		||||
        <dc:title></dc:title>
 | 
			
		||||
      </cc:Work>
 | 
			
		||||
    </rdf:RDF>
 | 
			
		||||
  </metadata>
 | 
			
		||||
  <g
 | 
			
		||||
     inkscape:label="Layer 1"
 | 
			
		||||
     inkscape:groupmode="layer"
 | 
			
		||||
     id="layer1"
 | 
			
		||||
     transform="translate(-165.00893,-164.53963)">
 | 
			
		||||
    <rect
 | 
			
		||||
       style="fill:#000000"
 | 
			
		||||
       id="rect2991"
 | 
			
		||||
       width="30.809652"
 | 
			
		||||
       height="42.426407"
 | 
			
		||||
       x="175.00893"
 | 
			
		||||
       y="174.53963" />
 | 
			
		||||
    <text
 | 
			
		||||
       xml:space="preserve"
 | 
			
		||||
       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
 | 
			
		||||
       x="178.15302"
 | 
			
		||||
       y="209.50504"
 | 
			
		||||
       id="text2985"
 | 
			
		||||
       sodipodi:linespacing="125%"><tspan
 | 
			
		||||
         sodipodi:role="line"
 | 
			
		||||
         id="tspan2987"
 | 
			
		||||
         x="178.15302"
 | 
			
		||||
         y="209.50504"
 | 
			
		||||
         style="font-weight:bold;letter-spacing:5.28999996px;-inkscape-font-specification:Ubuntu Bold"><tspan
 | 
			
		||||
           style="letter-spacing:6.60000228999999994px;fill:#ffffff"
 | 
			
		||||
           id="tspan2989">E</tspan><tspan
 | 
			
		||||
           style="fill:#333333"
 | 
			
		||||
           id="tspan2995">VIL</tspan></tspan></text>
 | 
			
		||||
    <g
 | 
			
		||||
       style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
 | 
			
		||||
       id="text2997"
 | 
			
		||||
       transform="matrix(0.89694705,0.44213798,-0.44213798,0.89694705,260.2961,-122.4502)">
 | 
			
		||||
      <path
 | 
			
		||||
         d="m 144.8919,272.13985 c 0.57684,-0.24621 1.4908,-0.78829 1.94103,-1.23149 0.46429,-0.46428 0.81251,-0.98134 1.04466,-1.55116 0.23214,-0.5698 0.33721,-0.99165 0.33722,-1.62479 0.0155,-0.43449 -0.28674,-1.22826 -0.57298,-1.8313 -0.26496,-0.55821 -0.52007,-1.02571 -0.52007,-1.02571 l -1.99277,2.29588 0.22983,-5.91917 5.5976,0.45081 -2.34283,1.96492 c 0,0 0.49752,1.04212 0.73633,1.68916 0.23881,0.64704 0.58739,1.34614 0.66973,2.19566 0.0366,0.62546 -0.16181,1.70241 -0.4854,2.4903 -0.33767,0.79493 -0.81956,1.50544 -1.44564,2.13152 -0.59093,0.58389 -1.53465,1.17717 -2.35067,1.54297"
 | 
			
		||||
         style="fill:#333333"
 | 
			
		||||
         id="path3002"
 | 
			
		||||
         inkscape:connector-curvature="0"
 | 
			
		||||
         sodipodi:nodetypes="ccscsccccczcccc" />
 | 
			
		||||
    </g>
 | 
			
		||||
    <text
 | 
			
		||||
       xml:space="preserve"
 | 
			
		||||
       style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
 | 
			
		||||
       x="309.28571"
 | 
			
		||||
       y="111.6479"
 | 
			
		||||
       id="text3011"
 | 
			
		||||
       sodipodi:linespacing="125%"><tspan
 | 
			
		||||
         sodipodi:role="line"
 | 
			
		||||
         id="tspan3013"
 | 
			
		||||
         x="309.28571"
 | 
			
		||||
         y="111.6479" /></text>
 | 
			
		||||
  </g>
 | 
			
		||||
</svg>
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 4.3 KiB  | 
| 
						 | 
				
			
			@ -1,13 +0,0 @@
 | 
			
		|||
@c -*-texinfo-*-
 | 
			
		||||
@c This is part of the Evil manual.
 | 
			
		||||
@c Copyright (C) 2011 Frank Fischer and Vegard Øye.
 | 
			
		||||
@c See the file evil.texi for copying conditions.
 | 
			
		||||
 | 
			
		||||
@ifclear macros
 | 
			
		||||
@set macros
 | 
			
		||||
 | 
			
		||||
@macro authors {}
 | 
			
		||||
Frank Fischer and Vegard Øye
 | 
			
		||||
@end macro
 | 
			
		||||
 | 
			
		||||
@end ifclear
 | 
			
		||||
| 
						 | 
				
			
			@ -1,7 +0,0 @@
 | 
			
		|||
@c -*-texinfo-*-
 | 
			
		||||
@c This is part of the Evil manual.
 | 
			
		||||
@c Copyright (C) 2011 Frank Fischer and Vegard Øye.
 | 
			
		||||
@c See the file evil.texi for copying conditions.
 | 
			
		||||
 | 
			
		||||
@set VERSION 0.1
 | 
			
		||||
@set UPDATED 2011-07-30
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,449 +0,0 @@
 | 
			
		|||
;;; 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.9
 | 
			
		||||
 | 
			
		||||
;;
 | 
			
		||||
;; 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)
 | 
			
		||||
(require 'evil-macros)
 | 
			
		||||
(require 'evil-types)
 | 
			
		||||
(require 'evil-repeat)
 | 
			
		||||
 | 
			
		||||
;;; Code:
 | 
			
		||||
 | 
			
		||||
;;; Evilize some commands
 | 
			
		||||
 | 
			
		||||
;; unbound keys should be ignored
 | 
			
		||||
(evil-declare-ignore-repeat 'undefined)
 | 
			
		||||
 | 
			
		||||
(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
 | 
			
		||||
        redo
 | 
			
		||||
        save-buffer
 | 
			
		||||
        split-window
 | 
			
		||||
        split-window-horizontally
 | 
			
		||||
        split-window-vertically
 | 
			
		||||
        undo
 | 
			
		||||
        undo-tree-redo
 | 
			
		||||
        undo-tree-undo))
 | 
			
		||||
 | 
			
		||||
(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
 | 
			
		||||
 | 
			
		||||
;; 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
 | 
			
		||||
     (defvar dired-mode-map)
 | 
			
		||||
     (evil-make-overriding-map dired-mode-map 'normal)
 | 
			
		||||
     (evil-add-hjkl-bindings dired-mode-map 'normal
 | 
			
		||||
       "J" 'dired-goto-file                   ; "j"
 | 
			
		||||
       "K" 'dired-do-kill-lines               ; "k"
 | 
			
		||||
       "r" 'dired-do-redisplay                ; "l"
 | 
			
		||||
       ;; ":d", ":v", ":s", ":e"
 | 
			
		||||
       ";" (lookup-key dired-mode-map ":"))))
 | 
			
		||||
 | 
			
		||||
(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
 | 
			
		||||
        (dolist (ov '(show-paren--overlay
 | 
			
		||||
                      show-paren--overlay-1
 | 
			
		||||
                      show-paren-overlay
 | 
			
		||||
                      show-paren-overlay-1))
 | 
			
		||||
          (let ((ov (and (boundp ov) (symbol-value ov))))
 | 
			
		||||
            (when (overlayp ov) (delete-overlay ov))))))))
 | 
			
		||||
 | 
			
		||||
;;; 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
 | 
			
		||||
     (defvar ibuffer-mode-map)
 | 
			
		||||
     (evil-make-overriding-map ibuffer-mode-map 'normal)
 | 
			
		||||
     (evil-define-key 'normal ibuffer-mode-map
 | 
			
		||||
       "j" 'evil-next-line
 | 
			
		||||
       "k" 'evil-previous-line
 | 
			
		||||
       "RET" 'ibuffer-visit-buffer)))
 | 
			
		||||
 | 
			
		||||
;;; Undo tree
 | 
			
		||||
(when (and (require 'undo-tree nil t)
 | 
			
		||||
           (fboundp 'global-undo-tree-mode))
 | 
			
		||||
  (global-undo-tree-mode 1))
 | 
			
		||||
 | 
			
		||||
(eval-after-load 'undo-tree
 | 
			
		||||
  '(progn
 | 
			
		||||
     (defun evil-turn-on-undo-tree-mode ()
 | 
			
		||||
       "Enable `undo-tree-mode' if evil is enabled.
 | 
			
		||||
This function enables `undo-tree-mode' when Evil is activated in
 | 
			
		||||
some buffer, but only if `global-undo-tree-mode' is also
 | 
			
		||||
activated."
 | 
			
		||||
       (when global-undo-tree-mode (undo-tree-mode 1)))
 | 
			
		||||
 | 
			
		||||
     (add-hook 'evil-local-mode-hook #'evil-turn-on-undo-tree-mode)
 | 
			
		||||
 | 
			
		||||
     (defadvice undo-tree-visualize (after evil activate)
 | 
			
		||||
       "Initialize Evil in the visualization buffer."
 | 
			
		||||
       (when evil-local-mode
 | 
			
		||||
         (evil-initialize-state)))
 | 
			
		||||
 | 
			
		||||
     (when (fboundp 'undo-tree-visualize)
 | 
			
		||||
       (evil-ex-define-cmd "undol[ist]" 'undo-tree-visualize)
 | 
			
		||||
       (evil-ex-define-cmd "ul" 'undo-tree-visualize))
 | 
			
		||||
 | 
			
		||||
     (when (boundp 'undo-tree-visualizer-mode-map)
 | 
			
		||||
       (define-key undo-tree-visualizer-mode-map
 | 
			
		||||
         [remap evil-backward-char] 'undo-tree-visualize-switch-branch-left)
 | 
			
		||||
       (define-key undo-tree-visualizer-mode-map
 | 
			
		||||
         [remap evil-forward-char] 'undo-tree-visualize-switch-branch-right)
 | 
			
		||||
       (define-key undo-tree-visualizer-mode-map
 | 
			
		||||
         [remap evil-next-line] 'undo-tree-visualize-redo)
 | 
			
		||||
       (define-key undo-tree-visualizer-mode-map
 | 
			
		||||
         [remap evil-previous-line] 'undo-tree-visualize-undo)
 | 
			
		||||
       (define-key undo-tree-visualizer-mode-map
 | 
			
		||||
         [remap evil-ret] 'undo-tree-visualizer-set))
 | 
			
		||||
 | 
			
		||||
     (when (boundp 'undo-tree-visualizer-selection-mode-map)
 | 
			
		||||
       (define-key undo-tree-visualizer-selection-mode-map
 | 
			
		||||
         [remap evil-backward-char] 'undo-tree-visualizer-select-left)
 | 
			
		||||
       (define-key undo-tree-visualizer-selection-mode-map
 | 
			
		||||
         [remap evil-forward-char] 'undo-tree-visualizer-select-right)
 | 
			
		||||
       (define-key undo-tree-visualizer-selection-mode-map
 | 
			
		||||
         [remap evil-next-line] 'undo-tree-visualizer-select-next)
 | 
			
		||||
       (define-key undo-tree-visualizer-selection-mode-map
 | 
			
		||||
         [remap evil-previous-line] 'undo-tree-visualizer-select-previous)
 | 
			
		||||
       (define-key undo-tree-visualizer-selection-mode-map
 | 
			
		||||
         [remap evil-ret] 'undo-tree-visualizer-set))))
 | 
			
		||||
 | 
			
		||||
;;; Auto-complete
 | 
			
		||||
(eval-after-load 'auto-complete
 | 
			
		||||
  '(progn
 | 
			
		||||
     (evil-add-command-properties 'auto-complete :repeat 'evil-ac-repeat)
 | 
			
		||||
     (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.")
 | 
			
		||||
 | 
			
		||||
     (defvar ac-prefix)
 | 
			
		||||
     (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))))))
 | 
			
		||||
 | 
			
		||||
;;; Company
 | 
			
		||||
(eval-after-load 'company
 | 
			
		||||
  '(progn
 | 
			
		||||
     (mapc #'evil-declare-change-repeat
 | 
			
		||||
           '(company-complete-mouse
 | 
			
		||||
             company-complete-selection
 | 
			
		||||
             company-complete-common))
 | 
			
		||||
 | 
			
		||||
     (mapc #'evil-declare-ignore-repeat
 | 
			
		||||
           '(company-abort
 | 
			
		||||
             company-select-next
 | 
			
		||||
             company-select-previous
 | 
			
		||||
             company-select-next-or-abort
 | 
			
		||||
             company-select-previous-or-abort
 | 
			
		||||
             company-select-mouse
 | 
			
		||||
             company-show-doc-buffer
 | 
			
		||||
             company-show-location
 | 
			
		||||
             company-search-candidates
 | 
			
		||||
             company-filter-candidates))))
 | 
			
		||||
 | 
			
		||||
;; Eval last sexp
 | 
			
		||||
(defadvice preceding-sexp (around evil activate)
 | 
			
		||||
  "In normal-state or motion-state, last sexp ends at point."
 | 
			
		||||
  (if (or (evil-normal-state-p) (evil-motion-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 or motion-state, last sexp ends at point."
 | 
			
		||||
  (if (or (evil-normal-state-p) (evil-motion-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))
 | 
			
		||||
 | 
			
		||||
;; ace-jump-mode
 | 
			
		||||
(declare-function 'ace-jump-char-mode "ace-jump-mode")
 | 
			
		||||
(declare-function 'ace-jump-word-mode "ace-jump-mode")
 | 
			
		||||
(declare-function 'ace-jump-line-mode "ace-jump-mode")
 | 
			
		||||
 | 
			
		||||
(defvar evil-ace-jump-active nil)
 | 
			
		||||
 | 
			
		||||
(defmacro evil-enclose-ace-jump-for-motion (&rest body)
 | 
			
		||||
  "Enclose ace-jump to make it suitable for motions.
 | 
			
		||||
This includes restricting `ace-jump-mode' to the current window
 | 
			
		||||
in visual and operator state, deactivating visual updates, saving
 | 
			
		||||
the mark and entering `recursive-edit'."
 | 
			
		||||
  (declare (indent defun)
 | 
			
		||||
           (debug t))
 | 
			
		||||
  `(let ((old-mark (mark))
 | 
			
		||||
         (ace-jump-mode-scope
 | 
			
		||||
          (if (and (not (memq evil-state '(visual operator)))
 | 
			
		||||
                   (boundp 'ace-jump-mode-scope))
 | 
			
		||||
              ace-jump-mode-scope
 | 
			
		||||
            'window)))
 | 
			
		||||
     (remove-hook 'pre-command-hook #'evil-visual-pre-command t)
 | 
			
		||||
     (remove-hook 'post-command-hook #'evil-visual-post-command t)
 | 
			
		||||
     (unwind-protect
 | 
			
		||||
         (let ((evil-ace-jump-active 'prepare))
 | 
			
		||||
           (add-hook 'ace-jump-mode-end-hook
 | 
			
		||||
                     #'evil-ace-jump-exit-recursive-edit)
 | 
			
		||||
           ,@body
 | 
			
		||||
           (when evil-ace-jump-active
 | 
			
		||||
             (setq evil-ace-jump-active t)
 | 
			
		||||
             (recursive-edit)))
 | 
			
		||||
       (remove-hook 'post-command-hook
 | 
			
		||||
                    #'evil-ace-jump-exit-recursive-edit)
 | 
			
		||||
       (remove-hook 'ace-jump-mode-end-hook
 | 
			
		||||
                    #'evil-ace-jump-exit-recursive-edit)
 | 
			
		||||
       (if (evil-visual-state-p)
 | 
			
		||||
           (progn
 | 
			
		||||
             (add-hook 'pre-command-hook #'evil-visual-pre-command nil t)
 | 
			
		||||
             (add-hook 'post-command-hook #'evil-visual-post-command nil t)
 | 
			
		||||
             (set-mark old-mark))
 | 
			
		||||
         (push-mark old-mark)))))
 | 
			
		||||
 | 
			
		||||
(eval-after-load 'ace-jump-mode
 | 
			
		||||
  `(defadvice ace-jump-done (after evil activate)
 | 
			
		||||
     (when evil-ace-jump-active
 | 
			
		||||
       (add-hook 'post-command-hook #'evil-ace-jump-exit-recursive-edit))))
 | 
			
		||||
 | 
			
		||||
(defun evil-ace-jump-exit-recursive-edit ()
 | 
			
		||||
  "Exit a recursive edit caused by an evil jump."
 | 
			
		||||
  (cond
 | 
			
		||||
   ((eq evil-ace-jump-active 'prepare)
 | 
			
		||||
    (setq evil-ace-jump-active nil))
 | 
			
		||||
   (evil-ace-jump-active
 | 
			
		||||
    (remove-hook 'post-command-hook #'evil-ace-jump-exit-recursive-edit)
 | 
			
		||||
    (exit-recursive-edit))))
 | 
			
		||||
 | 
			
		||||
(evil-define-motion evil-ace-jump-char-mode (count)
 | 
			
		||||
  "Jump visually directly to a char using ace-jump."
 | 
			
		||||
  :type inclusive
 | 
			
		||||
  (evil-without-repeat
 | 
			
		||||
    (let ((pnt (point))
 | 
			
		||||
          (buf (current-buffer)))
 | 
			
		||||
      (evil-enclose-ace-jump-for-motion
 | 
			
		||||
        (call-interactively 'ace-jump-char-mode))
 | 
			
		||||
      ;; if we jump backwards, motion type is exclusive, analogously
 | 
			
		||||
      ;; to `evil-find-char-backward'
 | 
			
		||||
      (when (and (equal buf (current-buffer))
 | 
			
		||||
                 (< (point) pnt))
 | 
			
		||||
        (setq evil-this-type 'exclusive)))))
 | 
			
		||||
 | 
			
		||||
(evil-define-motion evil-ace-jump-char-to-mode (count)
 | 
			
		||||
  "Jump visually to the char in front of a char using ace-jump."
 | 
			
		||||
  :type inclusive
 | 
			
		||||
  (evil-without-repeat
 | 
			
		||||
    (let ((pnt (point))
 | 
			
		||||
          (buf (current-buffer)))
 | 
			
		||||
      (evil-enclose-ace-jump-for-motion
 | 
			
		||||
        (call-interactively 'ace-jump-char-mode))
 | 
			
		||||
      (if (and (equal buf (current-buffer))
 | 
			
		||||
               (< (point) pnt))
 | 
			
		||||
          (progn
 | 
			
		||||
            (or (eobp) (forward-char))
 | 
			
		||||
            (setq evil-this-type 'exclusive))
 | 
			
		||||
        (backward-char)))))
 | 
			
		||||
 | 
			
		||||
(evil-define-motion evil-ace-jump-line-mode (count)
 | 
			
		||||
  "Jump visually to the beginning of a line using ace-jump."
 | 
			
		||||
  :type line
 | 
			
		||||
  :repeat abort
 | 
			
		||||
  (evil-without-repeat
 | 
			
		||||
    (evil-enclose-ace-jump-for-motion
 | 
			
		||||
      (call-interactively 'ace-jump-line-mode))))
 | 
			
		||||
 | 
			
		||||
(evil-define-motion evil-ace-jump-word-mode (count)
 | 
			
		||||
  "Jump visually to the beginning of a word using ace-jump."
 | 
			
		||||
  :type exclusive
 | 
			
		||||
  :repeat abort
 | 
			
		||||
  (evil-without-repeat
 | 
			
		||||
    (evil-enclose-ace-jump-for-motion
 | 
			
		||||
      (call-interactively 'ace-jump-word-mode))))
 | 
			
		||||
 | 
			
		||||
(define-key evil-motion-state-map [remap ace-jump-char-mode] #'evil-ace-jump-char-mode)
 | 
			
		||||
(define-key evil-motion-state-map [remap ace-jump-line-mode] #'evil-ace-jump-line-mode)
 | 
			
		||||
(define-key evil-motion-state-map [remap ace-jump-word-mode] #'evil-ace-jump-word-mode)
 | 
			
		||||
 | 
			
		||||
;;; nXhtml/mumamo
 | 
			
		||||
;; ensure that mumamo does not toggle evil through its globalized mode
 | 
			
		||||
(eval-after-load 'mumamo
 | 
			
		||||
  '(push 'evil-mode-cmhh mumamo-change-major-mode-no-nos))
 | 
			
		||||
 | 
			
		||||
(provide 'evil-integration)
 | 
			
		||||
 | 
			
		||||
;;; evil-integration.el ends here
 | 
			
		||||
| 
						 | 
				
			
			@ -1,764 +0,0 @@
 | 
			
		|||
;;; evil-macros.el --- Macros
 | 
			
		||||
 | 
			
		||||
;; Author: Vegard Øye <vegard_oye at hotmail.com>
 | 
			
		||||
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
 | 
			
		||||
 | 
			
		||||
;; Version: 1.0.9
 | 
			
		||||
 | 
			
		||||
;;
 | 
			
		||||
;; 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")
 | 
			
		||||
 | 
			
		||||
;; set some error codes
 | 
			
		||||
(put 'beginning-of-line 'error-conditions '(beginning-of-line error))
 | 
			
		||||
(put 'beginning-of-line 'error-message "Beginning of line")
 | 
			
		||||
(put 'end-of-line 'error-conditions '(end-of-line error))
 | 
			
		||||
(put 'end-of-line 'error-message "End of line")
 | 
			
		||||
 | 
			
		||||
(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)
 | 
			
		||||
                         ;; some operators depend on succeeding
 | 
			
		||||
                         ;; motions, in particular for
 | 
			
		||||
                         ;; `evil-forward-char' (e.g., used by
 | 
			
		||||
                         ;; `evil-substitute'), therefore we let
 | 
			
		||||
                         ;; end-of-line and end-of-buffer pass
 | 
			
		||||
                         (if (not (memq (car err) '(end-of-line end-of-buffer)))
 | 
			
		||||
                             (signal (car err) (cdr err))
 | 
			
		||||
                           (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
 | 
			
		||||
           '(and (fboundp 'eldoc-add-command)
 | 
			
		||||
                 (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))
 | 
			
		||||
              (signal 'beginning-of-line nil)))
 | 
			
		||||
           (end-of-buffer
 | 
			
		||||
            (if (= end max)
 | 
			
		||||
                (signal (car err) (cdr err))
 | 
			
		||||
              (signal 'end-of-line nil))))))))
 | 
			
		||||
 | 
			
		||||
;; 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 (and (evil-visual-state-p)
 | 
			
		||||
                            (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
 | 
			
		||||
| 
						 | 
				
			
			@ -1,504 +0,0 @@
 | 
			
		|||
;;; evil-maps.el --- Default keymaps
 | 
			
		||||
 | 
			
		||||
;; Author: Vegard Øye <vegard_oye at hotmail.com>
 | 
			
		||||
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
 | 
			
		||||
 | 
			
		||||
;; Version: 1.0.9
 | 
			
		||||
 | 
			
		||||
;;
 | 
			
		||||
;; 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)
 | 
			
		||||
(require 'evil-commands)
 | 
			
		||||
 | 
			
		||||
;;; 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 "z=" 'ispell-word)
 | 
			
		||||
(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)
 | 
			
		||||
(define-key evil-normal-state-map "\C-r" '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" 'evil-window-delete)
 | 
			
		||||
(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" 'evil-window-split)
 | 
			
		||||
(define-key evil-window-map "S" 'evil-window-split)
 | 
			
		||||
(define-key evil-window-map "t" 'evil-window-top-left)
 | 
			
		||||
(define-key evil-window-map "v" 'evil-window-vsplit)
 | 
			
		||||
(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" 'evil-window-delete)
 | 
			
		||||
(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" 'evil-window-split)
 | 
			
		||||
(define-key evil-window-map "\C-S" 'evil-window-split)
 | 
			
		||||
(define-key evil-window-map "\C-t" 'evil-window-top-left)
 | 
			
		||||
(define-key evil-window-map "\C-v" 'evil-window-vsplit)
 | 
			
		||||
(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 "gm" 'evil-middle-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-word-backward)
 | 
			
		||||
(define-key evil-motion-state-map "g#" 'evil-search-unbounded-word-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-word-forward)
 | 
			
		||||
(define-key evil-motion-state-map "g*" 'evil-search-unbounded-word-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 "zl" 'evil-scroll-column-right)
 | 
			
		||||
(define-key evil-motion-state-map [?z right] "zl")
 | 
			
		||||
(define-key evil-motion-state-map "zh" 'evil-scroll-column-left)
 | 
			
		||||
(define-key evil-motion-state-map [?z left] "zh")
 | 
			
		||||
(define-key evil-motion-state-map "zL" 'evil-scroll-right)
 | 
			
		||||
(define-key evil-motion-state-map "zH" 'evil-scroll-left)
 | 
			
		||||
(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)
 | 
			
		||||
(define-key evil-motion-state-map "gn" 'evil-next-match)
 | 
			
		||||
(define-key evil-motion-state-map "gN" 'evil-previous-match)
 | 
			
		||||
 | 
			
		||||
(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 "z=" 'ispell-word)
 | 
			
		||||
(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 "\C-t" 'evil-shift-right-line)
 | 
			
		||||
(define-key evil-insert-state-map "\C-d" 'evil-shift-left-line)
 | 
			
		||||
(define-key evil-insert-state-map [remap delete-backward-char] 'evil-delete-backward-char-and-join)
 | 
			
		||||
(define-key evil-insert-state-map [delete] 'delete-char)
 | 
			
		||||
(define-key evil-insert-state-map [remap newline] 'evil-ret)
 | 
			
		||||
(define-key evil-insert-state-map [remap newline-and-indent] 'evil-ret-and-indent)
 | 
			
		||||
(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)
 | 
			
		||||
(define-key evil-motion-state-map "!" 'evil-shell-command)
 | 
			
		||||
 | 
			
		||||
(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" 'buffer-menu)
 | 
			
		||||
(evil-ex-define-cmd "files" 'evil-show-files)
 | 
			
		||||
(evil-ex-define-cmd "ls" "buffers")
 | 
			
		||||
 | 
			
		||||
(evil-ex-define-cmd "c[hange]" 'evil-change)
 | 
			
		||||
(evil-ex-define-cmd "co[py]" 'evil-copy)
 | 
			
		||||
(evil-ex-define-cmd "t" "copy")
 | 
			
		||||
(evil-ex-define-cmd "m[ove]" 'evil-move)
 | 
			
		||||
(evil-ex-define-cmd "d[elete]" 'evil-delete)
 | 
			
		||||
(evil-ex-define-cmd "y[ank]" 'evil-yank)
 | 
			
		||||
(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]" 'evil-window-delete)
 | 
			
		||||
(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 "norm[al]" 'evil-ex-normal)
 | 
			
		||||
(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)
 | 
			
		||||
(evil-ex-define-cmd "show-digraphs" 'evil-ex-show-digraphs)
 | 
			
		||||
 | 
			
		||||
;; search command line
 | 
			
		||||
(define-key evil-ex-search-keymap "\d" #'evil-ex-delete-backward-char)
 | 
			
		||||
 | 
			
		||||
;; ex command line
 | 
			
		||||
(define-key evil-ex-completion-map "\d" #'evil-ex-delete-backward-char)
 | 
			
		||||
(define-key evil-ex-completion-map "\t" #'evil-ex-completion)
 | 
			
		||||
(define-key evil-ex-completion-map [tab] #'evil-ex-completion)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-a" 'evil-ex-completion)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-b" 'move-beginning-of-line)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-c" 'abort-recursive-edit)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-d" 'evil-ex-completion)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-g" 'abort-recursive-edit)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-k" 'evil-insert-digraph)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-l" 'evil-ex-completion)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-p" #'next-complete-history-element)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-r" 'evil-paste-from-register)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-n" #'next-complete-history-element)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-u" 'evil-delete-whole-line)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-v" #'quoted-insert)
 | 
			
		||||
(define-key evil-ex-completion-map "\C-w" 'backward-kill-word)
 | 
			
		||||
(define-key evil-ex-completion-map [escape] 'abort-recursive-edit)
 | 
			
		||||
(define-key evil-ex-completion-map [S-left] 'backward-word)
 | 
			
		||||
(define-key evil-ex-completion-map [S-right] 'forward-word)
 | 
			
		||||
(define-key evil-ex-completion-map [up] 'previous-complete-history-element)
 | 
			
		||||
(define-key evil-ex-completion-map [down] 'next-complete-history-element)
 | 
			
		||||
(define-key evil-ex-completion-map [prior] 'previous-history-element)
 | 
			
		||||
(define-key evil-ex-completion-map [next] 'next-history-element)
 | 
			
		||||
(define-key evil-ex-completion-map [return] 'exit-minibuffer)
 | 
			
		||||
(define-key evil-ex-completion-map (kbd "RET") 'exit-minibuffer)
 | 
			
		||||
 | 
			
		||||
;; 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 (kbd "C-k") #'evil-read-digraph-char)
 | 
			
		||||
(define-key evil-read-key-map "\r" "\n")
 | 
			
		||||
 | 
			
		||||
(provide 'evil-maps)
 | 
			
		||||
 | 
			
		||||
;;; evil-maps.el ends here
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +0,0 @@
 | 
			
		|||
(define-package
 | 
			
		||||
  "evil"
 | 
			
		||||
  "1.0.9"
 | 
			
		||||
  "Extensible Vi layer for Emacs."
 | 
			
		||||
  '((undo-tree "0.6.3")
 | 
			
		||||
    (goto-chg "1.6")))
 | 
			
		||||
| 
						 | 
				
			
			@ -1,629 +0,0 @@
 | 
			
		|||
;;; 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.9
 | 
			
		||||
 | 
			
		||||
;;
 | 
			
		||||
;; 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")
 | 
			
		||||
 | 
			
		||||
(defmacro evil-without-repeat (&rest body)
 | 
			
		||||
  (declare (indent defun)
 | 
			
		||||
           (debug t))
 | 
			
		||||
  `(let ((pre-command-hook (remq 'evil-repeat-pre-hook pre-command-hook))
 | 
			
		||||
         (post-command-hook (remq 'evil-repeat-post-hook post-command-hook)))
 | 
			
		||||
     ,@body
 | 
			
		||||
     (evil-repeat-abort)))
 | 
			
		||||
 | 
			
		||||
(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)
 | 
			
		||||
    (when evil-this-register
 | 
			
		||||
      (evil-repeat-record
 | 
			
		||||
       `(set evil-this-register ,evil-this-register)))
 | 
			
		||||
    (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))
 | 
			
		||||
        (let ((input-method current-input-method)
 | 
			
		||||
              (evil-input-method nil))
 | 
			
		||||
          (deactivate-input-method)
 | 
			
		||||
          (unwind-protect
 | 
			
		||||
              (execute-kbd-macro rep)
 | 
			
		||||
            (activate-input-method input-method))))
 | 
			
		||||
       ((consp rep)
 | 
			
		||||
        (when (and (= 3 (length rep))
 | 
			
		||||
                   (eq (nth 0 rep) 'set)
 | 
			
		||||
                   (eq (nth 1 rep) 'evil-this-register)
 | 
			
		||||
                   (>= (nth 2 rep) ?0)
 | 
			
		||||
                   (< (nth 2 rep) ?9))
 | 
			
		||||
          (setcar (nthcdr 2 rep) (1+ (nth 2 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
											
										
									
								
							| 
						 | 
				
			
			@ -1,873 +0,0 @@
 | 
			
		|||
;;; evil-states.el --- States
 | 
			
		||||
 | 
			
		||||
;; Author: Vegard Øye <vegard_oye at hotmail.com>
 | 
			
		||||
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
 | 
			
		||||
 | 
			
		||||
;; Version: 1.0.9
 | 
			
		||||
 | 
			
		||||
;;
 | 
			
		||||
;; 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 (or (evil-initializing-p)
 | 
			
		||||
              (null this-command))
 | 
			
		||||
    (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))
 | 
			
		||||
    (when evil-visual-x-select-timer
 | 
			
		||||
      (cancel-timer evil-visual-x-select-timer))
 | 
			
		||||
    (unless (evil-get-command-property command :keep-visual)
 | 
			
		||||
      (evil-visual-update-x-selection)
 | 
			
		||||
      (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))
 | 
			
		||||
    (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."
 | 
			
		||||
  (let ((buf (or buffer (current-buffer))))
 | 
			
		||||
    (when (buffer-live-p buf)
 | 
			
		||||
      (with-current-buffer buf
 | 
			
		||||
        (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)
 | 
			
		||||
      (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 --"
 | 
			
		||||
  :input-method t
 | 
			
		||||
  (cond
 | 
			
		||||
   ((evil-replace-state-p)
 | 
			
		||||
    (overwrite-mode 1)
 | 
			
		||||
    (add-hook 'pre-command-hook #'evil-replace-pre-command nil t)
 | 
			
		||||
    (unless evil-want-fine-undo
 | 
			
		||||
      (evil-start-undo-step t)))
 | 
			
		||||
   (t
 | 
			
		||||
    (overwrite-mode -1)
 | 
			
		||||
    (remove-hook 'pre-command-hook #'evil-replace-pre-command t)
 | 
			
		||||
    (unless evil-want-fine-undo
 | 
			
		||||
      (evil-end-undo-step 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
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,375 +0,0 @@
 | 
			
		|||
;;; evil-types.el --- Type system
 | 
			
		||||
 | 
			
		||||
;; Author: Vegard Øye <vegard_oye at hotmail.com>
 | 
			
		||||
;; Maintainer: Vegard Øye <vegard_oye at hotmail.com>
 | 
			
		||||
 | 
			
		||||
;; Version: 1.0.9
 | 
			
		||||
 | 
			
		||||
;;
 | 
			
		||||
;; 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
 | 
			
		||||
   (if (evil-operator-state-p)
 | 
			
		||||
       (evil-without-restriction (evil-read-key))
 | 
			
		||||
     (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 "<addr>"
 | 
			
		||||
  "Ex line number."
 | 
			
		||||
  (list
 | 
			
		||||
   (and (evil-ex-p)
 | 
			
		||||
        (let ((expr (evil-ex-parse  evil-ex-argument)))
 | 
			
		||||
          (if (eq (car expr) 'evil-goto-line)
 | 
			
		||||
              (save-excursion
 | 
			
		||||
                (goto-char evil-ex-point)
 | 
			
		||||
                (eval (cadr expr)))
 | 
			
		||||
            (error "Invalid address"))))))
 | 
			
		||||
 | 
			
		||||
(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 t)))
 | 
			
		||||
 | 
			
		||||
(provide 'evil-types)
 | 
			
		||||
 | 
			
		||||
;;; evil-types.el ends here
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,125 +0,0 @@
 | 
			
		|||
;;; evil.el --- extensible vi layer
 | 
			
		||||
 | 
			
		||||
;; Authors:
 | 
			
		||||
;;      Alessandro Piras <laynor@gmail.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 shadow-soft.de>
 | 
			
		||||
;;      Frank Terbeck <ft at bewatermyfriend.org>
 | 
			
		||||
;;      Gordon Gustafson <gordon3.14@gmail.com>
 | 
			
		||||
;;      Jonathan Claggett <jclaggett at lonocloud.com>
 | 
			
		||||
;;      José A. Romero L. <escherdragon@gmail.com>
 | 
			
		||||
;;      Lars Andersen <expez at expez.com>
 | 
			
		||||
;;      Lintaro Ina <tarao.gnn at gmail.com>
 | 
			
		||||
;;      Lukasz Wrzosek <wrzoski@gmail.com>
 | 
			
		||||
;;      Marian Schubert <maio@netsafe.cz>
 | 
			
		||||
;;      Michael Markert <markert.michael at googlemail.com>
 | 
			
		||||
;;      Nikolai Weibull <now at bitwi.se>
 | 
			
		||||
;;      phaebz <phaebz at gmail.com>
 | 
			
		||||
;;      Sanel Zukan <sanelz at gmail.com>
 | 
			
		||||
;;      Sarah Brofeldt <sarah at thinkmonster.(none)>
 | 
			
		||||
;;      Simon Hafner <hafnersimon at gmail.com>
 | 
			
		||||
;;      Stefan Wehr <mail at stefanwehr.de>
 | 
			
		||||
;;      Sune Simonsen <sune.simonsen at jayway.com>
 | 
			
		||||
;;      Thomas Hisch <thomas at opentech.at>
 | 
			
		||||
;;      Trevor Murphy <trevor.m.murphy at gmail.com>
 | 
			
		||||
;;      Ulrich Müller <ulm at gentoo.org>
 | 
			
		||||
;;      Vegard Øye <vegard_oye at hotmail.com>
 | 
			
		||||
;;      Winfred Lu <winfred.lu@gmail.com>
 | 
			
		||||
;;      Wolfgang Jenkner <wjenkner at inode.at>
 | 
			
		||||
;;      Xiao Hanyu <xiaohanyu1988 at gmail.com>
 | 
			
		||||
;;      York Zhao <yzhao at telecor.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.9
 | 
			
		||||
;; 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
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +0,0 @@
 | 
			
		|||
This folder contains external libraries that are freely distributable
 | 
			
		||||
under the GNU GPL license. They may not be up to date.
 | 
			
		||||
 | 
			
		||||
Emacs does not add subdirectories to the `load-path' by default.
 | 
			
		||||
Therefore this directory is not covered by the installation
 | 
			
		||||
instructions.
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,317 +0,0 @@
 | 
			
		|||
;;; goto-chg.el --- goto last change
 | 
			
		||||
;;--------------------------------------------------------------------
 | 
			
		||||
;;
 | 
			
		||||
;; Copyright (C) 2002-2008, David Andersson
 | 
			
		||||
;;
 | 
			
		||||
;; 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 2 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, write to the Free
 | 
			
		||||
;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 | 
			
		||||
;; MA 02111-1307 USA
 | 
			
		||||
;;
 | 
			
		||||
;;-------------------------------------------------------------------
 | 
			
		||||
;;
 | 
			
		||||
;; Author: David Andersson <l.david.andersson(at)sverige.nu>
 | 
			
		||||
;; Created: 16 May 2002
 | 
			
		||||
;; Version: 1.4
 | 
			
		||||
;;
 | 
			
		||||
;;; Commentary:
 | 
			
		||||
;;
 | 
			
		||||
;; Goto Last Change
 | 
			
		||||
;;
 | 
			
		||||
;; Goto the point of the most recent edit in the buffer.
 | 
			
		||||
;; When repeated, goto the second most recent edit, etc.
 | 
			
		||||
;; Negative argument, C-u -, for reverse direction.
 | 
			
		||||
;; Works by looking into buffer-undo-list to find points of edit.
 | 
			
		||||
;;
 | 
			
		||||
;; You would probably like to bind this command to a key.
 | 
			
		||||
;; For example in your ~/.emacs:
 | 
			
		||||
;;
 | 
			
		||||
;;   (require 'goto-chg)
 | 
			
		||||
;;
 | 
			
		||||
;;   (global-set-key [(control ?.)] 'goto-last-change)
 | 
			
		||||
;;   (global-set-key [(control ?,)] 'goto-last-change-reverse)
 | 
			
		||||
;;
 | 
			
		||||
;; Works with emacs-19.29, 19.31, 20.3, 20.7, 21.1, 21.4 and 22.1.
 | 
			
		||||
;; Works with XEmacs-20.4 and 21.4 (but see todo about `last-command' below)
 | 
			
		||||
;;
 | 
			
		||||
;;--------------------------------------------------------------------
 | 
			
		||||
;; History
 | 
			
		||||
;;
 | 
			
		||||
;; Ver 1.4 2008-09-20 David Andersson
 | 
			
		||||
;;    Improved property change description; Update comments.
 | 
			
		||||
;; Ver 1.3 2007-03-14 David Andersson
 | 
			
		||||
;;    Added `goto-last-change-reverse'
 | 
			
		||||
;; Ver 1.2 2003-04-06 David Andersson
 | 
			
		||||
;;    Don't let repeating error depthen glc-probe-depth.
 | 
			
		||||
;; Ver 1.1 2003-04-06 David Andersson
 | 
			
		||||
;;    Zero arg describe changes. Negative arg go back.
 | 
			
		||||
;;    Autoload. Remove message using nil in stead of an empty string.
 | 
			
		||||
;; Ver 1.0 2002-05-18 David Andersson
 | 
			
		||||
;;    Initial version
 | 
			
		||||
;;
 | 
			
		||||
;;--------------------------------------------------------------------
 | 
			
		||||
;;
 | 
			
		||||
;;todo: Rename "goto-chg.el" -> "gotochange.el" or "goto-chgs" ?
 | 
			
		||||
;;todo: Rename function goto-last-change -> goto-last-edit ?
 | 
			
		||||
;;todo: Rename adjective "-last-" -> "-latest-" or "-most-recent-" ?
 | 
			
		||||
;;todo: There are some, maybe useful, funcs  for region undo 
 | 
			
		||||
;;       in simple.el in emacs 20. Take a look.
 | 
			
		||||
;;todo: Add functionality to visit changed point in text order, not only in
 | 
			
		||||
;;        chronological order. (Naa, highlight-changes-mode does that).
 | 
			
		||||
;;todo: Inverse indication that a change has been saved or not
 | 
			
		||||
;;todo: Highlight the range of text involved in the last change?
 | 
			
		||||
;;todo: Function that goes in reverse direction. Either a function
 | 
			
		||||
;;        'goto-next-change' only callable after 'goto-last-change'
 | 
			
		||||
;;        or enter a minor mode similar to isearch.
 | 
			
		||||
;;todo: See session-jump-to-last-change in session.el?
 | 
			
		||||
;;todo: Unhide invisible text (e.g. outline mode) like isearch do.
 | 
			
		||||
;;todo: XEmacs sets last-command to `t' after an error, so you cannot reverse
 | 
			
		||||
;;        after "No furter change info". Should we bother?
 | 
			
		||||
;;todo: Try distinguish "No further change info" (end of truncated undo list)
 | 
			
		||||
;;        and "No further changes" (end of a complete undo list).
 | 
			
		||||
;;
 | 
			
		||||
;;--------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
;;; Code:
 | 
			
		||||
 | 
			
		||||
(defvar glc-default-span 8 "*goto-last-change don't visit the same point twice. glc-default-span tells how far around a visited point not to visit again.")
 | 
			
		||||
(defvar glc-current-span 8 "Internal for goto-last-change.\nA copy of glc-default-span or the ARG passed to goto-last-change.")
 | 
			
		||||
(defvar glc-probe-depth 0 "Internal for goto-last-change.\nIt is non-zero between successive goto-last-change.")
 | 
			
		||||
 | 
			
		||||
;;todo: Find begin and end of line, then use it somewhere
 | 
			
		||||
 | 
			
		||||
(defun glc-center-ellipsis (str maxlen &optional ellipsis)
 | 
			
		||||
  "Truncate STRING in the middle to length MAXLEN.
 | 
			
		||||
If STRING is max MAXLEN just return the string.
 | 
			
		||||
Optional third argument is the replacement, which defaults to \"...\"."
 | 
			
		||||
  (if (<= (length str) maxlen)
 | 
			
		||||
      str
 | 
			
		||||
    ;; else
 | 
			
		||||
    (let* ((lipsis (or ellipsis "..."))
 | 
			
		||||
	   (i (/ (- maxlen (length lipsis)) 2)))
 | 
			
		||||
      (concat (substring str 0 i)
 | 
			
		||||
	      lipsis 
 | 
			
		||||
	      (substring str (- i))))))
 | 
			
		||||
 | 
			
		||||
(defun glc-adjust-pos2 (pos p1 p2 adj)
 | 
			
		||||
  ;; Helper function to glc-adjust-pos
 | 
			
		||||
  (cond ((<= pos (- p1 glc-current-span))
 | 
			
		||||
	 pos)
 | 
			
		||||
	((> pos (+ p2 glc-current-span))
 | 
			
		||||
	 (+ pos adj))
 | 
			
		||||
	((zerop glc-current-span)
 | 
			
		||||
	 p1)
 | 
			
		||||
	(t
 | 
			
		||||
	 nil)))
 | 
			
		||||
 | 
			
		||||
(defun glc-adjust-pos (pos e)
 | 
			
		||||
  "Given POS, a buffer position before the edit E, compute and return
 | 
			
		||||
the \"same\" buffer position after E happened.
 | 
			
		||||
Exception: return nil if POS is closer than `glc-current-span' to the edit E.
 | 
			
		||||
\nInsertion edits before POS returns a larger value.
 | 
			
		||||
Deletion edits before POS returns a smaller value.
 | 
			
		||||
\nThe edit E is an entry from the `buffer-undo-list'. See for details."
 | 
			
		||||
  (cond ((atom e)			; nil==cmd boundary, or, num==changed pos
 | 
			
		||||
	 pos)
 | 
			
		||||
	((numberp (car e))		; (beg . end)==insertion
 | 
			
		||||
	 (glc-adjust-pos2 pos (car e) (car e) (- (cdr e) (car e))))
 | 
			
		||||
;; 	 (cond ((< pos (- (car e) glc-current-span)) pos)
 | 
			
		||||
;; 	       ((> pos (+ (car e) glc-current-span)) (+ pos (- (cdr e) (car e))))
 | 
			
		||||
;; 	       (t nil)))
 | 
			
		||||
	((stringp (car e))		; (string . pos)==deletion
 | 
			
		||||
	 (glc-adjust-pos2 pos (abs (cdr e)) (+ (abs (cdr e)) (length (car e))) (- (length (car e)))))
 | 
			
		||||
;; 	 (cond ((< pos (- (abs (cdr e)) glc-current-span)) pos)
 | 
			
		||||
;; 	       ((> pos (+ (abs (cdr e)) (length (car e)) glc-current-span)) (- pos (length (car e))))
 | 
			
		||||
;; 	       (t nil)))
 | 
			
		||||
	((null (car e))			; (nil prop val beg . end)==prop change
 | 
			
		||||
	 (glc-adjust-pos2 pos (nth 3 e) (nthcdr 4 e) 0))
 | 
			
		||||
;; 	 (cond ((< pos (- (nth 3 e) glc-current-span)) pos)
 | 
			
		||||
;; 	       ((> pos (+ (nthcdr 4 e) glc-current-span)) pos)
 | 
			
		||||
;; 	       (t nil)))
 | 
			
		||||
	(t				; (marker . dist)==marker moved
 | 
			
		||||
	 pos)))
 | 
			
		||||
 | 
			
		||||
;; If recursive in stead of iterative (while), it tends to fill the call stack.
 | 
			
		||||
;; (Isn't it tail optimized?)
 | 
			
		||||
(defun glc-adjust-list (r)
 | 
			
		||||
  "R is list of edit entries in chronological order.
 | 
			
		||||
Pick the point of the first edit entry and update that point with
 | 
			
		||||
the second, third, etc, edit entries. Return the final updated point,
 | 
			
		||||
or nil if the point was closer than `glc-current-span' to some edit in R.
 | 
			
		||||
\nR is basically a reversed slice from the buffer-undo-list."
 | 
			
		||||
  (if r
 | 
			
		||||
      ;; Get pos
 | 
			
		||||
      (let ((pos (glc-get-pos (car r))))
 | 
			
		||||
	(setq r (cdr r))
 | 
			
		||||
	;; Walk back in reverse list
 | 
			
		||||
	(while (and r pos)
 | 
			
		||||
	  (setq pos (glc-adjust-pos pos (car r))
 | 
			
		||||
		r (cdr r)))
 | 
			
		||||
	pos)
 | 
			
		||||
    ;; else
 | 
			
		||||
    nil))
 | 
			
		||||
 | 
			
		||||
(defun glc-get-pos (e)
 | 
			
		||||
  "If E represents an edit, return a position value in E, the position
 | 
			
		||||
where the edit took place. Return nil if E represents no real change.
 | 
			
		||||
\nE is a entry in the buffer-undo-list."
 | 
			
		||||
  (cond ((numberp e) e)			; num==changed position
 | 
			
		||||
	((atom e) nil)			; nil==command boundary
 | 
			
		||||
	((numberp (car e)) (cdr e))	; (beg . end)==insertion
 | 
			
		||||
	((stringp (car e)) (abs (cdr e))) ; (string . pos)==deletion
 | 
			
		||||
	((null (car e)) (nthcdr 4 e))	; (nil ...)==text property change
 | 
			
		||||
	((atom (car e)) nil)		; (t ...)==file modification time
 | 
			
		||||
	(t nil)))			; (marker ...)==marker moved
 | 
			
		||||
 | 
			
		||||
(defun glc-get-descript (e &optional n)
 | 
			
		||||
  "If E represents an edit, return a short string describing E.
 | 
			
		||||
Return nil if E represents no real change.
 | 
			
		||||
\nE is a entry in the buffer-undo-list."
 | 
			
		||||
  (let ((nn (or (format "T-%d: " n) "")))
 | 
			
		||||
    (cond ((numberp e) "New position")	; num==changed position
 | 
			
		||||
	  ((atom e) nil)		; nil==command boundary
 | 
			
		||||
	  ((numberp (car e))		; (beg . end)==insertion
 | 
			
		||||
	   (if (and n (< n 2))
 | 
			
		||||
	       (format "%sInserted %d chars \"%s\"" nn (- (cdr e) (car e)) 
 | 
			
		||||
		       (glc-center-ellipsis (buffer-substring (car e) (cdr e)) 60))
 | 
			
		||||
	     ;; else
 | 
			
		||||
	     ;; An older insert. The inserted text cannot easily be computed.
 | 
			
		||||
	     ;; Just show the char count.
 | 
			
		||||
	     (format "%sInserted %d chars" nn (- (cdr e) (car e)))))
 | 
			
		||||
	  ((stringp (car e))		; (string . pos)==deletion
 | 
			
		||||
	   (format "%sDeleted \"%s\"" nn (glc-center-ellipsis (car e) 60)))
 | 
			
		||||
	  ((null (car e))		; (nil ...)==text property change
 | 
			
		||||
	   (format "%sProperty change" nn))
 | 
			
		||||
	  ((atom (car e)) nil)		; (t ...)==file modification time
 | 
			
		||||
	  (t nil))))			; (marker ...)==marker moved
 | 
			
		||||
 | 
			
		||||
(defun glc-is-positionable (e)
 | 
			
		||||
  "Return non-nil if E is an insertion, deletion or text property change.
 | 
			
		||||
\nE is a entry in the buffer-undo-list."
 | 
			
		||||
  (and (not (numberp e)) (glc-get-pos e)))
 | 
			
		||||
 | 
			
		||||
(defun glc-is-filetime (e)
 | 
			
		||||
  "Return t if E indicates a buffer became \"modified\",
 | 
			
		||||
that is, it was previously saved or unchanged. Nil otherwise."
 | 
			
		||||
  (and (listp e) (eq (car e) t)))
 | 
			
		||||
 | 
			
		||||
;;;###autoload
 | 
			
		||||
(defun goto-last-change (arg)
 | 
			
		||||
"Go to the point where the last edit was made in the current buffer.
 | 
			
		||||
Repeat the command to go to the second last edit, etc.
 | 
			
		||||
A preceding \\[universal-argument] - (minus) will reverse direction for the next command in
 | 
			
		||||
the sequence, to go back to a more recent edit.
 | 
			
		||||
\nIt does not go to the same point twice even if there has been many edits
 | 
			
		||||
there. I call the minimal distance between distinguishable edits \"span\".
 | 
			
		||||
Set variable `glc-default-span' to control how close is \"the same point\".
 | 
			
		||||
Default span is 8.
 | 
			
		||||
The span can be changed temporarily with \\[universal-argument] right before \\[goto-last-change]:
 | 
			
		||||
\\[universal-argument] <NUMBER> set current span to that number,
 | 
			
		||||
\\[universal-argument] (no number) multiplies span by 4, starting with default.
 | 
			
		||||
The so set span remains until it is changed again with \\[universal-argument], or the consecutive
 | 
			
		||||
repetition of this command is ended by any other command.
 | 
			
		||||
\nWhen span is zero (i.e. \\[universal-argument] 0) subsequent \\[goto-last-change] visits each and
 | 
			
		||||
every point of edit and a message shows what change was made there.
 | 
			
		||||
In this case it may go to the same point twice.
 | 
			
		||||
\nThis command uses undo information. If undo is disabled, so is this command.
 | 
			
		||||
At times, when undo information becomes too large, the oldest information is
 | 
			
		||||
discarded. See variable `undo-limit'."
 | 
			
		||||
  (interactive "P")
 | 
			
		||||
  (cond ((not (eq this-command last-command))
 | 
			
		||||
	 ;; Start a glc sequence
 | 
			
		||||
	 ;; Don't go to current point if last command was an obvious edit
 | 
			
		||||
	 ;; (yank or self-insert, but not kill-region). Makes it easier to
 | 
			
		||||
	 ;; jump back and forth when copying seleced lines.
 | 
			
		||||
	 (setq glc-probe-depth (if (memq last-command '(yank self-insert-command)) 1 0)
 | 
			
		||||
	       glc-direction 1
 | 
			
		||||
	       glc-current-span glc-default-span)
 | 
			
		||||
	 (if (< (prefix-numeric-value arg) 0)
 | 
			
		||||
	     (error "Negative arg: Cannot reverse as the first operation"))))
 | 
			
		||||
  (cond ((null buffer-undo-list)
 | 
			
		||||
	 (error "Buffer has not been changed"))
 | 
			
		||||
	((eq buffer-undo-list t)
 | 
			
		||||
	 (error "No change info (undo is disabled)")))
 | 
			
		||||
  (cond ((numberp arg)			; Numeric arg sets span
 | 
			
		||||
	 (setq glc-current-span (abs arg)))
 | 
			
		||||
	((consp arg)			; C-u's multiply previous span by 4
 | 
			
		||||
	 (setq glc-current-span (* (abs (car arg)) glc-default-span))
 | 
			
		||||
	 (message "Current span is %d chars" glc-current-span))) ;todo: keep message with "waiting" and "is saved"
 | 
			
		||||
  (cond ((< (prefix-numeric-value arg) 0)
 | 
			
		||||
	 (setq glc-direction -1))
 | 
			
		||||
	(t
 | 
			
		||||
	 (setq glc-direction 1)))
 | 
			
		||||
  (let (rev				; Reversed (and filtered) undo list
 | 
			
		||||
	pos				; The pos we look for, nil until found
 | 
			
		||||
	(n 0)				; Steps in undo list (length of 'rev')
 | 
			
		||||
	(l buffer-undo-list) 
 | 
			
		||||
	(passed-save-entry (not (buffer-modified-p)))
 | 
			
		||||
	(new-probe-depth glc-probe-depth))
 | 
			
		||||
    ;; Walk back and forth in the buffer-undo-list, each time one step deeper,
 | 
			
		||||
    ;; until we can walk back the whole list with a 'pos' that is not coming
 | 
			
		||||
    ;; too close to another edit.
 | 
			
		||||
    (while (null pos)
 | 
			
		||||
      (setq new-probe-depth (+ new-probe-depth glc-direction))
 | 
			
		||||
      (if (< glc-direction 0)
 | 
			
		||||
	  (setq rev ()
 | 
			
		||||
		n 0
 | 
			
		||||
		l buffer-undo-list
 | 
			
		||||
		passed-save-entry (not (buffer-modified-p))))
 | 
			
		||||
      (if (< new-probe-depth 1)
 | 
			
		||||
	  (error "No later change info"))
 | 
			
		||||
      (if (> n 150)
 | 
			
		||||
	  (message "working..."))
 | 
			
		||||
      ;; Walk forward in buffer-undo-list, glc-probe-depth steps.
 | 
			
		||||
      ;; Build reverse list along the way
 | 
			
		||||
      (while (< n new-probe-depth)
 | 
			
		||||
	(cond ((null l)
 | 
			
		||||
	       ;(setq this-command t)	; Disrupt repeat sequence
 | 
			
		||||
	       (error "No further change info"))
 | 
			
		||||
	      ((glc-is-positionable (car l))
 | 
			
		||||
	       (setq n (1+ n)
 | 
			
		||||
		     rev (cons (car l) rev)))
 | 
			
		||||
	      ((or passed-save-entry (glc-is-filetime (car l)))
 | 
			
		||||
	       (setq passed-save-entry t)))
 | 
			
		||||
	(setq l (cdr l)))
 | 
			
		||||
      ;; Walk back in reverse list, from older to newer edits.
 | 
			
		||||
      ;; Adjusting pos along the way.
 | 
			
		||||
      (setq pos (glc-adjust-list rev)))
 | 
			
		||||
    ;; Found a place not previously visited, in 'pos'.
 | 
			
		||||
    ;; (An error have been issued if nothing (more) found.)
 | 
			
		||||
    (if (> n 150)
 | 
			
		||||
	(message nil))			; remove message "working..."
 | 
			
		||||
    (if (and (= glc-current-span 0) (glc-get-descript (car rev) n))
 | 
			
		||||
	(message "%s" (glc-get-descript (car rev) n))
 | 
			
		||||
      ;; else
 | 
			
		||||
      (if passed-save-entry
 | 
			
		||||
	  (message "(This change is saved)")))
 | 
			
		||||
    (setq glc-probe-depth new-probe-depth)
 | 
			
		||||
    (goto-char pos)))
 | 
			
		||||
 | 
			
		||||
;; ;;;###autoload
 | 
			
		||||
(defun goto-last-change-reverse (arg)
 | 
			
		||||
  (interactive "P")
 | 
			
		||||
  ;; Negate arg, all kinds
 | 
			
		||||
  (cond ((eq arg nil)  (setq arg '-))
 | 
			
		||||
	((eq arg '-)   (setq arg nil))
 | 
			
		||||
	((listp arg)   (setq arg (list (- (car arg)))))
 | 
			
		||||
	(t (setq arg   (- arg))))
 | 
			
		||||
  ;; Make 'goto-last-change-reverse' look like 'goto-last-change'
 | 
			
		||||
  (cond ((eq last-command this-command)
 | 
			
		||||
	 (setq last-command 'goto-last-change)))
 | 
			
		||||
  (setq this-command 'goto-last-change)
 | 
			
		||||
  ;; Call 'goto-last-change' to do the job
 | 
			
		||||
  (goto-last-change arg))
 | 
			
		||||
 | 
			
		||||
(provide 'goto-chg)
 | 
			
		||||
 | 
			
		||||
;;; goto-chg.el ends here
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue