From e4f7ed9609d85f80f3f54dae7485f06a49fc4d3c Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 11 Jan 2022 16:01:03 -0600 Subject: Lots o changes at work I need to fix +circe-define-filter or something --- lisp/+modeline.el | 72 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 25 deletions(-) (limited to 'lisp/+modeline.el') diff --git a/lisp/+modeline.el b/lisp/+modeline.el index 3f25a40..10bf6d2 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el @@ -183,32 +183,54 @@ The order of elements matters: whichever one matches first is applied." "Toggle the percentage display in the mode line (File Percentage Mode)." :init-value t :global t :group 'mode-line) -(defun +modeline-position (&optional _) ; adapted from `simple-modeline' - "Display the current cursor position." +(defun +modeline-file-percentage (&optional spacer) + "Display the position in the current file." + `(,(or spacer +modeline-default-spacer) + (:propertize (file-percentage-mode + (" " (-3 "%p") "%%")) + font-lock-face font-lock-comment-face))) + +(define-minor-mode region-indicator-mode + "Toggle the region indicator in the mode line." + :init-value t :global t :group 'mode-line) + +(defun +modeline-region (&optional spacer) + "Display an indicator if the region is active." + (when (and region-indicator-mode + (region-active-p)) + (list + (format "%s%6s" + (or spacer +modeline-default-spacer) + (propertize (format "%s%d" + (if (and (< (point) (mark))) "-" "+") + (apply '+ (mapcar (lambda (pos) + (- (cdr pos) + (car pos))) + (region-bounds)))) + 'font-lock-face 'font-lock-variable-name-face))))) + +(defun +modeline-line-column (&optional spacer) ; adapted from `simple-modeline' + "Display the current cursor line and column depending on modes." (let ((sep "|") (before " [") (after "]")) - (list `(:propertize (line-number-mode - ((column-number-mode - (column-number-indicator-zero-based - ,(concat before "%l" sep "%c" after) - ,(concat before "%l" sep "%C" after)) - ,(concat before "%l" sep "" after))) - ((column-number-mode - (column-number-indicator-zero-based - ,(concat before sep "%c" after) - ,(concat before sep "%C" after))))) - font-lock-face font-lock-comment-face) - (if (region-active-p) - (propertize (format "%s%-5d" - (if (and (mark) (< (point) (mark))) "-" "+") - (apply '+ (mapcar - (lambda (pos) - (- (cdr pos) - (car pos))) - (region-bounds)))) - 'font-lock-face 'font-lock-variable-name-face)) - '(:propertize (file-percentage-mode - (" " (-3 "%p") "%%")) - font-lock-face font-lock-comment-face)))) + `(,(or spacer +modeline-default-spacer) + (:propertize (line-number-mode + ((column-number-mode + (column-number-indicator-zero-based + ,(concat before "%l" sep "%c" after) + ,(concat before "%l" sep "%C" after)) + ,(concat before "%l" sep "" after))) + ((column-number-mode + (column-number-indicator-zero-based + ,(concat before sep "%c" after) + ,(concat before sep "%C" after))))) + font-lock-face font-lock-comment-face)))) + +(defun +modeline-position (&optional _) + "Display the current cursor position. +See `line-number-mode', `column-number-mode', `file-percentage-mode'" + (append (+modeline-line-column) + (+modeline-region) + (+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