diff options
-rw-r--r-- | init.el | 27 | ||||
-rw-r--r-- | lisp/acdw-modeline.el | 20 |
2 files changed, 34 insertions, 13 deletions
diff --git a/init.el b/init.el index 06caede..b8584b6 100644 --- a/init.el +++ b/init.el | |||
@@ -972,19 +972,20 @@ if ripgrep is installed, otherwise `consult-grep'." | |||
972 | 972 | ||
973 | (setup (:straight simple-modeline) | 973 | (setup (:straight simple-modeline) |
974 | (setup (:straight minions)) | 974 | (setup (:straight minions)) |
975 | (:option simple-modeline-segments | 975 | (:option |
976 | '((acdw-modeline/modified | 976 | ;; (prepend acdw-modeline/word-count-modes) '(org-mode . #'acdw-org/word-count) |
977 | acdw-modeline/buffer-name | 977 | simple-modeline-segments '((acdw-modeline/modified |
978 | acdw-modeline/vc-branch | 978 | acdw-modeline/buffer-name |
979 | simple-modeline-segment-position | 979 | acdw-modeline/vc-branch |
980 | simple-modeline-segment-word-count) | 980 | simple-modeline-segment-position) |
981 | (simple-modeline-segment-misc-info | 981 | (simple-modeline-segment-misc-info |
982 | acdw-modeline/winum | 982 | acdw-modeline/word-count |
983 | acdw-modeline/text-scale | 983 | acdw-modeline/winum |
984 | simple-modeline-segment-process | 984 | acdw-modeline/text-scale |
985 | acdw-modeline/god-mode-indicator | 985 | simple-modeline-segment-process |
986 | acdw-modeline/minions | 986 | acdw-modeline/god-mode-indicator |
987 | simple-modeline-segment-major-mode))) | 987 | acdw-modeline/minions |
988 | simple-modeline-segment-major-mode))) | ||
988 | 989 | ||
989 | (require 'acdw-modeline) | 990 | (require 'acdw-modeline) |
990 | (simple-modeline-mode +1)) | 991 | (simple-modeline-mode +1)) |
diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index 81b808d..4f78816 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el | |||
@@ -93,4 +93,24 @@ indicator in the mode-line." | |||
93 | (> winum--window-count 1)) | 93 | (> winum--window-count 1)) |
94 | (format winum-format (winum-get-number-string)))) | 94 | (format winum-format (winum-get-number-string)))) |
95 | 95 | ||
96 | (defcustom acdw-modeline/word-count-modes | ||
97 | (mapcar (lambda (m) (cons m nil)) simple-modeline-word-count-modes) | ||
98 | "Alist of modes to functions that `acdw-modeline/word-count' should dispatch. | ||
99 | If the cdr of the cons cell is nil, use the default function (`count-words'). | ||
100 | Otherwise, cdr should be a function that takes two points (see `count-words')." | ||
101 | :type '(alist :key-type (symbol :tag "Major-Mode") | ||
102 | :value-type function) | ||
103 | :group 'simple-modeline) | ||
104 | |||
105 | (defun acdw-modeline/word-count () | ||
106 | "Display a buffer word count, depending on the major mode. | ||
107 | Uses `acdw-modeline/word-count-modes' to determine which function to use." | ||
108 | (when-let ((modefun | ||
109 | (assoc major-mode acdw-modeline/word-count-modes #'equal))) | ||
110 | (let ((fn (or (cdr modefun) | ||
111 | #'count-words)) | ||
112 | (min (if (region-active-p) (region-beginning) (point-min))) | ||
113 | (max (if (region-active-p) (region-end) (point-max)))) | ||
114 | (format "%dW" (funcall fn min max))))) | ||
115 | |||
96 | (provide 'acdw-modeline) | 116 | (provide 'acdw-modeline) |