diff options
-rw-r--r-- | init.el | 227 | ||||
-rw-r--r-- | lisp/acdw-irc.el | 35 | ||||
-rw-r--r-- | lisp/acdw.el | 24 |
3 files changed, 282 insertions, 4 deletions
diff --git a/init.el b/init.el index 7c40722..8503809 100644 --- a/init.el +++ b/init.el | |||
@@ -192,6 +192,148 @@ In short, DO NOT USE THIS FUNCTION!!!" | |||
192 | (setup calendar | 192 | (setup calendar |
193 | (:option calendar-week-start-day 1)) | 193 | (:option calendar-week-start-day 1)) |
194 | 194 | ||
195 | (setup (:straight circe) | ||
196 | (require 'circe) | ||
197 | (require 'acdw-irc) | ||
198 | |||
199 | (:option acdw-irc/left-margin 12 | ||
200 | acdw-irc/post-my-nick "-> " | ||
201 | circe-channel-killed-confirmation nil | ||
202 | circe-color-nicks-everywhere t | ||
203 | circe-default-nick "acdw" | ||
204 | circe-default-part-message "See You, Space Cowpokes . . ." | ||
205 | circe-default-user "acdw" | ||
206 | circe-format-action | ||
207 | (lambda (&rest plist) | ||
208 | (concat | ||
209 | (acdw-irc/margin-format "" "*" "*" t) | ||
210 | " " (plist-get plist :nick) " " (plist-get plist :body))) | ||
211 | circe-format-say | ||
212 | (lambda (&rest plist) | ||
213 | (concat | ||
214 | (acdw-irc/margin-format (plist-get plist :nick) "" " |" t) | ||
215 | " " (plist-get plist :body))) | ||
216 | circe-format-self-action | ||
217 | (lambda (&rest plist) | ||
218 | (concat | ||
219 | (acdw-irc/margin-format "" "-*" " *" t) | ||
220 | " " (plist-get plist :nick) " " (plist-get plist :body))) | ||
221 | circe-format-self-say | ||
222 | (lambda (&rest plist) | ||
223 | (concat | ||
224 | (acdw-irc/margin-format (plist-get plist :nick) "-" " >" t) | ||
225 | " " (plist-get plist :body))) | ||
226 | ;; circe-highlight-nick-type 'message | ||
227 | circe-network-options | ||
228 | `(("Libera Chat" | ||
229 | :channels ("#emacs" "#systemcrafters" "##webpals") | ||
230 | :sasl-username ,circe-default-nick | ||
231 | :sasl-password ,(acdw/make-password-fetcher | ||
232 | :host "libera.chat")) | ||
233 | ("Tilde Chat" :host "irc.tilde.chat" :port 6697 :use-tls t | ||
234 | :channels ("#meta" "#bread" "#dadjokes" "#team" | ||
235 | "#emacs") | ||
236 | :sasl-username ,circe-default-nick | ||
237 | :sasl-password ,(acdw/make-password-fetcher | ||
238 | :host "tilde.chat")) | ||
239 | ("Casa" :host "m455.casa" :port 6697 :use-tls t | ||
240 | :channels ("#basement") | ||
241 | :sasl-username ,circe-default-nick | ||
242 | :sasl-password ,(acdw/make-password-fetcher | ||
243 | :host "m455.casa")) | ||
244 | ("Pissnet" :host "piss.hmm.st" :port 6697 :use-tls t | ||
245 | :channels ("#i-just-peed") | ||
246 | :sasl-username ,circe-default-nick | ||
247 | :sasl-password ,(acdw/make-password-fetcher | ||
248 | :host "piss.hmm.st")) | ||
249 | ;; TODO: irc.chat.twitch.tv | ||
250 | ) | ||
251 | circe-reduce-lurker-spam t | ||
252 | circe-server-auto-join-default-type :after-auth | ||
253 | circe-server-buffer-action (lambda (buf) | ||
254 | (message "Connected to %s" buf))) | ||
255 | |||
256 | ;; (:face circe-nick-highlight-face | ||
257 | ;; ((t (:inherit (modus-themes-hl-line))))) | ||
258 | |||
259 | (:bind "C-c C-p" #'circe-command-PART | ||
260 | "C-l" #'lui-track-jump-to-indicator) | ||
261 | |||
262 | (:advise circe-command-PART :after | ||
263 | (defun circe-part@kill-buffer (&rest _) | ||
264 | (let ((circe-channel-killed-confirmation nil)) | ||
265 | (kill-buffer))) | ||
266 | |||
267 | circe-command-QUIT :after | ||
268 | (defun circe-quit@kill-buffer (&rest _) | ||
269 | ;; `circe-server-killed-confirmation' set to nil, and manually | ||
270 | ;; deleting all chat buffers, pending Github issue #402 | ||
271 | ;; (https://github.com/emacs-circe/circe/issues/402) | ||
272 | (let ((circe-server-killed-confirmation nil)) | ||
273 | (with-circe-server-buffer | ||
274 | (dolist (buf (circe-server-chat-buffers)) | ||
275 | (let ((circe-channel-killed-confirmation nil)) | ||
276 | (kill-buffer buf))) | ||
277 | (kill-buffer)))) | ||
278 | |||
279 | circe-command-GQUIT :after | ||
280 | (defun circe-gquit@kill-buffer (&rest _) | ||
281 | ;; `circe-server-killed-confirmation' set to nil, and manually | ||
282 | ;; deleting all chat buffers, pending Github issue #402 | ||
283 | ;; (https://github.com/emacs-circe/circe/issues/402) | ||
284 | (let ((circe-server-killed-confirmation nil)) | ||
285 | (dolist (buf (circe-server-buffers)) | ||
286 | (with-current-buffer buf | ||
287 | (dolist (buf (circe-server-chat-buffers)) | ||
288 | (let ((circe-channel-killed-confirmation nil)) | ||
289 | (kill-buffer buf))) | ||
290 | (message "%s: %s" buf circe-server-killed-confirmation) | ||
291 | (kill-buffer)))))) | ||
292 | |||
293 | (defun circe-command-SHORTEN (url) | ||
294 | "Shorten URL using `0x0-shorten-uri'." | ||
295 | (interactive "sURL to shorten: ") | ||
296 | ;; TODO: enable /shorten URL comment syntax | ||
297 | (let ((short-url (0x0-shorten-uri (0x0--choose-server) url))) | ||
298 | (circe-command-SAY short-url))) | ||
299 | |||
300 | (:with-mode circe-chat-mode | ||
301 | (:hook #'acdw/stop-paren-annoyances | ||
302 | #'enable-circe-color-nicks | ||
303 | #'enable-circe-display-images | ||
304 | #'enable-circe-new-day-notifier | ||
305 | (defun circe-chat@set-prompt () | ||
306 | (lui-set-prompt | ||
307 | (concat | ||
308 | (propertize | ||
309 | (acdw-irc/margin-format (buffer-name) "" ">") | ||
310 | 'face 'circe-prompt-face | ||
311 | 'read-only t | ||
312 | 'intangible t | ||
313 | 'cursor-intangible t) | ||
314 | " "))))) | ||
315 | |||
316 | (autoload 'circe-nick-color-reset "circe-color-nicks") | ||
317 | (add-hook 'modus-themes-after-load-theme-hook | ||
318 | #'circe-nick-color-reset) | ||
319 | |||
320 | (:with-mode lui-mode | ||
321 | (:option lui-fill-column fill-column | ||
322 | lui-fill-type (repeat-string acdw-irc/left-margin " ") | ||
323 | lui-time-stamp-position 'right-margin | ||
324 | lui-time-stamp-format "%H:%M" | ||
325 | lui-track-behavior 'before-switch-to-buffer | ||
326 | lui-track-indicator 'fringe) | ||
327 | |||
328 | (:local-set fringes-outside-margins t | ||
329 | right-margin-width 5 | ||
330 | scroll-margin 0 | ||
331 | word-wrap t | ||
332 | wrap-prefix (repeat-string acdw-irc/left-margin " ") | ||
333 | line-number-mode nil) | ||
334 | |||
335 | (:hook #'enable-lui-track))) | ||
336 | |||
195 | (setup completion | 337 | (setup completion |
196 | (:option completion-ignore-case t | 338 | (:option completion-ignore-case t |
197 | read-buffer-completion-ignore-case t | 339 | read-buffer-completion-ignore-case t |
@@ -209,13 +351,18 @@ In short, DO NOT USE THIS FUNCTION!!!" | |||
209 | (blink-cursor-mode +1)) | 351 | (blink-cursor-mode +1)) |
210 | 352 | ||
211 | (setup cus-edit | 353 | (setup cus-edit |
212 | (:option custom-file null-device ; don't store customizations | 354 | (:option custom-file (acdw/dir "custom.el") |
213 | custom-magic-show nil | 355 | custom-magic-show nil |
214 | custom-magic-show-button t | 356 | custom-magic-show-button t |
215 | custom-raised-buttons nil | 357 | custom-raised-buttons nil |
216 | custom-unlispify-tag-names nil | 358 | custom-unlispify-tag-names nil |
217 | custom-variable-default-form 'lisp) | 359 | custom-variable-default-form 'lisp) |
218 | 360 | ||
361 | ;; I need this to save `safe-local-variables' between Emacs invocations. For | ||
362 | ;; now, of course .... I would /love/ a better solution. | ||
363 | (when (file-exists-p custom-file) | ||
364 | (load custom-file nil nil)) | ||
365 | |||
219 | ;; `Custom-mode-hook' fires /before/ the widgets are built, so I have to | 366 | ;; `Custom-mode-hook' fires /before/ the widgets are built, so I have to |
220 | ;; install advice after the widgets are made. | 367 | ;; install advice after the widgets are made. |
221 | (:advise custom-buffer-create :after | 368 | (:advise custom-buffer-create :after |
@@ -341,6 +488,28 @@ In short, DO NOT USE THIS FUNCTION!!!" | |||
341 | ;; https://oremacs.com/2015/01/17/setting-up-ediff/ | 488 | ;; https://oremacs.com/2015/01/17/setting-up-ediff/ |
342 | (add-hook 'ediff-after-quit-hook-internal #'winner-undo)) | 489 | (add-hook 'ediff-after-quit-hook-internal #'winner-undo)) |
343 | 490 | ||
491 | (setup (:straight edit-indirect)) | ||
492 | |||
493 | ;; requires extension: | ||
494 | ;; https://addons.mozilla.org/en-US/firefox/addon/edit-with-emacs1/ | ||
495 | (setup (:straight edit-server) | ||
496 | (:require edit-server) | ||
497 | (edit-server-start) | ||
498 | |||
499 | (:option edit-server-default-major-mode 'text-mode | ||
500 | edit-server-url-major-mode-alist | ||
501 | (list (cons (rx (| "reddit.com" | ||
502 | "tildes.net")) | ||
503 | 'markdown-mode) | ||
504 | (cons (rx "github.com") | ||
505 | 'gfm-mode))) | ||
506 | |||
507 | (:advise edit-server-make-frame :before | ||
508 | (defun edit-server@set-a-variable (&rest _) | ||
509 | (setq-local edit-server-frame-p t)))) | ||
510 | |||
511 | (setup (:straight el-patch)) | ||
512 | |||
344 | (setup eldoc | 513 | (setup eldoc |
345 | (:option eldoc-idle-delay 0.1 | 514 | (:option eldoc-idle-delay 0.1 |
346 | eldoc-echo-area-use-multiline-p nil)) | 515 | eldoc-echo-area-use-multiline-p nil)) |
@@ -1486,7 +1655,7 @@ specific to most general, they are these: | |||
1486 | (:with-feature flyspell | 1655 | (:with-feature flyspell |
1487 | (:bind "C-." #'flyspell-correct-wrapper | 1656 | (:bind "C-." #'flyspell-correct-wrapper |
1488 | "<f7>" #'acdw/flyspell-correct-f7) | 1657 | "<f7>" #'acdw/flyspell-correct-f7) |
1489 | (:unbind "C-," "C-." "C-M-i"))) | 1658 | (:unbind "C-;" "C-," "C-." "C-M-i"))) |
1490 | 1659 | ||
1491 | (setup (:straight-if forge | 1660 | (setup (:straight-if forge |
1492 | (acdw/system :home)) | 1661 | (acdw/system :home)) |
@@ -1634,9 +1803,26 @@ specific to most general, they are these: | |||
1634 | w3m-link | 1803 | w3m-link |
1635 | w3m-message-link)) | 1804 | w3m-message-link)) |
1636 | (link-hint-define-type type | 1805 | (link-hint-define-type type |
1637 | :open-secondary browse-url-secondary-browser-function)) | 1806 | :open-secondary browse-url-secondary-browser-function |
1807 | :open-secondary-multiple t)) | ||
1808 | |||
1809 | (defun acdw/link-hint-open-all-links (prefix) | ||
1810 | "Open all visible links. | ||
1811 | When PREFIX is non-nil, open links with | ||
1812 | `browse-url-secondary-browser-function'." | ||
1813 | (interactive "P") | ||
1814 | (avy-with link-hint-open-all-links | ||
1815 | (link-hint--all (if prefix :open-secondary :open)))) | ||
1816 | |||
1817 | (defun acdw/link-hint-open-multiple-links (prefix) | ||
1818 | "Use `avy' to open multiple visible links at once. | ||
1819 | When PREFIX is non-nil, open links with | ||
1820 | `browse-url-secondary-browser-function'." | ||
1821 | (interactive "P") | ||
1822 | (avy-with link-hint-open-multiple-links | ||
1823 | (link-hint--multiple (if prefix :open-secondary :open)))) | ||
1638 | 1824 | ||
1639 | (:option link-hint-avy-style 'at) | 1825 | (:option link-hint-avy-style 'post) |
1640 | (:global "C-;" | 1826 | (:global "C-;" |
1641 | (defun acdw/link-hint-open-link (arg) | 1827 | (defun acdw/link-hint-open-link (arg) |
1642 | "Open a link using `link-hint-open-link', prefix-aware. | 1828 | "Open a link using `link-hint-open-link', prefix-aware. |
@@ -1933,6 +2119,39 @@ browser defined in `browse-url-secondary-browser-function'." | |||
1933 | (setup (:straight powerthesaurus) | 2119 | (setup (:straight powerthesaurus) |
1934 | (:global "C-c l t" #'powerthesaurus-lookup-word-dwim)) | 2120 | (:global "C-c l t" #'powerthesaurus-lookup-word-dwim)) |
1935 | 2121 | ||
2122 | ;; (setup (:straight prism) | ||
2123 | ;; (dolist (mode lispy-modes) | ||
2124 | ;; (add-hook (intern (format "%s-hook" mode)) #'prism-mode))) | ||
2125 | |||
2126 | (setup prog | ||
2127 | (:option show-paren-delay 0 | ||
2128 | show-paren-style 'mixed | ||
2129 | show-paren-when-point-inside-paren t | ||
2130 | show-paren-when-point-in-periphery t | ||
2131 | smie-indent-basic tab-width) | ||
2132 | |||
2133 | (:hook show-paren-mode | ||
2134 | electric-pair-local-mode | ||
2135 | acdw/setup-fringes | ||
2136 | |||
2137 | (defun prog-mode@auto-fill () | ||
2138 | (setq-local comment-auto-fill-only-comments t) | ||
2139 | (turn-on-auto-fill))) | ||
2140 | |||
2141 | (mapc (lambda (buf) | ||
2142 | (with-current-buffer buf | ||
2143 | (when (funcall persistent-scratch-scratch-buffer-p-function) | ||
2144 | (persistent-scratch-mode +1)))) | ||
2145 | |||
2146 | (buffer-list))) | ||
2147 | |||
2148 | (setup (:straight-if pkgbuild-mode | ||
2149 | (executable-find "makepkg")) | ||
2150 | (:file-match "PKGBUILD")) | ||
2151 | |||
2152 | (setup (:straight powerthesaurus) | ||
2153 | (:global "C-c l t" #'powerthesaurus-lookup-word-dwim)) | ||
2154 | |||
1936 | (setup (:straight prism) | 2155 | (setup (:straight prism) |
1937 | (dolist (mode lispy-modes) | 2156 | (dolist (mode lispy-modes) |
1938 | (add-hook (intern (format "%s-hook" mode)) #'prism-mode))) | 2157 | (add-hook (intern (format "%s-hook" mode)) #'prism-mode))) |
diff --git a/lisp/acdw-irc.el b/lisp/acdw-irc.el index b4b75ec..305dc93 100644 --- a/lisp/acdw-irc.el +++ b/lisp/acdw-irc.el | |||
@@ -73,6 +73,41 @@ and right on t." | |||
73 | (dolist (network (mapcar #'car circe-network-options)) | 73 | (dolist (network (mapcar #'car circe-network-options)) |
74 | (circe-maybe-connect network))) | 74 | (circe-maybe-connect network))) |
75 | 75 | ||
76 | (el-patch-feature circe) | ||
77 | (with-eval-after-load 'circe | ||
78 | (defvar circe-server-buffer-action 'pop-to-buffer-same-window | ||
79 | "What to do with `circe-server' buffers when created.") | ||
80 | |||
81 | (el-patch-defun circe (network-or-server &rest server-options) | ||
82 | "Connect to IRC. | ||
83 | |||
84 | Connect to the given network specified by NETWORK-OR-SERVER. | ||
85 | |||
86 | When this function is called, it collects options from the | ||
87 | SERVER-OPTIONS argument, the user variable | ||
88 | `circe-network-options', and the defaults found in | ||
89 | `circe-network-defaults', in this order. | ||
90 | |||
91 | If NETWORK-OR-SERVER is not found in any of these variables, the | ||
92 | argument is assumed to be the host name for the server, and all | ||
93 | relevant settings must be passed via SERVER-OPTIONS. | ||
94 | |||
95 | All SERVER-OPTIONS are treated as variables by getting the string | ||
96 | \"circe-\" prepended to their name. This variable is then set | ||
97 | locally in the server buffer. | ||
98 | |||
99 | See `circe-network-options' for a list of common options." | ||
100 | (interactive (circe--read-network-and-options)) | ||
101 | (let* ((options (circe--server-get-network-options network-or-server | ||
102 | server-options)) | ||
103 | (buffer (circe--server-generate-buffer options))) | ||
104 | (with-current-buffer buffer | ||
105 | (circe-server-mode) | ||
106 | (circe--server-set-variables options) | ||
107 | (circe-reconnect)) | ||
108 | (el-patch-swap (pop-to-buffer-same-window buffer) | ||
109 | (funcall circe-server-buffer-action buffer))))) | ||
110 | |||
76 | (defun circe-network-connected-p (network) | 111 | (defun circe-network-connected-p (network) |
77 | "Return non-nil if there's any Circe server-buffer whose | 112 | "Return non-nil if there's any Circe server-buffer whose |
78 | `circe-server-netwok' is NETWORK." | 113 | `circe-server-netwok' is NETWORK." |
diff --git a/lisp/acdw.el b/lisp/acdw.el index d3b0bf9..dcf7b19 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el | |||
@@ -402,6 +402,30 @@ first." | |||
402 | (setq deactivate-mark t) | 402 | (setq deactivate-mark t) |
403 | nil) | 403 | nil) |
404 | 404 | ||
405 | (defun acdw/org-export-copy () | ||
406 | "copy a tree" | ||
407 | (interactive) | ||
408 | (require 'ox-ascii) | ||
409 | (let ((extracted-heading (acdw/org-extract-heading-text))) | ||
410 | ;; Export to ASCII - not async, subtree only, visible-only, body-only | ||
411 | (let ((org-export-show-temporary-export-buffer nil)) | ||
412 | (org-ascii-export-as-ascii nil t t t)) | ||
413 | (with-current-buffer "*Org ASCII Export*" | ||
414 | (goto-char (point-min)) | ||
415 | (insert extracted-heading) | ||
416 | (newline) | ||
417 | (newline) | ||
418 | |||
419 | (unfill-region (point-min) (point-max)) | ||
420 | (flush-lines "^$" (point-min) (point-max)) | ||
421 | |||
422 | (copy-region-as-kill (point-min) (point-max))) | ||
423 | |||
424 | (when (called-interactively-p 'interactive) | ||
425 | (indicate-copied-region)) | ||
426 | (setq deactivate-mark t) | ||
427 | nil)) | ||
428 | |||
405 | (defun acdw/org-extract-heading-text () | 429 | (defun acdw/org-extract-heading-text () |
406 | "Extract the heading text from an `org-mode' heading." | 430 | "Extract the heading text from an `org-mode' heading." |
407 | (let ((heading (org-no-properties (org-get-heading t t t t)))) | 431 | (let ((heading (org-no-properties (org-get-heading t t t t)))) |