]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't shadow bindings by the same command
authorStefan Kangas <stefan@marxist.se>
Fri, 13 Nov 2020 14:28:34 +0000 (15:28 +0100)
committerStefan Kangas <stefan@marxist.se>
Sun, 22 Nov 2020 01:45:03 +0000 (02:45 +0100)
* src/keymap.c (describe_vector): Do not say binding is shadowed if
the other key binding points to the same command.  (Bug#9293)
* test/src/keymap-tests.el
(help--describe-vector/bug-9293-same-command-does-not-shadow): New
test.

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

index 749f4b6b91c6b97924756b44dbcee999089169d9..aaba2ac838ae300e6635a6913b574ff1b68607af 100644 (file)
@@ -3130,7 +3130,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
        {
          shadowed_by = shadow_lookup (shadow, kludge, Qt, 0);
 
-         if (!NILP (shadowed_by))
+         if (!NILP (shadowed_by) && !EQ (shadowed_by, definition))
            {
              if (mention_shadow)
                this_shadowed = 1;
index 68a8438cb4a1ff39361b87bd957f4273e6cfd3c8..e467b1f0551e5cb3a63bcfe5207ccb2151fa5c04 100644 (file)
@@ -224,6 +224,30 @@ f          foo  (binding currently shadowed)
 g .. h         foo
 ")))))
 
+(ert-deftest help--describe-vector/bug-9293-same-command-does-not-shadow ()
+  "Check that a command can't be shadowed by the same command."
+  (let ((range-map
+         (let ((map (make-keymap)))
+           (define-key map "0" 'foo)
+           (define-key map "1" 'foo)
+           (define-key map "2" 'foo)
+           (define-key map "3" 'foo)
+           map))
+        (shadow-map
+         (let ((map (make-keymap)))
+           (define-key map "0" 'foo)
+           (define-key map "1" 'foo)
+           (define-key map "2" 'foo)
+           (define-key map "3" 'foo)
+           map)))
+   (with-temp-buffer
+     (help--describe-vector (cadr range-map) nil #'help--describe-command
+                            t shadow-map range-map t)
+     (should (equal (buffer-string)
+                    "
+0 .. 3         foo
+")))))
+
 \f
 ;;;; apropos-internal