mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-23 21:37:34 +00:00
* lisp/tab-bar.el (tab-bar-close-other-tabs): Add arg ‘tab-number’.
(tab-bar-mouse-context-menu): Bind menu-item "Close other tabs" to tab-bar-close-other-tabs with arg ‘tab-number’.
This commit is contained in:
parent
cc52f6d995
commit
b172049717
1 changed files with 21 additions and 6 deletions
|
|
@ -316,7 +316,12 @@ that closes only when clicked on the close button."
|
|||
(define-key-after menu [close]
|
||||
`(menu-item "Close" (lambda () (interactive)
|
||||
(tab-bar-close-tab ,tab-number))
|
||||
:help "Close the tab"))))
|
||||
:help "Close the tab"))
|
||||
(define-key-after menu [close-other]
|
||||
`(menu-item "Close other tabs"
|
||||
(lambda () (interactive)
|
||||
(tab-bar-close-other-tabs ,tab-number))
|
||||
:help "Close all other tabs"))))
|
||||
|
||||
(popup-menu menu event)))
|
||||
|
||||
|
|
@ -1405,15 +1410,25 @@ for the last tab on a frame is determined by
|
|||
(funcall tab-bar-tabs-function)))))
|
||||
(tab-bar-close-tab (1+ (tab-bar--tab-index-by-name name))))
|
||||
|
||||
(defun tab-bar-close-other-tabs ()
|
||||
"Close all tabs on the selected frame, except the selected one."
|
||||
(defun tab-bar-close-other-tabs (&optional tab-number)
|
||||
"Close all tabs on the selected frame, except TAB-NUMBER.
|
||||
TAB-NUMBER counts from 1 and defaults to the current tab."
|
||||
(interactive)
|
||||
(let* ((tabs (funcall tab-bar-tabs-function))
|
||||
(current-tab (tab-bar--current-tab-find tabs))
|
||||
(current-index (tab-bar--current-tab-index tabs))
|
||||
(keep-index (if (integerp tab-number)
|
||||
(1- (max 0 (min tab-number (length tabs))))
|
||||
current-index))
|
||||
(keep-tab (nth keep-index tabs))
|
||||
(index 0))
|
||||
(when current-tab
|
||||
|
||||
(when keep-tab
|
||||
(unless (eq keep-index current-index)
|
||||
(tab-bar-select-tab (1+ keep-index))
|
||||
(setq tabs (funcall tab-bar-tabs-function)))
|
||||
|
||||
(dolist (tab tabs)
|
||||
(unless (or (eq tab current-tab)
|
||||
(unless (or (eq tab keep-tab)
|
||||
(run-hook-with-args-until-success
|
||||
'tab-bar-tab-prevent-close-functions tab
|
||||
;; `last-tab-p' logically can't ever be true
|
||||
|
|
|
|||
Loading…
Reference in a new issue