diff options
| author | Jared Finder | 2024-01-26 10:08:30 -0800 |
|---|---|---|
| committer | Eli Zaretskii | 2024-05-18 12:46:22 +0300 |
| commit | da325ff7b29b0becdd1356021428fa100d240ec4 (patch) | |
| tree | 7bedb7552cad4e73e53bebea9aa04099d37d8ba4 | |
| parent | fd3ab22a3eec5c3151b0791fc768e555b66e267c (diff) | |
| download | emacs-da325ff7b29b0becdd1356021428fa100d240ec4.tar.gz emacs-da325ff7b29b0becdd1356021428fa100d240ec4.zip | |
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.
| -rw-r--r-- | lisp/tool-bar.el | 17 |
1 files 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 | |||
| 100 | (defconst tool-bar-keymap-cache (make-hash-table :test #'equal)) | 100 | (defconst tool-bar-keymap-cache (make-hash-table :test #'equal)) |
| 101 | 101 | ||
| 102 | (defsubst tool-bar--cache-key () | 102 | (defsubst tool-bar--cache-key () |
| 103 | (cons (frame-terminal) (sxhash-eq tool-bar-map))) | 103 | (cons (frame-terminal) |
| 104 | (sxhash-eq (if tool-bar-always-show-default (default-value 'tool-bar-map) | ||
| 105 | tool-bar-map)))) | ||
| 104 | 106 | ||
| 105 | (defsubst tool-bar--secondary-cache-key () | 107 | (defsubst tool-bar--secondary-cache-key () |
| 106 | (cons (frame-terminal) (sxhash-eq secondary-tool-bar-map))) | 108 | (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." | |||
| 191 | bind)) | 193 | bind)) |
| 192 | (plist-put plist :image image))) | 194 | (plist-put plist :image image))) |
| 193 | bind)) | 195 | bind)) |
| 194 | (or map tool-bar-map))) | 196 | (or map |
| 197 | (if tool-bar-always-show-default (default-value 'tool-bar-map) | ||
| 198 | tool-bar-map)))) | ||
| 195 | 199 | ||
| 196 | ;;;###autoload | 200 | ;;;###autoload |
| 197 | (defun tool-bar-add-item (icon def key &rest props) | 201 | (defun tool-bar-add-item (icon def key &rest props) |
| @@ -378,6 +382,15 @@ the tool bar." | |||
| 378 | (modify-all-frames-parameters | 382 | (modify-all-frames-parameters |
| 379 | (list (cons 'tool-bar-position val)))))) | 383 | (list (cons 'tool-bar-position val)))))) |
| 380 | 384 | ||
| 385 | (defcustom tool-bar-always-show-default nil | ||
| 386 | "If non-nil, `tool-bar-mode' only shows the default tool bar. | ||
| 387 | This works well when also using `global-window-tool-bar-mode' to | ||
| 388 | display buffer-specific tool bars." | ||
| 389 | :type 'boolean | ||
| 390 | :group 'frames | ||
| 391 | :group 'mouse | ||
| 392 | :version "30.1") | ||
| 393 | |||
| 381 | 394 | ||
| 382 | 395 | ||
| 383 | ;; Modifier bar mode. | 396 | ;; Modifier bar mode. |