summaryrefslogtreecommitdiff
path: root/src/keyboard.c
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2019-06-09 04:27:09 +0200
committerEli Zaretskii <eliz@gnu.org>2019-06-22 12:12:34 +0300
commit54256143ef770a48ece146e1f7884447fce8cfd8 (patch)
treecbc19dce868bdb753b157317069a4b024e9eac5a /src/keyboard.c
parentefda44fb72d0f1ed7f8a6506f2cb1ddd504d93b8 (diff)
downloademacs-54256143ef770a48ece146e1f7884447fce8cfd8.tar.gz
emacs-54256143ef770a48ece146e1f7884447fce8cfd8.tar.bz2
emacs-54256143ef770a48ece146e1f7884447fce8cfd8.zip
Make toolbar show keyboard equivalents in its tooltips
* src/keyboard.c (parse_tool_bar_item): Add equivalent key binding to the tooltip string of toolbar buttons. * etc/NEWS: Announce it. * etc/TODO: Remove its entry. (Bug#36156)
Diffstat (limited to 'src/keyboard.c')
-rw-r--r--src/keyboard.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index ab6ca36219d..0d7f124f5f3 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -8297,6 +8297,19 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
if (CONSP (get_keymap (PROP (TOOL_BAR_ITEM_BINDING), 0, 1)))
return 0;
+ /* If there is a key binding, add it to the help, which will be
+ displayed as a tooltip for this entry. */
+ Lisp_Object binding = PROP (TOOL_BAR_ITEM_BINDING);
+ Lisp_Object keys = Fwhere_is_internal (binding, Qnil, Qt, Qnil, Qnil);
+ if (!NILP (keys))
+ {
+ AUTO_STRING (beg, " (");
+ AUTO_STRING (end, ")");
+ Lisp_Object orig = PROP (TOOL_BAR_ITEM_HELP);
+ Lisp_Object desc = Fkey_description (keys, Qnil);
+ set_prop (TOOL_BAR_ITEM_HELP, CALLN (Fconcat, orig, beg, desc, end));
+ }
+
/* Enable or disable selection of item. */
if (!EQ (PROP (TOOL_BAR_ITEM_ENABLED_P), Qt))
set_prop (TOOL_BAR_ITEM_ENABLED_P,