]> git.eshelyaron.com Git - emacs.git/commitdiff
Add command symbol property 'repeat-continue-only' for 'repeat-mode'
authorJuri Linkov <juri@linkov.net>
Wed, 27 Nov 2024 07:45:19 +0000 (09:45 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 27 Nov 2024 19:57:13 +0000 (20:57 +0100)
* lisp/repeat.el: (repeat-post-hook): Ignore commands
with 'repeat-continue-only' symbol property
when repeat was not in progress (bug#74140).

* test/lisp/repeat-tests.el (repeat-tests-continue-only): New test.
(repeat-tests-bind-keys): Prepare for :continue-only.

(cherry picked from commit 64c289590b56ea08d646b74f1a4b5de0a1faa2e2)

etc/NEWS
lisp/repeat.el
test/lisp/repeat-tests.el

index 6d458701af5f53d2ee1d72b6cef35bcae06d9df7..9451ea8f94d2081f1651be03ed08d050590d8d79 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -812,6 +812,9 @@ provide a ':columns' spec, so that the number of columns and their
 widths can be determined.  Columns widths can be set explicitly, or they
 will be calculated based on the window width.
 
+** New symbol propery 'repeat-continue-only' for 'repeat-mode'.
+A command with this symbol propery will not activate the repeat map,
+but will only continue the already activated repeating sequence.
 
 \f
 * Changes in Emacs 31.1 on Non-Free Operating Systems
index 2be182769aded372fed5e3426924d2e3000b774a..6b0c69905d8546746cb012a6373244514498de91 100644 (file)
@@ -503,7 +503,9 @@ See `describe-repeat-maps' for a list of all repeatable commands."
   (let ((was-in-progress repeat-in-progress))
     (setq repeat-in-progress nil)
     (let ((map (repeat-get-map)))
-      (when (repeat-check-map map)
+      (when (and (repeat-check-map map)
+                 (or (null (repeat--command-property 'repeat-continue-only))
+                     was-in-progress))
         ;; Messaging
         (funcall repeat-echo-function map)
 
index 5b3a72a37ae7ecc44b55b676f9f4f4701522d7c1..c560a283039b8760bcbe7a2918b0e7612cb82e5e 100644 (file)
@@ -25,7 +25,7 @@
 (require 'repeat)
 
 ;; Key mnemonics: a - Activate (enter, also b), c - Continue (also d),
-;;                q - Quit (exit)
+;;                o - continue-Only (not activate), q - Quit (exit)
 
 (defvar repeat-tests-calls nil)
 
   (interactive "p")
   (push `(,arg d) repeat-tests-calls))
 
+(defun repeat-tests-call-o (&optional arg)
+  (interactive "p")
+  (push `(,arg o) repeat-tests-calls))
+
 (defun repeat-tests-call-q (&optional arg)
   (interactive "p")
   (push `(,arg q) repeat-tests-calls))
@@ -54,7 +58,8 @@
   :doc "Keymap for keys that initiate repeating sequences."
   "C-x w a" 'repeat-tests-call-a
   "C-M-a"   'repeat-tests-call-a
-  "C-M-b"   'repeat-tests-call-b)
+  "C-M-b"   'repeat-tests-call-b
+  "C-M-o"   'repeat-tests-call-o)
 
 (defvar-keymap repeat-tests-repeat-map
   :doc "Keymap for repeating sequences."
   "a"     'ignore ;; for non-nil repeat-check-key only
   "c"     'repeat-tests-call-c
   "d"     'repeat-tests-call-d
+  "C-M-o" 'repeat-tests-call-o
   "q"     'repeat-tests-call-q)
 
+;; TODO: add new keyword ':continue-only (repeat-tests-call-o)'
+(put 'repeat-tests-call-o 'repeat-continue-only t)
+
 ;; Test using a variable instead of the symbol:
 (put 'repeat-tests-call-b 'repeat-map repeat-tests-repeat-map)
 
 
 ;; TODO: :tags '(:expensive-test)  for repeat-exit-timeout
 
+(ert-deftest repeat-tests-continue-only ()
+  (with-repeat-mode repeat-tests-map
+    (let ((repeat-echo-function 'ignore)
+          (repeat-check-key nil))
+      ;; 'C-M-o' used as continue-only
+      (repeat-tests--check
+       "C-M-a c C-M-o c z"
+       '((1 a) (1 c) (1 o) (1 c)) "z")
+      ;; 'C-M-o' should not activate
+      (repeat-tests--check
+       "C-M-o c z"
+       '((1 o)) "cz"))))
+
 \f
 (require 'use-package)
 
   (interactive "p")
   (push `(,arg d) repeat-tests-calls))
 
+(defun repeat-tests-bind-call-o (&optional arg)
+  (interactive "p")
+  (push `(,arg o) repeat-tests-calls))
+
 (defun repeat-tests-bind-call-q (&optional arg)
   (interactive "p")
   (push `(,arg q) repeat-tests-calls))
   (bind-keys
    :map repeat-tests-bind-keys-map
    ("C-M-a" . repeat-tests-bind-call-a)
+   ("C-M-o" . repeat-tests-bind-call-o)
    :repeat-map repeat-tests-bind-keys-repeat-map
    :continue
    ("c"     . repeat-tests-bind-call-c)
+   ;; :continue-only
+   ("C-M-o" . repeat-tests-bind-call-o)
    :exit
    ("q"     . repeat-tests-bind-call-q)
    )
   (with-repeat-mode repeat-tests-bind-keys-map
     (let ((repeat-echo-function 'ignore)
           (repeat-check-key nil))
+      ;; 'C-M-o' used as continue-only
+      (repeat-tests--check
+       "C-M-a c C-M-o c z"
+       '((1 a) (1 c) (1 o) (1 c)) "z")
+      ;; 'C-M-o' should not activate
+      ;; (repeat-tests--check
+      ;;  "C-M-o c z"
+      ;;  '((1 o)) "cz")
       ;; 'q' should exit
       (repeat-tests--check
        "C-M-a c q c"