diff --git a/evil-commands.el b/evil-commands.el index eec70386..33ded32f 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -2357,7 +2357,11 @@ leave the cursor just after the new text." :repeat ignore :suppress-operator t (interactive "") - (setq evil-this-register register)) + (setq evil-this-register register) + (when (eval-when-compile (>= emacs-major-version 25)) + (evil--add-prefix-keystrokes) + ;; Pass count on to next command, i.a. + (run-hooks 'prefix-command-preserve-state-hook))) (defvar evil-macro-buffer nil "The buffer that has been active on macro recording.") diff --git a/evil-common.el b/evil-common.el index b991b869..7b74b1ac 100644 --- a/evil-common.el +++ b/evil-common.el @@ -539,7 +539,7 @@ Both COUNT and CMD may be nil." (when input (setq unread-command-events (append input unread-command-events))) (catch 'done (while t - (let ((seq (read-key-sequence ""))) + (let ((seq (read-key-sequence nil))) (when seq (let ((cmd (key-binding seq))) (cond @@ -767,10 +767,38 @@ filename." (defun evil-lookup-key (map key) "Return non-nil value if KEY is bound in MAP." (let ((definition (lookup-key map key))) - (if (numberp definition) ; in-band error - nil + (unless (numberp definition) ; in-band error definition))) +(defvar evil--prefix-keystrokes nil + "The value of `evil--current-prefix-keystrokes' for the next editing command.") +(defvar evil--current-prefix-keystrokes nil + "List of keystroke strings to echo in addition to unfinished command. +The keys for `evil-use-register' and operators etc. get appended to +this variable, in order to better emulate the \"showcmd\" feature of +Vim when `echo-keystrokes' is on. This is needed as Vim considers +them part of a single command, whereas in Evil they are separate.") + +(defun evil--prefix-keystrokes () + "Format `evil--current-prefix-keystrokes' as a string. +Intended for `prefix-command-echo-keystrokes-functions'." + (when evil--current-prefix-keystrokes + (mapconcat #'identity evil--current-prefix-keystrokes " "))) + +(defun evil--add-prefix-keystrokes () + "Continue to echo the key sequence of this command for the next one too." + (setq evil--current-prefix-keystrokes + (nconc evil--current-prefix-keystrokes (list (this-command-keys)))) + (prefix-command-update)) + +(defun evil--reset-prefix-keystrokes () + "Reset `evil--current-prefix-keystrokes' unless it has been preserved." + (setq evil--current-prefix-keystrokes evil--prefix-keystrokes + evil--prefix-keystrokes nil)) + +(defun evil--prefix-keystrokes-preserve () + (setq evil--prefix-keystrokes evil--current-prefix-keystrokes)) + ;;; Display (defun evil-set-cursor (specs) @@ -4025,17 +4053,16 @@ should be left-aligned for left justification." (defmacro evil-with-view-list (&rest properties) "Open new list view buffer. - PROPERTIES is a property-list which supports the following properties: -:name (required) The name of the buffer. -:mode-name (required) The name for the mode line. -:format (required) The value for `tabulated-list-format'. -:entries (required) The value for `tabulated-list-entries'. -:select-action (optional) A function for row selection. - It takes in a single parameter, which is the selected row's - vector value that is passed into `:entries'. -" +:name (required) The name of the buffer. +:mode-name (required) The name for the mode line. +:format (required) The value for `tabulated-list-format'. +:entries (required) The value for `tabulated-list-entries'. +:select-action (optional) A function for row selection. + It takes a single parameter, which is the + selected row's vector value that is passed + into `:entries'." (declare (indent defun) (debug t)) `(let ((bufname (concat "*" ,(plist-get properties :name) "*")) (inhibit-read-only t)) diff --git a/evil-core.el b/evil-core.el index 2205ea52..51c24db6 100644 --- a/evil-core.el +++ b/evil-core.el @@ -180,11 +180,28 @@ To enable Evil globally, do (evil-mode)." (and (eval-when-compile (version< emacs-version "26.1")) (eq (default-value 'major-mode) 'fundamental-mode) (setq-default major-mode 'evil--fundamental-mode)) + + (add-hook 'post-command-hook #'evil--reset-prefix-keystrokes) + (when (eval-when-compile (>= emacs-major-version 25)) + (add-hook 'prefix-command-echo-keystrokes-functions + ;; Add before `universal-argument--description' + #'evil--prefix-keystrokes -50) + (add-hook 'prefix-command-preserve-state-hook + #'evil--prefix-keystrokes-preserve)) + (ad-enable-regexp "^evil") (ad-activate-regexp "^evil") (evil-esc-mode 1)) (when (eq (default-value 'major-mode) 'evil--fundamental-mode) (setq-default major-mode 'fundamental-mode)) + + (remove-hook 'post-command-hook #'evil--reset-prefix-keystrokes) + (when (eval-when-compile (>= emacs-major-version 25)) + (remove-hook 'prefix-command-echo-keystrokes-functions + #'evil--prefix-keystrokes) + (remove-hook 'prefix-command-preserve-state-hook + #'evil--prefix-keystrokes-preserve)) + (ad-disable-regexp "^evil") (ad-update-regexp "^evil") (evil-esc-mode -1))) diff --git a/evil-types.el b/evil-types.el index 276cdbbf..eea81a1d 100644 --- a/evil-types.el +++ b/evil-types.el @@ -281,8 +281,7 @@ the last column is excluded." (evil-define-interactive-code "" "Count." (list (when current-prefix-arg - (prefix-numeric-value - current-prefix-arg)))) + (prefix-numeric-value current-prefix-arg)))) (evil-define-interactive-code "" "Count, but only in visual state. @@ -292,12 +291,12 @@ 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)))) + (list (and (evil-visual-state-p) current-prefix-arg + (prefix-numeric-value current-prefix-arg)))) (evil-define-interactive-code "" "Character read through `evil-read-key'." + (evil--add-prefix-keystrokes) (list (if (evil-operator-state-p) (evil-without-restriction (evil-read-key)) @@ -305,10 +304,12 @@ directly." (evil-define-interactive-code "" "Untyped motion range (BEG END)." + (evil--add-prefix-keystrokes) (evil-operator-range)) (evil-define-interactive-code "" "Typed motion range (BEG END TYPE)." + (evil--add-prefix-keystrokes) (evil-operator-range t)) (evil-define-interactive-code ""