From 8761a55b751cf2a208496d3441e35c9699127732 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 13 Nov 2020 19:15:21 +0100 Subject: [PATCH 3/3] Say which command shadows a key binding * 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 | 8 +++++++- test/src/keymap-tests.el | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/keymap.c b/src/keymap.c index 174ee4fd50..72141bdd5a 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -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); } } diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el index 340227311c..f62589f74b 100644 --- a/test/src/keymap-tests.el +++ b/test/src/keymap-tests.el @@ -183,14 +183,15 @@ help--describe-vector/bug-9293-one-shadowed-in-range 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 "))))) -- 2.29.2