diff options
| author | Tom Dalziel <tom_dl@hotmail.com> | 2022-09-26 17:18:10 +0100 |
|---|---|---|
| committer | Tom Dalziel <33435574+tomdl89@users.noreply.github.com> | 2022-09-26 19:05:39 +0200 |
| commit | dba2fa9907cf096f5e615df2e8b0381b643d47ee (patch) | |
| tree | 8d61b59f11891b21c392e63818c3f2de39d75fce | |
| parent | 26ec0cda1bcb899ae37086a1268a055484171519 (diff) | |
Store digraph character directly for repetition
Fixes #1675
| -rw-r--r-- | evil-common.el | 13 | ||||
| -rw-r--r-- | evil-repeat.el | 5 | ||||
| -rw-r--r-- | evil-tests.el | 9 | ||||
| -rw-r--r-- | evil-vars.el | 3 |
4 files changed, 23 insertions, 7 deletions
diff --git a/evil-common.el b/evil-common.el index 7f0bad4..7ae8feb 100644 --- a/evil-common.el +++ b/evil-common.el @@ -604,6 +604,7 @@ Translates it according to the input method." ((eq cmd 'self-insert-command) char) (cmd + (setq evil-last-read-digraph-char nil) (call-interactively cmd)) (t (user-error "No replacement character typed")))) @@ -649,11 +650,13 @@ Return the digraph from `evil-digraph', else return second char." This function creates an overlay at (point), hiding the next HIDE-CHARS characters. HIDE-CHARS defaults to 1." (interactive) - (let ((overlay (make-overlay (point) - (min (point-max) - (+ (or hide-chars 1) - (point)))))) - (evil-read-digraph-char-with-overlay overlay))) + (let* ((overlay (make-overlay (point) + (min (point-max) + (+ (or hide-chars 1) + (point))))) + (char (evil-read-digraph-char-with-overlay overlay))) + (setq evil-last-read-digraph-char char) + char)) (defun evil-read-motion (&optional motion count type modifier) "Read a MOTION, motion COUNT and motion TYPE from the keyboard. diff --git a/evil-repeat.el b/evil-repeat.el index f305704..1234c1c 100644 --- a/evil-repeat.el +++ b/evil-repeat.el @@ -329,7 +329,9 @@ invoked the current command" ;; Only add prefix if no repeat info recorded yet (null evil-repeat-info)) (string-to-vector (number-to-string arg))) - (this-single-command-keys)))) + (or (when evil-last-read-digraph-char + (vector evil-last-read-digraph-char)) + (this-single-command-keys))))) (defun evil-repeat-keystrokes (flag) "Repeation recording function for commands that are repeated by keystrokes." @@ -343,6 +345,7 @@ invoked the current command" (evil-repeat-record (if (zerop (length (evil-this-command-keys t))) evil-repeat-keys (evil-this-command-keys t))) + (setq evil-last-read-digraph-char nil) ;; erase commands keys to prevent double recording (evil-clear-command-keys)))) diff --git a/evil-tests.el b/evil-tests.el index 91492f0..34926c0 100644 --- a/evil-tests.el +++ b/evil-tests.el @@ -938,7 +938,14 @@ If nil, KEYS is used." ("re'") "[é]; This buffer is for notes you don't want to save" ("3rc*") - "ξξ[ξ]This buffer is for notes you don't want to save")) + "ξξ[ξ]This buffer is for notes you don't want to save") + (ert-info ("Repeat replace digraph") + (evil-test-buffer + "ab[c]defghijkl" + ("rW*") + "ab[Ω]defghijkl" + ("fg" "2.") + "abΩdefΩ[Ω]ijkl"))) (ert-info ("Replacing \\n should insert only one newline") (evil-test-buffer "(setq var xxx [y]yy zzz)\n" diff --git a/evil-vars.el b/evil-vars.el index c99bf85..6dbb1bc 100644 --- a/evil-vars.el +++ b/evil-vars.el @@ -1538,6 +1538,9 @@ This keymap can be used to bind some commands during the execution of `evil-read-key' which is usually used to read a character argument for some commands, e.g. `evil-replace'.") +(defvar evil-last-read-digraph-char nil + "The last digraph character read. Used for repeats.") + ;; TODO: customize size of ring (defvar evil-repeat-ring (make-ring 10) "A ring of repeat-informations to repeat the last command.") |
