Correctly handle evil function properties in evil-escape

Fix a bug where `f` motion could act like a `t` motion.
This commit is contained in:
syl20bnr 2015-01-21 21:34:54 -05:00
parent 827ab01066
commit ba2447dde0
3 changed files with 61 additions and 5 deletions

View file

@ -851,7 +851,7 @@ is **guaranteed** to never conflict with `Spacemacs` defaults key bindings.
## Escaping
`Spacemacs` uses [evil-escape][] to easily switch between `insert state` and
`normal state` with the key chord `fd`.
`normal state` by quickly pressing the `fd` keys.
The choice of `fd` was made to be able to use the same sequence to escape from
"everything" in Emacs:
@ -877,6 +877,10 @@ to `jj` (it is important set the variable in `dotspacemacs/init`):
(setq-default evil-escape-key-sequence "jj"))
```
**Note:** Although `jj` or `jk` are popular choices of vim users, these key
sequences are not optimal for `Spacemacs`. Indeed it is very easy in
`visual state` to press quickly `jj` and inadvertently escape to `normal state`.
## Executing Vim, Emacs and shell commands
Command | Key Binding

View file

@ -11,6 +11,7 @@
- [Customization](#customization)
- [Key sequence](#key-sequence)
- [Delay between keys](#delay-between-keys)
- [Limitations](#limitations)
<!-- markdown-toc end -->
@ -84,4 +85,52 @@ composed with the two same characters it is recommended to set the delay to
**Note:** The variable `evil-escape-delay` must be set before requiring
`evil-escape`.
## Limitations
Due to the current implementation only the following characters can be used
as the first character of the key sequence:
| Keys |
|:----------:|
|<kbd>b</kbd>|
|<kbd>B</kbd>|
|<kbd>e</kbd>|
|<kbd>E</kbd>|
|<kbd>f</kbd>|
|<kbd>F</kbd>|
|<kbd>G</kbd>|
|<kbd>h</kbd>|
|<kbd>H</kbd>|
|<kbd>j</kbd>|
|<kbd>k</kbd>|
|<kbd>l</kbd>|
|<kbd> </kbd>|
|<kbd>K</kbd>|
|<kbd>L</kbd>|
|<kbd>M</kbd>|
|<kbd>n</kbd>|
|<kbd>N</kbd>|
|<kbd>t</kbd>|
|<kbd>T</kbd>|
|<kbd>w</kbd>|
|<kbd>W</kbd>|
|<kbd>{</kbd>|
|<kbd>}</kbd>|
|<kbd>#</kbd>|
|<kbd>%</kbd>|
|<kbd>`</kbd>|
|<kbd>'</kbd>|
|<kbd>(</kbd>|
|<kbd>)</kbd>|
|<kbd>*</kbd>|
|<kbd>,</kbd>|
|<kbd>/</kbd>|
|<kbd>;</kbd>|
|<kbd>?</kbd>|
|<kbd>|</kbd>|
|<kbd>^</kbd>|
|<kbd>+</kbd>|
|<kbd>_</kbd>|
|<kbd>-</kbd>|
[MELPA]: http://melpa.org/

View file

@ -5,7 +5,7 @@
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; Keywords: convenience editing evil
;; Created: 22 Oct 2014
;; Version: 2.05
;; Version: 2.06
;; Package-Requires: ((emacs "24") (evil "1.0.9"))
;; URL: https://github.com/syl20bnr/evil-escape
@ -128,13 +128,16 @@ with a key sequence."
`:delete-func FUNCTION'
Specify the delete function to call when deleting the first key."
(let ((shadowed-func (plist-get properties :shadowed-func))
(insert-func (plist-get properties :insert-func))
(delete-func (plist-get properties :delete-func)))
(let* ((shadowed-func (plist-get properties :shadowed-func))
(evil-func-props (when shadowed-func
(evil-get-command-properties shadowed-func)))
(insert-func (plist-get properties :insert-func))
(delete-func (plist-get properties :delete-func)))
`(progn
(define-key ,map ,(evil-escape--first-key)
(evil-define-motion ,(evil-escape--escape-function-symbol from)
(count)
,@evil-func-props
;; called by the user
(if (called-interactively-p 'interactive)
(evil-escape--escape ,evil-escape-key-sequence