diff options
author | JSDurand <mmemmew@gmail.com> | 2021-07-23 14:45:26 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2021-07-23 14:45:26 +0800 |
commit | e28d8de0d23b9bafb73d08d70eac1a5a45b0e096 (patch) | |
tree | dca7e299a6ff2e8fb52849c2b4162fd8e342eb71 | |
parent | c15ef3011e70b6981e16715bbaf82b7dc147e27a (diff) |
new: add functionality to durand-switch-tab-dwim
* tab-conf.el (durand-switch-tab-dwim): Include rename-tab,
dired-other-tab, and find-file-other-tab now.
-rw-r--r-- | tab-conf.el | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/tab-conf.el b/tab-conf.el index 6fccb7b..d720cb6 100644 --- a/tab-conf.el +++ b/tab-conf.el @@ -16,11 +16,14 @@ If there is only one tab, or if ARG is '(4), create another one, prompting me for the buffer to display in the new tab. -If there are two tabs and ARG is not '(4) or '(16), just switch -between them. +If there are two tabs and ARG is not '(4) or '(16) or 0, just +switch between them. -If there are more than two tabs and if ARG is not '(4) or '(16), -then use `completing-read' to ask for a tab to switch to. +If ARG is 0, then use `completing-read' to read an action from +`find-file-other-tab', `dired-other-tab', `tab-rename'. + +If there are more than two tabs and if ARG is not '(4) or '(16) +or 0, then use `completing-read' to ask for a tab to switch to. If ARG is '(16), then use `completing-read' to ask for a tab to delete. The default is the current tab. However, if there is only @@ -36,6 +39,19 @@ display in the new tab." (alist-get 'time t2))))) (tab-bar-tabs)))) (cond + ((equal arg 0) + (let* ((action-list (list + (cons"f: file" 'find-file-other-tab) + (cons "d: dired" 'dired-other-tab) + (cons "r: rename" 'tab-rename))) + (action (cdr + (assoc + (minibuffer-with-setup-hook 'durand-headlong-minibuffer-setup-hook + (completing-read "Choose an action: " + action-list nil t)) + action-list #'string=))) + (current-prefix-arg nil)) + (call-interactively action))) ((or (equal arg (cons 4 nil)) (null (cdr tabs))) (switch-to-buffer-other-tab (read-buffer "Switch to buffer in a new tab" @@ -43,10 +59,12 @@ display in the new tab." ((and (cdr tabs) (null (cddr tabs)) (not (or (equal arg (cons 4 nil)) - (equal arg (cons 16 nil))))) + (equal arg (cons 16 nil)) + (equal arg 0)))) (tab-bar-switch-to-tab (cdr (assoc 'name (cadr tabs))))) ((not (or (equal arg (cons 4 nil)) - (equal arg (cons 16 nil)))) + (equal arg (cons 16 nil)) + (equal arg 0))) (tab-bar-switch-to-tab (completing-read (format "Switch to tab by name (default %s): " |