summary refs log tree commit diff stats
path: root/lisp/+tab-bar.el
diff options
context:
space:
mode:
authorCase Duckworth2022-01-10 23:44:45 -0600
committerCase Duckworth2022-01-10 23:44:45 -0600
commit3379638199bf15bb1439209c1d5ace8daa560cfd (patch)
tree6aa3315e26d9d6c67dd10c019ce0acb53bc92f6f /lisp/+tab-bar.el
parentAdd a few packages and .. stuff (diff)
downloademacs-3379638199bf15bb1439209c1d5ace8daa560cfd.tar.gz
emacs-3379638199bf15bb1439209c1d5ace8daa560cfd.zip
Change mode-line and tab-bar
Diffstat (limited to 'lisp/+tab-bar.el')
-rw-r--r--lisp/+tab-bar.el80
1 files changed, 80 insertions, 0 deletions
diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el new file mode 100644 index 0000000..2a03121 --- /dev/null +++ b/lisp/+tab-bar.el
@@ -0,0 +1,80 @@
1;;; +tab-bar.el -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;; Emacs 28 comes with an easy-to-use `tab-bar-format' option, but I still use
6;; Emacs 27 on my Windows machine. Thus, the code in this file.
7
8;;; Code:
9
10(require 'tab-bar)
11
12
13;; Common
14
15(defun +tab-bar-misc-info ()
16 "Display `mode-line-misc-info', formatted for the tab-bar."
17 `((global menu-item ,(string-trim-right
18 (format-mode-line mode-line-misc-info))
19 ignore)))
20
21(defvar +tab-bar-show-original nil
22 "Original value of `tab-bar-show'.")
23
24
25;; Emacs 27
26
27(defun +tab-bar-misc-info-27 (output &rest _)
28 "Display `mode-line-misc-info' in the `tab-bar' on Emacs 27.
29This is :filter-return advice for `tab-bar-make-keymap-1'."
30 (let* ((reserve (length (format-mode-line mode-line-misc-info)))
31 (str (propertize " "
32 'display `(space :align-to (- right (- 0 right-margin)
33 ,reserve)))))
34 (prog1 (append output
35 `((align-right menu-item ,str nil))
36 (+tab-bar-misc-info)))))
37
38
39;; Emacs 28
40
41(defvar +tab-bar-format-original nil
42 "Original value of `tab-bar-format'.")
43
44(defun +tab-bar-misc-info-28 ()
45 "Display `mode-line-misc-info', right-aligned, on Emacs 28."
46 (append (unless (memq 'tab-bar-format-align-right tab-bar-format)
47 '(tab-bar-format-align-right))
48 '(+tab-bar-misc-info)))
49
50
51
52(define-minor-mode +tab-bar-misc-info-mode
53 "Show the `mode-line-misc-info' in the `tab-bar'."
54 :lighter ""
55 :global t
56 (if +tab-bar-misc-info-mode
57 (progn ; Enable
58 (setq +tab-bar-show-original tab-bar-show)
59 (cond
60 ((boundp 'tab-bar-format) ; Emacs 28
61 (setq +tab-bar-format-original tab-bar-format)
62 (unless (memq '+tab-bar-misc-info tab-bar-format)
63 (setq tab-bar-format
64 (append tab-bar-format (+tab-bar-misc-info-28)))))
65 ((fboundp 'tab-bar-make-keymap-1) ; Emacs 27
66 (advice-add 'tab-bar-make-keymap-1 :filter-return
67 '+tab-bar-misc-info-27)))
68 (setq tab-bar-show t))
69 (progn ; Disable
70 (setq tab-bar-show +tab-bar-show-original)
71 (cond
72 ((boundp 'tab-bar-format) ; Emacs 28
73 (setq tab-bar-format +tab-bar-format-original))
74 ((fboundp 'tab-bar-make-keymap-1) ; Emacs 27
75 (advice-remove 'tab-bar-make-keymap-1 '+tab-bar-misc-info-27))))))
76
77
78
79(provide '+tab-bar)
80;;; +tab-bar.el ends here