summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-01-04 14:39:54 -0600
committerCase Duckworth2022-01-04 14:39:54 -0600
commitbe93fbccf5509920732120888d30d0675ab0f161 (patch)
tree31b01d0206f7c4e05d1701441ba108f6dbdf5821 /lisp
parentMerge branch 'bankruptcy8' of https://tildegit.org/acdw/emacs into bankruptcy8 (diff)
downloademacs-be93fbccf5509920732120888d30d0675ab0f161.tar.gz
emacs-be93fbccf5509920732120888d30d0675ab0f161.zip
Add +casing
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+casing.el62
1 files changed, 62 insertions, 0 deletions
diff --git a/lisp/+casing.el b/lisp/+casing.el new file mode 100644 index 0000000..bcab7fa --- /dev/null +++ b/lisp/+casing.el
@@ -0,0 +1,62 @@
1;;; +casing.el --- Word-case-twiddling things -*- lexical-binding: t; -*-
2
3;;; Code:
4
5(require 'thingatpt)
6
7(defvar +casing-map (let ((map (make-sparse-keymap)))
8 (define-key map "u" #'+upcase-dwim)
9 (define-key map "l" #'+downcase-dwim)
10 (define-key map "c" #'+capitalize-dwim)
11 map)
12 "Keymap for word-casing.")
13
14;;;###autoload
15(defun +upcase-dwim (arg)
16 "Upcase words in the region, or upcase word at point.
17If the region is active, this function calls `upcase-region'.
18Otherwise, it calls `upcase-word' on the word at point (using
19`thingatpt'), and the following ARG - 1 words."
20 (interactive "*p")
21 (if (use-region-p)
22 (upcase-region (region-beginning) (region-end) (region-noncontiguous-p))
23 (let ((following (1- arg))
24 (word-bound (bounds-of-thing-at-point 'word)))
25 (upcase-region (car word-bound) (cdr word-bound))
26 (goto-char (cdr word-bound))
27 (upcase-word following))))
28
29;;;###autoload
30(defun +downcase-dwim (arg)
31 "Downcase words in the region, or downcase word at point.
32If the region is active, this function calls `downcase-region'.
33Otherwise, it calls `downcase-word' on the word at point (using
34`thingatpt'), and the following ARG - 1 words."
35 (interactive "*p")
36 (if (use-region-p)
37 (downcase-region (region-beginning) (region-end) (region-noncontiguous-p))
38 (let ((following (1- arg))
39 (word-bound (bounds-of-thing-at-point 'word)))
40 (downcase-region (car word-bound) (cdr word-bound))
41 (goto-char (cdr word-bound))
42 (downcase-word following))))
43
44;;;###autoload
45(defun +capitalize-dwim (arg)
46 "Capitalize words in the region, or capitalize word at point.
47If the region is active, this function calls `capitalize-region'.
48Otherwise, it calls `capitalize-word' on the word at point (using
49`thingatpt'), and the following ARG - 1 words."
50 (interactive "*p")
51 (if (use-region-p)
52 (capitalize-region (region-beginning) (region-end) (region-noncontiguous-p))
53 (let ((following (1- arg))
54 (word-bound (bounds-of-thing-at-point 'word)))
55 (capitalize-region (car word-bound) (cdr word-bound))
56 (goto-char (cdr word-bound))
57 (capitalize-word following))))
58
59;; Later on, I'll add repeat maps and stuff in here...
60
61(provide '+casing)
62;;; +casing.el ends here