Skip to content

Commit

Permalink
Fix #1518: "custom functions bound to '0' break motion parsing" in a …
Browse files Browse the repository at this point in the history
…saner way (#1534)

* Try just comparing to '0'

* Remove cruft and clean things up

* Remove magic number
  • Loading branch information
erganemic committed Nov 17, 2021
1 parent c28e421 commit 040210a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
11 changes: 6 additions & 5 deletions evil-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ Both COUNT and CMD may be nil."
(list (car cmd) (* (or count 1)
(or (cadr cmd) 1))))))))
((or (eq cmd #'digit-argument)
(and (memq cmd evil-digit-bound-motions)
(and (equal seq "0")
count))
(let* ((event (aref seq (- (length seq) 1)))
(char (or (when (characterp event) event)
Expand Down Expand Up @@ -710,10 +710,11 @@ recursively."
(end 1)
(found-prefix nil))
(while (and (<= end len))
(let ((cmd (key-binding (substring keys beg end))))
(let* ((seq (substring keys beg end))
(cmd (key-binding seq)))
(cond
((memq cmd '(undefined nil))
(user-error "No command bound to %s" (substring keys beg end)))
(user-error "No command bound to %s" seq))
((arrayp cmd) ; keyboard macro, replace command with macro
(setq keys (vconcat (substring keys 0 beg)
cmd
Expand All @@ -723,7 +724,7 @@ recursively."
((functionp cmd)
(if (or (memq cmd '(digit-argument negative-argument))
(and found-prefix
(memq cmd evil-digit-bound-motions)))
(equal (vconcat seq) (vector ?0))))
;; skip those commands
(setq found-prefix t ; found at least one prefix argument
beg end
Expand All @@ -734,7 +735,7 @@ recursively."
(string-to-number
(concat (substring keys 0 beg))))
cmd
(substring keys beg end)
seq
(when (< end len)
(substring keys end))))))
(t ; append a further event
Expand Down
1 change: 0 additions & 1 deletion evil-integration.el
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,6 @@ Based on `evil-enclose-ace-jump-for-motion'."

;; visual-line-mode integration
(when evil-respect-visual-line-mode
(customize-set-variable 'evil-digit-bound-motions '(evil-beginning-of-visual-line))
(evil-define-minor-mode-key 'motion 'visual-line-mode
"j" 'evil-next-visual-line
"gj" 'evil-next-line
Expand Down
9 changes: 0 additions & 9 deletions evil-vars.el
Original file line number Diff line number Diff line change
Expand Up @@ -611,15 +611,6 @@ in insert state."
:type 'boolean
:group 'evil)

(defcustom evil-digit-bound-motions
'(evil-beginning-of-line)
"The motion commands that can be bound to some digit key (typically 0).
While Evil is reading a motion command, functions in this list act as themselves
if their corresponding key was the first digit in the key sequence, and behave
like `digit-argument' for the purposes of `evil-keypress-parser' otherwise."
:type '(repeat function)
:group 'evil)

(defvar dabbrev-search-these-buffers-only)
(defvar dabbrev-case-distinction)
(defcustom evil-complete-next-func
Expand Down

0 comments on commit 040210a

Please sign in to comment.