emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d6c1c76ba4 1/2: * lisp/repeat.el (describe-repeat-maps): Improve


From: Juri Linkov
Subject: master d6c1c76ba4 1/2: * lisp/repeat.el (describe-repeat-maps): Improve the output.
Date: Thu, 17 Nov 2022 02:30:27 -0500 (EST)

branch: master
commit d6c1c76ba4d1dad4c1a66cfabb54399bf0d4b304
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/repeat.el (describe-repeat-maps): Improve the output.
    
    Print the table of keybindings and a list of commands that
    enter and exit repeat-map.  Use default outline headings.
    https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg00969.html
---
 lisp/repeat.el | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/lisp/repeat.el b/lisp/repeat.el
index 0ae68d6024..f2e1c0ad5a 100644
--- a/lisp/repeat.el
+++ b/lisp/repeat.el
@@ -588,21 +588,32 @@ Used in `repeat-mode'."
                                           (when (and (symbolp (car a))
                                                      (symbolp (car b)))
                                             (string-lessp (car a) (car b))))))
-            (insert (format-message
-                     "`%s' keymap is repeatable by these commands:\n"
-                     (car keymap)))
-            (dolist (command (sort (cdr keymap) #'string-lessp))
-              (let* ((info (help-fns--analyze-function command))
-                     (map (list (if (symbolp (car keymap))
-                                    (symbol-value (car keymap))
-                                  (car keymap))))
-                     (desc (mapconcat (lambda (key)
-                                        (propertize (key-description key)
-                                                    'face 'help-key-binding))
-                                      (or (where-is-internal command map)
-                                          (where-is-internal (nth 3 info) map))
-                                      ", ")))
-                (insert (format-message " `%s' (bound to %s)\n" command 
desc))))
+            (insert (format-message "* `%s'\n" (car keymap)))
+
+            (let* ((map (if (symbolp (car keymap))
+                            (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)
+              (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) (insert "\n"))
+              (when commands-enter
+                (insert (concat "Entered with: "
+                                (mapconcat (lambda (cmd) (format-message 
"`%s'" cmd))
+                                           commands-enter ", ")
+                                "\n")))
+              (when commands-exit
+                (insert (concat "Exited with: "
+                                (mapconcat (lambda (cmd) (format-message 
"`%s'" cmd))
+                                           commands-exit ", ")
+                                "\n"))))
+
+            (when (symbolp (car keymap))
+              (insert (substitute-command-keys (format-message "\\{%s}" (car 
keymap)))))
             (insert "\n")))))))
 
 (provide 'repeat)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]