about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw-modeline.el20
1 files changed, 20 insertions, 0 deletions
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.
99If the cdr of the cons cell is nil, use the default function (`count-words').
100Otherwise, 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.
107Uses `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)