about summary refs log tree commit diff stats
path: root/lisp/+casing.el
diff options
context:
space:
mode:
authorCase Duckworth2022-01-05 17:12:32 -0600
committerCase Duckworth2022-01-05 17:12:32 -0600
commit9e46efac61fc4246b810c8b19127248ed7b3080e (patch)
tree0486104411f0edeabbb340070765b57f3be9133e /lisp/+casing.el
parentBreak function into library (diff)
downloademacs-9e46efac61fc4246b810c8b19127248ed7b3080e.tar.gz
emacs-9e46efac61fc4246b810c8b19127248ed7b3080e.zip
Lots of changes, maybe breaking something
I have to do a big debugging tonight.  Keybinds aren't getting picked up, idk
what's going on.
Diffstat (limited to 'lisp/+casing.el')
-rw-r--r--lisp/+casing.el47
1 files changed, 27 insertions, 20 deletions
diff --git a/lisp/+casing.el b/lisp/+casing.el index fe97310..a21e710 100644 --- a/lisp/+casing.el +++ b/lisp/+casing.el
@@ -3,17 +3,7 @@
3;;; Code: 3;;; Code:
4 4
5(require 'thingatpt) 5(require 'thingatpt)
6 6(require '+key)
7(defvar +casing-map (make-sparse-keymap)
8 "Keymap for word-casing.")
9
10(let ((map +casing-map))
11 (define-key map "u" #'+upcase-dwim)
12 (define-key map (kbd "M-u") #'+upcase-dwim)
13 (define-key map "l" #'+downcase-dwim)
14 (define-key map (kbd "M-l") #'+downcase-dwim)
15 (define-key map "c" #'+capitalize-dwim)
16 (define-key map (kbd "M-c") #'+capitalize-dwim))
17 7
18;;;###autoload 8;;;###autoload
19(defun +upcase-dwim (arg) 9(defun +upcase-dwim (arg)
@@ -28,9 +18,10 @@ Otherwise, it calls `upcase-word' on the word at point (using
28 (word-bound (save-excursion 18 (word-bound (save-excursion
29 (skip-chars-forward "^[:word:]") 19 (skip-chars-forward "^[:word:]")
30 (bounds-of-thing-at-point 'word)))) 20 (bounds-of-thing-at-point 'word))))
31 (upcase-region (car word-bound) (cdr word-bound)) 21 (when (and (car word-bound) (cdr word-bound))
32 (goto-char (cdr word-bound)) 22 (upcase-region (car word-bound) (cdr word-bound))
33 (upcase-word following)))) 23 (goto-char (cdr word-bound))
24 (upcase-word following)))))
34 25
35;;;###autoload 26;;;###autoload
36(defun +downcase-dwim (arg) 27(defun +downcase-dwim (arg)
@@ -45,9 +36,10 @@ Otherwise, it calls `downcase-word' on the word at point (using
45 (word-bound (save-excursion 36 (word-bound (save-excursion
46 (skip-chars-forward "^[:word:]") 37 (skip-chars-forward "^[:word:]")
47 (bounds-of-thing-at-point 'word)))) 38 (bounds-of-thing-at-point 'word))))
48 (downcase-region (car word-bound) (cdr word-bound)) 39 (when (and (car word-bound) (cdr word-bound))
49 (goto-char (cdr word-bound)) 40 (downcase-region (car word-bound) (cdr word-bound))
50 (downcase-word following)))) 41 (goto-char (cdr word-bound))
42 (downcase-word following)))))
51 43
52;;;###autoload 44;;;###autoload
53(defun +capitalize-dwim (arg) 45(defun +capitalize-dwim (arg)
@@ -62,11 +54,26 @@ Otherwise, it calls `capitalize-word' on the word at point (using
62 (word-bound (save-excursion 54 (word-bound (save-excursion
63 (skip-chars-forward "^[:word:]") 55 (skip-chars-forward "^[:word:]")
64 (bounds-of-thing-at-point 'word)))) 56 (bounds-of-thing-at-point 'word))))
65 (capitalize-region (car word-bound) (cdr word-bound)) 57 (when (and (car word-bound) (cdr word-bound))
66 (goto-char (cdr word-bound)) 58 (capitalize-region (car word-bound) (cdr word-bound))
67 (capitalize-word following)))) 59 (goto-char (cdr word-bound))
60 (capitalize-word following)))))
68 61
69;; Later on, I'll add repeat maps and stuff in here... 62;; Later on, I'll add repeat maps and stuff in here...
70 63
64(define-minor-mode +casing-mode
65 "Enable easy case-twiddling commands."
66 :lighter " cC"
67 :keymap (let ((map (make-sparse-keymap)))
68 (define-key map "u" #'+upcase-dwim)
69 (define-key map (kbd "M-u") #'+upcase-dwim)
70 (define-key map "l" #'+downcase-dwim)
71 (define-key map (kbd "M-l") #'+downcase-dwim)
72 (define-key map "c" #'+capitalize-dwim)
73 (define-key map (kbd "M-c") #'+capitalize-dwim)
74 map)
75 (define-key +key-mode-map (kbd "M-c") (when +casing-mode
76 +casing-mode-map)))
77
71(provide '+casing) 78(provide '+casing)
72;;; +casing.el ends here 79;;; +casing.el ends here