[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil 17c635f: Fix for #1518 custom functions bound to "0"
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil 17c635f: Fix for #1518 custom functions bound to "0" break motion parsing (#1519) |
Date: |
Thu, 21 Oct 2021 18:05:24 -0400 (EDT) |
branch: elpa/evil
commit 17c635f6e1f538bf4b2c3c276ddd9d4d165a52fb
Author: jmmathena <46335614+jmmathena@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Fix for #1518 custom functions bound to "0" break motion parsing (#1519)
* Modify evil-keypress-parser logic to be more modular
* Rewrite tests and update visual line logic for updated digit handling
* Completely remove need for redirect-digit-argument at cost of ugliness
* Remove reference to obsolete func in evil-keybindings.el
---
evil-commands.el | 13 -------------
evil-common.el | 30 ++----------------------------
evil-integration.el | 16 ++--------------
evil-keybindings.el | 2 +-
evil-maps.el | 2 +-
evil-tests.el | 6 +++---
evil-vars.el | 9 +++++++++
7 files changed, 18 insertions(+), 60 deletions(-)
diff --git a/evil-commands.el b/evil-commands.el
index 656b897..147e6af 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -234,19 +234,6 @@ move COUNT - 1 screen lines downward first."
-1
(/ (with-no-warnings (window-body-width)) 2)))))
-(evil-define-motion evil-beginning-of-line-or-digit-argument ()
- "Move the cursor to the beginning of the current line.
-This function passes its command to `digit-argument' (usually a 0)
-if it is not the first event."
- :type exclusive
- (cond
- (current-prefix-arg
- (setq this-command #'digit-argument)
- (call-interactively #'digit-argument))
- (t
- (setq this-command #'evil-beginning-of-line)
- (call-interactively #'evil-beginning-of-line))))
-
(evil-define-motion evil-first-non-blank ()
"Move the cursor to the first non-blank character of the current line."
:type exclusive
diff --git a/evil-common.el b/evil-common.el
index d843bda..70204af 100644
--- a/evil-common.el
+++ b/evil-common.el
@@ -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 (eq cmd
'evil-digit-argument-or-evil-beginning-of-line)
+ (and (memq cmd evil-digit-bound-motions)
count))
(let* ((event (aref seq (- (length seq) 1)))
(char (or (when (characterp event) event)
@@ -723,8 +723,7 @@ recursively."
((functionp cmd)
(if (or (memq cmd '(digit-argument negative-argument))
(and found-prefix
- (evil-get-command-property
- cmd :digit-argument-redirection)))
+ (memq cmd evil-digit-bound-motions)))
;; skip those commands
(setq found-prefix t ; found at least one prefix argument
beg end
@@ -742,31 +741,6 @@ recursively."
(setq end (1+ end))))))
(user-error "Key sequence contains no complete binding"))))
-(defmacro evil-redirect-digit-argument (map keys target)
- "Bind a wrapper function calling TARGET or `digit-argument'.
-MAP is a keymap for binding KEYS to the wrapper for TARGET.
-The wrapper only calls `digit-argument' if a prefix-argument
-has already been started; otherwise TARGET is called."
- (let* ((target (eval target))
- (wrapper (intern (format "evil-digit-argument-or-%s"
- target))))
- `(progn
- (define-key ,map ,keys ',wrapper)
- (evil-define-command ,wrapper ()
- :digit-argument-redirection ,target
- :keep-visual t
- :repeat nil
- (interactive)
- (cond
- (current-prefix-arg
- (setq this-command #'digit-argument)
- (call-interactively #'digit-argument))
- (t
- (let ((target (or (command-remapping #',target)
- #',target)))
- (setq this-command target)
- (call-interactively target))))))))
-
(defun evil-extract-append (file-or-append)
"Return an (APPEND . FILENAME) pair based on FILE-OR-APPEND.
FILE-OR-APPEND should either be a filename or a \">> FILE\"
diff --git a/evil-integration.el b/evil-integration.el
index 3c09fc1..4cc2e65 100644
--- a/evil-integration.el
+++ b/evil-integration.el
@@ -476,25 +476,13 @@ Based on `evil-enclose-ace-jump-for-motion'."
;; visual-line-mode integration
(when evil-respect-visual-line-mode
- (evil-define-command evil-digit-argument-or-evil-beginning-of-visual-line ()
- :digit-argument-redirection evil-beginning-of-visual-line
- :keep-visual t
- :repeat nil
- (interactive)
- (cond
- (current-prefix-arg
- (setq this-command #'digit-argument)
- (call-interactively #'digit-argument))
- (t
- (setq this-command 'evil-beginning-of-visual-line)
- (call-interactively 'evil-beginning-of-visual-line))))
-
+ (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
"k" 'evil-previous-visual-line
"gk" 'evil-previous-line
- "0" 'evil-digit-argument-or-evil-beginning-of-visual-line
+ "0" 'evil-beginning-of-visual-line
"g0" 'evil-beginning-of-line
"$" 'evil-end-of-visual-line
"g$" 'evil-end-of-line
diff --git a/evil-keybindings.el b/evil-keybindings.el
index 084a06a..71b8e55 100644
--- a/evil-keybindings.el
+++ b/evil-keybindings.el
@@ -75,7 +75,7 @@
;;; Info
(evil-add-hjkl-bindings Info-mode-map 'motion
- "0" 'evil-digit-argument-or-evil-beginning-of-line
+ "0" 'evil-beginning-of-line
(kbd "\M-h") 'Info-help ; "h"
"\C-t" 'Info-history-back ; "l"
"\C-o" 'Info-history-back
diff --git a/evil-maps.el b/evil-maps.el
index 11325c0..3c0f6a8 100644
--- a/evil-maps.el
+++ b/evil-maps.el
@@ -169,7 +169,7 @@
;;; 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 "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)
diff --git a/evil-tests.el b/evil-tests.el
index 9a874a9..0ceb04d 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -1605,7 +1605,7 @@ New Tex[t]
(ert-info ("Treat 0 as a motion")
(should (equal
(evil-keypress-parser '(?0))
- '(evil-digit-argument-or-evil-beginning-of-line nil))))
+ '(evil-beginning-of-line nil))))
(ert-info ("Handle keyboard macros")
(evil-test-buffer
(define-key evil-motion-state-local-map (kbd "W") (kbd "w"))
@@ -8633,12 +8633,12 @@ Source
(ert-info ("Exact \"0\" count")
(should (equal (evil-extract-count "0")
- (list nil 'evil-digit-argument-or-evil-beginning-of-line
+ (list nil 'evil-beginning-of-line
"0" nil))))
(ert-info ("Extra elements and \"0\"")
(should (equal (evil-extract-count "0XY")
- (list nil 'evil-digit-argument-or-evil-beginning-of-line
+ (list nil 'evil-beginning-of-line
"0" "XY"))))
(ert-info ("Count only")
diff --git a/evil-vars.el b/evil-vars.el
index d516ef1..42a45a1 100644
--- a/evil-vars.el
+++ b/evil-vars.el
@@ -611,6 +611,15 @@ 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/evil 17c635f: Fix for #1518 custom functions bound to "0" break motion parsing (#1519),
ELPA Syncer <=