aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Øye <vegard_oye@hotmail.com>2012-01-29 13:19:48 +0100
committerVegard Øye <vegard_oye@hotmail.com>2012-01-29 13:19:48 +0100
commitb9bf41600820f20c3878667becc69ee157366e46 (patch)
treef62be957f50d4eba392fb6064ceb640cb2b68f70
parent8742ccd11d7724a0828d9862cb703a0c88d6e462 (diff)
Add :suppress-operator t to a couple of commands
This property prevents the command from being applied to an operator. Also fix an old bug in `evil-keypress-parser' where the input was unnecessarily converted from a symbol to a character.
-rw-r--r--evil-commands.el7
-rw-r--r--evil-common.el26
-rw-r--r--evil-core.el3
-rw-r--r--evil-integration.el5
-rw-r--r--evil-macros.el22
-rw-r--r--evil-maps.el2
-rw-r--r--evil-repeat.el3
7 files changed, 41 insertions, 27 deletions
diff --git a/evil-commands.el b/evil-commands.el
index f728bb8..2b092b0 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -1281,6 +1281,7 @@ The default for width is the value of `fill-column'."
(count &optional register yank-handler)
"Pastes the latest yanked text before the cursor position.
The return value is the yanked text."
+ :suppress-operator t
(interactive "P<x>")
(if (evil-visual-state-p)
(evil-visual-paste count register)
@@ -1322,6 +1323,7 @@ The return value is the yanked text."
(count &optional register yank-handler)
"Pastes the latest yanked text behind point.
The return value is the yanked text."
+ :suppress-operator t
(interactive "P<x>")
(if (evil-visual-state-p)
(evil-visual-paste count register)
@@ -1365,6 +1367,7 @@ The return value is the yanked text."
(evil-define-command evil-visual-paste (count &optional register)
"Paste over Visual selection."
+ :suppress-operator t
(interactive "P<x>")
(let* ((text (if register
(evil-get-register register)
@@ -1417,6 +1420,7 @@ The return value is the yanked text."
(evil-define-command evil-record-macro (register)
"Record a keyboard macro into REGISTER."
:keep-visual t
+ :suppress-operator t
(interactive
(list (unless evil-this-macro
(or evil-this-register (read-char)))))
@@ -1442,6 +1446,7 @@ When called with a non-numerical prefix \
COUNT is infinite. MACRO is read from a register
when called interactively."
:keep-visual t
+ :suppress-operator t
(interactive
(let (count macro register)
(setq count (if current-prefix-arg
@@ -2235,6 +2240,7 @@ Change to `%s'? "
(evil-define-command evil-force-normal-state ()
"Switch to normal state without recording current command."
:repeat abort
+ :suppress-operator t
(evil-normal-state))
(evil-define-motion evil-ex-search-next (count)
@@ -2844,6 +2850,7 @@ and redisplays the current buffer there."
Changes the state to the previous state, or to Normal state
if the previous state was Emacs state."
:keep-visual t
+ :suppress-operator t
(interactive '(nil t))
(with-current-buffer (or buffer (current-buffer))
(when (evil-emacs-state-p)
diff --git a/evil-common.el b/evil-common.el
index d4c155f..748e4fb 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -445,31 +445,30 @@ Returns (CMD COUNT), where COUNT is the numeric prefix argument.
Both COUNT and CMD may be nil."
(let ((input (listify-key-sequence input))
(inhibit-quit t)
- char cmd count digit seq)
+ char cmd count digit event seq)
(while (progn
- (setq char (or (pop input) (read-event)))
- (cond
- ((eq char 'escape))
- ((eq char ?\e)
+ (setq event (or (pop input) (read-event)))
+ (when (eq event ?\e)
(when (sit-for evil-esc-delay t)
- (setq char 'escape)))
- ((symbolp char)
- (setq char (or (get char 'ascii-character) char))))
+ (setq event 'escape)))
+ (setq char (or (when (characterp event) event)
+ (when (symbolp event)
+ (get event 'ascii-character))))
;; this trick from simple.el's `digit-argument'
;; converts keystrokes like C-0 and C-M-1 to digits
(if (or (characterp char) (integerp char))
(setq digit (- (logand char ?\177) ?0))
(setq digit nil))
(if (keymapp cmd)
- (setq seq (append seq (list char)))
- (setq seq (list char)))
+ (setq seq (append seq (list event)))
+ (setq seq (list event)))
(setq cmd (key-binding (vconcat seq) t))
(cond
;; if CMD is a keymap, we need to read more
((keymapp cmd)
t)
;; numeric prefix argument
- ((or (memq cmd '(digit-argument))
+ ((or (eq cmd #'digit-argument)
(and (eq (length seq) 1)
(not (keymapp cmd))
count
@@ -492,10 +491,7 @@ Both COUNT and CMD may be nil."
t)
((eq cmd 'negative-argument)
(unless count
- (setq count "-")))
- ;; user pressed C-g, so return nil for CMD
- ((memq cmd '(keyboard-quit undefined))
- (setq cmd nil)))))
+ (setq count "-"))))))
;; determine COUNT
(when (stringp count)
(if (string= count "-")
diff --git a/evil-core.el b/evil-core.el
index a54067a..238583b 100644
--- a/evil-core.el
+++ b/evil-core.el
@@ -232,6 +232,7 @@ This is the state the buffer comes up in."
"Change the state of BUFFER to its initial state.
This is the state the buffer came up in."
:keep-visual t
+ :suppress-operator t
(with-current-buffer (or buffer (current-buffer))
(evil-change-state (evil-initial-state-for-buffer
buffer (or evil-default-state 'normal))
@@ -242,6 +243,7 @@ This is the state the buffer came up in."
"Change the state of BUFFER to its previous state."
:keep-visual t
:repeat abort
+ :suppress-operator t
(with-current-buffer (or buffer (current-buffer))
(evil-change-state (or evil-previous-state evil-default-state 'normal)
message)))
@@ -992,6 +994,7 @@ If ARG is nil, don't display a message in the echo area.%s" name doc)
(evil-echo ,message))))))))
(evil-set-command-property ',toggle :keep-visual t)
+ (evil-set-command-property ',toggle :suppress-operator t)
(evil-define-keymap ,keymap nil
:mode ,mode
diff --git a/evil-integration.el b/evil-integration.el
index d1b06b9..fec4036 100644
--- a/evil-integration.el
+++ b/evil-integration.el
@@ -31,8 +31,11 @@
(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))
+
(dolist (cmd evil-visual-newline-commands)
- (evil-add-command-properties cmd :exclude-newline t))
+ (evil-set-command-property cmd :exclude-newline t))
(dolist (map evil-overriding-maps)
(eval-after-load (cdr map)
diff --git a/evil-macros.el b/evil-macros.el
index 10fb9d4..d3434d9 100644
--- a/evil-macros.el
+++ b/evil-macros.el
@@ -579,13 +579,14 @@ a predefined type may be specified with TYPE."
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))
- ((eq motion #'undefined)
- (setq range (if return-type '(nil nil nil) '(nil nil))
+ (setq quit-flag t
motion nil))
(evil-repeat-count
(setq count evil-repeat-count
@@ -596,13 +597,14 @@ a predefined type may be specified with TYPE."
(setq count
(* (prefix-numeric-value count)
(prefix-numeric-value current-prefix-arg)))))
- (let ((evil-state 'operator))
- ;; calculate motion range
- (setq range (evil-motion-range
- motion
- count
- type))
- (evil-set-marker ?. (evil-range-end range) t))
+ (when motion
+ (let ((evil-state 'operator))
+ ;; calculate motion range
+ (setq range (evil-motion-range
+ motion
+ count
+ type))
+ (evil-set-marker ?. (evil-range-end range) t)))
;; update global variables
(setq evil-this-motion motion
evil-this-motion-count count
diff --git a/evil-maps.el b/evil-maps.el
index a46340d..b17f6f2 100644
--- a/evil-maps.el
+++ b/evil-maps.el
@@ -299,7 +299,7 @@
(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)
+;; (define-key evil-operator-state-map [escape] 'keyboard-quit)
;;; Insert state
diff --git a/evil-repeat.el b/evil-repeat.el
index 63dccdf..0c6b1a0 100644
--- a/evil-repeat.el
+++ b/evil-repeat.el
@@ -473,6 +473,7 @@ and only if COUNT is non-nil."
"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
@@ -503,6 +504,7 @@ 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
@@ -533,6 +535,7 @@ If COUNT is negative, this is a more recent kill."
(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))