diff options
Diffstat (limited to 'lisp/+tab-bar.el')
-rw-r--r-- | lisp/+tab-bar.el | 78 |
1 files changed, 53 insertions, 25 deletions
diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el index dce84d8..95f657d 100644 --- a/lisp/+tab-bar.el +++ b/lisp/+tab-bar.el | |||
@@ -47,12 +47,40 @@ | |||
47 | (when-let ((help (plist-get item 'help-echo))) | 47 | (when-let ((help (plist-get item 'help-echo))) |
48 | (list :help help))))))) | 48 | (list :help help))))))) |
49 | 49 | ||
50 | (defun +tab-bar-timer () | ||
51 | "Display `+timer-string' in the tab-bar." | ||
52 | (when +timer-string | ||
53 | `((timer-string menu-item | ||
54 | ,(concat " " +timer-string) | ||
55 | (lambda (ev) | ||
56 | (interactive "e") | ||
57 | (cond ((not +timer-timer) nil) | ||
58 | ((equal +timer-string +timer-running-string) | ||
59 | (popup-menu | ||
60 | '("Running timer" | ||
61 | ["Cancel timer" +timer-cancel t]) | ||
62 | ev)) | ||
63 | (t (setq +timer-string "")))))))) | ||
64 | |||
50 | (defun +tab-bar-date () | 65 | (defun +tab-bar-date () |
51 | "Display `display-time-string' in the tab-bar." | 66 | "Display `display-time-string' in the tab-bar." |
52 | (when display-time-mode | 67 | (when display-time-mode |
53 | `((date-time-string menu-item | 68 | `((date-time-string menu-item |
54 | ,(propertize (concat " " display-time-string)) | 69 | ,(propertize (concat " " display-time-string)) |
55 | ignore | 70 | (lambda (ev) |
71 | (interactive "e") | ||
72 | (popup-menu | ||
73 | (append '("Timer") | ||
74 | (let (r) | ||
75 | (dolist (time '(3 5 10)) | ||
76 | (push (vector (format "Timer for %d minutes" time) | ||
77 | `(lambda () (interactive) | ||
78 | (+timer ,time)) | ||
79 | :active t) | ||
80 | r)) | ||
81 | (nreverse r)) | ||
82 | '(["Timer for ..." +timer t])) | ||
83 | ev)) | ||
56 | :help (discord-date-string))))) | 84 | :help (discord-date-string))))) |
57 | 85 | ||
58 | (defun +tab-bar-notmuch-count () | 86 | (defun +tab-bar-notmuch-count () |
@@ -220,7 +248,7 @@ name to the left." | |||
220 | (when (> (+ l-name l-ell) tab-bar-tab-name-truncated-max) | 248 | (when (> (+ l-name l-ell) tab-bar-tab-name-truncated-max) |
221 | ellipsis) | 249 | ellipsis) |
222 | (truncate-string-to-width tab-name l-name | 250 | (truncate-string-to-width tab-name l-name |
223 | (max 0 (- l-name tab-bar-tab-name-truncated-max l-ell)))) | 251 | (max 0 (- l-name tab-bar-tab-name-truncated-max l-ell)))) |
224 | 'help-echo tab-name)))) | 252 | 'help-echo tab-name)))) |
225 | 253 | ||
226 | (defun +tab-bar-format-align-right () | 254 | (defun +tab-bar-format-align-right () |
@@ -267,27 +295,27 @@ Used by `tab-bar-format-menu-bar'." | |||
267 | (el-patch-feature tab-bar) | 295 | (el-patch-feature tab-bar) |
268 | (with-eval-after-load 'tab-bar | 296 | (with-eval-after-load 'tab-bar |
269 | (el-patch-defun tab-bar--format-tab (tab i) | 297 | (el-patch-defun tab-bar--format-tab (tab i) |
270 | "Format TAB using its index I and return the result as a keymap." | 298 | "Format TAB using its index I and return the result as a keymap." |
271 | (append | 299 | (append |
272 | (el-patch-remove | 300 | (el-patch-remove |
273 | `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore))) | 301 | `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore))) |
274 | (cond | 302 | (cond |
275 | ((eq (car tab) 'current-tab) | 303 | ((eq (car tab) 'current-tab) |
276 | `((current-tab | 304 | `((current-tab |
277 | menu-item | 305 | menu-item |
278 | ,(funcall tab-bar-tab-name-format-function tab i) | 306 | ,(funcall tab-bar-tab-name-format-function tab i) |
279 | ignore | 307 | ignore |
280 | :help "Current tab"))) | 308 | :help "Current tab"))) |
281 | (t | 309 | (t |
282 | `((,(intern (format "tab-%i" i)) | 310 | `((,(intern (format "tab-%i" i)) |
283 | menu-item | 311 | menu-item |
284 | ,(funcall tab-bar-tab-name-format-function tab i) | 312 | ,(funcall tab-bar-tab-name-format-function tab i) |
285 | ,(alist-get 'binding tab) | 313 | ,(alist-get 'binding tab) |
286 | :help "Click to visit tab")))) | 314 | :help "Click to visit tab")))) |
287 | (when (alist-get 'close-binding tab) | 315 | (when (alist-get 'close-binding tab) |
288 | `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i))) | 316 | `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i))) |
289 | menu-item "" | 317 | menu-item "" |
290 | ,(alist-get 'close-binding tab))))))) | 318 | ,(alist-get 'close-binding tab))))))) |
291 | 319 | ||
292 | 320 | ||
293 | ;; Emacs 27 | 321 | ;; Emacs 27 |
@@ -300,8 +328,8 @@ This is :filter-return advice for `tab-bar-make-keymap-1'." | |||
300 | 'display `(space :align-to (- right (- 0 right-margin) | 328 | 'display `(space :align-to (- right (- 0 right-margin) |
301 | ,reserve))))) | 329 | ,reserve))))) |
302 | (prog1 (append output | 330 | (prog1 (append output |
303 | `((align-right menu-item ,str nil)) | 331 | `((align-right menu-item ,str nil)) |
304 | (+tab-bar-misc-info))))) | 332 | (+tab-bar-misc-info))))) |
305 | 333 | ||
306 | 334 | ||
307 | ;; Emacs 28 | 335 | ;; Emacs 28 |