]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix substitute-command-keys for global binding lookup
authorRobert Pluim <rpluim@gmail.com>
Wed, 21 Sep 2022 07:12:53 +0000 (09:12 +0200)
committerRobert Pluim <rpluim@gmail.com>
Wed, 21 Sep 2022 07:15:47 +0000 (09:15 +0200)
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
test/lisp/help-tests.el

index 0ec5b9c85b80467e07d0ef5df065db30397f158e..b4b9120da3e00db611bf29e7fe8963539baa226a 100644 (file)
@@ -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)))
index 6f1dcfa5b6b06ec87c216be6f1a58e93def4e4e3..0fcaacb644352873d69845ece9fcd7d3d8f96600 100644 (file)
@@ -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