aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2020-04-27 01:28:36 +0300
committerJuri Linkov2020-04-27 01:28:36 +0300
commitf0e1bf56f041a7f104839678db61e47006b5657c (patch)
treeff86a10a6c121382f99278ba6f7193eb1ccb3a02
parentf0b9f184576a326f4359b4955a5ecff69c11c3aa (diff)
downloademacs-f0e1bf56f041a7f104839678db61e47006b5657c.tar.gz
emacs-f0e1bf56f041a7f104839678db61e47006b5657c.zip
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'.
-rw-r--r--doc/emacs/frames.texi57
-rw-r--r--doc/emacs/windows.texi12
-rw-r--r--lisp/tab-bar.el38
-rw-r--r--lisp/tab-line.el6
4 files changed, 94 insertions, 19 deletions
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index d9373b8bc78..8f448e1aedc 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -1266,7 +1266,7 @@ Note that the Tab Bar is different from the Tab Line (@pxref{Tab Line}).
1266Whereas tabs on the Tab Line at the top of each window are used to 1266Whereas tabs on the Tab Line at the top of each window are used to
1267switch between buffers, tabs on the Tab Bar at the top of each frame 1267switch between buffers, tabs on the Tab Bar at the top of each frame
1268are used to switch between window configurations containing several 1268are used to switch between window configurations containing several
1269windows. 1269windows with buffers.
1270 1270
1271@findex tab-bar-mode 1271@findex tab-bar-mode
1272 To toggle the use of tab bars, type @kbd{M-x tab-bar-mode}. This 1272 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.
1324To start a new tab with other buffers, customize the variable 1324To start a new tab with other buffers, customize the variable
1325@code{tab-bar-new-tab-choice}. 1325@code{tab-bar-new-tab-choice}.
1326 1326
1327@vindex tab-bar-new-tab-to
1328 The variable @code{tab-bar-new-tab-to} defines where to place a new tab.
1329By default, a new tab is added on the right side of the current tab.
1330
1327 The following commands can be used to delete tabs: 1331 The following commands can be used to delete tabs:
1328 1332
1329@table @kbd 1333@table @kbd
@@ -1331,7 +1335,8 @@ To start a new tab with other buffers, customize the variable
1331@kindex C-x t 0 1335@kindex C-x t 0
1332@findex tab-close 1336@findex tab-close
1333Close the selected tab (@code{tab-close}). It has no effect if there 1337Close the selected tab (@code{tab-close}). It has no effect if there
1334is only one tab. 1338is only one tab, unless the variable @code{tab-bar-close-last-tab-choice}
1339is customized to a non-default value.
1335 1340
1336@item C-x t 1 1341@item C-x t 1
1337@kindex C-x t 1 1342@kindex C-x t 1
@@ -1339,6 +1344,14 @@ is only one tab.
1339Close all tabs on the selected frame, except the selected one. 1344Close all tabs on the selected frame, except the selected one.
1340@end table 1345@end table
1341 1346
1347@vindex tab-bar-close-tab-select
1348 The variable @code{tab-bar-close-tab-select} defines what tab to
1349select after closing the current tab. By default, it selects
1350a recently used tab.
1351
1352@findex tab-undo
1353 The command @code{tab-undo} restores the last closed tab.
1354
1342 The following commands can be used to switch between tabs: 1355 The following commands can be used to switch between tabs:
1343 1356
1344@table @kbd 1357@table @kbd
@@ -1358,22 +1371,60 @@ switches back to the previous Nth tab.
1358Switch to the previous tab. With a positive numeric argument N, it 1371Switch to the previous tab. With a positive numeric argument N, it
1359switches to the previous Nth tab; with a negative argument −N, it 1372switches to the previous Nth tab; with a negative argument −N, it
1360switches back to the next Nth tab. 1373switches back to the next Nth tab.
1374
1375@item C-x t @key{RET} @var{tabname} @key{RET}
1376Switch to the tab by its name, with completion on all tab names.
1377Default values are tab names sorted by recency, so you can use
1378@kbd{M-n} (@code{next-history-element}) to get the name of the last
1379visited tab, the second last, and so on.
1380
1381@item @var{modifier}-@var{tabnumber}
1382@findex tab-select
1383Switch to the tab by its number. After customizing the variable
1384@code{tab-bar-select-tab-modifiers} to specify a @var{modifier} key, you
1385can select a tab by its ordinal number using the specified modifier in
1386combination with the tab number to select. To display the tab number
1387alongside the tab name, you can customize another variable
1388@code{tab-bar-tab-hints}. This will help you to decide what key to press
1389to select the tab by its number.
1390
1391@item @var{modifier}-@kbd{0}
1392@findex tab-recent
1393Switch to the recent tab. The key combination is the modifier key
1394defined by @code{tab-bar-select-tab-modifiers} and the key @kbd{0}.
1395With a numeric argument N, switch to the Nth recent tab.
1361@end table 1396@end table
1362 1397
1363 The following commands can be used to operate on tabs: 1398 The following commands can be used to operate on tabs:
1364 1399
1365@table @kbd 1400@table @kbd
1366@item C-x t r @var{tabname} @key{RET} 1401@item C-x t r @var{tabname} @key{RET}
1402@findex tab-rename
1367Rename the current tab to @var{tabname}. You can control the 1403Rename the current tab to @var{tabname}. You can control the
1368programmatic name given to a tab by default by customizing the 1404programmatic name given to a tab by default by customizing the
1369variable @code{tab-bar-tab-name-function}. 1405variable @code{tab-bar-tab-name-function}.
1370 1406
1371@item C-x t m 1407@item C-x t m
1408@findex tab-move
1372Move the current tab N positions to the right with a positive numeric 1409Move the current tab N positions to the right with a positive numeric
1373argument N. With a negative argument −N, it moves the current tab 1410argument N. With a negative argument −N, move the current tab
1374N positions to the left. 1411N positions to the left.
1375@end table 1412@end table
1376 1413
1414@findex tab-bar-history-mode
1415 You can enable @code{tab-bar-history-mode} to remember window
1416configurations used in every tab, and restore them.
1417
1418@table @kbd
1419@item tab-bar-history-back
1420Restore a previous window configuration used in the current tab.
1421This navigates back in the history of window configurations.
1422
1423@item tab-bar-history-forward
1424Cancel restoration of the previous window configuration.
1425This navigates forward in the history of window configurations.
1426@end table
1427
1377@node Dialog Boxes 1428@node Dialog Boxes
1378@section Using Dialog Boxes 1429@section Using Dialog Boxes
1379@cindex dialog boxes 1430@cindex dialog boxes
diff --git a/doc/emacs/windows.texi b/doc/emacs/windows.texi
index cb5e9bce4d1..4c67660b92d 100644
--- a/doc/emacs/windows.texi
+++ b/doc/emacs/windows.texi
@@ -628,8 +628,16 @@ Selecting the previous window-local tab is the same as typing @kbd{C-x
628same as @kbd{C-x @key{RIGHT}} (@code{next-buffer}). Both commands 628same as @kbd{C-x @key{RIGHT}} (@code{next-buffer}). Both commands
629support a numeric prefix argument as a repeat count. 629support a numeric prefix argument as a repeat count.
630 630
631You can customize the variable @code{tab-line-tabs-function} to define
632the preferred contents of the tab line. By default, it displays all
633buffers previously visited in the window, as described above. But you
634can also set it to display a list of buffers with the same major mode
635as the current buffer, or to display buffers grouped by their major
636mode, where clicking on the mode name in the first tab displays a list
637of all major modes where you can select another group of buffers.
638
631Note that the Tab Line is different from the Tab Bar (@pxref{Tab Bars}). 639Note that the Tab Line is different from the Tab Bar (@pxref{Tab Bars}).
632Whereas tabs on the Tab Bar at the top of each frame are used to 640Whereas tabs on the Tab Bar at the top of each frame are used to
633switch between window configurations containing several windows, 641switch between window configurations containing several windows with buffers,
634tabs on the Tab Line at the top of each window are used to switch 642tabs on the Tab Line at the top of each window are used to switch
635between buffers. 643between buffers in the window.
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 8c2027eb6a2..a1ff2b0ca8b 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -87,10 +87,11 @@
87 87
88 88
89(defcustom tab-bar-select-tab-modifiers '() 89(defcustom tab-bar-select-tab-modifiers '()
90 "List of key modifiers for selecting a tab by its index digit. 90 "List of modifier keys for selecting a tab by its index digit.
91Possible modifiers are `control', `meta', `shift', `hyper', `super' and 91Possible modifier keys are `control', `meta', `shift', `hyper', `super' and
92`alt'." 92`alt'. To help you to select a tab by its number, you can customize
93 :type '(set :tag "Tab selection key modifiers" 93`tab-bar-tab-hints' that will show tab numbers alongside the tab name."
94 :type '(set :tag "Tab selection modifier keys"
94 (const control) 95 (const control)
95 (const meta) 96 (const meta)
96 (const shift) 97 (const shift)
@@ -310,7 +311,8 @@ If nil, don't show it at all."
310 311
311(defcustom tab-bar-tab-hints nil 312(defcustom tab-bar-tab-hints nil
312 "Show absolute numbers on tabs in the tab bar before the tab name. 313 "Show absolute numbers on tabs in the tab bar before the tab name.
313This helps to select the tab by its number using `tab-bar-select-tab'." 314This helps to select the tab by its number using `tab-bar-select-tab'
315and `tab-bar-select-tab-modifiers'."
314 :type 'boolean 316 :type 'boolean
315 :initialize 'custom-initialize-default 317 :initialize 'custom-initialize-default
316 :set (lambda (sym val) 318 :set (lambda (sym val)
@@ -563,9 +565,10 @@ Return its existing value or a new value."
563 565
564(defun tab-bar-select-tab (&optional arg) 566(defun tab-bar-select-tab (&optional arg)
565 "Switch to the tab by its absolute position ARG in the tab bar. 567 "Switch to the tab by its absolute position ARG in the tab bar.
566When this command is bound to a numeric key (with a prefix or modifier), 568When this command is bound to a numeric key (with a prefix or modifier key
567calling it without an argument will translate its bound numeric key 569using `tab-bar-select-tab-modifiers'), calling it without an argument
568to the numeric argument. ARG counts from 1." 570will translate its bound numeric key to the numeric argument.
571ARG counts from 1."
569 (interactive "P") 572 (interactive "P")
570 (unless (integerp arg) 573 (unless (integerp arg)
571 (let ((key (event-basic-type last-command-event))) 574 (let ((key (event-basic-type last-command-event)))
@@ -664,7 +667,10 @@ to the numeric argument. ARG counts from 1."
664 (message "No more recent tabs")))) 667 (message "No more recent tabs"))))
665 668
666(defun tab-bar-switch-to-tab (name) 669(defun tab-bar-switch-to-tab (name)
667 "Switch to the tab by NAME." 670 "Switch to the tab by NAME.
671Default values are tab names sorted by recency, so you can use \
672\\<minibuffer-local-map>\\[next-history-element]
673to get the name of the last visited tab, the second last, and so on."
668 (interactive 674 (interactive
669 (let* ((recent-tabs (mapcar (lambda (tab) 675 (let* ((recent-tabs (mapcar (lambda (tab)
670 (alist-get 'name tab)) 676 (alist-get 'name tab))
@@ -789,7 +795,7 @@ After the tab is created, the hooks in
789 (pcase tab-bar-new-tab-to 795 (pcase tab-bar-new-tab-to
790 ('leftmost 0) 796 ('leftmost 0)
791 ('rightmost (length tabs)) 797 ('rightmost (length tabs))
792 ('left (1- (or from-index 1))) 798 ('left (or from-index 1))
793 ('right (1+ (or from-index 0))) 799 ('right (1+ (or from-index 0)))
794 ((pred functionp) 800 ((pred functionp)
795 (funcall tab-bar-new-tab-to)))))) 801 (funcall tab-bar-new-tab-to))))))
@@ -920,7 +926,7 @@ for the last tab on a frame is determined by
920 ;; Select another tab before deleting the current tab 926 ;; Select another tab before deleting the current tab
921 (let ((to-index (or (if to-index (1- to-index)) 927 (let ((to-index (or (if to-index (1- to-index))
922 (pcase tab-bar-close-tab-select 928 (pcase tab-bar-close-tab-select
923 ('left (1- current-index)) 929 ('left (1- (if (< current-index 1) 2 current-index)))
924 ('right (if (> (length tabs) (1+ current-index)) 930 ('right (if (> (length tabs) (1+ current-index))
925 (1+ current-index) 931 (1+ current-index)
926 (1- current-index))) 932 (1- current-index)))
@@ -1004,7 +1010,7 @@ for the last tab on a frame is determined by
1004 (unless (eq frame (selected-frame)) 1010 (unless (eq frame (selected-frame))
1005 (select-frame-set-input-focus frame)) 1011 (select-frame-set-input-focus frame))
1006 1012
1007 (let ((tabs (tab-bar-tabs))) 1013 (let ((tabs (funcall tab-bar-tabs-function)))
1008 (setq index (max 0 (min index (length tabs)))) 1014 (setq index (max 0 (min index (length tabs))))
1009 (cl-pushnew tab (nthcdr index tabs)) 1015 (cl-pushnew tab (nthcdr index tabs))
1010 (when (eq index 0) 1016 (when (eq index 0)
@@ -1102,6 +1108,8 @@ function `tab-bar-tab-name-function'."
1102 (setq tab-bar-history-omit nil))) 1108 (setq tab-bar-history-omit nil)))
1103 1109
1104(defun tab-bar-history-back () 1110(defun tab-bar-history-back ()
1111 "Restore a previous window configuration used in the current tab.
1112This navigates back in the history of window configurations."
1105 (interactive) 1113 (interactive)
1106 (setq tab-bar-history-omit t) 1114 (setq tab-bar-history-omit t)
1107 (let* ((history (pop (gethash (selected-frame) tab-bar-history-back))) 1115 (let* ((history (pop (gethash (selected-frame) tab-bar-history-back)))
@@ -1119,6 +1127,8 @@ function `tab-bar-tab-name-function'."
1119 (message "No more tab back history")))) 1127 (message "No more tab back history"))))
1120 1128
1121(defun tab-bar-history-forward () 1129(defun tab-bar-history-forward ()
1130 "Cancel restoration of the previous window configuration.
1131This navigates forward in the history of window configurations."
1122 (interactive) 1132 (interactive)
1123 (setq tab-bar-history-omit t) 1133 (setq tab-bar-history-omit t)
1124 (let* ((history (pop (gethash (selected-frame) tab-bar-history-forward))) 1134 (let* ((history (pop (gethash (selected-frame) tab-bar-history-forward)))
@@ -1136,7 +1146,9 @@ function `tab-bar-tab-name-function'."
1136 (message "No more tab forward history")))) 1146 (message "No more tab forward history"))))
1137 1147
1138(define-minor-mode tab-bar-history-mode 1148(define-minor-mode tab-bar-history-mode
1139 "Toggle tab history mode for the tab bar." 1149 "Toggle tab history mode for the tab bar.
1150Tab history mode remembers window configurations used in every tab,
1151and can restore them."
1140 :global t :group 'tab-bar 1152 :global t :group 'tab-bar
1141 (if tab-bar-history-mode 1153 (if tab-bar-history-mode
1142 (progn 1154 (progn
diff --git a/lisp/tab-line.el b/lisp/tab-line.el
index eb279deab4c..7a2bdc0b72f 100644
--- a/lisp/tab-line.el
+++ b/lisp/tab-line.el
@@ -474,8 +474,12 @@ variable `tab-line-tabs-function'."
474 "Template for displaying tab line for selected window." 474 "Template for displaying tab line for selected window."
475 (let* ((tabs (funcall tab-line-tabs-function)) 475 (let* ((tabs (funcall tab-line-tabs-function))
476 (cache-key (list tabs 476 (cache-key (list tabs
477 ;; handle buffer renames
477 (buffer-name (window-buffer)) 478 (buffer-name (window-buffer))
478 (window-parameter nil 'tab-line-hscroll))) 479 ;; handle tab-line scrolling
480 (window-parameter nil 'tab-line-hscroll)
481 ;; for setting face 'tab-line-tab-current'
482 (eq (selected-window) (old-selected-window))))
479 (cache (window-parameter nil 'tab-line-cache))) 483 (cache (window-parameter nil 'tab-line-cache)))
480 ;; Enable auto-hscroll again after it was disabled on manual scrolling. 484 ;; Enable auto-hscroll again after it was disabled on manual scrolling.
481 ;; The moment to enable it is when the window-buffer was updated. 485 ;; The moment to enable it is when the window-buffer was updated.