summaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authornoa@gaiwan.org2024-06-15 17:08:12 +0000
committernoa@gaiwan.org2024-06-15 17:08:12 +0000
commit11d310d52004bb1c79abdca98f29b3973ffd25a6 (patch)
tree080233c576580803c36f86ff98b362e090e87194 /emacs
parentb8c2ca53cb586fb91b0a7b6fd749b7180a82cd4a (diff)
Update mode line to have right-aligned text
Diffstat (limited to 'emacs')
-rw-r--r--emacs/init.el20
1 files changed, 12 insertions, 8 deletions
diff --git a/emacs/init.el b/emacs/init.el
index 02e2118..f5d8180 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -77,15 +77,19 @@
;; Below that, show a line and column coördinate. There are special minor modes that will enable or disable this for the default mode line, but i ignore that and put the formatting code here directly. The docstring for the mode-line-format variable suggests that the column might not be displayed correctly in some situations without enabling the minor mode, but i haven't noticed that yet so i don't bother. This column number is zero-indexed; a capital c would make it one-indexed. For now i stick with zero-indexed as that's the emacs default and i'm not sure which is better. I guess it makes a bit more sense that the first character on a line is labeled "1".
;; I don't know exactly what the final variable covers, so i keep it here so that if something shows up i know that it gets put here. Because i have a global mode line in my tab bar, some of the things that would otherwise be here (like the time, battery percentage, and notifications for chat buffers) don't show up.
+
+;; This function taken from Nicolas Rougier's elegant emacs
+(defun mode-line-render (left right)
+ "Function to render the modeline LEFT to RIGHT."
+ (concat left
+ (propertize " " 'display `(space :align-to (- right ,(length right))))
+ right))
+
(setq-default header-line-format
- '((:propertize
- ("" mode-line-modified mode-line-remote)
- face highlight)
- " %b"
- ":%l,%c"
- " "
- ;; mode-line-misc-info
- mode-line-end-spaces))
+ '((:eval
+ (mode-line-render
+ (format-mode-line "%b:%l,%c ")
+ (format-mode-line "%1*%1+%1@")))))
(defun pulse-line (&rest _)
"Pulse the current line."