aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2021-03-11 21:05:12 +0200
committerJuri Linkov2021-03-11 21:05:12 +0200
commit8ad221cdf4337a3c4e2d270e09973b4e67a4b4a2 (patch)
tree878b99334a54e9b1e9899bcfdd0c5aa1447ad0e4
parentb8bf62b60a63e4af4be0cfdd7b4e0d4b424af45c (diff)
downloademacs-8ad221cdf4337a3c4e2d270e09973b4e67a4b4a2.tar.gz
emacs-8ad221cdf4337a3c4e2d270e09973b4e67a4b4a2.zip
* lisp/tab-bar.el (tab-bar--current-tab-find): New function.
(tab-bar-close-other-tabs, tab-bar-close-group-tabs): Use it. (tab-bar--history-pre-change): Rename from 'tab-bar-history--pre-change' to follow naming convention. (tab-bar-history-mode): Use renamed 'tab-bar--history-pre-change'.
-rw-r--r--lisp/tab-bar.el19
1 files changed, 10 insertions, 9 deletions
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 66f8ccae472..29465aae63f 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -681,6 +681,10 @@ on the tab bar instead."
681 (explicit-name . ,tab-explicit-name) 681 (explicit-name . ,tab-explicit-name)
682 ,@(if tab-group `((group . ,tab-group)))))) 682 ,@(if tab-group `((group . ,tab-group))))))
683 683
684(defun tab-bar--current-tab-find (&optional tabs frame)
685 (seq-find (lambda (tab) (eq (car tab) 'current-tab))
686 (or tabs (funcall tab-bar-tabs-function frame))))
687
684(defun tab-bar--current-tab-index (&optional tabs frame) 688(defun tab-bar--current-tab-index (&optional tabs frame)
685 (seq-position (or tabs (funcall tab-bar-tabs-function frame)) 689 (seq-position (or tabs (funcall tab-bar-tabs-function frame))
686 'current-tab (lambda (a b) (eq (car a) b)))) 690 'current-tab (lambda (a b) (eq (car a) b))))
@@ -1148,8 +1152,7 @@ for the last tab on a frame is determined by
1148 "Close all tabs on the selected frame, except the selected one." 1152 "Close all tabs on the selected frame, except the selected one."
1149 (interactive) 1153 (interactive)
1150 (let* ((tabs (funcall tab-bar-tabs-function)) 1154 (let* ((tabs (funcall tab-bar-tabs-function))
1151 (current-index (tab-bar--current-tab-index tabs)) 1155 (current-tab (tab-bar--current-tab-find tabs))
1152 (current-tab (and current-index (nth current-index tabs)))
1153 (index 0)) 1156 (index 0))
1154 (when current-tab 1157 (when current-tab
1155 (dolist (tab tabs) 1158 (dolist (tab tabs)
@@ -1284,8 +1287,7 @@ If GROUP-NAME is the empty string, then remove the tab from any group."
1284 "Close all tabs that belong to GROUP-NAME on the selected frame." 1287 "Close all tabs that belong to GROUP-NAME on the selected frame."
1285 (interactive 1288 (interactive
1286 (let* ((tabs (funcall tab-bar-tabs-function)) 1289 (let* ((tabs (funcall tab-bar-tabs-function))
1287 (tab-index (1+ (tab-bar--current-tab-index tabs))) 1290 (group-name (alist-get 'group (tab-bar--current-tab-find tabs))))
1288 (group-name (alist-get 'group (nth (1- tab-index) tabs))))
1289 (list (completing-read 1291 (list (completing-read
1290 "Close all tabs with group name: " 1292 "Close all tabs with group name: "
1291 (delete-dups (delq nil (cons group-name 1293 (delete-dups (delq nil (cons group-name
@@ -1300,8 +1302,7 @@ If GROUP-NAME is the empty string, then remove the tab from any group."
1300 (tab-bar-close-other-tabs) 1302 (tab-bar-close-other-tabs)
1301 1303
1302 (let* ((tabs (funcall tab-bar-tabs-function)) 1304 (let* ((tabs (funcall tab-bar-tabs-function))
1303 (current-index (tab-bar--current-tab-index tabs)) 1305 (current-tab (tab-bar--current-tab-find tabs)))
1304 (current-tab (and current-index (nth current-index tabs))))
1305 (when (and current-tab (equal (alist-get 'group current-tab) 1306 (when (and current-tab (equal (alist-get 'group current-tab)
1306 close-group)) 1307 close-group))
1307 (tab-bar-close-tab))))) 1308 (tab-bar-close-tab)))))
@@ -1327,7 +1328,7 @@ If GROUP-NAME is the empty string, then remove the tab from any group."
1327(defvar tab-bar-history-old-minibuffer-depth 0 1328(defvar tab-bar-history-old-minibuffer-depth 0
1328 "Minibuffer depth before the current command.") 1329 "Minibuffer depth before the current command.")
1329 1330
1330(defun tab-bar-history--pre-change () 1331(defun tab-bar--history-pre-change ()
1331 (setq tab-bar-history-old-minibuffer-depth (minibuffer-depth)) 1332 (setq tab-bar-history-old-minibuffer-depth (minibuffer-depth))
1332 ;; Store wc before possibly entering the minibuffer 1333 ;; Store wc before possibly entering the minibuffer
1333 (when (zerop tab-bar-history-old-minibuffer-depth) 1334 (when (zerop tab-bar-history-old-minibuffer-depth)
@@ -1410,9 +1411,9 @@ and can restore them."
1410 :ascent center)) 1411 :ascent center))
1411 tab-bar-forward-button)) 1412 tab-bar-forward-button))
1412 1413
1413 (add-hook 'pre-command-hook 'tab-bar-history--pre-change) 1414 (add-hook 'pre-command-hook 'tab-bar--history-pre-change)
1414 (add-hook 'window-configuration-change-hook 'tab-bar--history-change)) 1415 (add-hook 'window-configuration-change-hook 'tab-bar--history-change))
1415 (remove-hook 'pre-command-hook 'tab-bar-history--pre-change) 1416 (remove-hook 'pre-command-hook 'tab-bar--history-pre-change)
1416 (remove-hook 'window-configuration-change-hook 'tab-bar--history-change))) 1417 (remove-hook 'window-configuration-change-hook 'tab-bar--history-change)))
1417 1418
1418 1419