[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 5425614 1/3: Make toolbar show keyboard equivalents
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] master 5425614 1/3: Make toolbar show keyboard equivalents in its tooltips |
Date: |
Sat, 22 Jun 2019 05:16:24 -0400 (EDT) |
branch: master
commit 54256143ef770a48ece146e1f7884447fce8cfd8
Author: Stefan Kangas <address@hidden>
Commit: Eli Zaretskii <address@hidden>
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)
---
etc/NEWS | 3 +++
etc/TODO | 2 --
src/keyboard.c | 13 +++++++++++++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index f0d7457..0cfac24 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -125,6 +125,9 @@ This is intended mostly to help developers.
** Emacs now requires GTK 2.24 and GTK 3.10 for the GTK 2 and GTK 3
builds respectively.
+---
+** The toolbar now shows the equivalent key binding in its tooltips.
+
* Startup Changes in Emacs 27.1
diff --git a/etc/TODO b/etc/TODO
index 273455c..34de81b 100644
--- a/etc/TODO
+++ b/etc/TODO
@@ -176,8 +176,6 @@ See the 'test' directory for examples.
** In Emacs Info, examples of using Customize should be clickable
and they should create Custom buffers.
-** The toolbar should show keyboard equivalents in its tooltips.
-
** Add function to redraw the tool bar.
** Redesign the load-history data structure so it can cope better
diff --git a/src/keyboard.c b/src/keyboard.c
index ab6ca36..0d7f124 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,