about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2022-01-16 15:54:00 -0600
committerCase Duckworth2022-01-16 15:54:00 -0600
commit84c320cda4fd0257eb9d2e1d78ff1124a473cf69 (patch)
treeb1ce41347b18e3925da4558acc45efa97b499487
parentFix typo (diff)
downloademacs-84c320cda4fd0257eb9d2e1d78ff1124a473cf69.tar.gz
emacs-84c320cda4fd0257eb9d2e1d78ff1124a473cf69.zip
Make tab bar more better
-rw-r--r--init.el12
-rw-r--r--lisp/+tab-bar.el66
2 files changed, 73 insertions, 5 deletions
diff --git a/init.el b/init.el index 4136271..63d0f87 100644 --- a/init.el +++ b/init.el
@@ -584,7 +584,17 @@
584 tab-bar-tab-name-ellipsis truncate-string-ellipsis 584 tab-bar-tab-name-ellipsis truncate-string-ellipsis
585 tab-bar-show t) 585 tab-bar-show t)
586 (tab-bar-mode +1) 586 (tab-bar-mode +1)
587 (+tab-bar-misc-info-mode +1)) 587 (if (version< emacs-version "28.0")
588 (+tab-bar-misc-info-mode +1)
589 (:option tab-bar-format '(+tab-bar-format-menu-bar
590 tab-bar-format-history
591 tab-bar-format-tabs
592 tab-bar-separator
593 tab-bar-format-add-tab
594 tab-bar-format-align-right
595 +tab-bar-misc-info
596 tab-bar-separator
597 ))))
588 598
589(setup text 599(setup text
590 (:hook #'turn-on-auto-fill)) 600 (:hook #'turn-on-auto-fill))
diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el index 1ee7606..02f3a0d 100644 --- a/lisp/+tab-bar.el +++ b/lisp/+tab-bar.el
@@ -24,10 +24,12 @@
24(defun +tab-bar-basename () 24(defun +tab-bar-basename ()
25 "Generate the tab name from the basename of the buffer of the 25 "Generate the tab name from the basename of the buffer of the
26 selected window." 26 selected window."
27 (let* ((tab-file-name (buffer-file-name (window-buffer (minibuffer-selected-window))))) 27 (let* ((tab-file-name (buffer-file-name (window-buffer
28 (if tab-file-name 28 (minibuffer-selected-window)))))
29 (file-name-nondirectory tab-file-name) 29 (concat " "
30 (+tab-bar-tab-name-truncated-left)))) 30 (if tab-file-name
31 (file-name-nondirectory tab-file-name)
32 (+tab-bar-tab-name-truncated-left)))))
31 33
32(defun +tab-bar-tab-name-truncated-left () 34(defun +tab-bar-tab-name-truncated-left ()
33 "Generate the tab name from the buffer of the selected window. 35 "Generate the tab name from the buffer of the selected window.
@@ -50,6 +52,62 @@ name to the left."
50 'help-echo tab-name)))) 52 'help-echo tab-name))))
51 53
52 54
55;;; Menu bar
56;; stole from https://github.com/emacs-mirror/emacs/blob/master/lisp/tab-bar.el
57
58(defun +tab-bar-menu-bar (event)
59 "Pop up the same menu as displayed by the menu bar.
60Used by `tab-bar-format-menu-bar'."
61 (interactive "e")
62 (let ((menu (make-sparse-keymap (propertize "Menu Bar" 'hide t))))
63 (run-hooks 'activate-menubar-hook 'menu-bar-update-hook)
64 (map-keymap (lambda (key binding)
65 (when (consp binding)
66 (define-key-after menu (vector key)
67 (copy-sequence binding))))
68 (menu-bar-keymap))
69 (popup-menu menu event)))
70
71(defun +tab-bar-format-menu-bar ()
72 "Produce the Menu button for the tab bar that shows the menu bar."
73 `((menu-bar menu-item (propertize "Ɛ " 'face 'tab-bar-tab-inactive)
74 +tab-bar-menu-bar :help "Menu Bar")))
75
76
77;;; Tab bar format tabs
78
79(require 'el-patch)
80
81(el-patch-defun tab-bar--format-tab (tab i)
82 (append
83 (el-patch-remove
84 `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore)))
85 (cond
86 ((eq (car tab) 'current-tab)
87 `((current-tab
88 menu-item
89 ,(funcall tab-bar-tab-name-format-function tab i)
90 ignore
91 :help "Current tab")))
92 (t
93 `((,(intern (format "tab-%i" i))
94 menu-item
95 ,(funcall tab-bar-tab-name-format-function tab i)
96 ,(or
97 (alist-get 'binding tab)
98 `(lambda ()
99 (interactive)
100 (tab-bar-select-tab ,i)))
101 :help "Click to visit tab"))))
102 `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i)))
103 menu-item ""
104 ,(or
105 (alist-get 'close-binding tab)
106 `(lambda ()
107 (interactive)
108 (tab-bar-close-tab ,i)))))))
109
110
53;; Emacs 27 111;; Emacs 27
54 112
55(defun +tab-bar-misc-info-27 (output &rest _) 113(defun +tab-bar-misc-info-27 (output &rest _)