emacs-diffs
[Top][All Lists]
Advanced

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

master f0cd91067d: Improve `C-h b' output for remapped commands.


From: Lars Ingebrigtsen
Subject: master f0cd91067d: Improve `C-h b' output for remapped commands.
Date: Thu, 9 Jun 2022 10:42:40 -0400 (EDT)

branch: master
commit f0cd91067d5706bfe95f9fc8bb05c8a9e0e2d052
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Improve `C-h b' output for remapped commands.
    
    * lisp/help.el (describe-map): Include the bindings of the
    remapped commands (bug#14084).
    
    This will result in output like this, instead of just listing the
    remapped commands:
    
    <remap> <display-buffer>                ido-display-buffer
    C-x 4 C-o                               display-buffer
    <remap> <display-buffer-other-frame>    ido-display-buffer-other-frame
    C-x 5 C-o                               display-buffer-other-frame
    <remap> <insert-buffer>                 ido-insert-buffer
    C-x x i                                 insert-buffer
    <remap> <kill-buffer>                   ido-kill-buffer
    C-x k                                   kill-buffer
    <remap> <switch-to-buffer>              ido-switch-buffer
    C-x b                                   switch-to-buffer
    <remap> <switch-to-buffer-other-frame>  ido-switch-buffer-other-frame
    C-x 5 b                                 switch-to-buffer-other-frame
    <remap> <switch-to-buffer-other-window> ido-switch-buffer-other-window
    C-x 4 b                                 switch-to-buffer-other-window
---
 lisp/help.el | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/lisp/help.el b/lisp/help.el
index 1faebdf461..4e0d807cb2 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1503,12 +1503,30 @@ in `describe-map-tree'."
     (let ((vect (sort vect 'help--describe-map-compare))
           (columns ())
           line-start key-end column)
+      ;; If we're in a <remap> section of the output, then also
+      ;; display the bindings of the keys that we've remapped from.
+      ;; This enables the user to actually see what keys to tap to
+      ;; execute the remapped commands.
+      (when (equal prefix [remap])
+        (dolist (binding (prog1 vect
+                           (setq vect nil)))
+          (push binding vect)
+          (when-let ((other (and (not (eq (car binding) 'self-insert-command))
+                                 (car (where-is-internal (car binding))))))
+            (push (list (elt other (1- (length other)))
+                        (car binding)
+                        nil
+                        (seq-into (butlast (seq-into other 'list)) 'vector))
+                  vect)))
+        (setq vect (nreverse vect)))
       ;; Now output them in sorted order.
       (while vect
         (let* ((elem (car vect))
-               (start (car elem))
-               (definition (cadr elem))
-               (shadowed (caddr elem))
+               (start (nth 0 elem))
+               (definition (nth 1 elem))
+               (shadowed (nth 2 elem))
+               ;; We override the prefix for the <remap> extra commands.
+               (prefix (or (nth 3 elem) prefix))
                (end start))
           ;; Find consecutive chars that are identically defined.
           (when (fixnump start)



reply via email to

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