From 9e81aee67bdf075e675519294fa8d17c379f64c8 Mon Sep 17 00:00:00 2001 From: Jared Finder Date: Mon, 20 May 2024 21:59:14 -0700 Subject: [PATCH] Adding documentation for window-tool-bar (bug#68765) * doc/emacs/emacs.texi (Top): * doc/emacs/frames.texi (Tool Bars): * doc/emacs/glossary.texi (Glossary): * doc/emacs/modes.texi (Minor Modes): Mention Window Tool Bar and add xref. * doc/emacs/windows.texi (Windows, Tab Line): New documentation. * doc/lispref/elisp.texi (Top): * doc/lispref/modes.texi (Mode Line Format, Mode Line Basics) (Mode Line Data): Mention Tab Lines and add xref. (Tab Lines): New documentation. * etc/NEWS: Mention newly added variable 'tool-bar-always-show-default' and new package 'window-tool-bar' --- doc/emacs/emacs.texi | 1 + doc/emacs/frames.texi | 14 ++++++++--- doc/emacs/glossary.texi | 10 +++++--- doc/emacs/modes.texi | 4 +++ doc/emacs/windows.texi | 37 +++++++++++++++++++++++++++ doc/lispref/elisp.texi | 1 + doc/lispref/modes.texi | 56 ++++++++++++++++++++++++++++++----------- etc/NEWS | 14 +++++++++++ 8 files changed, 115 insertions(+), 22 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 @@ Top * Temporary Displays:: Displaying non-editable buffers. * Window Convenience:: Convenience functions for window handling. * Tab Line:: Window tab line. +* Window Tool Bar:: A tool bar that is attached to windows. Displaying a Buffer in a Window 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 @@ Menu Bars @node Tool Bars @section Tool Bars @cindex tool bar mode +@cindex tool bar, attached to frame @cindex mode, Tool Bar @cindex icons, toolbar - On graphical displays, Emacs puts a @dfn{tool bar} at the top of -each frame, just below the menu bar. This is a row of icons which you -can click on with the mouse to invoke various commands. + On graphical displays, Emacs puts a @dfn{tool bar} at the top of each +frame, just below the menu bar. This is a row of buttons with icons +which you can click on with the mouse to invoke various commands. Emacs +can also optionally display a tool bar at the top of each window +(@pxref{Window Tool Bar}). +@vindex tool-bar-always-show-default The global (default) tool bar contains general commands. Some major modes define their own tool bars; whenever a buffer with such a major -mode is current, the mode's tool bar replaces the global tool bar. +mode is current, the mode's tool bar replaces the global tool bar. To +prevent this replacement from happening, customize the variable +@code{tool-bar-always-show-default}. @findex tool-bar-mode @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 @@ Glossary for your favorite set of faces (q.v.). @item Tool Bar -The tool bar is a line (sometimes multiple lines) of icons at the top -of an Emacs frame. Clicking on one of these icons executes a command. -You can think of this as a graphical relative of the menu bar (q.v.). -@xref{Tool Bars}. +The tool bar is a line (sometimes multiple lines) of buttons with icons +at the top of an Emacs frame. Clicking on one of these buttons executes +a command. You can think of this as a graphical relative of the menu +bar (q.v.). @xref{Tool Bars}. There is also a window tool bar that +behaves similarly, but is at the top of an Emacs window. @xref{Window +Tool Bar}. @anchor{Glossary---Tooltips} @item Tooltips diff --git a/doc/emacs/modes.texi b/doc/emacs/modes.texi index 2776dc72a27..253042b28a3 100644 --- a/doc/emacs/modes.texi +++ b/doc/emacs/modes.texi @@ -295,6 +295,10 @@ Minor Modes but the tool bar is only displayed on graphical terminals. @xref{Tool Bars}. +@item +Window Tool Bar mode gives windows a tool bar when it is different from +the default tool bar. @xref{Window Tool Bar}. + @item Tab Bar mode gives each frame a tab bar. @xref{Tab Bars}. diff --git a/doc/emacs/windows.texi b/doc/emacs/windows.texi index ad2225b5922..67b107dcaff 100644 --- a/doc/emacs/windows.texi +++ b/doc/emacs/windows.texi @@ -22,6 +22,7 @@ Windows * Displaying Buffers:: How Emacs picks a window for displaying a buffer. * Window Convenience:: Convenience functions for window handling. * Tab Line:: Window tab line. +* Window Tool Bar:: A tool bar that is attached to windows. @end menu @node Basic Window @@ -689,3 +690,39 @@ Tab Line switch between window configurations containing several windows with buffers, tabs on the Tab Line at the top of each window are used to switch between buffers in the window. + + +@node Window Tool Bar +@section Window Tool Bar + +@cindex window tool bar +@cindex mode, window tool bar +@cindex tool bar, attached to window + +@findex global-window-tool-bar-mode + The command @code{global-window-tool-bar-mode} toggles the display of +a tool bar at the top of each window. When enabled, multiple windows +can display their own tool bar simultaneously. To conserve space, a +window tool bar is hidden if there are no buttons to show, i.e. if +@var{tool-bar-map} is @code{nil}. + +@findex window-tool-bar-mode +If you want to toggle the display of a window tool bar for only some +buffers, run the command @code{window-tool-bar-mode} in those buffers. +This is useful to put in a mode hook. For example, if you want the window +tool bar to appear only for buffers that do not represent files and have +a custom tool bar, you could add the following code to your init file +(@pxref{Init File}): + +@example +(add-hook 'special-mode-hook 'window-tool-bar-mode) +@end example + +Emacs can also display a single tool bar at the top of frames +(@pxref{Tool Bars}). + +Note that the window tool bar displays in the same space as the tab +line, so only one of these can be display at a time unless you customize +the value of @code{tab-line-format} in Lisp. In this case, add +@code{(:eval (window-tool-bar-string))} to @code{tab-line-format}. +@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 @@ Top * %-Constructs:: Putting information into a mode line. * Properties in Mode:: Using text properties in the mode line. * Header Lines:: Like a mode line, but at the top. +* Tab Lines:: A line that is above the header line. * Emulating Mode Line:: Formatting text as the mode line would. Font 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 @@ Mode Line Format line at the bottom, which displays status information about the buffer displayed in the window. The mode line contains information about the buffer, such as its name, associated file, depth of recursive editing, -and major and minor modes. A window can also have a @dfn{header -line}, which is much like the mode line but appears at the top of the -window. +and major and minor modes. A window can also have a @dfn{header line} +and a @dfn{tab line}, which are much like the mode line but they appear +at the top of the window. - This section describes how to control the contents of the mode line -and header line. We include it in this chapter because much of the -information displayed in the mode line relates to the enabled major and -minor modes. + This section describes how to control the contents of the mode line, +header line, and tab line. We include it in this chapter because much +of the information displayed in the mode line relates to the enabled +major and minor modes. @menu * Base: Mode Line Basics. Basic ideas of mode line control. @@ -2091,6 +2091,7 @@ Mode Line Format * %-Constructs:: Putting information into a mode line. * Properties in Mode:: Using text properties in the mode line. * Header Lines:: Like a mode line, but at the top. +* Tab Lines:: A line that is above the header line. * Emulating Mode Line:: Formatting text as the mode line would. @end menu @@ -2101,11 +2102,13 @@ Mode Line Basics variable @code{mode-line-format} (@pxref{Mode Line Top}). This variable holds a @dfn{mode line construct}: a template that controls what is displayed on the buffer's mode line. The value of -@code{header-line-format} specifies the buffer's header line in the same -way. All windows for the same buffer use the same -@code{mode-line-format} and @code{header-line-format} unless a -@code{mode-line-format} or @code{header-line-format} parameter has been -specified for that window (@pxref{Window Parameters}). +@code{header-line-format} and @code{tab-line-format} specifies the +buffer's header line and tab line in the same way. All windows for the +same buffer use the same @code{mode-line-format}, +@code{header-line-format}, and @code{tab-line-format} unless a +@code{mode-line-format}, @code{header-line-format}, or +@code{tab-line-format} parameter has been specified for that window +(@pxref{Window Parameters}). For efficiency, Emacs does not continuously recompute each window's mode line and header line. It does so when circumstances appear to call @@ -2167,8 +2170,8 @@ Mode Line Data @dfn{mode line construct}, made up of lists, strings, symbols, and numbers kept in buffer-local variables. Each data type has a specific meaning for the mode line appearance, as described below. The same data -structure is used for constructing frame titles (@pxref{Frame Titles}) -and header lines (@pxref{Header Lines}). +structure is used for constructing frame titles (@pxref{Frame Titles}), +header lines (@pxref{Header Lines}), and tab lines (@pxref{Tab Lines}). A mode line construct may be as simple as a fixed string of text, but it usually specifies how to combine fixed strings with variables' @@ -2816,6 +2819,31 @@ Header Lines header line at once; if it has a mode line, then it does not display a header line. +@node Tab Lines +@subsection Window Tab Lines +@cindex tab line (of a window) +@cindex window tab line + + A window can have a @dfn{tab line} at the top. If both the tab line +and header line are visible, the tab line appears above the header line. +The tab line feature is controlled like the mode line feature, except +that it's controlled by @code{tab-line-format}. Unlike the mode line, +the tab line is only expected to be used to display a list of tabs +(@pxref{Tab Line,,, emacs, The GNU Emacs Manual}) or the window +tool bar (@pxref{Window Tool Bar,,, emacs, The GNU Emacs Manual}): + +@defvar tab-line-format +This variable, local in every buffer, specifies how to display the tab +line, for windows displaying the buffer. The format of the value is the +same as for @code{mode-line-format} (@pxref{Mode Line Data}). It is +normally @code{nil}, so that ordinary buffers have no tab line. +@end defvar + +@defun window-tab-line-height &optional window +This function returns the height in pixels of @var{window}'s tab line. +@var{window} must be a live window, and defaults to the selected window. +@end defun + @node Emulating Mode Line @subsection Emulating Mode Line Formatting diff --git a/etc/NEWS b/etc/NEWS index e5a63cc8a67..39870035160 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -245,6 +245,12 @@ window systems other than Nextstep. When this minor mode is enabled, buttons representing modifier keys are displayed along the tool bar. ++++ +** New user option 'tool-bar-always-show-default'. +When non-nil, the tool bar at the top of a frame does not show buffer +local customization of the tool bar. This is convenient when using the +newly added 'global-window-tool-bar-mode'. The default value is nil. + +++ ** "d" in the mode line now indicates that the window is dedicated. Windows have always been able to be dedicated to a specific buffer; @@ -1907,6 +1913,14 @@ This mode is used by default for the output of 'async-shell-command'. To revert to the previous behavior, set the (also new) variable 'async-shell-command-mode' to 'shell-mode'. Any hooks or mode-specific variables used should be adapted appropriately. + ++++ +** New package Window-Tool-Bar. +This provides a new minor mode, 'window-tool-bar-mode'. When this minor +mode is enabled, a tool bar is displayed at the top of a window if the +buffer in the window has a buffer local tool bar, commonly from its +major mode. The global minor mode 'global-window-tool-bar-mode' enables +this minor mode in all buffers. * Incompatible Lisp Changes in Emacs 30.1 -- 2.39.2