From 6b915359efc24ea1262c77b9a35725929b06b08b Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Sun, 6 Oct 2019 00:54:46 +0300 Subject: [PATCH] More tab bar related key bindings. * lisp/subr.el (ctl-x-6-map, ctl-x-6-prefix): Move here from tab-bar.el to make it available to other modes like dired for 'C-x 6 d'. * lisp/dired.el (dired-other-tab): New command bound to 'C-x 6 d'. * lisp/tab-bar.el: Bind 'C-x 6 o' to tab-next. * doc/emacs/frames.texi (Tab Bars): Describe C-x 6 prefix key bindings. --- doc/emacs/frames.texi | 46 +++++++++++++++++++++++++++++++++++++++++++ etc/NEWS | 3 +++ lisp/dired.el | 7 +++++++ lisp/subr.el | 5 +++++ lisp/tab-bar.el | 6 +----- 5 files changed, 62 insertions(+), 5 deletions(-) diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi index 43cdb2664d6..ba1424aa2a3 100644 --- a/doc/emacs/frames.texi +++ b/doc/emacs/frames.texi @@ -1255,12 +1255,58 @@ use persistent named window configurations without using the tab bar by typing the related commands: @kbd{M-x tab-new}, @kbd{M-x tab-next}, @kbd{M-x tab-list}, @kbd{M-x tab-close}, etc. +@kindex C-x 6 + The prefix key @kbd{C-x 6} is analogous to @kbd{C-x 5}. +Whereas each @kbd{C-x 5} command pops up a buffer in a different frame +(@pxref{Creating Frames}), the @kbd{C-x 6} commands use a different +tab with a different window configuration in the selected frame. + + The various @kbd{C-x 6} commands differ in how they find or create the +buffer to select: + +@table @kbd +@item C-x 6 2 +@kindex C-x 6 2 +@findex tab-new +Add a new tab (@code{tab-new}). You can control the choice of the +buffer displayed in a new tab by customizing the variable +@code{tab-bar-new-tab-choice}. +@item C-x 6 b @var{bufname} @key{RET} +Select buffer @var{bufname} in another tab. This runs +@code{switch-to-buffer-other-tab}. +@item C-x 6 f @var{filename} @key{RET} +Visit file @var{filename} and select its buffer in another tab. This +runs @code{find-file-other-tab}. @xref{Visiting}. +@item C-x 6 d @var{directory} @key{RET} +Select a Dired buffer for directory @var{directory} in another tab. +This runs @code{dired-other-tab}. @xref{Dired}. +@end table + @vindex tab-bar-new-tab-choice By default, a new tab starts with the current buffer that was current before calling the command that adds a new tab. To start a new tab with other buffers, customize the variable @code{tab-bar-new-tab-choice}. + The following commands are used to delete and operate on tabs: + +@table @kbd +@item C-x 6 0 +@kindex C-x 6 0 +@findex tab-close +Close the selected tab (@code{tab-close}). It has no effect if there +is only one tab. + +@item C-x 6 o +@kindex C-x 6 o +@kindex C-TAB +@findex tab-next +Switch to another tab. If you repeat this command, it cycles through +all the tabs on the selected frame. With a positive numeric argument +N, it switches to the next Nth tab; with a negative argument −N, it +switches back to the previous Nth tab. +@end table + @node Dialog Boxes @section Using Dialog Boxes @cindex dialog boxes diff --git a/etc/NEWS b/etc/NEWS index cadd6d9ef4b..0edbec68944 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2058,6 +2058,9 @@ tabs with a mouse. Tab-related commands are available even when the Tab-Bar mode is disabled: by default, they enable Tab-Bar mode in that case. +Read the new Info node "(emacs) Tab Bars" for full description +of all related features. + *** Tab-Line mode The new command 'global-tab-line-mode' enables the tab-line above each window, which you can use to switch buffers in the window. Selecting diff --git a/lisp/dired.el b/lisp/dired.el index 854bc9f7d7e..efe00d1ba40 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -835,6 +835,13 @@ If DIRNAME is already in a Dired buffer, that buffer is used without refresh." (interactive (dired-read-dir-and-switches "in other frame ")) (switch-to-buffer-other-frame (dired-noselect dirname switches))) +;;;###autoload (define-key ctl-x-6-map "d" 'dired-other-tab) +;;;###autoload +(defun dired-other-tab (dirname &optional switches) + "\"Edit\" directory DIRNAME. Like `dired' but makes a new tab." + (interactive (dired-read-dir-and-switches "in other tab ")) + (switch-to-buffer-other-tab (dired-noselect dirname switches))) + ;;;###autoload (defun dired-noselect (dir-or-list &optional switches) "Like `dired' but returns the Dired buffer as value, does not select it." diff --git a/lisp/subr.el b/lisp/subr.el index 985bdc6b711..b0a9a839583 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1238,6 +1238,11 @@ The normal global definition of the character C-x indirects to this keymap.") (defalias 'ctl-x-5-prefix ctl-x-5-map) (define-key ctl-x-map "5" 'ctl-x-5-prefix) +(defvar ctl-x-6-map (make-sparse-keymap) + "Keymap for tab commands.") +(defalias 'ctl-x-6-prefix ctl-x-6-map) +(define-key ctl-x-map "6" 'ctl-x-6-prefix) + ;;;; Event manipulation functions. diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index d8d9bdac26d..27ae274eaa4 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -793,11 +793,6 @@ in the selected frame." (tab-bar-list-select)) -(defvar ctl-x-6-map (make-sparse-keymap) - "Keymap for tab commands.") -(defalias 'ctl-x-6-prefix ctl-x-6-map) -(define-key ctl-x-map "6" 'ctl-x-6-prefix) - (defun switch-to-buffer-other-tab (buffer-or-name &optional norecord) "Switch to buffer BUFFER-OR-NAME in another tab. Like \\[switch-to-buffer-other-frame] (which see), but creates a new tab." @@ -825,6 +820,7 @@ Like \\[find-file-other-frame] (which see), but creates a new tab." (define-key ctl-x-6-map "2" 'tab-new) (define-key ctl-x-6-map "0" 'tab-close) +(define-key ctl-x-6-map "o" 'tab-next) (define-key ctl-x-6-map "b" 'switch-to-buffer-other-tab) (define-key ctl-x-6-map "f" 'find-file-other-tab) (define-key ctl-x-6-map "\C-f" 'find-file-other-tab) -- 2.39.5