aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2019-10-07 00:53:34 +0300
committerJuri Linkov2019-10-07 00:53:34 +0300
commit01465915c93d11fe26c189386d7103cf4904bf6a (patch)
tree97cff9145b5062d6bdd6d2f86d5f27edd4175320
parentd24a19779028f1fe940b43eb72e6c68d2d835bd7 (diff)
downloademacs-01465915c93d11fe26c189386d7103cf4904bf6a.tar.gz
emacs-01465915c93d11fe26c189386d7103cf4904bf6a.zip
Implement tab-close-other bound to C-x 6 1 by analogy with C-x 5 1.
* lisp/tab-bar.el (tab-close-other): New command bound to C-x 6 1. * doc/emacs/frames.texi (Tab Bars): Document it.
-rw-r--r--doc/emacs/frames.texi5
-rw-r--r--lisp/tab-bar.el12
2 files changed, 17 insertions, 0 deletions
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index 869b77d86bd..169eebab3e6 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -1307,6 +1307,11 @@ Switch to another tab. If you repeat this command, it cycles through
1307all the tabs on the selected frame. With a positive numeric argument 1307all the tabs on the selected frame. With a positive numeric argument
1308N, it switches to the next Nth tab; with a negative argument −N, it 1308N, it switches to the next Nth tab; with a negative argument −N, it
1309switches back to the previous Nth tab. 1309switches back to the previous Nth tab.
1310
1311@item C-x 6 1
1312@kindex C-x 6 1
1313@findex tab-close-other
1314Close all tabs on the selected frame, except the selected one.
1310@end table 1315@end table
1311 1316
1312@node Dialog Boxes 1317@node Dialog Boxes
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 27ae274eaa4..1c1acaafa47 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -560,6 +560,17 @@ TO-INDEX counts from 1."
560 (tab-bar-tabs))))) 560 (tab-bar-tabs)))))
561 (tab-bar-close-tab (1+ (tab-bar--tab-index-by-name name)))) 561 (tab-bar-close-tab (1+ (tab-bar--tab-index-by-name name))))
562 562
563(defun tab-close-other ()
564 "Close all tabs on the selected frame, except the selected one."
565 (interactive)
566 (let* ((tabs (tab-bar-tabs))
567 (current-index (tab-bar--current-tab-index tabs)))
568 (when current-index
569 (set-frame-parameter nil 'tabs (list (nth current-index tabs)))
570 (if tab-bar-mode
571 (force-mode-line-update)
572 (message "Deleted all other tabs")))))
573
563 574
564;;; Short aliases 575;;; Short aliases
565 576
@@ -819,6 +830,7 @@ Like \\[find-file-other-frame] (which see), but creates a new tab."
819 (switch-to-buffer-other-tab value)))) 830 (switch-to-buffer-other-tab value))))
820 831
821(define-key ctl-x-6-map "2" 'tab-new) 832(define-key ctl-x-6-map "2" 'tab-new)
833(define-key ctl-x-6-map "1" 'tab-close-other)
822(define-key ctl-x-6-map "0" 'tab-close) 834(define-key ctl-x-6-map "0" 'tab-close)
823(define-key ctl-x-6-map "o" 'tab-next) 835(define-key ctl-x-6-map "o" 'tab-next)
824(define-key ctl-x-6-map "b" 'switch-to-buffer-other-tab) 836(define-key ctl-x-6-map "b" 'switch-to-buffer-other-tab)