From: Stefan Kangas Date: Fri, 13 Nov 2020 14:28:34 +0000 (+0100) Subject: Don't shadow bindings by the same command X-Git-Tag: emacs-28.0.90~5072 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=84dd5c9bea9112daa339e4c1b8e4e556988f3195;p=emacs.git 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. --- diff --git a/src/keymap.c b/src/keymap.c index 749f4b6b91c..aaba2ac838a 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 68a8438cb4a..e467b1f0551 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