summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--init.el52
-rw-r--r--lisp/+modeline.el47
-rw-r--r--lisp/+tab-bar.el80
3 files changed, 136 insertions, 43 deletions
diff --git a/init.el b/init.el index f4d6533..f0a93a6 100644 --- a/init.el +++ b/init.el
@@ -1278,27 +1278,32 @@ See also `crux-reopen-as-root-mode'."
1278(setup (:straight (simple-modeline 1278(setup (:straight (simple-modeline
1279 :fork (:host github :repo "duckwork/simple-modeline"))) 1279 :fork (:host github :repo "duckwork/simple-modeline")))
1280 (:require +modeline) 1280 (:require +modeline)
1281 (:option simple-modeline-segments `((;; left 1281 (:option simple-modeline-segments
1282 +modeline-ace-window-display 1282 `(( ; left
1283 +modeline-modified 1283 +modeline-ace-window-display
1284 ,(+modeline-concat 1284 +modeline-modified
1285 '(+modeline-god-mode 1285 +modeline-buffer-name
1286 +modeline-reading-mode 1286 (lambda () (+modeline-vc ": "))
1287 +modeline-narrowed) 1287 ,(+modeline-concat
1288 ",") 1288 '(+modeline-minions
1289 +modeline-buffer-name 1289 +modeline-major-mode))
1290 +modeline-position 1290 +modeline-anzu
1291 +modeline-anzu 1291 )
1292 ) 1292 ( ; right
1293 (;; right 1293 (lambda ()
1294 +modeline-track 1294 (unless +tab-bar-misc-info-mode
1295 +modeline-vc 1295 (+modeline-concat
1296 simple-modeline-segment-misc-info 1296 '(+modeline-track
1297 simple-modeline-segment-process 1297 simple-modeline-segment-misc-info))))
1298 +modeline-text-scale 1298
1299 +modeline-minions 1299 simple-modeline-segment-process
1300 +modeline-major-mode 1300 +modeline-text-scale
1301 ))) 1301 ,(+modeline-concat
1302 '(+modeline-god-mode
1303 +modeline-reading-mode
1304 +modeline-narrowed)
1305 ",")
1306 +modeline-position)))
1302 (simple-modeline-mode +1)) 1307 (simple-modeline-mode +1))
1303 1308
1304(setup (:straight smartscan) 1309(setup (:straight smartscan)
@@ -1469,3 +1474,8 @@ See also `crux-reopen-as-root-mode'."
1469 (:require +zzz-to-char) 1474 (:require +zzz-to-char)
1470 (:option zzz-to-char-reach 1024) 1475 (:option zzz-to-char-reach 1024)
1471 (:global "M-z" #'+zzz-to-char)) 1476 (:global "M-z" #'+zzz-to-char))
1477
1478(setup tab-bar
1479 (:require +tab-bar)
1480 (tab-bar-mode +1)
1481 (+tab-bar-misc-info-mode +1))
diff --git a/lisp/+modeline.el b/lisp/+modeline.el index a0195f1..3f25a40 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el
@@ -88,7 +88,7 @@ This function makes a lambda, so you can throw it straight into
88(defun +modeline-major-mode (&optional spacer) 88(defun +modeline-major-mode (&optional spacer)
89 "Display the current `major-mode'." 89 "Display the current `major-mode'."
90 (concat (or spacer +modeline-default-spacer) 90 (concat (or spacer +modeline-default-spacer)
91 (propertize (+string-truncate (format-mode-line mode-name) 12) 91 (propertize (+string-truncate (format-mode-line mode-name) 16)
92 'face 'bold 92 'face 'bold
93 'keymap mode-line-major-mode-keymap 93 'keymap mode-line-major-mode-keymap
94 'help-echo (concat (format-mode-line mode-name) 94 'help-echo (concat (format-mode-line mode-name)
@@ -185,27 +185,30 @@ The order of elements matters: whichever one matches first is applied."
185 185
186(defun +modeline-position (&optional _) ; adapted from `simple-modeline' 186(defun +modeline-position (&optional _) ; adapted from `simple-modeline'
187 "Display the current cursor position." 187 "Display the current cursor position."
188 (list '((line-number-mode 188 (let ((sep "|") (before " [") (after "]"))
189 ((column-number-mode 189 (list `(:propertize (line-number-mode
190 (column-number-indicator-zero-based 190 ((column-number-mode
191 (9 " %l:%c") 191 (column-number-indicator-zero-based
192 (9 " %l:%C")) 192 ,(concat before "%l" sep "%c" after)
193 (6 " %l:"))) 193 ,(concat before "%l" sep "%C" after))
194 ((column-number-mode 194 ,(concat before "%l" sep "" after)))
195 (column-number-indicator-zero-based 195 ((column-number-mode
196 (5 " :%c") 196 (column-number-indicator-zero-based
197 (5 " :%C")))))) 197 ,(concat before sep "%c" after)
198 '(file-percentage-mode 198 ,(concat before sep "%C" after)))))
199 ((-3 "%p") "%% ")) 199 font-lock-face font-lock-comment-face)
200 (if (region-active-p) 200 (if (region-active-p)
201 (propertize (format "%s%-5d" 201 (propertize (format "%s%-5d"
202 (if (and (mark) (< (point) (mark))) "-" "+") 202 (if (and (mark) (< (point) (mark))) "-" "+")
203 (apply '+ (mapcar 203 (apply '+ (mapcar
204 (lambda (pos) 204 (lambda (pos)
205 (- (cdr pos) 205 (- (cdr pos)
206 (car pos))) 206 (car pos)))
207 (region-bounds)))) 207 (region-bounds))))
208 'font-lock-face 'font-lock-variable-name-face)))) 208 'font-lock-face 'font-lock-variable-name-face))
209 '(:propertize (file-percentage-mode
210 (" " (-3 "%p") "%%"))
211 font-lock-face font-lock-comment-face))))
209 212
210(defun +modeline-vc (&optional spacer) 213(defun +modeline-vc (&optional spacer)
211 "Display the version control branch of the current buffer in the modeline." 214 "Display the version control branch of the current buffer in the modeline."
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