about summary refs log tree commit diff stats
path: root/lisp/+modeline.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/+modeline.el')
-rw-r--r--lisp/+modeline.el41
1 files changed, 21 insertions, 20 deletions
diff --git a/lisp/+modeline.el b/lisp/+modeline.el index 11d6a4c..c6e8463 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el
@@ -89,14 +89,15 @@ and appended with `truncate-string-ellipsis'."
89 89
90(defun +modeline-buffer-name (&optional spacer) ; gonsie 90(defun +modeline-buffer-name (&optional spacer) ; gonsie
91 "Display the buffer name." 91 "Display the buffer name."
92 (let ((bufname (string-trim (string-replace "%" "" (buffer-name))))) 92 (let ((bufname (string-trim (string-replace "%" "%%%%" (buffer-name)))))
93 (+modeline-spacer nil spacer 93 (+modeline-spacer nil spacer
94 (if (and +modeline-buffer-position (fboundp +modeline-buffer-position)) 94 (if (and +modeline-buffer-position (fboundp +modeline-buffer-position))
95 (funcall +modeline-buffer-position) 95 (funcall +modeline-buffer-position)
96 (propertize (cond 96 (propertize (cond
97 ((ignore-errors 97 ((ignore-errors
98 (and (> +modeline-buffer-name-max-length 0) 98 (and
99 (< +modeline-buffer-name-max-length 1))) 99 (> +modeline-buffer-name-max-length 0)
100 (< +modeline-buffer-name-max-length 1)))
100 (truncate-string-to-width bufname 101 (truncate-string-to-width bufname
101 (* (window-total-width) 102 (* (window-total-width)
102 +modeline-buffer-name-max-length) 103 +modeline-buffer-name-max-length)
@@ -149,14 +150,14 @@ in the cdr will be applied to the major-mode in the mode line."
149 (propertize ;; (+string-truncate (format-mode-line mode-name) 16) 150 (propertize ;; (+string-truncate (format-mode-line mode-name) 16)
150 (format-mode-line mode-name) 151 (format-mode-line mode-name)
151 'face (when (actually-selected-window-p) 152 'face (when (actually-selected-window-p)
152 ;; XXX: This is probably really inefficient. I need to 153 ;; XXX: This is probably really inefficient. I need to
153 ;; simply detect which mode it's in when I change major 154 ;; simply detect which mode it's in when I change major
154 ;; modes (`change-major-mode-hook') and change the face 155 ;; modes (`change-major-mode-hook') and change the face
155 ;; there, probably. 156 ;; there, probably.
156 ;; (catch :done (dolist (cel +modeline-major-mode-faces) 157 ;; (catch :done (dolist (cel +modeline-major-mode-faces)
157 ;; (when (derived-mode-p (car cel)) 158 ;; (when (derived-mode-p (car cel))
158 ;; (throw :done (cdr cel)))) 159 ;; (throw :done (cdr cel))))
159 ;; (alist-get t +modeline-major-mode-faces)) 160 ;; (alist-get t +modeline-major-mode-faces))
160 '+modeline-major-mode-face) 161 '+modeline-major-mode-face)
161 'keymap (let ((map (make-sparse-keymap))) 162 'keymap (let ((map (make-sparse-keymap)))
162 (bindings--define-key map [mode-line down-mouse-1] 163 (bindings--define-key map [mode-line down-mouse-1]
@@ -302,13 +303,13 @@ The order of elements matters: whichever one matches first is applied."
302 (when file-percentage-mode 303 (when file-percentage-mode
303 (+modeline-spacer nil spacer 304 (+modeline-spacer nil spacer
304 (let ((perc (format-mode-line '(-2 "%p")))) 305 (let ((perc (format-mode-line '(-2 "%p"))))
305 (pcase perc 306 (pcase perc
306 ("To" "/\\") 307 ("To" "/\\")
307 ("Bo" "\\/") 308 ("Bo" "\\/")
308 ("Al" "[]") 309 ("Al" "[]")
309 (_ (let ((vec (vector "/|" "//" "||" "\\\\" "\\|" "\\|")) 310 (_ (let ((vec (vector "/|" "//" "||" "\\\\" "\\|" "\\|"))
310 (perc (string-to-number perc))) 311 (perc (string-to-number perc)))
311 (aref vec (floor (/ perc 17)))))))))) 312 (aref vec (floor (/ perc 17))))))))))
312 313
313(defun +modeline-file-percentage-icon (&optional spacer) 314(defun +modeline-file-percentage-icon (&optional spacer)
314 "Display the position in the current file as an icon." 315 "Display the position in the current file as an icon."
@@ -379,8 +380,8 @@ to a function in the current buffer, call that function instead."
379 "Display the version control branch of the current buffer in the modeline." 380 "Display the version control branch of the current buffer in the modeline."
380 ;; from https://www.gonsie.com/blorg/modeline.html, from Doom 381 ;; from https://www.gonsie.com/blorg/modeline.html, from Doom
381 (when-let ((backend (vc-backend buffer-file-name))) 382 (when-let ((backend (vc-backend buffer-file-name)))
382 (+modeline-spacer nil spacer 383 (+modeline-spacer nil spacer
383 (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))))) 384 (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2)))))
384 385
385(defun +modeline-track (&optional spacer) 386(defun +modeline-track (&optional spacer)
386 "Display `tracking-mode' information." 387 "Display `tracking-mode' information."