emacs-diffs
[Top][All Lists]
Advanced

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

master cee9a2cbe0: Fix substitute-command-keys for global binding lookup


From: Robert Pluim
Subject: master cee9a2cbe0: Fix substitute-command-keys for global binding lookup
Date: Wed, 21 Sep 2022 03:16:53 -0400 (EDT)

branch: master
commit cee9a2cbe0cd2cb1af602077727c03f2ae62fa90
Author: Robert Pluim <rpluim@gmail.com>
Commit: Robert Pluim <rpluim@gmail.com>

    Fix substitute-command-keys for global binding lookup
    
    The previous change forgot to account for the (rare) case of doing a
    lookup for a global binding when a specific keymap is in force.
    
    * lisp/help.el (substitute-command-keys): Redo lookup in global map if
    lookup in specific map fails.
    *
    test/lisp/help-tests.el (help-tests-substitute-command-keys/keymap-change):
    Add testcase for specific map overriding advertised-binding.
---
 lisp/help.el            | 6 ++++++
 test/lisp/help-tests.el | 6 +++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/help.el b/lisp/help.el
index 0ec5b9c85b..b4b9120da3 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1208,6 +1208,12 @@ Otherwise, return a new string."
                                                  (and keymap
                                                       (list keymap))
                                                  t))))
+                  ;; If we're looking in a particular keymap which has
+                  ;; no binding, then we need to redo the lookup, with
+                  ;; the global map as well this time.
+                  (when (and (not key) keymap)
+                    (setq key (with-current-buffer orig-buf
+                                (where-is-internal fun keymap t))))
                   (if (not key)
                       ;; Function is not on any key.
                       (let ((op (point)))
diff --git a/test/lisp/help-tests.el b/test/lisp/help-tests.el
index 6f1dcfa5b6..0fcaacb644 100644
--- a/test/lisp/help-tests.el
+++ b/test/lisp/help-tests.el
@@ -181,8 +181,12 @@ M-g M-c            switch-to-completions
 
 (ert-deftest help-tests-substitute-command-keys/keymap-change ()
   (with-substitute-command-keys-test
+   ;; Global binding should be found even if specifying a specific map
    (test "\\<minibuffer-local-must-match-map>\\[abort-recursive-edit]" "C-]")
-   (test "\\<emacs-lisp-mode-map>\\[eval-defun]" "C-M-x")))
+   (test "\\<emacs-lisp-mode-map>\\[eval-defun]" "C-M-x")
+   ;; Specific map overrides advertised-binding
+   (test "\\<undo-repeat-map>\\[undo]" "u")
+   (test "\\[undo]" "C-x u")))
 
 (defvar-keymap help-tests-remap-map
   :full t



reply via email to

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