From bfa31f593c904458e697477c8a7c3cb0018aa0c9 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 26 Aug 2021 16:04:08 -0500 Subject: Add `case-repeat-map' to change word case I'm pretty proud of this one, actually. --- init.el | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'init.el') diff --git a/init.el b/init.el index 02cd850..77856e1 100644 --- a/init.el +++ b/init.el @@ -1005,7 +1005,32 @@ like a dumbass." "C-c c" capitalize-dwim "C-c u" upcase-dwim "C-c l" downcase-dwim - "C-c t" acdw/insert-iso-date)) + "C-c t" acdw/insert-iso-date) + + (defalias 'forward-word-with-case 'forward-word + "Alias for `forward-word' for use in `case-repeat-map'.") + (defalias 'backward-word-with-case 'backward-word + "Alias for `backward-word for use in `case-repeat-map'.") + + (defvar case-repeat-map + (let ((map (make-sparse-keymap))) + (define-key map "c" #'capitalize-word) + (define-key map "u" #'upcase-word) + (define-key map "l" #'downcase-word) + ;; movement + (define-key map "f" #'forward-word-with-case) + (define-key map "b" #'backward-word-with-case) + map) + "A map to repeat word-casing commands. For use with `repeat-mode'.") + (dolist (command '(capitalize-word + capitalize-dwim + upcase-word + upcase-dwim + downcase-word + downcase-dwim + forward-word-with-case + backward-word-with-case)) + (put command 'repeat-map 'case-repeat-map))) ;;; Packages -- cgit 1.4.1-21-gabe81