From 921122b6fd2bacdf0248d71bc8871731e5ca87cb Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Tue, 17 Dec 2024 20:51:03 +0200 Subject: [PATCH] Display commands with repeat-continue-only in describe-repeat-maps * lisp/repeat.el (describe-repeat-maps): Display commands with the property 'repeat-continue-only' used to continue the currently active repeat-map (bug#74140). Also use 'cl--map-keymap-recursively' instead of 'map-keymap' to find more deep keybindings. (cherry picked from commit f025c9df48f8ad5f1cb13c9adac2fc1fbeb81b79) --- lisp/repeat.el | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/lisp/repeat.el b/lisp/repeat.el index a0e4ae6bafb..df0eeaecc1a 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -654,15 +654,23 @@ Click on a keymap to see the commands repeatable by the keymap.\n") (symbol-value (car keymap)) (car keymap))) (repeat-commands (cdr keymap)) - map-commands commands-enter commands-exit) - (map-keymap (lambda (_key cmd) - (when (symbolp cmd) (push cmd map-commands))) - map) + map-commands commands-enter commands-exit commands-continue) + (cl--map-keymap-recursively + (lambda (_key cmd) + (when (symbolp cmd) (push cmd map-commands))) + map) (setq map-commands (seq-uniq map-commands)) - (setq commands-enter (seq-difference repeat-commands map-commands)) - (setq commands-exit (seq-difference map-commands repeat-commands)) - - (when (or commands-enter commands-exit) + (setq commands-continue + (seq-filter (lambda (s) (memq (car keymap) + (get s 'repeat-continue-only))) + map-commands)) + (setq commands-enter + (seq-difference repeat-commands map-commands)) + (setq commands-exit + (seq-difference (seq-difference map-commands repeat-commands) + commands-continue)) + + (when (or commands-enter commands-exit commands-continue) (when commands-enter (insert "\n** Entered with:\n\n") (fill-region-as-paragraph @@ -674,6 +682,17 @@ Click on a keymap to see the commands repeatable by the keymap.\n") ", ")) (point))) (insert "\n")) + (when commands-continue + (insert "\n** Continued only with:\n\n") + (fill-region-as-paragraph + (point) + (progn + (insert (mapconcat (lambda (cmd) + (format-message "`%s'" cmd)) + (sort commands-continue #'string<) + ", ")) + (point))) + (insert "\n")) (when commands-exit (insert "\n** Exited with:\n\n") (fill-region-as-paragraph @@ -689,7 +708,7 @@ Click on a keymap to see the commands repeatable by the keymap.\n") ;; Hide ^Ls. (goto-char (point-min)) (while (search-forward "\n\f\n" nil t) - (put-text-property (1+ (match-beginning 0)) (1- (match-end 0)) + (put-text-property (1+ (match-beginning 0)) (1- (match-end 0)) 'invisible t))))))) (provide 'repeat) -- 2.39.5