]> git.eshelyaron.com Git - emacs.git/commitdiff
Add new keyword :continue-only to defvar-keymap for repeat-mode (bug#74140)
authorJuri Linkov <juri@linkov.net>
Tue, 3 Dec 2024 18:12:03 +0000 (20:12 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 4 Dec 2024 17:05:11 +0000 (18:05 +0100)
* doc/lispref/keymaps.texi (Creating Keymaps): Add :continue-only
to :repeat part of defvar-keymap.

* lisp/keymap.el (defvar-keymap): Add support for new :repeat
keyword :continue-only.

* lisp/repeat.el (repeat-post-hook): The property 'repeat-continue-only'
is handled as a list of repeat-maps.

* test/lisp/repeat-tests.el (repeat-tests-repeat-map): Use new
:repeat keyword :continue-only.

(cherry picked from commit 69e1f787528eaf2f223c53a6ff518ba4f984bc17)

doc/lispref/keymaps.texi
etc/NEWS
lisp/keymap.el
lisp/repeat.el
test/lisp/repeat-tests.el

index 2f9529a2a1891b70ab931ad92b2652e8ae0a6388..87723720b1e21325221586b377b58ecfb90f1bfb 100644 (file)
@@ -480,7 +480,8 @@ following values are available:
 This means all the commands in the keymap are repeatable, and is the
 most common usage.
 
-@item (:enter (commands ...) :exit (commands ...) :hints ((command . "hint") ...))
+@item (:enter (commands ...) :exit (commands ...)
+@itemx :continue-only (commands ...) :hints ((command . "hint") ...))
 This specifies that the commands in the @code{:enter} list enter
 @code{repeat-mode}, and the commands in the @code{:exit} list exit
 repeat mode.
@@ -495,6 +496,10 @@ If the @code{:exit} list is empty then no commands in the map exit
 useful if the keymap being defined contains a command that should not
 have the @code{repeat-map} property.
 
+The @code{:continue-only'} list specifies the commands that should not
+enter @code{repeat-mode}.  These command should only continue the
+already activated repeating sequence.
+
 The @code{:hints} list can contain cons pairs where the @sc{car} is
 a command and the @sc{cdr} is a string that is displayed alongside of
 the repeatable key in the echo area.
index 10f1f912de610a84621c00fd45ffd05c6d8e69f7..9985451e3fdbfb03eda0be162aec0b3a97962628 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -814,10 +814,13 @@ 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 property 'repeat-continue-only' for 'repeat-mode'.
-A command with this symbol property whose value is non-nil will not
-activate the repeat map in 'repeat-mode', it will only continue the
-already activated repeating sequence.
+A command with this symbol property whose value is a list of repeat
+maps will not activate the repeat map in 'repeat-mode'.  It will only
+continue the already activated repeating sequence.  Also 'defvar-keymap'
+supports a new keyword ':continue-only' with a list of commands that
+only continue the active repeating sequence.
 
 \f
 * Changes in Emacs 31.1 on Non-Free Operating Systems
index abb293e7f230eeaac1beb070fd90a46c20048918..4cb4d40635cf26de5efb17730e2248626a67decf 100644 (file)
@@ -679,6 +679,7 @@ value can also be a property list with properties `:enter',
 `:exit' and `:hints', for example:
 
      :repeat (:enter (commands ...) :exit (commands ...)
+              :continue-only (commands ...)
               :hints ((command . \"hint\") ...))
 
 `:enter' specifies the list of additional commands that only
@@ -694,6 +695,10 @@ Specifying a list of commands is useful when those commands exist
 in this specific map, but should not have the `repeat-map' symbol
 property.
 
+`:continue-only' specifies the list of commands that should not
+enter `repeat-mode'.  These command should only continue the
+already activated repeating sequence.
+
 `:hints' is a list of cons pairs where car is a command and
 cdr is a string that is displayed alongside of the repeatable key
 in the echo area.
@@ -732,6 +737,10 @@ in the echo area.
             def)
         (dolist (def (plist-get repeat :enter))
           (push `(put ',def 'repeat-map ',variable-name) props))
+        (dolist (def (plist-get repeat :continue-only))
+          (push `(put ',def 'repeat-continue-only
+                      (cons ',variable-name (get ',def 'repeat-continue-only)))
+                props))
         (while defs
           (pop defs)
           (setq def (pop defs))
index 6b0c69905d8546746cb012a6373244514498de91..cea54b75868d7f059b09cc8ae56856751fdf9adf 100644 (file)
@@ -504,8 +504,12 @@ See `describe-repeat-maps' for a list of all repeatable commands."
     (setq repeat-in-progress nil)
     (let ((map (repeat-get-map)))
       (when (and (repeat-check-map map)
-                 (or (null (repeat--command-property 'repeat-continue-only))
-                     was-in-progress))
+                 (let ((continue-only (repeat--command-property 'repeat-continue-only)))
+                   (or (null continue-only)
+                       (and (or (not (consp continue-only))
+                                (memq (repeat--command-property 'repeat-map)
+                                      continue-only))
+                            was-in-progress))))
         ;; Messaging
         (funcall repeat-echo-function map)
 
index c560a283039b8760bcbe7a2918b0e7612cb82e5e..d69d431146a2d565cd23bbbf7358956b2637353c 100644 (file)
 
 (defvar-keymap repeat-tests-repeat-map
   :doc "Keymap for repeating sequences."
-  :repeat ( :enter (repeat-tests-call-a)
-            :exit  (repeat-tests-call-q))
+  :repeat ( :enter         (repeat-tests-call-a)
+            :continue-only (repeat-tests-call-o)
+            :exit          (repeat-tests-call-q))
   "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)
 
    ;; :continue-only
    ("C-M-o" . repeat-tests-bind-call-o)
    :exit
-   ("q"     . repeat-tests-bind-call-q)
-   )
+   ("q"     . repeat-tests-bind-call-q))
 
   ;; TODO: it seems there is no :entry, so need to do explicitly:
   (put 'repeat-tests-bind-call-a 'repeat-map 'repeat-tests-bind-keys-repeat-map)