[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master da325ff7b29 2/3: Add user option to only display default tool bar
From: |
Eli Zaretskii |
Subject: |
master da325ff7b29 2/3: Add user option to only display default tool bar |
Date: |
Sat, 18 May 2024 05:47:56 -0400 (EDT) |
branch: master
commit da325ff7b29b0becdd1356021428fa100d240ec4
Author: Jared Finder <jared@finder.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Add user option to only display default tool bar
This works well with `window-tool-bar-mode', to be added in upcoming
commit. Then the default tool bar is displayed frame-wide and
mode-specific tool bars are displayed in the window that mode is
active in.
* lisp/tool-bar.el (tool-bar-always-show-default): New user option.
(tool-bar--cache-key, tool-bar-make-keymap-1): Return default tool bar
when option is set.
---
lisp/tool-bar.el | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/lisp/tool-bar.el b/lisp/tool-bar.el
index 0f645338674..01c65c42324 100644
--- a/lisp/tool-bar.el
+++ b/lisp/tool-bar.el
@@ -100,7 +100,9 @@ parameter is set to `top', and above the tool bar it is set
to
(defconst tool-bar-keymap-cache (make-hash-table :test #'equal))
(defsubst tool-bar--cache-key ()
- (cons (frame-terminal) (sxhash-eq tool-bar-map)))
+ (cons (frame-terminal)
+ (sxhash-eq (if tool-bar-always-show-default (default-value
'tool-bar-map)
+ tool-bar-map))))
(defsubst tool-bar--secondary-cache-key ()
(cons (frame-terminal) (sxhash-eq secondary-tool-bar-map)))
@@ -191,7 +193,9 @@ in which case the value of `tool-bar-map' is used instead."
bind))
(plist-put plist :image image)))
bind))
- (or map tool-bar-map)))
+ (or map
+ (if tool-bar-always-show-default (default-value 'tool-bar-map)
+ tool-bar-map))))
;;;###autoload
(defun tool-bar-add-item (icon def key &rest props)
@@ -378,6 +382,15 @@ the tool bar."
(modify-all-frames-parameters
(list (cons 'tool-bar-position val))))))
+(defcustom tool-bar-always-show-default nil
+ "If non-nil, `tool-bar-mode' only shows the default tool bar.
+This works well when also using `global-window-tool-bar-mode' to
+display buffer-specific tool bars."
+ :type 'boolean
+ :group 'frames
+ :group 'mouse
+ :version "30.1")
+
;; Modifier bar mode.