.emacs.d

the most bloated Emacs config on this planet
git clone https://git.trogloxene.org/.emacs.d.git
Log | Files | Refs

commit 006605cdbeeefec78eb629050e316d2ea90825bd
parent d8c85e370fdb82e0b757315a9d06baab372443ff
Author: andsy10 <andsy1016@gmail.com>
Date:   Fri, 16 Oct 2026 10:06:44 +0800

Add custom word count command

Diffstat:
Mlisp/init-kbd-func.el | 12++++++++++++
Mlisp/init-kbd.el | 1+
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el @@ -31,6 +31,18 @@ (message "Save `%s' to kill ring." buf)) (message "Cannot find the name of the current buffer."))) +(defun my-count-words-region (start end &optional totals) + "Count the number of words in the region. +With prefix ARG, report for the entire buffer rather than the region." + (interactive (if current-prefix-arg + (list nil nil current-prefix-arg) + (list (region-beginning) (region-end) nil))) + (cl-letf (((symbol-function 'forward-word-strictly) #'forward-word)) + (if totals + (message "%s" (count-words--buffer-format)) + (message "%s" (count-words--format + "Region" (region-beginning) (region-end)))))) + (defun my-bounds-of-next-thing (thing) "Return the bounds of THING at or after point." (or (bounds-of-thing-at-point thing) diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el @@ -93,6 +93,7 @@ "<f8>" #'emms-pause "<f7>" #'emms-previous "<f9>" #'emms-next + [remap count-words-region] #'my-count-words-region [remap eval-expression] #'pp-eval-expression [remap ispell-word] #'jinx-correct [remap describe-function] #'helpful-callable