From 4ef177d0133d1e97b13b8dcfe98c3093ac02d897 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 13 Nov 2020 15:28:34 +0100 Subject: [PATCH 2/3] 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 4616f27c25..174ee4fd50 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 b230958b36..340227311c 100644 --- a/test/src/keymap-tests.el +++ b/test/src/keymap-tests.el @@ -194,6 +194,30 @@ help--describe-vector/bug-9293-one-shadowed-in-range 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 -- 2.29.2