From e28d8de0d23b9bafb73d08d70eac1a5a45b0e096 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 23 Jul 2021 14:45:26 +0800 Subject: 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. --- tab-conf.el | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'tab-conf.el') 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): " -- cgit v1.2.3-18-g5258