summaryrefslogtreecommitdiff
path: root/tab-conf.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-01-16 14:04:07 +0800
committerJSDurand <mmemmew@gmail.com>2021-01-16 14:06:06 +0800
commit96d038c44a1ef26892adf4b775d1e2efe9e7b44b (patch)
tree559dd92faefcba14bb7b045289017dc34d80c9b5 /tab-conf.el
parent66e440458db37f91903ce8d0c19867f010f7a1a2 (diff)
The first stable version
Fixes: Avoid adding suffix-link repeatedly * embark-conf.el ("embark"): Use view-mode instead of view-file * init.el (load-after-function): Modify the macro so that it no longer redefines built-in functions. (global-map): ("view-conf.el"): Rename view-functions.el to view-conf.el * suffix tree/generalized-suffix-tree.el (gst-edge-length): (gst-add-suffix-link): (gst-canonize): (gst-extend-tree): (gst-build-for-strs): Fixed the bug. * suffix tree/gst debugging platform.txt (strs): Add a new debugging file * suffix tree/gst test ground (2).txt (strs): Do more debugging * tab-conf.el (durand-switch-tab-dwim): Add my own dwim tab function. (global-map): Bind it to the global map. * theme.el Update the modus-themes. * view-conf.el Rename view-functions.el to view-conf.el.
Diffstat (limited to 'tab-conf.el')
-rw-r--r--tab-conf.el58
1 files changed, 58 insertions, 0 deletions
diff --git a/tab-conf.el b/tab-conf.el
index f55259c..eb58fe1 100644
--- a/tab-conf.el
+++ b/tab-conf.el
@@ -6,6 +6,64 @@
(define-key tab-switcher-mode-map (vector ?p) 'tab-switcher-prev-or-last)
(define-key tab-prefix-map (vector 'tab) 'tab-switcher)
+(define-key global-map (vector ?\s-t) #'durand-switch-tab-dwim)
+
+;;;###autoload
+(defun durand-switch-tab-dwim (&optional arg)
+ "Do what I mean if I want to switch tabs.
+
+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 more than two tabs and if ARG is not '(4) or '(16),
+then use complting-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
+one tab, create another one, prompting me for the buffer to
+display in the new tab."
+ (interactive "P")
+ (let ((tabs (seq-sort
+ (lambda (t1 t2)
+ (cond
+ ((null (assoc 'time t1)))
+ ((null (assoc 'time t2)) nil)
+ (t (> (alist-get 'time t1)
+ (alist-get 'time t2)))))
+ (tab-bar-tabs))))
+ (cond
+ ((or (equal arg (cons 4 nil))
+ (null (cdr tabs)))
+ (switch-to-buffer-other-tab (read-buffer "Switch to buffer in a new tab"
+ (other-buffer))))
+ ((and (cdr tabs)
+ (null (cddr tabs))
+ (not (or (equal arg (cons 4 nil))
+ (equal arg (cons 16 nil)))))
+ (tab-bar-switch-to-tab (cdr (assoc 'name (cadr tabs)))))
+ ((not (or (equal arg (cons 4 nil))
+ (equal arg (cons 16 nil))))
+ (tab-bar-switch-to-tab
+ (completing-read (format
+ "Switch to tab by name (default %s): "
+ (cdr (assoc 'name (cadr tabs))))
+ (mapcar (lambda (tab)
+ (cdr (assoc 'name tab)))
+ tabs)
+ nil nil nil nil
+ (cdr (assoc 'name (cadr tabs))))))
+ ((equal arg (cons 16 nil))
+ (tab-bar-close-tab-by-name
+ (completing-read "Close tab: "
+ (mapcar (lambda (tab)
+ (cdr (assoc 'name tab)))
+ tabs)
+ nil nil nil nil
+ (cdr (assoc 'name (car tabs)))))))))
+
;;;###autoload
(defun tab-switcher-first ()
"Go to the first window configuration line."