summary refs log tree commit diff stats
path: root/lisp/+casing.el
diff options
context:
space:
mode:
authorCase Duckworth2022-10-17 21:41:28 -0500
committerCase Duckworth2022-10-17 21:41:28 -0500
commitaab5bfd074e57d06a79e39d7c7c4760e1f385a06 (patch)
tree7b111190a44458a970355f7a327cc5278c850293 /lisp/+casing.el
parentasoi (diff)
downloademacs-aab5bfd074e57d06a79e39d7c7c4760e1f385a06.tar.gz
emacs-aab5bfd074e57d06a79e39d7c7c4760e1f385a06.zip
Bankruptcy 9
Diffstat (limited to 'lisp/+casing.el')
-rw-r--r--lisp/+casing.el82
1 files changed, 0 insertions, 82 deletions
diff --git a/lisp/+casing.el b/lisp/+casing.el deleted file mode 100644 index c8e9e4d..0000000 --- a/lisp/+casing.el +++ /dev/null
@@ -1,82 +0,0 @@
1;;; +casing.el --- Word-case-twiddling things -*- lexical-binding: t; -*-
2
3;;; Code:
4
5(require 'thingatpt)
6
7;;;###autoload
8(defun +upcase-dwim (arg)
9 "Upcase words in the region, or upcase word at point.
10If the region is active, this function calls `upcase-region'.
11Otherwise, it calls `upcase-word' on the word at point (using
12`thingatpt'), and the following ARG - 1 words."
13 (interactive "*p")
14 (if (use-region-p)
15 (upcase-region (region-beginning) (region-end) (region-noncontiguous-p))
16 (let ((following (1- arg))
17 (word-bound (save-excursion
18 (skip-chars-forward "^[:word:]")
19 (bounds-of-thing-at-point 'word))))
20 (when (and (car word-bound) (cdr word-bound))
21 (upcase-region (car word-bound) (cdr word-bound))
22 (goto-char (cdr word-bound))
23 (upcase-word following)))))
24
25;;;###autoload
26(defun +downcase-dwim (arg)
27 "Downcase words in the region, or downcase word at point.
28If the region is active, this function calls `downcase-region'.
29Otherwise, it calls `downcase-word' on the word at point (using
30`thingatpt'), and the following ARG - 1 words."
31 (interactive "*p")
32 (if (use-region-p)
33 (downcase-region (region-beginning) (region-end) (region-noncontiguous-p))
34 (let ((following (1- arg))
35 (word-bound (save-excursion
36 (skip-chars-forward "^[:word:]")
37 (bounds-of-thing-at-point 'word))))
38 (when (and (car word-bound) (cdr word-bound))
39 (downcase-region (car word-bound) (cdr word-bound))
40 (goto-char (cdr word-bound))
41 (downcase-word following)))))
42
43;;;###autoload
44(defun +capitalize-dwim (arg)
45 "Capitalize words in the region, or capitalize word at point.
46If the region is active, this function calls `capitalize-region'.
47Otherwise, it calls `capitalize-word' on the word at point (using
48`thingatpt'), and the following ARG - 1 words."
49 (interactive "*p")
50 (if (use-region-p)
51 (capitalize-region (region-beginning) (region-end) (region-noncontiguous-p))
52 (let ((following (1- arg))
53 (word-bound (save-excursion
54 (skip-chars-forward "^[:word:]")
55 (bounds-of-thing-at-point 'word))))
56 (when (and (car word-bound) (cdr word-bound))
57 (capitalize-region (car word-bound) (cdr word-bound))
58 (goto-char (cdr word-bound))
59 (capitalize-word following)))))
60
61;; Later on, I'll add repeat maps and stuff in here...
62
63(defvar +casing-map (let ((map (make-sparse-keymap)))
64 (define-key map "u" #'+upcase-dwim)
65 (define-key map (kbd "M-u") #'+upcase-dwim)
66 (define-key map "l" #'+downcase-dwim)
67 (define-key map (kbd "M-l") #'+downcase-dwim)
68 (define-key map "c" #'+capitalize-dwim)
69 (define-key map (kbd "M-c") #'+capitalize-dwim)
70 map)
71 "Keymap for case-related twiddling.")
72
73(define-minor-mode +casing-mode
74 "Enable easy case-twiddling commands."
75 :lighter " cC"
76 :global t
77 :keymap (let ((map (make-sparse-keymap)))
78 (define-key map (kbd "M-c") +casing-map)
79 map))
80
81(provide '+casing)
82;;; +casing.el ends here