aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Finder2024-06-08 17:23:58 -0700
committerEli Zaretskii2024-06-09 15:21:34 +0300
commita5c0d682b10fa60925641c6abc3a5dbee024fa46 (patch)
treed8ad62800a6d19bc37b5dc03f3ca87d4df930d3b
parent7f8ded2a85d551c6e3303eaca1697bbd7b9427ef (diff)
downloademacs-a5c0d682b10fa60925641c6abc3a5dbee024fa46.tar.gz
emacs-a5c0d682b10fa60925641c6abc3a5dbee024fa46.zip
Add documentation for window-tool-bar package
Also change window-tool-mode to not pay attention to if tool-bar-map has a buffer local value or not as that made the documentation complicated. Documentation added in Emacs manual, Elisp manual, package commentary, and docstrings. Also extend window-tool-bar support to Emacs 27 and newer. (bug#68765) * doc/emacs/emacs.texi (Top): * doc/emacs/frames.texi (Menu Bars): * doc/emacs/glossary.texi (Glossary): * doc/emacs/modes.texi (Minor Modes): * doc/emacs/windows.texi (Windows, Tab Line): Mention Window Tool Bar. (Window Tool Bar): New documentation. * doc/lispref/elisp.texi (Top): * doc/lispref/modes.texi (Mode Line Format, Mode Line Basics) (Mode Line Data): Mention Tab Lines. (Tab Lines): New documentation. * etc/NEWS: Mention newly added variable and package. * lisp/window-tool-bar.el (window-tool-bar-mode): Don't display tool bar when tool-bar-map is nil. * lisp/window-tool-bar.el (tool-bar-always-show-default): Define variable for older Emacs versions.
-rw-r--r--doc/emacs/emacs.texi1
-rw-r--r--doc/emacs/frames.texi14
-rw-r--r--doc/emacs/glossary.texi10
-rw-r--r--doc/emacs/modes.texi3
-rw-r--r--doc/emacs/windows.texi43
-rw-r--r--doc/lispref/elisp.texi1
-rw-r--r--doc/lispref/modes.texi56
-rw-r--r--etc/NEWS12
-rw-r--r--lisp/window-tool-bar.el27
9 files changed, 135 insertions, 32 deletions
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index 7d77f13ab21..8246041fb95 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -529,6 +529,7 @@ Multiple Windows
529* Temporary Displays:: Displaying non-editable buffers. 529* Temporary Displays:: Displaying non-editable buffers.
530* Window Convenience:: Convenience functions for window handling. 530* Window Convenience:: Convenience functions for window handling.
531* Tab Line:: Window tab line. 531* Tab Line:: Window tab line.
532* Window Tool Bar:: A tool bar that is attached to windows.
532 533
533Displaying a Buffer in a Window 534Displaying a Buffer in a Window
534 535
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index 6c62fde4ffb..e1fbf9768af 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -1295,16 +1295,22 @@ menus' visual appearance.
1295@node Tool Bars 1295@node Tool Bars
1296@section Tool Bars 1296@section Tool Bars
1297@cindex tool bar mode 1297@cindex tool bar mode
1298@cindex tool bar, attached to frame
1298@cindex mode, Tool Bar 1299@cindex mode, Tool Bar
1299@cindex icons, toolbar 1300@cindex icons, toolbar
1300 1301
1301 On graphical displays, Emacs puts a @dfn{tool bar} at the top of 1302 On graphical displays, Emacs puts a @dfn{tool bar} at the top of each
1302each frame, just below the menu bar. This is a row of icons which you 1303frame, just below the menu bar. This is a row of buttons with icons
1303can click on with the mouse to invoke various commands. 1304which you can click on with the mouse to invoke various commands. Emacs
1305can also optionally display a tool bar at the top of each window
1306(@pxref{Window Tool Bar}).
1304 1307
1308@vindex tool-bar-always-show-default
1305 The global (default) tool bar contains general commands. Some major 1309 The global (default) tool bar contains general commands. Some major
1306modes define their own tool bars; whenever a buffer with such a major 1310modes define their own tool bars; whenever a buffer with such a major
1307mode is current, the mode's tool bar replaces the global tool bar. 1311mode is current, the mode's tool bar replaces the global tool bar. To
1312prevent this replacement from happening, customize the variable
1313@code{tool-bar-always-show-default}.
1308 1314
1309@findex tool-bar-mode 1315@findex tool-bar-mode
1310@vindex tool-bar-mode 1316@vindex tool-bar-mode
diff --git a/doc/emacs/glossary.texi b/doc/emacs/glossary.texi
index 344e4831f36..e245cb81754 100644
--- a/doc/emacs/glossary.texi
+++ b/doc/emacs/glossary.texi
@@ -1436,10 +1436,12 @@ particular appearance or behavior. For example, you might use a theme
1436for your favorite set of faces (q.v.). 1436for your favorite set of faces (q.v.).
1437 1437
1438@item Tool Bar 1438@item Tool Bar
1439The tool bar is a line (sometimes multiple lines) of icons at the top 1439The tool bar is a line (sometimes multiple lines) of buttons with icons
1440of an Emacs frame. Clicking on one of these icons executes a command. 1440at the top of an Emacs frame. Clicking on one of these buttons executes
1441You can think of this as a graphical relative of the menu bar (q.v.). 1441a command. You can think of this as a graphical relative of the menu
1442@xref{Tool Bars}. 1442bar (q.v.). @xref{Tool Bars}. There is also a window tool bar that
1443behaves similarly, but is at the top of an Emacs window. @xref{Window
1444Tool Bar}.
1443 1445
1444@anchor{Glossary---Tooltips} 1446@anchor{Glossary---Tooltips}
1445@item Tooltips 1447@item Tooltips
diff --git a/doc/emacs/modes.texi b/doc/emacs/modes.texi
index 2776dc72a27..1321464014d 100644
--- a/doc/emacs/modes.texi
+++ b/doc/emacs/modes.texi
@@ -296,6 +296,9 @@ but the tool bar is only displayed on graphical terminals. @xref{Tool
296Bars}. 296Bars}.
297 297
298@item 298@item
299Window Tool Bar mode gives windows a tool bar. @xref{Window Tool Bar}.
300
301@item
299Tab Bar mode gives each frame a tab bar. @xref{Tab Bars}. 302Tab Bar mode gives each frame a tab bar. @xref{Tab Bars}.
300 303
301@item 304@item
diff --git a/doc/emacs/windows.texi b/doc/emacs/windows.texi
index ad2225b5922..80394e0e571 100644
--- a/doc/emacs/windows.texi
+++ b/doc/emacs/windows.texi
@@ -22,6 +22,7 @@ one frame.
22* Displaying Buffers:: How Emacs picks a window for displaying a buffer. 22* Displaying Buffers:: How Emacs picks a window for displaying a buffer.
23* Window Convenience:: Convenience functions for window handling. 23* Window Convenience:: Convenience functions for window handling.
24* Tab Line:: Window tab line. 24* Tab Line:: Window tab line.
25* Window Tool Bar:: A tool bar that is attached to windows.
25@end menu 26@end menu
26 27
27@node Basic Window 28@node Basic Window
@@ -689,3 +690,45 @@ Whereas tabs on the Tab Bar at the top of each frame are used to
689switch between window configurations containing several windows with buffers, 690switch between window configurations containing several windows with buffers,
690tabs on the Tab Line at the top of each window are used to switch 691tabs on the Tab Line at the top of each window are used to switch
691between buffers in the window. 692between buffers in the window.
693
694Also note that the tab line displays in the same space as the window
695tool bar, so only one of these can be display at a time unless you
696customize the value of @code{tab-line-format} in Lisp. In this case,
697add @code{(:eval (tab-line-format))} to @code{tab-line-format}.
698@xref{Mode Line Format,,, elisp, The Emacs Lisp Reference Manual}.
699
700
701@node Window Tool Bar
702@section Window Tool Bar
703
704@cindex window tool bar
705@cindex mode, window tool bar
706@cindex tool bar, attached to window
707
708@findex global-window-tool-bar-mode
709 The command @code{global-window-tool-bar-mode} toggles the display of
710a tool bar at the top of each window. When enabled, multiple windows
711can display their own tool bar simultaneously. To conserve space, a
712window tool bar is hidden if there are no buttons to show, i.e. if
713@code{tool-bar-map} is @code{nil}.
714
715@findex window-tool-bar-mode
716If you want to toggle the display of a window tool bar for only some
717buffers, run the command @code{window-tool-bar-mode} in those buffers.
718This is useful to put in a mode hook. For example, if you want the window
719tool bar to appear only for buffers that do not represent files and have
720a custom tool bar, you could add the following code to your init file
721(@pxref{Init File}):
722
723@example
724(add-hook 'special-mode-hook 'window-tool-bar-mode)
725@end example
726
727Emacs can also display a single tool bar at the top of frames
728(@pxref{Tool Bars}).
729
730Note that the window tool bar displays in the same space as the tab
731line, so only one of these can be display at a time unless you customize
732the value of @code{tab-line-format} in Lisp. In this case, add
733@code{(:eval (window-tool-bar-string))} to @code{tab-line-format}.
734@xref{Mode Line Format,,, elisp, The Emacs Lisp Reference Manual}.
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 339272d1f05..1059d0dcf61 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -925,6 +925,7 @@ Mode Line Format
925* %-Constructs:: Putting information into a mode line. 925* %-Constructs:: Putting information into a mode line.
926* Properties in Mode:: Using text properties in the mode line. 926* Properties in Mode:: Using text properties in the mode line.
927* Header Lines:: Like a mode line, but at the top. 927* Header Lines:: Like a mode line, but at the top.
928* Tab Lines:: A line that is above the header line.
928* Emulating Mode Line:: Formatting text as the mode line would. 929* Emulating Mode Line:: Formatting text as the mode line would.
929 930
930Font Lock Mode 931Font Lock Mode
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index cf67b319924..f3d4f5347b3 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -2074,14 +2074,14 @@ their previous values/states (using the companion function
2074line at the bottom, which displays status information about the buffer 2074line at the bottom, which displays status information about the buffer
2075displayed in the window. The mode line contains information about the 2075displayed in the window. The mode line contains information about the
2076buffer, such as its name, associated file, depth of recursive editing, 2076buffer, such as its name, associated file, depth of recursive editing,
2077and major and minor modes. A window can also have a @dfn{header 2077and major and minor modes. A window can also have a @dfn{header line}
2078line}, which is much like the mode line but appears at the top of the 2078and a @dfn{tab line}, which are much like the mode line but they appear
2079window. 2079at the top of the window.
2080 2080
2081 This section describes how to control the contents of the mode line 2081 This section describes how to control the contents of the mode line,
2082and header line. We include it in this chapter because much of the 2082header line, and tab line. We include it in this chapter because much
2083information displayed in the mode line relates to the enabled major and 2083of the information displayed in the mode line relates to the enabled
2084minor modes. 2084major and minor modes.
2085 2085
2086@menu 2086@menu
2087* Base: Mode Line Basics. Basic ideas of mode line control. 2087* Base: Mode Line Basics. Basic ideas of mode line control.
@@ -2091,6 +2091,7 @@ minor modes.
2091* %-Constructs:: Putting information into a mode line. 2091* %-Constructs:: Putting information into a mode line.
2092* Properties in Mode:: Using text properties in the mode line. 2092* Properties in Mode:: Using text properties in the mode line.
2093* Header Lines:: Like a mode line, but at the top. 2093* Header Lines:: Like a mode line, but at the top.
2094* Tab Lines:: A line that is above the header line.
2094* Emulating Mode Line:: Formatting text as the mode line would. 2095* Emulating Mode Line:: Formatting text as the mode line would.
2095@end menu 2096@end menu
2096 2097
@@ -2101,11 +2102,13 @@ minor modes.
2101variable @code{mode-line-format} (@pxref{Mode Line Top}). This variable 2102variable @code{mode-line-format} (@pxref{Mode Line Top}). This variable
2102holds a @dfn{mode line construct}: a template that controls what is 2103holds a @dfn{mode line construct}: a template that controls what is
2103displayed on the buffer's mode line. The value of 2104displayed on the buffer's mode line. The value of
2104@code{header-line-format} specifies the buffer's header line in the same 2105@code{header-line-format} and @code{tab-line-format} specifies the
2105way. All windows for the same buffer use the same 2106buffer's header line and tab line in the same way. All windows for the
2106@code{mode-line-format} and @code{header-line-format} unless a 2107same buffer use the same @code{mode-line-format},
2107@code{mode-line-format} or @code{header-line-format} parameter has been 2108@code{header-line-format}, and @code{tab-line-format} unless a
2108specified for that window (@pxref{Window Parameters}). 2109@code{mode-line-format}, @code{header-line-format}, or
2110@code{tab-line-format} parameter has been specified for that window
2111(@pxref{Window Parameters}).
2109 2112
2110 For efficiency, Emacs does not continuously recompute each window's 2113 For efficiency, Emacs does not continuously recompute each window's
2111mode line and header line. It does so when circumstances appear to call 2114mode line and header line. It does so when circumstances appear to call
@@ -2167,8 +2170,8 @@ buffers.
2167@dfn{mode line construct}, made up of lists, strings, symbols, and 2170@dfn{mode line construct}, made up of lists, strings, symbols, and
2168numbers kept in buffer-local variables. Each data type has a specific 2171numbers kept in buffer-local variables. Each data type has a specific
2169meaning for the mode line appearance, as described below. The same data 2172meaning for the mode line appearance, as described below. The same data
2170structure is used for constructing frame titles (@pxref{Frame Titles}) 2173structure is used for constructing frame titles (@pxref{Frame Titles}),
2171and header lines (@pxref{Header Lines}). 2174header lines (@pxref{Header Lines}), and tab lines (@pxref{Tab Lines}).
2172 2175
2173 A mode line construct may be as simple as a fixed string of text, 2176 A mode line construct may be as simple as a fixed string of text,
2174but it usually specifies how to combine fixed strings with variables' 2177but it usually specifies how to combine fixed strings with variables'
@@ -2816,6 +2819,31 @@ window that is two lines tall cannot display both a mode line and a
2816header line at once; if it has a mode line, then it does not display a 2819header line at once; if it has a mode line, then it does not display a
2817header line. 2820header line.
2818 2821
2822@node Tab Lines
2823@subsection Window Tab Lines
2824@cindex tab line (of a window)
2825@cindex window tab line
2826
2827 A window can have a @dfn{tab line} at the top. If both the tab line
2828and header line are visible, the tab line appears above the header line.
2829The tab line feature is controlled like the mode line feature, except
2830that it's controlled by @code{tab-line-format}. Unlike the mode line,
2831the tab line is only expected to be used to display a list of tabs
2832(@pxref{Tab Line,,, emacs, The GNU Emacs Manual}) or the window
2833tool bar (@pxref{Window Tool Bar,,, emacs, The GNU Emacs Manual}):
2834
2835@defvar tab-line-format
2836This variable, local in every buffer, specifies how to display the tab
2837line, for windows displaying the buffer. The format of the value is the
2838same as for @code{mode-line-format} (@pxref{Mode Line Data}). It is
2839normally @code{nil}, so that ordinary buffers have no tab line.
2840@end defvar
2841
2842@defun window-tab-line-height &optional window
2843This function returns the height in pixels of @var{window}'s tab line.
2844@var{window} must be a live window, and defaults to the selected window.
2845@end defun
2846
2819@node Emulating Mode Line 2847@node Emulating Mode Line
2820@subsection Emulating Mode Line Formatting 2848@subsection Emulating Mode Line Formatting
2821 2849
diff --git a/etc/NEWS b/etc/NEWS
index dba709279bb..f86794cd099 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -265,6 +265,11 @@ When this minor mode is enabled, buttons representing modifier keys
265are displayed along the tool bar. 265are displayed along the tool bar.
266 266
267+++ 267+++
268** New user option 'tool-bar-always-show-default'.
269When non-nil, the tool bar at the top of a frame does not show buffer
270local customization of the tool bar. The default value is nil.
271
272+++
268** "d" in the mode line now indicates that the window is dedicated. 273** "d" in the mode line now indicates that the window is dedicated.
269Windows have always been able to be dedicated to a specific buffer; 274Windows have always been able to be dedicated to a specific buffer;
270see 'window-dedicated-p'. Now the mode line indicates the dedicated 275see 'window-dedicated-p'. Now the mode line indicates the dedicated
@@ -2017,6 +2022,13 @@ To revert to the previous behavior, set the (also new) variable
2017'async-shell-command-mode' to 'shell-mode'. Any hooks or mode-specific 2022'async-shell-command-mode' to 'shell-mode'. Any hooks or mode-specific
2018variables used should be adapted appropriately. 2023variables used should be adapted appropriately.
2019 2024
2025+++
2026** New package Window-Tool-Bar.
2027This provides a new minor mode, 'window-tool-bar-mode'. When this minor
2028mode is enabled, a tool bar is displayed at the top of a window. To
2029conserve space, no tool bar is shown if 'tool-bar-map' is nil. The
2030global minor mode 'global-window-tool-bar-mode' enables this minor mode
2031in all buffers.
2020 2032
2021* Incompatible Lisp Changes in Emacs 30.1 2033* Incompatible Lisp Changes in Emacs 30.1
2022 2034
diff --git a/lisp/window-tool-bar.el b/lisp/window-tool-bar.el
index a9d10650b98..63484da3255 100644
--- a/lisp/window-tool-bar.el
+++ b/lisp/window-tool-bar.el
@@ -4,9 +4,9 @@
4 4
5;; Author: Jared Finder <jared@finder.org> 5;; Author: Jared Finder <jared@finder.org>
6;; Created: Nov 21, 2023 6;; Created: Nov 21, 2023
7;; Version: 0.2 7;; Version: 0.2.1
8;; Keywords: mouse 8;; Keywords: mouse
9;; Package-Requires: ((emacs "29.1")) 9;; Package-Requires: ((emacs "27.1") (compat "29.1"))
10 10
11;; This is a GNU ELPA :core package. Avoid adding functionality that 11;; This is a GNU ELPA :core package. Avoid adding functionality that
12;; is not available in the version of Emacs recorded above or any of 12;; is not available in the version of Emacs recorded above or any of
@@ -35,11 +35,11 @@
35;; generally have sensible tool bars, for example: *info*, *help*, and 35;; generally have sensible tool bars, for example: *info*, *help*, and
36;; *eww* have them. 36;; *eww* have them.
37;; 37;;
38;; It does this while being mindful of screen real estate. Most modes 38;; It does this while being mindful of screen real estate. If
39;; do not provide a custom tool bar, and this package does not show the 39;; `tool-bar-map' is nil, then this package will not take up any space
40;; default tool bar. This means that for most buffers there will be no 40;; for an empty tool bar. Most modes do not define a custom tool bar,
41;; space taken up. Furthermore, you can put this tool bar in the mode 41;; so calling (setq tool-bar-map nil) in your init file will make most
42;; line or tab line if you want to share it with existing content. 42;; buffers not take up space for a tool bar.
43;; 43;;
44;; To get the default behavior, run (global-window-tool-bar-mode 1) or 44;; To get the default behavior, run (global-window-tool-bar-mode 1) or
45;; enable via M-x customize-group RET window-tool-bar RET. This uses 45;; enable via M-x customize-group RET window-tool-bar RET. This uses
@@ -48,6 +48,9 @@
48;; If you want to share space with an existing tab line, mode line, or 48;; If you want to share space with an existing tab line, mode line, or
49;; header line, add (:eval (window-tool-bar-string)) to 49;; header line, add (:eval (window-tool-bar-string)) to
50;; `tab-line-format', `mode-line-format', or `header-line-format'. 50;; `tab-line-format', `mode-line-format', or `header-line-format'.
51;;
52;; For additional documentation, see info node `(emacs)Window Tool
53;; Bar'
51 54
52;;; Known issues: 55;;; Known issues:
53;; 56;;
@@ -92,6 +95,7 @@
92 95
93;;; Code: 96;;; Code:
94 97
98(require 'compat)
95(require 'mwheel) 99(require 'mwheel)
96(require 'tab-line) 100(require 'tab-line)
97(require 'tool-bar) 101(require 'tool-bar)
@@ -271,7 +275,7 @@ This is for when you want more customizations than
271(defun window-tool-bar--keymap-entry-to-string (menu-item) 275(defun window-tool-bar--keymap-entry-to-string (menu-item)
272 "Convert MENU-ITEM into a (propertized) string representation. 276 "Convert MENU-ITEM into a (propertized) string representation.
273 277
274MENU-ITEM is a menu item to convert. See info node (elisp)Tool Bar." 278MENU-ITEM is a menu item to convert. See info node `(elisp)Tool Bar'."
275 (pcase-exhaustive menu-item 279 (pcase-exhaustive menu-item
276 ;; Separators 280 ;; Separators
277 ((or `(,_ "--") 281 ((or `(,_ "--")
@@ -394,8 +398,7 @@ enclosed in a `progn' form. ELSE-FORMS may be empty."
394 "Toggle display of the tool bar in the tab line of the current buffer." 398 "Toggle display of the tool bar in the tab line of the current buffer."
395 :global nil 399 :global nil
396 (let ((should-display (and window-tool-bar-mode 400 (let ((should-display (and window-tool-bar-mode
397 (not (eq tool-bar-map 401 tool-bar-map))
398 (default-value 'tool-bar-map)))))
399 (default-value '(:eval (window-tool-bar-string)))) 402 (default-value '(:eval (window-tool-bar-string))))
400 403
401 ;; Preserve existing tab-line set outside of this mode 404 ;; Preserve existing tab-line set outside of this mode
@@ -465,6 +468,10 @@ capabilities."
465 :group 'window-tool-bar) 468 :group 'window-tool-bar)
466 469
467;;; Workaround for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68334. 470;;; Workaround for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68334.
471
472;; This special variable is added in Emacs 30.1.
473(defvar tool-bar-always-show-default)
474
468(defun window-tool-bar--get-keymap () 475(defun window-tool-bar--get-keymap ()
469 "Return the tool bar keymap." 476 "Return the tool bar keymap."
470 (let ((tool-bar-always-show-default nil)) 477 (let ((tool-bar-always-show-default nil))