summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-01-10 08:33:43 -0600
committerCase Duckworth2022-01-10 08:33:43 -0600
commit2918cb39a25558b8896bf212b68e22d1fde02032 (patch)
treee6eef338bddf327236d305ef0310fd793e9f8062 /lisp
parentAdd markdown (diff)
parentAdd a few packages and .. stuff (diff)
downloademacs-2918cb39a25558b8896bf212b68e22d1fde02032.tar.gz
emacs-2918cb39a25558b8896bf212b68e22d1fde02032.zip
Merge branch 'main' of https://tildegit.org/acdw/emacs
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+apheleia.el3
-rw-r--r--lisp/+casing.el25
-rw-r--r--lisp/+circe.el130
-rw-r--r--lisp/+elfeed.el13
-rw-r--r--lisp/+embark.el4
-rw-r--r--lisp/+lookup.el26
-rw-r--r--lisp/+org-capture.el16
-rw-r--r--lisp/+vertico.el8
-rw-r--r--lisp/acdw.el10
9 files changed, 159 insertions, 76 deletions
diff --git a/lisp/+apheleia.el b/lisp/+apheleia.el index f3b16e4..469232a 100644 --- a/lisp/+apheleia.el +++ b/lisp/+apheleia.el
@@ -8,9 +8,8 @@
8 (setq-local indent-line-function 8 (setq-local indent-line-function
9 (buffer-local-value 'indent-line-function orig)) 9 (buffer-local-value 'indent-line-function orig))
10 (indent-region (point-min) 10 (indent-region (point-min)
11(point-max)) 11 (point-max))
12 (funcall callback))) 12 (funcall callback)))
13 13
14(provide '+apheleia) 14(provide '+apheleia)
15;;; +apheleia.el ends here 15;;; +apheleia.el ends here
16 \ No newline at end of file
diff --git a/lisp/+casing.el b/lisp/+casing.el index 5f39b2e..c8e9e4d 100644 --- a/lisp/+casing.el +++ b/lisp/+casing.el
@@ -3,7 +3,6 @@
3;;; Code: 3;;; Code:
4 4
5(require 'thingatpt) 5(require 'thingatpt)
6(require '+key)
7 6
8;;;###autoload 7;;;###autoload
9(defun +upcase-dwim (arg) 8(defun +upcase-dwim (arg)
@@ -61,21 +60,23 @@ Otherwise, it calls `capitalize-word' on the word at point (using
61 60
62;; Later on, I'll add repeat maps and stuff in here... 61;; Later on, I'll add repeat maps and stuff in here...
63 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
64(define-minor-mode +casing-mode 73(define-minor-mode +casing-mode
65 "Enable easy case-twiddling commands." 74 "Enable easy case-twiddling commands."
66 :lighter " cC" 75 :lighter " cC"
76 :global t
67 :keymap (let ((map (make-sparse-keymap))) 77 :keymap (let ((map (make-sparse-keymap)))
68 (define-key map "u" #'+upcase-dwim) 78 (define-key map (kbd "M-c") +casing-map)
69 (define-key map (kbd "M-u") #'+upcase-dwim) 79 map))
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
78(defvaralias '+casing-map '+casing-mode-map)
79 80
80(provide '+casing) 81(provide '+casing)
81;;; +casing.el ends here 82;;; +casing.el ends here
diff --git a/lisp/+circe.el b/lisp/+circe.el index c29cea6..3d6ea60 100644 --- a/lisp/+circe.el +++ b/lisp/+circe.el
@@ -101,9 +101,11 @@ For entry into `lui-formatting-list'."
101 101
102(defun +circe-kill-buffer (&rest _) 102(defun +circe-kill-buffer (&rest _)
103 "Kill a circe buffer without confirmation, and after a delay." 103 "Kill a circe buffer without confirmation, and after a delay."
104 (let ((circe-channel-killed-confirmation nil) 104 (let ((circe-channel-killed-confirmation)
105 (circe-server-killed-confirmation nil)) 105 (circe-server-killed-confirmation))
106 (run-with-timer 0.25 nil 'kill-buffer))) 106 (when (derived-mode-p 'lui-mode) ; don't spuriously kill
107 (ignore-errors
108 (kill-buffer)))))
107 109
108(defun +circe-quit@kill-buffer (&rest _) 110(defun +circe-quit@kill-buffer (&rest _)
109 "ADVICE: kill all buffers of a server after `circe-command-QUIT'." 111 "ADVICE: kill all buffers of a server after `circe-command-QUIT'."
@@ -115,9 +117,11 @@ For entry into `lui-formatting-list'."
115 117
116(defun +circe-gquit@kill-buffer (&rest _) 118(defun +circe-gquit@kill-buffer (&rest _)
117 "ADVICE: kill all Circe buffers after `circe-command-GQUIT'." 119 "ADVICE: kill all Circe buffers after `circe-command-GQUIT'."
118 (dolist (buf (circe-server-buffers)) 120 (let ((circe-channel-killed-confirmation)
119 (with-current-buffer buf 121 (circe-server-killed-confirmation))
120 (+circe-quit@kill-buffer)))) 122 (dolist (buf (circe-server-buffers))
123 (with-current-buffer buf
124 (+circe-quit@kill-buffer)))))
121 125
122(defun +circe-quit-all@kill-emacs () 126(defun +circe-quit-all@kill-emacs ()
123 "Quit all circe buffers when killing Emacs." 127 "Quit all circe buffers when killing Emacs."
@@ -165,28 +169,104 @@ See `circe-network-options' for a list of common options."
165 (funcall +circe-server-buffer-action buffer)))) 169 (funcall +circe-server-buffer-action buffer))))
166 170
167;;; Chat commands 171;;; Chat commands
168;; TODO: Actually ... write these~!?!?!
169
170(defun circe-command-SHORTEN (url)
171 "Shorten URL using `0x0-shorten-uri'.")
172 172
173(defun circe-command-SLAP (nick) 173(defun circe-command-SLAP (nick)
174 "Slap NICK around a bit with a large trout.") 174 "Slap NICK around a bit with a large trout."
175 175 (interactive (list (completing-read "Nick to slap: "
176(defun circe-command-POKE (nick) 176 (circe-channel-nicks)
177 "Poke NICK like in the old Facebook days.") 177 nil t nil)))
178 178 (circe-command-ME (format "slaps %s about a bit with a large trout" nick)))
179;;; Pure idiocy 179
180 180;;; Filtering functions
181(define-minor-mode circe-cappy-hour-mode 181;; Set `lui-input-function' to `+lui-filter', then add the filters you want to
182;; `circe-channel-mode-hook'.
183
184(require 'dash)
185
186(defvar +lui-filters nil
187 "Stack of input functions to apply.
188This is an alist with cells of the structure (TAG . FN), so we
189can easily remove elements.")
190(make-variable-buffer-local '+lui-filters)
191
192(defun +lui-filter (text &optional fn-alist)
193 (let ((fs (nreverse (purecopy (or fn-alist +lui-filters)))))
194 (while fs
195 (setq text (funcall (cdr (pop fs)) text)))
196 (circe--input text)))
197
198(defmacro +circe-define-filter (name docstring &rest body)
199 "Define a filter for circe-inputted text."
200 (declare (doc-string 2)
201 (indent 1))
202 (let (plist)
203 (while (keywordp (car-safe body))
204 (push (pop body) plist)
205 (push (pop body) plist))
206 ;; Return value
207 `(define-minor-mode ,name
208 ,docstring
209 ,@(nreverse plist)
210 (when (derived-mode-p 'circe-chat-mode)
211 (if ,name
212 (push '(,name . (lambda (it) ,@body)) +lui-filters)
213 (setq +lui-filters
214 (assoc-delete-all ',name +lui-filters)))))))
215
216;; CAPPY HOUR! (Pure idiocy)
217
218(+circe-define-filter +circe-cappy-hour-mode
182 "ENABLE CAPPY HOUR IN CIRCE!" 219 "ENABLE CAPPY HOUR IN CIRCE!"
183 :lighter "CAPPY HOUR" 220 :lighter " CAPPY HOUR"
184 (when (derived-mode-p 'circe-chat-mode) 221 (upcase it))
185 (if circe-cappy-hour-mode 222
186 (setq-local lui-input-function 223;; URL Shortener
187 (lambda (input) (circe--input (upcase input)))) 224
188 ;; XXX: It'd be better if this were more general, but whatever. 225(+circe-define-filter +circe-shorten-url-mode
189 (setq-local lui-input-function #'circe--input)))) 226 "Shorten long urls when chatting."
227 :lighter " c0x0"
228 (+circe-0x0-shorten-urls it))
229
230(defvar +circe-0x0-max-length 20
231 "Maximum length of URLs before using a shortener.")
232
233(defun +circe-0x0-shorten-urls (text)
234 "Find urls in TEXT and shorten them using `0x0'."
235 (require '0x0)
236 (require 'browse-url)
237 (let ((case-fold-search t))
238 (replace-regexp-in-string
239 browse-url-button-regexp
240 (lambda (match)
241 (if (> (length match) +circe-0x0-max-length)
242 (+with-message (format "Shortening URL: %s" match)
243 (0x0-shorten-uri (0x0--choose-server)
244 (substring-no-properties match)))
245 match))
246 text)))
247
248;; Temperature conversion
249
250(+circe-define-filter +circe-F/C-mode
251 "Convert degF to degF/degC for international chats."
252 :lighter " F/C"
253 (str-F/C it))
254
255(defun fahrenheit-to-celsius (degf)
256 "Convert DEGF to Celsius."
257 (round (* (/ 5.0 9.0) (- degf 32))))
258
259(defun celsius-to-fahrenheit (degc)
260 "Convert DEGC to Fahrenheit."
261 (round (+ 32 (* (/ 9.0 5.0) degc))))
262
263(defun str-F/C (text)
264 (replace-regexp-in-string "[0-9.]+[Ff]"
265 (lambda (match)
266 (format "%s/%dC" match
267 (fahrenheit-to-celsius
268 (string-to-number match))))
269 text))
190 270
191(provide '+circe) 271(provide '+circe)
192;;; +circe.el ends here 272;;; +circe.el ends here
diff --git a/lisp/+elfeed.el b/lisp/+elfeed.el index c26bfab..9e5f787 100644 --- a/lisp/+elfeed.el +++ b/lisp/+elfeed.el
@@ -21,12 +21,15 @@
21 (scroll-down-command arg) 21 (scroll-down-command arg)
22 (error (elfeed-show-prev))))) 22 (error (elfeed-show-prev)))))
23 23
24;; https://babbagefiles.blogspot.com/2017/03/take-elfeed-everywhere-mobile-rss.html 24(defun +elfeed-search-browse-generic ()
25(defun +elfeed () 25 "Browse a url with `browse-url-generic-browser'."
26 "Wrapper to load the elfeed db from disk before opening."
27 (interactive) 26 (interactive)
28 (elfeed-db-load) 27 (elfeed-search-browse-url t))
29 (elfeed)) 28
29(defun +elfeed-show-browse-generic ()
30 "Browse a url with `browse-url-generic-browser'."
31 (interactive)
32 (elfeed-show-visit t))
30 33
31(provide '+elfeed) 34(provide '+elfeed)
32;;; +elfeed.el ends here 35;;; +elfeed.el ends here
diff --git a/lisp/+embark.el b/lisp/+embark.el index 3900492..e66d4b3 100644 --- a/lisp/+embark.el +++ b/lisp/+embark.el
@@ -7,7 +7,6 @@
7;;; Code: 7;;; Code:
8 8
9(require 'embark) 9(require 'embark)
10(require 'marginalia)
11 10
12(embark-define-keymap embark-straight-map 11(embark-define-keymap embark-straight-map
13 ("u" straight-visit-package-website) 12 ("u" straight-visit-package-website)
@@ -22,7 +21,8 @@
22 21
23(add-to-list 'embark-keymap-alist '(straight . embark-straight-map)) 22(add-to-list 'embark-keymap-alist '(straight . embark-straight-map))
24 23
25(add-to-list 'marginalia-prompt-categories '("recipe\\|package" . straight)) 24(with-eval-after-load 'marginalia
25 (add-to-list 'marginalia-prompt-categories '("recipe\\|package" . straight)))
26 26
27(provide '+embark) 27(provide '+embark)
28;;; +embark.el ends here 28;;; +embark.el ends here
diff --git a/lisp/+lookup.el b/lisp/+lookup.el deleted file mode 100644 index 755f84e..0000000 --- a/lisp/+lookup.el +++ /dev/null
@@ -1,26 +0,0 @@
1;;; +lookup.el -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;; I look up a lot of things in Emacs. Let's bind them all to an easy-to-use
6;; keymap.
7
8;;; Code:
9
10(require '+key)
11
12(define-minor-mode +lookup-mode
13 "A mode for easily looking things up."
14 :lighter " l^"
15 :keymap (let ((map (make-sparse-keymap)))
16 (define-key map "f" #'find-function)
17 (define-key map "l" #'find-library)
18 (define-key map "v" #'find-variable)
19 map)
20 (define-key +key-mode-map (kbd "C-c l") (when +lookup-mode
21 +lookup-mode-map)))
22
23(defvaralias '+lookup-map '+lookup-mode-map)
24
25(provide '+lookup)
26;;; +lookup.el ends here
diff --git a/lisp/+org-capture.el b/lisp/+org-capture.el index ba036bd..6c59b98 100644 --- a/lisp/+org-capture.el +++ b/lisp/+org-capture.el
@@ -85,5 +85,21 @@ properly process the variable."
85 ;; Sort after, maybe 85 ;; Sort after, maybe
86 (when sort-after (+org-capture-sort list)))) 86 (when sort-after (+org-capture-sort list))))
87 87
88(defun +org-template--ensure-path (keys &optional list)
89 "Ensure path of keys exists in `org-capture-templates'."
90 (unless list (setq list 'org-capture-templates))
91 (when (> (length key) 1)
92 ;; Check for existence of groups.
93 (let ((expected (cl-loop for i from 1 to (1- (length key))
94 collect (substring key 0 i) into keys
95 finally return keys)))
96 (cl-loop for ek in expected
97 if (not (+org-capture--get ek (symbol-value list))) do
98 (setf (+org-capture--get ek (symbol-value list))
99 (list (format "(Group %s)" ek)))))))
100
101(defun +org-define-capture-template (keys title &rest args)
102 )
103
88(provide '+org-capture) 104(provide '+org-capture)
89;;; +org-capture.el ends here 105;;; +org-capture.el ends here
diff --git a/lisp/+vertico.el b/lisp/+vertico.el index 4adde3d..d4fb3a3 100644 --- a/lisp/+vertico.el +++ b/lisp/+vertico.el
@@ -12,5 +12,13 @@
12 (unless (eq 1 (abs (- beg-index vertico--index))) 12 (unless (eq 1 (abs (- beg-index vertico--index)))
13 (ding)))) 13 (ding))))
14 14
15(defun +vertico-widen-or-complete ()
16 (interactive)
17 (if (or vertico-unobtrusive-mode
18 vertico-flat-mode)
19 (progn (vertico-unobtrusive-mode -1)
20 (vertico-flat-mode -1))
21 (call-interactively #'vertico-insert)))
22
15(provide '+vertico) 23(provide '+vertico)
16;;; +vertico.el ends here 24;;; +vertico.el ends here
diff --git a/lisp/acdw.el b/lisp/acdw.el index 262c15e..603f46f 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -128,10 +128,12 @@ I keep forgetting how they differ."
128(defmacro +with-message (message &rest body) 128(defmacro +with-message (message &rest body)
129 "Execute BODY, with MESSAGE. 129 "Execute BODY, with MESSAGE.
130If body executes without errors, MESSAGE...Done will be displayed." 130If body executes without errors, MESSAGE...Done will be displayed."
131 ;; ^ TODO 131 (declare (indent 1))
132 `(prog1 (progn (message ,(concat message "...")) 132 (let ((msg (gensym)))
133 ,@body) 133 `(let ((,msg ,message))
134 (message ,(concat message "...Done.")))) 134 (unwind-protect (progn (message "%s..." ,msg)
135 ,@body)
136 (message "%s... Done." ,msg)))))
135 137
136(defun +mapc-some-buffers (func &optional predicate) 138(defun +mapc-some-buffers (func &optional predicate)
137 "Perform FUNC on all buffers satisfied by PREDICATE. 139 "Perform FUNC on all buffers satisfied by PREDICATE.