]> git.eshelyaron.com Git - emacs.git/commitdiff
Say which command shadows a key binding
authorStefan Kangas <stefan@marxist.se>
Fri, 13 Nov 2020 18:15:21 +0000 (19:15 +0100)
committerStefan Kangas <stefan@marxist.se>
Sun, 22 Nov 2020 01:48:53 +0000 (02:48 +0100)
* src/keymap.c (describe_vector): Say which command shadows this
binding.  (Bug#9293)
* test/src/keymap-tests.el
(help--describe-vector/bug-9293-one-shadowed-in-range): Adapt
test.

src/keymap.c
test/src/keymap-tests.el

index aaba2ac838ae300e6635a6913b574ff1b68607af..e22eb411f63ce9e9d5d90a20c1dffcd22774e56b 100644 (file)
@@ -3223,7 +3223,13 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
       if (this_shadowed)
        {
          SET_PT (PT - 1);
-         insert_string ("  (binding currently shadowed)");
+         static char const fmt[] = "  (currently shadowed by `%s')";
+         USE_SAFE_ALLOCA;
+         char *buffer = SAFE_ALLOCA (sizeof fmt +
+                                     SBYTES (SYMBOL_NAME (shadowed_by)));
+         esprintf (buffer, fmt, SDATA (SYMBOL_NAME (shadowed_by)));
+         insert_string (buffer);
+         SAFE_FREE();
          SET_PT (PT + 1);
        }
     }
index e467b1f0551e5cb3a63bcfe5207ccb2151fa5c04..6411cd1f0d44d0b3b81b3384e895017d830bbfde 100644 (file)
@@ -58,7 +58,6 @@
   (let* (menu-item-filter-ran
          (object `(menu-item "2" identity
                              :filter ,(lambda (cmd)
-                                        (message "foo")
                                         (setq menu-item-filter-ran t)
                                         cmd))))
     (keymap--get-keyelt object t)
@@ -213,14 +212,15 @@ commit 86c19714b097aa477d339ed99ffb5136c755a046."
                     map))
         (shadow-map (let ((map (make-keymap)))
                       (define-key map "f" 'bar)
-                      map)))
+                      map))
+        (text-quoting-style 'grave))
     (with-temp-buffer
       (help--describe-vector (cadr orig-map) nil #'help--describe-command
                              t shadow-map orig-map t)
       (should (equal (buffer-string)
                      "
 e              foo
-f              foo  (binding currently shadowed)
+f              foo  (currently shadowed by `bar')
 g .. h         foo
 ")))))