diff options
Diffstat (limited to 'lisp/+tab-bar.el')
-rw-r--r-- | lisp/+tab-bar.el | 66 |
1 files changed, 62 insertions, 4 deletions
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. | ||
60 | Used 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 _) |