From f0febf681490412709be7b494232de8c41253769 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 5 May 2022 18:41:42 -0500 Subject: Change modeline --- lisp/+modeline.el | 68 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 29 deletions(-) (limited to 'lisp/+modeline.el') diff --git a/lisp/+modeline.el b/lisp/+modeline.el index 3a922e3..e5b5bc6 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el @@ -72,26 +72,34 @@ and appended with `truncate-string-ellipsis'." (natnum :tag "Number of characters") (float :tag "Fraction of window's width"))) +(defcustom +modeline-buffer-position nil + "What to put in the `+modeline-buffer-name' position." + :type 'function + :local t) + (defun +modeline-buffer-name (&optional spacer) ; gonsie "Display the buffer name." (let ((bufname (string-trim (string-replace "%" "" (buffer-name))))) (concat (or spacer +modeline-default-spacer) - (propertize (cond - ((ignore-errors - (and (> +modeline-buffer-name-max-length 0) - (< +modeline-buffer-name-max-length 1))) - (truncate-string-to-width bufname - (* (window-total-width) +modeline-buffer-name-max-length) - nil nil t)) - ((ignore-errors - (> +modeline-buffer-name-max-length 1)) - (truncate-string-to-width bufname - +modeline-buffer-name-max-length - nil nil t)) - (t bufname)) - 'help-echo (or (buffer-file-name) - (buffer-name)) - 'mouse-face 'mode-line-highlight)))) + (if (and +modeline-buffer-position (fboundp +modeline-buffer-position)) + (funcall +modeline-buffer-position) + (propertize (cond + ((ignore-errors + (and (> +modeline-buffer-name-max-length 0) + (< +modeline-buffer-name-max-length 1))) + (truncate-string-to-width bufname + (* (window-total-width) + +modeline-buffer-name-max-length) + nil nil t)) + ((ignore-errors + (> +modeline-buffer-name-max-length 1)) + (truncate-string-to-width bufname + +modeline-buffer-name-max-length + nil nil t)) + (t bufname)) + 'help-echo (or (buffer-file-name) + (buffer-name)) + 'mouse-face 'mode-line-highlight))))) (defcustom +modeline-minions-icon "&" "The \"icon\" for `+modeline-minions' button." @@ -152,17 +160,17 @@ The order of elements matters: whichever one matches first is applied." (defun +modeline-modified (&optional spacer) ; modified from `simple-modeline-status-modified' "Display a color-coded \"icon\" indicator for the buffer's status." (let* ((icon (catch :icon - (dolist (cell +modeline-modified-icon-alist) - (when (pcase (car cell) - ('ephemeral (not (buffer-file-name))) - ('readonly buffer-read-only) - ('modified (buffer-modified-p)) - ('special - (apply 'derived-mode-p - +modeline-modified-icon-special-modes)) - ('t t) - (_ nil)) - (throw :icon cell)))))) + (dolist (cell +modeline-modified-icon-alist) + (when (pcase (car cell) + ('ephemeral (not (buffer-file-name))) + ('readonly buffer-read-only) + ('modified (buffer-modified-p)) + ('special + (apply 'derived-mode-p + +modeline-modified-icon-special-modes)) + ('t t) + (_ nil)) + (throw :icon cell)))))) (concat (or spacer +modeline-default-spacer) (propertize (or (cdr-safe icon) "") 'help-echo (format "Buffer \"%s\" is %s." @@ -244,7 +252,8 @@ The order of elements matters: whichever one matches first is applied." perc (unless (seq-some (lambda (s) (string= perc s)) '("Top" "Bot" "All")) - "%%%%"))))) + "%%%%") + " ")))) (defun +modeline-file-percentage-icon (&optional spacer) "Display the position in the current file as an icon." @@ -312,7 +321,8 @@ to a function in the current buffer, call that function instead." +modeline-position-function (+modeline-concat '(+modeline-region +modeline-line-column - +modeline-file-percentage))))) + ;; +modeline-file-percentage + ))))) (defun +modeline-vc (&optional spacer) "Display the version control branch of the current buffer in the modeline." -- cgit 1.4.1-21-gabe81