Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include "{register} and operator in 'showcmd' msg #1757

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion evil-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -2357,7 +2357,11 @@ leave the cursor just after the new text."
:repeat ignore
:suppress-operator t
(interactive "<C>")
(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.")
Expand Down
51 changes: 39 additions & 12 deletions evil-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
17 changes: 17 additions & 0 deletions evil-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
11 changes: 6 additions & 5 deletions evil-types.el
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ the last column is excluded."
(evil-define-interactive-code "<c>"
"Count."
(list (when current-prefix-arg
(prefix-numeric-value
current-prefix-arg))))
(prefix-numeric-value current-prefix-arg))))

(evil-define-interactive-code "<vc>"
"Count, but only in visual state.
Expand All @@ -292,23 +291,25 @@ 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 "<C>"
"Character read through `evil-read-key'."
(evil--add-prefix-keystrokes)
(list
(if (evil-operator-state-p)
(evil-without-restriction (evil-read-key))
(evil-read-key))))

(evil-define-interactive-code "<r>"
"Untyped motion range (BEG END)."
(evil--add-prefix-keystrokes)
(evil-operator-range))

(evil-define-interactive-code "<R>"
"Typed motion range (BEG END TYPE)."
(evil--add-prefix-keystrokes)
(evil-operator-range t))

(evil-define-interactive-code "<v>"
Expand Down