aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2019-12-22 01:10:56 +0200
committerJuri Linkov2019-12-22 01:10:56 +0200
commit36abf6864604b3061c2e070f8997491fa2bce44c (patch)
treeb012cdac1810f6129d9724e7729f6c0d8c197506
parent485b423e8f0df2711a850be7f254665f64ab0bdb (diff)
downloademacs-36abf6864604b3061c2e070f8997491fa2bce44c.tar.gz
emacs-36abf6864604b3061c2e070f8997491fa2bce44c.zip
* lisp/tab-bar.el: Rename tab-bar-list to tab-switcher (bug#38624)
-rw-r--r--doc/emacs/frames.texi2
-rw-r--r--lisp/tab-bar.el132
2 files changed, 67 insertions, 67 deletions
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index 3a98df7de9d..8ea923fccb8 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -1268,7 +1268,7 @@ and shows it again when more tabs are created. The value @code{nil}
1268always keeps the tab bar hidden; in this case it's still possible to 1268always keeps the tab bar hidden; in this case it's still possible to
1269use persistent named window configurations without using the tab bar 1269use persistent named window configurations without using the tab bar
1270by typing the related commands: @kbd{M-x tab-new}, @kbd{M-x tab-next}, 1270by typing the related commands: @kbd{M-x tab-new}, @kbd{M-x tab-next},
1271@kbd{M-x tab-list}, @kbd{M-x tab-close}, etc. 1271@kbd{M-x tab-close}, @kbd{M-x tab-switcher}, etc.
1272 1272
1273@kindex C-x t 1273@kindex C-x t
1274 The prefix key @kbd{C-x t} is analogous to @kbd{C-x 5}. 1274 The prefix key @kbd{C-x t} is analogous to @kbd{C-x 5}.
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 84388c6cc93..ceeab1075bc 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -226,7 +226,7 @@ If the value is `1', then hide the tab bar when it has only one tab,
226and show it again once more tabs are created. 226and show it again once more tabs are created.
227If nil, always keep the tab bar hidden. In this case it's still 227If nil, always keep the tab bar hidden. In this case it's still
228possible to use persistent named window configurations by relying on 228possible to use persistent named window configurations by relying on
229keyboard commands `tab-list', `tab-new', `tab-close', `tab-next', etc." 229keyboard commands `tab-new', `tab-close', `tab-next', `tab-switcher', etc."
230 :type '(choice (const :tag "Always" t) 230 :type '(choice (const :tag "Always" t)
231 (const :tag "When more than one tab" 1) 231 (const :tag "When more than one tab" 1)
232 (const :tag "Never" nil)) 232 (const :tag "Never" nil))
@@ -630,7 +630,7 @@ to the numeric argument. ARG counts from 1."
630 (tab-bar--tabs-recent)))) 630 (tab-bar--tabs-recent))))
631 (list (completing-read "Switch to tab by name (default recent): " 631 (list (completing-read "Switch to tab by name (default recent): "
632 recent-tabs nil nil nil nil recent-tabs)))) 632 recent-tabs nil nil nil nil recent-tabs))))
633 (tab-bar-select-tab (1+ (tab-bar--tab-index-by-name name)))) 633 (tab-bar-select-tab (1+ (or (tab-bar--tab-index-by-name name) 0))))
634 634
635(defalias 'tab-bar-select-tab-by-name 'tab-bar-switch-to-tab) 635(defalias 'tab-bar-select-tab-by-name 'tab-bar-switch-to-tab)
636 636
@@ -1131,12 +1131,12 @@ function `tab-bar-tab-name-function'."
1131(defalias 'tab-move 'tab-bar-move-tab) 1131(defalias 'tab-move 'tab-bar-move-tab)
1132(defalias 'tab-move-to 'tab-bar-move-tab-to) 1132(defalias 'tab-move-to 'tab-bar-move-tab-to)
1133(defalias 'tab-rename 'tab-bar-rename-tab) 1133(defalias 'tab-rename 'tab-bar-rename-tab)
1134(defalias 'tab-list 'tab-bar-list) 1134(defalias 'tab-list 'tab-switcher)
1135 1135
1136 1136
1137;;; Non-graphical access to frame-local tabs (named window configurations) 1137;;; Non-graphical access to frame-local tabs (named window configurations)
1138 1138
1139(defun tab-bar-list () 1139(defun tab-switcher ()
1140 "Display a list of named window configurations. 1140 "Display a list of named window configurations.
1141The list is displayed in the buffer `*Tabs*'. 1141The list is displayed in the buffer `*Tabs*'.
1142It's placed in the center of the frame to resemble a window list 1142It's placed in the center of the frame to resemble a window list
@@ -1162,15 +1162,15 @@ marked for deletion."
1162 ;; its parameters left intact. 1162 ;; its parameters left intact.
1163 (split-window) (delete-window) 1163 (split-window) (delete-window)
1164 (let ((switch-to-buffer-preserve-window-point nil)) 1164 (let ((switch-to-buffer-preserve-window-point nil))
1165 (switch-to-buffer (tab-bar-list-noselect))) 1165 (switch-to-buffer (tab-switcher-noselect)))
1166 (setq default-directory dir)) 1166 (setq default-directory dir))
1167 (message "Commands: d, x; RET; q to quit; ? for help.")) 1167 (message "Commands: d, x; RET; q to quit; ? for help."))
1168 1168
1169(defun tab-bar-list-noselect () 1169(defun tab-switcher-noselect ()
1170 "Create and return a buffer with a list of window configurations. 1170 "Create and return a buffer with a list of window configurations.
1171The list is displayed in a buffer named `*Tabs*'. 1171The list is displayed in a buffer named `*Tabs*'.
1172 1172
1173For more information, see the function `tab-bar-list'." 1173For more information, see the function `tab-switcher'."
1174 (let* ((tabs (seq-remove (lambda (tab) 1174 (let* ((tabs (seq-remove (lambda (tab)
1175 (eq (car tab) 'current-tab)) 1175 (eq (car tab) 'current-tab))
1176 (funcall tab-bar-tabs-function))) 1176 (funcall tab-bar-tabs-function)))
@@ -1182,15 +1182,15 @@ For more information, see the function `tab-bar-list'."
1182 (frame-parameter nil 'name)))) 1182 (frame-parameter nil 'name))))
1183 (setq buffer-read-only nil) 1183 (setq buffer-read-only nil)
1184 (erase-buffer) 1184 (erase-buffer)
1185 (tab-bar-list-mode) 1185 (tab-switcher-mode)
1186 ;; Vertical alignment to the center of the frame 1186 ;; Vertical alignment to the center of the frame
1187 (insert-char ?\n (/ (- (frame-height) (length tabs) 1) 2)) 1187 (insert-char ?\n (/ (- (frame-height) (length tabs) 1) 2))
1188 ;; Horizontal alignment to the center of the frame 1188 ;; Horizontal alignment to the center of the frame
1189 (setq tab-bar-list-column (- (/ (frame-width) 2) 15)) 1189 (setq tab-switcher-column (- (/ (frame-width) 2) 15))
1190 (dolist (tab tabs) 1190 (dolist (tab tabs)
1191 (insert (propertize 1191 (insert (propertize
1192 (format "%s %s\n" 1192 (format "%s %s\n"
1193 (make-string tab-bar-list-column ?\040) 1193 (make-string tab-switcher-column ?\040)
1194 (propertize 1194 (propertize
1195 (cdr (assq 'name tab)) 1195 (cdr (assq 'name tab))
1196 'mouse-face 'highlight 1196 'mouse-face 'highlight
@@ -1199,96 +1199,96 @@ For more information, see the function `tab-bar-list'."
1199 (goto-char (point-min)) 1199 (goto-char (point-min))
1200 (goto-char (or (next-single-property-change (point) 'tab) (point-min))) 1200 (goto-char (or (next-single-property-change (point) 'tab) (point-min)))
1201 (when (> (length tabs) 1) 1201 (when (> (length tabs) 1)
1202 (tab-bar-list-next-line)) 1202 (tab-switcher-next-line))
1203 (move-to-column tab-bar-list-column) 1203 (move-to-column tab-switcher-column)
1204 (set-buffer-modified-p nil) 1204 (set-buffer-modified-p nil)
1205 (setq buffer-read-only t) 1205 (setq buffer-read-only t)
1206 (current-buffer)))) 1206 (current-buffer))))
1207 1207
1208(defvar tab-bar-list-column 3) 1208(defvar tab-switcher-column 3)
1209(make-variable-buffer-local 'tab-bar-list-column) 1209(make-variable-buffer-local 'tab-switcher-column)
1210 1210
1211(defvar tab-bar-list-mode-map 1211(defvar tab-switcher-mode-map
1212 (let ((map (make-keymap))) 1212 (let ((map (make-keymap)))
1213 (suppress-keymap map t) 1213 (suppress-keymap map t)
1214 (define-key map "q" 'quit-window) 1214 (define-key map "q" 'quit-window)
1215 (define-key map "\C-m" 'tab-bar-list-select) 1215 (define-key map "\C-m" 'tab-switcher-select)
1216 (define-key map "d" 'tab-bar-list-delete) 1216 (define-key map "d" 'tab-switcher-delete)
1217 (define-key map "k" 'tab-bar-list-delete) 1217 (define-key map "k" 'tab-switcher-delete)
1218 (define-key map "\C-d" 'tab-bar-list-delete-backwards) 1218 (define-key map "\C-d" 'tab-switcher-delete-backwards)
1219 (define-key map "\C-k" 'tab-bar-list-delete) 1219 (define-key map "\C-k" 'tab-switcher-delete)
1220 (define-key map "x" 'tab-bar-list-execute) 1220 (define-key map "x" 'tab-switcher-execute)
1221 (define-key map " " 'tab-bar-list-next-line) 1221 (define-key map " " 'tab-switcher-next-line)
1222 (define-key map "n" 'tab-bar-list-next-line) 1222 (define-key map "n" 'tab-switcher-next-line)
1223 (define-key map "p" 'tab-bar-list-prev-line) 1223 (define-key map "p" 'tab-switcher-prev-line)
1224 (define-key map "\177" 'tab-bar-list-backup-unmark) 1224 (define-key map "\177" 'tab-switcher-backup-unmark)
1225 (define-key map "?" 'describe-mode) 1225 (define-key map "?" 'describe-mode)
1226 (define-key map "u" 'tab-bar-list-unmark) 1226 (define-key map "u" 'tab-switcher-unmark)
1227 (define-key map [mouse-2] 'tab-bar-list-mouse-select) 1227 (define-key map [mouse-2] 'tab-switcher-mouse-select)
1228 (define-key map [follow-link] 'mouse-face) 1228 (define-key map [follow-link] 'mouse-face)
1229 map) 1229 map)
1230 "Local keymap for `tab-bar-list-mode' buffers.") 1230 "Local keymap for `tab-switcher-mode' buffers.")
1231 1231
1232(define-derived-mode tab-bar-list-mode nil "Window Configurations" 1232(define-derived-mode tab-switcher-mode nil "Window Configurations"
1233 "Major mode for selecting a window configuration. 1233 "Major mode for selecting a window configuration.
1234Each line describes one window configuration in Emacs. 1234Each line describes one window configuration in Emacs.
1235Letters do not insert themselves; instead, they are commands. 1235Letters do not insert themselves; instead, they are commands.
1236\\<tab-bar-list-mode-map> 1236\\<tab-switcher-mode-map>
1237\\[tab-bar-list-mouse-select] -- select window configuration you click on. 1237\\[tab-switcher-mouse-select] -- select window configuration you click on.
1238\\[tab-bar-list-select] -- select current line's window configuration. 1238\\[tab-switcher-select] -- select current line's window configuration.
1239\\[tab-bar-list-delete] -- mark that window configuration to be deleted, and move down. 1239\\[tab-switcher-delete] -- mark that window configuration to be deleted, and move down.
1240\\[tab-bar-list-delete-backwards] -- mark that window configuration to be deleted, and move up. 1240\\[tab-switcher-delete-backwards] -- mark that window configuration to be deleted, and move up.
1241\\[tab-bar-list-execute] -- delete marked window configurations. 1241\\[tab-switcher-execute] -- delete marked window configurations.
1242\\[tab-bar-list-unmark] -- remove all kinds of marks from current line. 1242\\[tab-switcher-unmark] -- remove all kinds of marks from current line.
1243 With prefix argument, also move up one line. 1243 With prefix argument, also move up one line.
1244\\[tab-bar-list-backup-unmark] -- back up a line and remove marks." 1244\\[tab-switcher-backup-unmark] -- back up a line and remove marks."
1245 (setq truncate-lines t)) 1245 (setq truncate-lines t))
1246 1246
1247(defun tab-bar-list-current-tab (error-if-non-existent-p) 1247(defun tab-switcher-current-tab (error-if-non-existent-p)
1248 "Return window configuration described by this line of the list." 1248 "Return window configuration described by this line of the list."
1249 (let* ((where (save-excursion 1249 (let* ((where (save-excursion
1250 (beginning-of-line) 1250 (beginning-of-line)
1251 (+ 2 (point) tab-bar-list-column))) 1251 (+ 2 (point) tab-switcher-column)))
1252 (tab (and (not (eobp)) (get-text-property where 'tab)))) 1252 (tab (and (not (eobp)) (get-text-property where 'tab))))
1253 (or tab 1253 (or tab
1254 (if error-if-non-existent-p 1254 (if error-if-non-existent-p
1255 (user-error "No window configuration on this line") 1255 (user-error "No window configuration on this line")
1256 nil)))) 1256 nil))))
1257 1257
1258(defun tab-bar-list-next-line (&optional arg) 1258(defun tab-switcher-next-line (&optional arg)
1259 (interactive "p") 1259 (interactive "p")
1260 (forward-line arg) 1260 (forward-line arg)
1261 (beginning-of-line) 1261 (beginning-of-line)
1262 (move-to-column tab-bar-list-column)) 1262 (move-to-column tab-switcher-column))
1263 1263
1264(defun tab-bar-list-prev-line (&optional arg) 1264(defun tab-switcher-prev-line (&optional arg)
1265 (interactive "p") 1265 (interactive "p")
1266 (forward-line (- arg)) 1266 (forward-line (- arg))
1267 (beginning-of-line) 1267 (beginning-of-line)
1268 (move-to-column tab-bar-list-column)) 1268 (move-to-column tab-switcher-column))
1269 1269
1270(defun tab-bar-list-unmark (&optional backup) 1270(defun tab-switcher-unmark (&optional backup)
1271 "Cancel all requested operations on window configuration on this line and move down. 1271 "Cancel all requested operations on window configuration on this line and move down.
1272Optional prefix arg means move up." 1272Optional prefix arg means move up."
1273 (interactive "P") 1273 (interactive "P")
1274 (beginning-of-line) 1274 (beginning-of-line)
1275 (move-to-column tab-bar-list-column) 1275 (move-to-column tab-switcher-column)
1276 (let* ((buffer-read-only nil)) 1276 (let* ((buffer-read-only nil))
1277 (delete-char 1) 1277 (delete-char 1)
1278 (insert " ")) 1278 (insert " "))
1279 (forward-line (if backup -1 1)) 1279 (forward-line (if backup -1 1))
1280 (move-to-column tab-bar-list-column)) 1280 (move-to-column tab-switcher-column))
1281 1281
1282(defun tab-bar-list-backup-unmark () 1282(defun tab-switcher-backup-unmark ()
1283 "Move up and cancel all requested operations on window configuration on line above." 1283 "Move up and cancel all requested operations on window configuration on line above."
1284 (interactive) 1284 (interactive)
1285 (forward-line -1) 1285 (forward-line -1)
1286 (tab-bar-list-unmark) 1286 (tab-switcher-unmark)
1287 (forward-line -1) 1287 (forward-line -1)
1288 (move-to-column tab-bar-list-column)) 1288 (move-to-column tab-switcher-column))
1289 1289
1290(defun tab-bar-list-delete (&optional arg) 1290(defun tab-switcher-delete (&optional arg)
1291 "Mark window configuration on this line to be deleted by \\<tab-bar-list-mode-map>\\[tab-bar-list-execute] command. 1291 "Mark window configuration on this line to be deleted by \\<tab-switcher-mode-map>\\[tab-switcher-execute] command.
1292Prefix arg is how many window configurations to delete. 1292Prefix arg is how many window configurations to delete.
1293Negative arg means delete backwards." 1293Negative arg means delete backwards."
1294 (interactive "p") 1294 (interactive "p")
@@ -1305,15 +1305,15 @@ Negative arg means delete backwards."
1305 (insert ?D) 1305 (insert ?D)
1306 (forward-line -1) 1306 (forward-line -1)
1307 (setq arg (1+ arg))) 1307 (setq arg (1+ arg)))
1308 (move-to-column tab-bar-list-column))) 1308 (move-to-column tab-switcher-column)))
1309 1309
1310(defun tab-bar-list-delete-backwards (&optional arg) 1310(defun tab-switcher-delete-backwards (&optional arg)
1311 "Mark window configuration on this line to be deleted by \\<tab-bar-list-mode-map>\\[tab-bar-list-execute] command. 1311 "Mark window configuration on this line to be deleted by \\<tab-switcher-mode-map>\\[tab-switcher-execute] command.
1312Then move up one line. Prefix arg means move that many lines." 1312Then move up one line. Prefix arg means move that many lines."
1313 (interactive "p") 1313 (interactive "p")
1314 (tab-bar-list-delete (- (or arg 1)))) 1314 (tab-switcher-delete (- (or arg 1))))
1315 1315
1316(defun tab-bar-list-delete-from-list (tab) 1316(defun tab-switcher-delete-from-list (tab)
1317 "Delete the window configuration from both lists." 1317 "Delete the window configuration from both lists."
1318 (push `((frame . ,(selected-frame)) 1318 (push `((frame . ,(selected-frame))
1319 (index . ,(tab-bar--tab-index tab)) 1319 (index . ,(tab-bar--tab-index tab))
@@ -1321,31 +1321,31 @@ Then move up one line. Prefix arg means move that many lines."
1321 tab-bar-closed-tabs) 1321 tab-bar-closed-tabs)
1322 (set-frame-parameter nil 'tabs (delq tab (funcall tab-bar-tabs-function)))) 1322 (set-frame-parameter nil 'tabs (delq tab (funcall tab-bar-tabs-function))))
1323 1323
1324(defun tab-bar-list-execute () 1324(defun tab-switcher-execute ()
1325 "Delete window configurations marked with \\<tab-bar-list-mode-map>\\[tab-bar-list-delete] commands." 1325 "Delete window configurations marked with \\<tab-switcher-mode-map>\\[tab-switcher-delete] commands."
1326 (interactive) 1326 (interactive)
1327 (save-excursion 1327 (save-excursion
1328 (goto-char (point-min)) 1328 (goto-char (point-min))
1329 (let ((buffer-read-only nil)) 1329 (let ((buffer-read-only nil))
1330 (while (re-search-forward 1330 (while (re-search-forward
1331 (format "^%sD" (make-string tab-bar-list-column ?\040)) 1331 (format "^%sD" (make-string tab-switcher-column ?\040))
1332 nil t) 1332 nil t)
1333 (forward-char -1) 1333 (forward-char -1)
1334 (let ((tab (tab-bar-list-current-tab nil))) 1334 (let ((tab (tab-switcher-current-tab nil)))
1335 (when tab 1335 (when tab
1336 (tab-bar-list-delete-from-list tab) 1336 (tab-switcher-delete-from-list tab)
1337 (beginning-of-line) 1337 (beginning-of-line)
1338 (delete-region (point) (progn (forward-line 1) (point)))))))) 1338 (delete-region (point) (progn (forward-line 1) (point))))))))
1339 (beginning-of-line) 1339 (beginning-of-line)
1340 (move-to-column tab-bar-list-column) 1340 (move-to-column tab-switcher-column)
1341 (force-mode-line-update)) 1341 (force-mode-line-update))
1342 1342
1343(defun tab-bar-list-select () 1343(defun tab-switcher-select ()
1344 "Select this line's window configuration. 1344 "Select this line's window configuration.
1345This command deletes and replaces all the previously existing windows 1345This command deletes and replaces all the previously existing windows
1346in the selected frame." 1346in the selected frame."
1347 (interactive) 1347 (interactive)
1348 (let* ((to-tab (tab-bar-list-current-tab t))) 1348 (let* ((to-tab (tab-switcher-current-tab t)))
1349 (kill-buffer (current-buffer)) 1349 (kill-buffer (current-buffer))
1350 ;; Delete the current window configuration of tab list 1350 ;; Delete the current window configuration of tab list
1351 ;; without storing it in the undo list of closed tabs 1351 ;; without storing it in the undo list of closed tabs
@@ -1353,12 +1353,12 @@ in the selected frame."
1353 tab-bar-closed-tabs) 1353 tab-bar-closed-tabs)
1354 (tab-bar-close-tab nil (1+ (tab-bar--tab-index to-tab)))))) 1354 (tab-bar-close-tab nil (1+ (tab-bar--tab-index to-tab))))))
1355 1355
1356(defun tab-bar-list-mouse-select (event) 1356(defun tab-switcher-mouse-select (event)
1357 "Select the window configuration whose line you click on." 1357 "Select the window configuration whose line you click on."
1358 (interactive "e") 1358 (interactive "e")
1359 (set-buffer (window-buffer (posn-window (event-end event)))) 1359 (set-buffer (window-buffer (posn-window (event-end event))))
1360 (goto-char (posn-point (event-end event))) 1360 (goto-char (posn-point (event-end event)))
1361 (tab-bar-list-select)) 1361 (tab-switcher-select))
1362 1362
1363 1363
1364(defun tab-bar--reusable-frames (all-frames) 1364(defun tab-bar--reusable-frames (all-frames)