emacs-diffs
[Top][All Lists]
Advanced

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

master 84dd5c9 2/3: Don't shadow bindings by the same command


From: Stefan Kangas
Subject: master 84dd5c9 2/3: Don't shadow bindings by the same command
Date: Sat, 21 Nov 2020 21:19:09 -0500 (EST)

branch: master
commit 84dd5c9bea9112daa339e4c1b8e4e556988f3195
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    Don't shadow bindings by the same command
    
    * 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             |  2 +-
 test/src/keymap-tests.el | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/keymap.c b/src/keymap.c
index 749f4b6..aaba2ac 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -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;
diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el
index 68a8438..e467b1f 100644
--- a/test/src/keymap-tests.el
+++ b/test/src/keymap-tests.el
@@ -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
+")))))
+
 
 ;;;; apropos-internal
 



reply via email to

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