From 11d310d52004bb1c79abdca98f29b3973ffd25a6 Mon Sep 17 00:00:00 2001 From: noa@gaiwan.org Date: Sat, 15 Jun 2024 17:08:12 +0000 Subject: Update mode line to have right-aligned text --- emacs/init.el | 20 ++++++++++++-------- 1 file 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." -- cgit 1.4.1-2-gfad0