diff options
| -rw-r--r-- | lisp/tab-bar.el | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index ccecdbc0440..63ab932ac0a 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el | |||
| @@ -260,6 +260,10 @@ a list of frames to update." | |||
| 260 | keymap)))))) | 260 | keymap)))))) |
| 261 | 261 | ||
| 262 | (defun tab-bar-mouse-select-tab (event) | 262 | (defun tab-bar-mouse-select-tab (event) |
| 263 | "Select the tab at mouse click, or add a new tab on the tab bar. | ||
| 264 | Whether this command adds a new tab or selects an existing tab | ||
| 265 | depends on whether the click is on the \"+\" button or on an | ||
| 266 | existing tab." | ||
| 263 | (interactive "e") | 267 | (interactive "e") |
| 264 | (let* ((item (tab-bar--event-to-item (event-start event))) | 268 | (let* ((item (tab-bar--event-to-item (event-start event))) |
| 265 | (tab-number (tab-bar--key-to-number (nth 0 item)))) | 269 | (tab-number (tab-bar--key-to-number (nth 0 item)))) |
| @@ -272,7 +276,9 @@ a list of frames to update." | |||
| 272 | (tab-bar-select-tab tab-number)))))) | 276 | (tab-bar-select-tab tab-number)))))) |
| 273 | 277 | ||
| 274 | (defun tab-bar-mouse-close-tab-from-button (event) | 278 | (defun tab-bar-mouse-close-tab-from-button (event) |
| 275 | "Close the tab only when clicked on the close button." | 279 | "Close the tab whose \"x\" close button you click. |
| 280 | See also `tab-bar-mouse-close-tab', which closes the tab | ||
| 281 | regardless of where you click on it." | ||
| 276 | (interactive "e") | 282 | (interactive "e") |
| 277 | (let* ((item (tab-bar--event-to-item (event-start event))) | 283 | (let* ((item (tab-bar--event-to-item (event-start event))) |
| 278 | (tab-number (tab-bar--key-to-number (nth 0 item)))) | 284 | (tab-number (tab-bar--key-to-number (nth 0 item)))) |
| @@ -281,9 +287,9 @@ a list of frames to update." | |||
| 281 | (tab-bar-close-tab tab-number))))) | 287 | (tab-bar-close-tab tab-number))))) |
| 282 | 288 | ||
| 283 | (defun tab-bar-mouse-close-tab (event) | 289 | (defun tab-bar-mouse-close-tab (event) |
| 284 | "Close the tab when clicked anywhere on the tab. | 290 | "Close the tab you click on. |
| 285 | This is in contrast with `tab-bar-mouse-close-tab-from-button' | 291 | This is in contrast with `tab-bar-mouse-close-tab-from-button' |
| 286 | that closes only when clicked on the close button." | 292 | that closes a tab only when you click on its \"x\" close button." |
| 287 | (interactive "e") | 293 | (interactive "e") |
| 288 | (let* ((item (tab-bar--event-to-item (event-start event))) | 294 | (let* ((item (tab-bar--event-to-item (event-start event))) |
| 289 | (tab-number (tab-bar--key-to-number (nth 0 item)))) | 295 | (tab-number (tab-bar--key-to-number (nth 0 item)))) |
| @@ -291,6 +297,7 @@ that closes only when clicked on the close button." | |||
| 291 | (tab-bar-close-tab tab-number)))) | 297 | (tab-bar-close-tab tab-number)))) |
| 292 | 298 | ||
| 293 | (defun tab-bar-mouse-context-menu (event) | 299 | (defun tab-bar-mouse-context-menu (event) |
| 300 | "Pop up the context menu for the tab on which you click." | ||
| 294 | (interactive "e") | 301 | (interactive "e") |
| 295 | (let* ((item (tab-bar--event-to-item (event-start event))) | 302 | (let* ((item (tab-bar--event-to-item (event-start event))) |
| 296 | (tab-number (tab-bar--key-to-number (nth 0 item))) | 303 | (tab-number (tab-bar--key-to-number (nth 0 item))) |
| @@ -330,6 +337,9 @@ that closes only when clicked on the close button." | |||
| 330 | (popup-menu menu event))) | 337 | (popup-menu menu event))) |
| 331 | 338 | ||
| 332 | (defun tab-bar-mouse-move-tab (event) | 339 | (defun tab-bar-mouse-move-tab (event) |
| 340 | "Move a tab to a different position on the tab bar. | ||
| 341 | This command should be bound to a drag event. It moves the tab | ||
| 342 | at the mouse-down event to the position at mouse-up event." | ||
| 333 | (interactive "e") | 343 | (interactive "e") |
| 334 | (let ((from (tab-bar--key-to-number | 344 | (let ((from (tab-bar--key-to-number |
| 335 | (nth 0 (tab-bar--event-to-item | 345 | (nth 0 (tab-bar--event-to-item |
| @@ -1089,7 +1099,8 @@ the tab bar." | |||
| 1089 | (force-mode-line-update)))) | 1099 | (force-mode-line-update)))) |
| 1090 | 1100 | ||
| 1091 | (defun tab-bar-switch-to-next-tab (&optional arg) | 1101 | (defun tab-bar-switch-to-next-tab (&optional arg) |
| 1092 | "Switch to ARGth next tab." | 1102 | "Switch to ARGth next tab. |
| 1103 | Interactively, ARG is the prefix numeric argument and defaults to 1." | ||
| 1093 | (interactive "p") | 1104 | (interactive "p") |
| 1094 | (unless (integerp arg) | 1105 | (unless (integerp arg) |
| 1095 | (setq arg 1)) | 1106 | (setq arg 1)) |
| @@ -1099,20 +1110,24 @@ the tab bar." | |||
| 1099 | (tab-bar-select-tab (1+ to-index)))) | 1110 | (tab-bar-select-tab (1+ to-index)))) |
| 1100 | 1111 | ||
| 1101 | (defun tab-bar-switch-to-prev-tab (&optional arg) | 1112 | (defun tab-bar-switch-to-prev-tab (&optional arg) |
| 1102 | "Switch to ARGth previous tab." | 1113 | "Switch to ARGth previous tab. |
| 1114 | Interactively, ARG is the prefix numeric argument and defaults to 1." | ||
| 1103 | (interactive "p") | 1115 | (interactive "p") |
| 1104 | (unless (integerp arg) | 1116 | (unless (integerp arg) |
| 1105 | (setq arg 1)) | 1117 | (setq arg 1)) |
| 1106 | (tab-bar-switch-to-next-tab (- arg))) | 1118 | (tab-bar-switch-to-next-tab (- arg))) |
| 1107 | 1119 | ||
| 1108 | (defun tab-bar-switch-to-last-tab (&optional arg) | 1120 | (defun tab-bar-switch-to-last-tab (&optional arg) |
| 1109 | "Switch to the last tab or ARGth tab from the end of the tab bar." | 1121 | "Switch to the last tab or ARGth tab from the end of the tab bar. |
| 1122 | Interactively, ARG is the prefix numeric argument; it defaults to 1, | ||
| 1123 | which means the last tab on the tab bar." | ||
| 1110 | (interactive "p") | 1124 | (interactive "p") |
| 1111 | (tab-bar-select-tab (- (length (funcall tab-bar-tabs-function)) | 1125 | (tab-bar-select-tab (- (length (funcall tab-bar-tabs-function)) |
| 1112 | (1- (or arg 1))))) | 1126 | (1- (or arg 1))))) |
| 1113 | 1127 | ||
| 1114 | (defun tab-bar-switch-to-recent-tab (&optional arg) | 1128 | (defun tab-bar-switch-to-recent-tab (&optional arg) |
| 1115 | "Switch to ARGth most recently visited tab." | 1129 | "Switch to ARGth most recently visited tab. |
| 1130 | Interactively, ARG is the prefix numeric argument and defaults to 1." | ||
| 1116 | (interactive "p") | 1131 | (interactive "p") |
| 1117 | (unless (integerp arg) | 1132 | (unless (integerp arg) |
| 1118 | (setq arg 1)) | 1133 | (setq arg 1)) |
| @@ -1160,8 +1175,9 @@ where argument addressing is relative." | |||
| 1160 | 1175 | ||
| 1161 | (defun tab-bar-move-tab (&optional arg) | 1176 | (defun tab-bar-move-tab (&optional arg) |
| 1162 | "Move the current tab ARG positions to the right. | 1177 | "Move the current tab ARG positions to the right. |
| 1163 | If a negative ARG, move the current tab ARG positions to the left. | 1178 | Interactively, ARG is the prefix numeric argument and defaults to 1. |
| 1164 | Argument addressing is relative in contrast to `tab-bar-move-tab-to' | 1179 | If ARG is negative, move the current tab ARG positions to the left. |
| 1180 | Argument addressing is relative in contrast to `tab-bar-move-tab-to', | ||
| 1165 | where argument addressing is absolute." | 1181 | where argument addressing is absolute." |
| 1166 | (interactive "p") | 1182 | (interactive "p") |
| 1167 | (let* ((tabs (funcall tab-bar-tabs-function)) | 1183 | (let* ((tabs (funcall tab-bar-tabs-function)) |
| @@ -1171,6 +1187,7 @@ where argument addressing is absolute." | |||
| 1171 | 1187 | ||
| 1172 | (defun tab-bar-move-tab-backward (&optional arg) | 1188 | (defun tab-bar-move-tab-backward (&optional arg) |
| 1173 | "Move the current tab ARG positions to the left. | 1189 | "Move the current tab ARG positions to the left. |
| 1190 | Interactively, ARG is the prefix numeric argument and defaults to 1. | ||
| 1174 | Like `tab-bar-move-tab', but moves in the opposite direction." | 1191 | Like `tab-bar-move-tab', but moves in the opposite direction." |
| 1175 | (interactive "p") | 1192 | (interactive "p") |
| 1176 | (tab-bar-move-tab (- (or arg 1)))) | 1193 | (tab-bar-move-tab (- (or arg 1)))) |
| @@ -1181,7 +1198,8 @@ FROM-NUMBER defaults to the current tab number. | |||
| 1181 | FROM-NUMBER and TO-NUMBER count from 1. | 1198 | FROM-NUMBER and TO-NUMBER count from 1. |
| 1182 | FROM-FRAME specifies the source frame and defaults to the selected frame. | 1199 | FROM-FRAME specifies the source frame and defaults to the selected frame. |
| 1183 | TO-FRAME specifies the target frame and defaults the next frame. | 1200 | TO-FRAME specifies the target frame and defaults the next frame. |
| 1184 | Interactively, ARG selects the ARGth different frame to move to." | 1201 | Interactively, ARG selects the ARGth next frame on the same terminal, |
| 1202 | to which to move the tab; ARG defaults to 1." | ||
| 1185 | (interactive "P") | 1203 | (interactive "P") |
| 1186 | (unless from-frame | 1204 | (unless from-frame |
| 1187 | (setq from-frame (selected-frame))) | 1205 | (setq from-frame (selected-frame))) |