Fix bugs in tab-bar and tab-line and mention remaining features in manual.
* doc/emacs/frames.texi (Tab Bars): Mention tab-bar-new-tab-to, tab-bar-close-last-tab-choice, tab-bar-close-tab-select, tab-undo, tab-select, tab-bar-history-mode. * doc/emacs/windows.texi (Tab Line): Mention tab-line-tabs-function. * lisp/tab-bar.el (tab-bar-select-tab-modifiers): Mention tab-bar-tab-hints in docstring. (tab-bar-tab-hints): Mention tab-bar-select-tab-modifiers in docstring. (tab-bar-select-tab): Mention tab-bar-select-tab-modifiers in docstring. (tab-bar-switch-to-tab): Expand the docstring. (tab-bar-new-tab-to): Fix bug in handling 'left' value. (tab-bar-close-tab): Fix bug in handling 'left' value. (tab-bar-undo-close-tab): Use funcall tab-bar-tabs-function instead of direct call to tab-bar-tabs. (tab-bar-history-back, tab-bar-history-forward): Add docstrings. (tab-bar-history-mode): Expand docstring. * lisp/tab-line.el (tab-line-format): Fix bug for handling window switching that should set face 'tab-line-tab-current'.
This commit is contained in:
parent
f0b9f18457
commit
f0e1bf56f0
4 changed files with 94 additions and 19 deletions
|
@ -1266,7 +1266,7 @@ Note that the Tab Bar is different from the Tab Line (@pxref{Tab Line}).
|
||||||
Whereas tabs on the Tab Line at the top of each window are used to
|
Whereas tabs on the Tab Line at the top of each window are used to
|
||||||
switch between buffers, tabs on the Tab Bar at the top of each frame
|
switch between buffers, tabs on the Tab Bar at the top of each frame
|
||||||
are used to switch between window configurations containing several
|
are used to switch between window configurations containing several
|
||||||
windows.
|
windows with buffers.
|
||||||
|
|
||||||
@findex tab-bar-mode
|
@findex tab-bar-mode
|
||||||
To toggle the use of tab bars, type @kbd{M-x tab-bar-mode}. This
|
To toggle the use of tab bars, type @kbd{M-x tab-bar-mode}. This
|
||||||
|
@ -1324,6 +1324,10 @@ current before calling the command that adds a new tab.
|
||||||
To start a new tab with other buffers, customize the variable
|
To start a new tab with other buffers, customize the variable
|
||||||
@code{tab-bar-new-tab-choice}.
|
@code{tab-bar-new-tab-choice}.
|
||||||
|
|
||||||
|
@vindex tab-bar-new-tab-to
|
||||||
|
The variable @code{tab-bar-new-tab-to} defines where to place a new tab.
|
||||||
|
By default, a new tab is added on the right side of the current tab.
|
||||||
|
|
||||||
The following commands can be used to delete tabs:
|
The following commands can be used to delete tabs:
|
||||||
|
|
||||||
@table @kbd
|
@table @kbd
|
||||||
|
@ -1331,7 +1335,8 @@ To start a new tab with other buffers, customize the variable
|
||||||
@kindex C-x t 0
|
@kindex C-x t 0
|
||||||
@findex tab-close
|
@findex tab-close
|
||||||
Close the selected tab (@code{tab-close}). It has no effect if there
|
Close the selected tab (@code{tab-close}). It has no effect if there
|
||||||
is only one tab.
|
is only one tab, unless the variable @code{tab-bar-close-last-tab-choice}
|
||||||
|
is customized to a non-default value.
|
||||||
|
|
||||||
@item C-x t 1
|
@item C-x t 1
|
||||||
@kindex C-x t 1
|
@kindex C-x t 1
|
||||||
|
@ -1339,6 +1344,14 @@ is only one tab.
|
||||||
Close all tabs on the selected frame, except the selected one.
|
Close all tabs on the selected frame, except the selected one.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@vindex tab-bar-close-tab-select
|
||||||
|
The variable @code{tab-bar-close-tab-select} defines what tab to
|
||||||
|
select after closing the current tab. By default, it selects
|
||||||
|
a recently used tab.
|
||||||
|
|
||||||
|
@findex tab-undo
|
||||||
|
The command @code{tab-undo} restores the last closed tab.
|
||||||
|
|
||||||
The following commands can be used to switch between tabs:
|
The following commands can be used to switch between tabs:
|
||||||
|
|
||||||
@table @kbd
|
@table @kbd
|
||||||
|
@ -1358,22 +1371,60 @@ switches back to the previous Nth tab.
|
||||||
Switch to the previous tab. With a positive numeric argument N, it
|
Switch to the previous tab. With a positive numeric argument N, it
|
||||||
switches to the previous Nth tab; with a negative argument −N, it
|
switches to the previous Nth tab; with a negative argument −N, it
|
||||||
switches back to the next Nth tab.
|
switches back to the next Nth tab.
|
||||||
|
|
||||||
|
@item C-x t @key{RET} @var{tabname} @key{RET}
|
||||||
|
Switch to the tab by its name, with completion on all tab names.
|
||||||
|
Default values are tab names sorted by recency, so you can use
|
||||||
|
@kbd{M-n} (@code{next-history-element}) to get the name of the last
|
||||||
|
visited tab, the second last, and so on.
|
||||||
|
|
||||||
|
@item @var{modifier}-@var{tabnumber}
|
||||||
|
@findex tab-select
|
||||||
|
Switch to the tab by its number. After customizing the variable
|
||||||
|
@code{tab-bar-select-tab-modifiers} to specify a @var{modifier} key, you
|
||||||
|
can select a tab by its ordinal number using the specified modifier in
|
||||||
|
combination with the tab number to select. To display the tab number
|
||||||
|
alongside the tab name, you can customize another variable
|
||||||
|
@code{tab-bar-tab-hints}. This will help you to decide what key to press
|
||||||
|
to select the tab by its number.
|
||||||
|
|
||||||
|
@item @var{modifier}-@kbd{0}
|
||||||
|
@findex tab-recent
|
||||||
|
Switch to the recent tab. The key combination is the modifier key
|
||||||
|
defined by @code{tab-bar-select-tab-modifiers} and the key @kbd{0}.
|
||||||
|
With a numeric argument N, switch to the Nth recent tab.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
The following commands can be used to operate on tabs:
|
The following commands can be used to operate on tabs:
|
||||||
|
|
||||||
@table @kbd
|
@table @kbd
|
||||||
@item C-x t r @var{tabname} @key{RET}
|
@item C-x t r @var{tabname} @key{RET}
|
||||||
|
@findex tab-rename
|
||||||
Rename the current tab to @var{tabname}. You can control the
|
Rename the current tab to @var{tabname}. You can control the
|
||||||
programmatic name given to a tab by default by customizing the
|
programmatic name given to a tab by default by customizing the
|
||||||
variable @code{tab-bar-tab-name-function}.
|
variable @code{tab-bar-tab-name-function}.
|
||||||
|
|
||||||
@item C-x t m
|
@item C-x t m
|
||||||
|
@findex tab-move
|
||||||
Move the current tab N positions to the right with a positive numeric
|
Move the current tab N positions to the right with a positive numeric
|
||||||
argument N. With a negative argument −N, it moves the current tab
|
argument N. With a negative argument −N, move the current tab
|
||||||
N positions to the left.
|
N positions to the left.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@findex tab-bar-history-mode
|
||||||
|
You can enable @code{tab-bar-history-mode} to remember window
|
||||||
|
configurations used in every tab, and restore them.
|
||||||
|
|
||||||
|
@table @kbd
|
||||||
|
@item tab-bar-history-back
|
||||||
|
Restore a previous window configuration used in the current tab.
|
||||||
|
This navigates back in the history of window configurations.
|
||||||
|
|
||||||
|
@item tab-bar-history-forward
|
||||||
|
Cancel restoration of the previous window configuration.
|
||||||
|
This navigates forward in the history of window configurations.
|
||||||
|
@end table
|
||||||
|
|
||||||
@node Dialog Boxes
|
@node Dialog Boxes
|
||||||
@section Using Dialog Boxes
|
@section Using Dialog Boxes
|
||||||
@cindex dialog boxes
|
@cindex dialog boxes
|
||||||
|
|
|
@ -628,8 +628,16 @@ Selecting the previous window-local tab is the same as typing @kbd{C-x
|
||||||
same as @kbd{C-x @key{RIGHT}} (@code{next-buffer}). Both commands
|
same as @kbd{C-x @key{RIGHT}} (@code{next-buffer}). Both commands
|
||||||
support a numeric prefix argument as a repeat count.
|
support a numeric prefix argument as a repeat count.
|
||||||
|
|
||||||
|
You can customize the variable @code{tab-line-tabs-function} to define
|
||||||
|
the preferred contents of the tab line. By default, it displays all
|
||||||
|
buffers previously visited in the window, as described above. But you
|
||||||
|
can also set it to display a list of buffers with the same major mode
|
||||||
|
as the current buffer, or to display buffers grouped by their major
|
||||||
|
mode, where clicking on the mode name in the first tab displays a list
|
||||||
|
of all major modes where you can select another group of buffers.
|
||||||
|
|
||||||
Note that the Tab Line is different from the Tab Bar (@pxref{Tab Bars}).
|
Note that the Tab Line is different from the Tab Bar (@pxref{Tab Bars}).
|
||||||
Whereas tabs on the Tab Bar at the top of each frame are used to
|
Whereas tabs on the Tab Bar at the top of each frame are used to
|
||||||
switch between window configurations containing several windows,
|
switch between window configurations containing several windows with buffers,
|
||||||
tabs on the Tab Line at the top of each window are used to switch
|
tabs on the Tab Line at the top of each window are used to switch
|
||||||
between buffers.
|
between buffers in the window.
|
||||||
|
|
|
@ -87,10 +87,11 @@
|
||||||
|
|
||||||
|
|
||||||
(defcustom tab-bar-select-tab-modifiers '()
|
(defcustom tab-bar-select-tab-modifiers '()
|
||||||
"List of key modifiers for selecting a tab by its index digit.
|
"List of modifier keys for selecting a tab by its index digit.
|
||||||
Possible modifiers are `control', `meta', `shift', `hyper', `super' and
|
Possible modifier keys are `control', `meta', `shift', `hyper', `super' and
|
||||||
`alt'."
|
`alt'. To help you to select a tab by its number, you can customize
|
||||||
:type '(set :tag "Tab selection key modifiers"
|
`tab-bar-tab-hints' that will show tab numbers alongside the tab name."
|
||||||
|
:type '(set :tag "Tab selection modifier keys"
|
||||||
(const control)
|
(const control)
|
||||||
(const meta)
|
(const meta)
|
||||||
(const shift)
|
(const shift)
|
||||||
|
@ -310,7 +311,8 @@ If nil, don't show it at all."
|
||||||
|
|
||||||
(defcustom tab-bar-tab-hints nil
|
(defcustom tab-bar-tab-hints nil
|
||||||
"Show absolute numbers on tabs in the tab bar before the tab name.
|
"Show absolute numbers on tabs in the tab bar before the tab name.
|
||||||
This helps to select the tab by its number using `tab-bar-select-tab'."
|
This helps to select the tab by its number using `tab-bar-select-tab'
|
||||||
|
and `tab-bar-select-tab-modifiers'."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:initialize 'custom-initialize-default
|
:initialize 'custom-initialize-default
|
||||||
:set (lambda (sym val)
|
:set (lambda (sym val)
|
||||||
|
@ -563,9 +565,10 @@ Return its existing value or a new value."
|
||||||
|
|
||||||
(defun tab-bar-select-tab (&optional arg)
|
(defun tab-bar-select-tab (&optional arg)
|
||||||
"Switch to the tab by its absolute position ARG in the tab bar.
|
"Switch to the tab by its absolute position ARG in the tab bar.
|
||||||
When this command is bound to a numeric key (with a prefix or modifier),
|
When this command is bound to a numeric key (with a prefix or modifier key
|
||||||
calling it without an argument will translate its bound numeric key
|
using `tab-bar-select-tab-modifiers'), calling it without an argument
|
||||||
to the numeric argument. ARG counts from 1."
|
will translate its bound numeric key to the numeric argument.
|
||||||
|
ARG counts from 1."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(unless (integerp arg)
|
(unless (integerp arg)
|
||||||
(let ((key (event-basic-type last-command-event)))
|
(let ((key (event-basic-type last-command-event)))
|
||||||
|
@ -664,7 +667,10 @@ to the numeric argument. ARG counts from 1."
|
||||||
(message "No more recent tabs"))))
|
(message "No more recent tabs"))))
|
||||||
|
|
||||||
(defun tab-bar-switch-to-tab (name)
|
(defun tab-bar-switch-to-tab (name)
|
||||||
"Switch to the tab by NAME."
|
"Switch to the tab by NAME.
|
||||||
|
Default values are tab names sorted by recency, so you can use \
|
||||||
|
\\<minibuffer-local-map>\\[next-history-element]
|
||||||
|
to get the name of the last visited tab, the second last, and so on."
|
||||||
(interactive
|
(interactive
|
||||||
(let* ((recent-tabs (mapcar (lambda (tab)
|
(let* ((recent-tabs (mapcar (lambda (tab)
|
||||||
(alist-get 'name tab))
|
(alist-get 'name tab))
|
||||||
|
@ -789,7 +795,7 @@ After the tab is created, the hooks in
|
||||||
(pcase tab-bar-new-tab-to
|
(pcase tab-bar-new-tab-to
|
||||||
('leftmost 0)
|
('leftmost 0)
|
||||||
('rightmost (length tabs))
|
('rightmost (length tabs))
|
||||||
('left (1- (or from-index 1)))
|
('left (or from-index 1))
|
||||||
('right (1+ (or from-index 0)))
|
('right (1+ (or from-index 0)))
|
||||||
((pred functionp)
|
((pred functionp)
|
||||||
(funcall tab-bar-new-tab-to))))))
|
(funcall tab-bar-new-tab-to))))))
|
||||||
|
@ -920,7 +926,7 @@ for the last tab on a frame is determined by
|
||||||
;; Select another tab before deleting the current tab
|
;; Select another tab before deleting the current tab
|
||||||
(let ((to-index (or (if to-index (1- to-index))
|
(let ((to-index (or (if to-index (1- to-index))
|
||||||
(pcase tab-bar-close-tab-select
|
(pcase tab-bar-close-tab-select
|
||||||
('left (1- current-index))
|
('left (1- (if (< current-index 1) 2 current-index)))
|
||||||
('right (if (> (length tabs) (1+ current-index))
|
('right (if (> (length tabs) (1+ current-index))
|
||||||
(1+ current-index)
|
(1+ current-index)
|
||||||
(1- current-index)))
|
(1- current-index)))
|
||||||
|
@ -1004,7 +1010,7 @@ for the last tab on a frame is determined by
|
||||||
(unless (eq frame (selected-frame))
|
(unless (eq frame (selected-frame))
|
||||||
(select-frame-set-input-focus frame))
|
(select-frame-set-input-focus frame))
|
||||||
|
|
||||||
(let ((tabs (tab-bar-tabs)))
|
(let ((tabs (funcall tab-bar-tabs-function)))
|
||||||
(setq index (max 0 (min index (length tabs))))
|
(setq index (max 0 (min index (length tabs))))
|
||||||
(cl-pushnew tab (nthcdr index tabs))
|
(cl-pushnew tab (nthcdr index tabs))
|
||||||
(when (eq index 0)
|
(when (eq index 0)
|
||||||
|
@ -1102,6 +1108,8 @@ function `tab-bar-tab-name-function'."
|
||||||
(setq tab-bar-history-omit nil)))
|
(setq tab-bar-history-omit nil)))
|
||||||
|
|
||||||
(defun tab-bar-history-back ()
|
(defun tab-bar-history-back ()
|
||||||
|
"Restore a previous window configuration used in the current tab.
|
||||||
|
This navigates back in the history of window configurations."
|
||||||
(interactive)
|
(interactive)
|
||||||
(setq tab-bar-history-omit t)
|
(setq tab-bar-history-omit t)
|
||||||
(let* ((history (pop (gethash (selected-frame) tab-bar-history-back)))
|
(let* ((history (pop (gethash (selected-frame) tab-bar-history-back)))
|
||||||
|
@ -1119,6 +1127,8 @@ function `tab-bar-tab-name-function'."
|
||||||
(message "No more tab back history"))))
|
(message "No more tab back history"))))
|
||||||
|
|
||||||
(defun tab-bar-history-forward ()
|
(defun tab-bar-history-forward ()
|
||||||
|
"Cancel restoration of the previous window configuration.
|
||||||
|
This navigates forward in the history of window configurations."
|
||||||
(interactive)
|
(interactive)
|
||||||
(setq tab-bar-history-omit t)
|
(setq tab-bar-history-omit t)
|
||||||
(let* ((history (pop (gethash (selected-frame) tab-bar-history-forward)))
|
(let* ((history (pop (gethash (selected-frame) tab-bar-history-forward)))
|
||||||
|
@ -1136,7 +1146,9 @@ function `tab-bar-tab-name-function'."
|
||||||
(message "No more tab forward history"))))
|
(message "No more tab forward history"))))
|
||||||
|
|
||||||
(define-minor-mode tab-bar-history-mode
|
(define-minor-mode tab-bar-history-mode
|
||||||
"Toggle tab history mode for the tab bar."
|
"Toggle tab history mode for the tab bar.
|
||||||
|
Tab history mode remembers window configurations used in every tab,
|
||||||
|
and can restore them."
|
||||||
:global t :group 'tab-bar
|
:global t :group 'tab-bar
|
||||||
(if tab-bar-history-mode
|
(if tab-bar-history-mode
|
||||||
(progn
|
(progn
|
||||||
|
|
|
@ -474,8 +474,12 @@ variable `tab-line-tabs-function'."
|
||||||
"Template for displaying tab line for selected window."
|
"Template for displaying tab line for selected window."
|
||||||
(let* ((tabs (funcall tab-line-tabs-function))
|
(let* ((tabs (funcall tab-line-tabs-function))
|
||||||
(cache-key (list tabs
|
(cache-key (list tabs
|
||||||
|
;; handle buffer renames
|
||||||
(buffer-name (window-buffer))
|
(buffer-name (window-buffer))
|
||||||
(window-parameter nil 'tab-line-hscroll)))
|
;; handle tab-line scrolling
|
||||||
|
(window-parameter nil 'tab-line-hscroll)
|
||||||
|
;; for setting face 'tab-line-tab-current'
|
||||||
|
(eq (selected-window) (old-selected-window))))
|
||||||
(cache (window-parameter nil 'tab-line-cache)))
|
(cache (window-parameter nil 'tab-line-cache)))
|
||||||
;; Enable auto-hscroll again after it was disabled on manual scrolling.
|
;; Enable auto-hscroll again after it was disabled on manual scrolling.
|
||||||
;; The moment to enable it is when the window-buffer was updated.
|
;; The moment to enable it is when the window-buffer was updated.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue