From 3a100209daa7f43cc2476c348b8f5d1b06b3a971 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 10 Aug 2021 14:47:00 -0500 Subject: Add acdw-modeline/position --- lisp/acdw-modeline.el | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'lisp/acdw-modeline.el') diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index 104ea28..4e6b002 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el @@ -94,6 +94,35 @@ indicator in the mode-line." 'mouse-2 #'mode-line-widen)) 'mouse-face 'mode-line-highlight)))) +(defun acdw-modeline/position () + "Displays the current cursor position in the mode-line. + +Unlike `simple-modeline-segment-position', this changes the first +character from '+' to '-' if the region goes 'backward' -- that +is, if point < mark." + `((line-number-mode + ((column-number-mode + (column-number-indicator-zero-based + (8 " %l:%c") + (8 " %l:%C")) + (5 " L%l"))) + ((column-number-mode + (column-number-indicator-zero-based + (5 " C%c") + (5 " C%C"))))) + ,(if (region-active-p) + (propertize (format "%s%s" + (if (and (mark) + (< (point) (mark))) + "-" + "+") + (apply #'+ (mapcar + (lambda (pos) + (- (cdr pos) + (car pos))) + (region-bounds)))) + 'font-lock-face 'font-lock-variable-name-face)))) + (defun acdw-modeline/text-scale () ;; adapted from https://github.com/seagle0128/doom-modeline (when (and (boundp 'text-scale-mode-amount) -- cgit 1.4.1-21-gabe81