summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2022-01-07 17:30:46 -0600
committerCase Duckworth2022-01-07 17:30:46 -0600
commit9360a54e6208c87911530ea8005b626680fa2e88 (patch)
tree1b72584d7cc38ddc336c6d513e1e54ba14ef12f0
parentAdd apheleia (diff)
downloademacs-9360a54e6208c87911530ea8005b626680fa2e88.tar.gz
emacs-9360a54e6208c87911530ea8005b626680fa2e88.zip
Gah, so many changes
-rw-r--r--init.el62
-rw-r--r--lisp/+init.el50
-rw-r--r--lisp/+org.el74
-rw-r--r--lisp/acdw.el19
4 files changed, 131 insertions, 74 deletions
diff --git a/init.el b/init.el index 19513ea..b32dfce 100644 --- a/init.el +++ b/init.el
@@ -115,6 +115,7 @@
115 (:global "C-c C-r" #'reading-mode)) 115 (:global "C-c C-r" #'reading-mode))
116 116
117(setup (:require user-save) 117(setup (:require user-save)
118 (add-hook 'user-save-hook #'+clean-empty-lines)
118 (user-save-mode +1)) 119 (user-save-mode +1))
119 120
120(setup +key 121(setup +key
@@ -176,9 +177,9 @@
176 browse-url-secondary-browser-function) 177 browse-url-secondary-browser-function)
177 args))) 178 args)))
178 (cons (+browse-url-secondary-browser-regexps-combine) ; non-text websites 179 (cons (+browse-url-secondary-browser-regexps-combine) ; non-text websites
179 browse-url-secondary-browser-function) 180 browse-url-secondary-browser-function)
180 (cons "." ; everything else 181 (cons "." ; everything else
181 +browse-url-browser-function))) 182 +browse-url-browser-function)))
182 ;; Transform URLs before passing to `browse-url' 183 ;; Transform URLs before passing to `browse-url'
183 (:option +browse-url-transformations `((,(rx "//" (or "youtube.com" 184 (:option +browse-url-transformations `((,(rx "//" (or "youtube.com"
184 "youtu.be")) 185 "youtu.be"))
@@ -463,9 +464,14 @@
463 "<S-return>" #'+org-table-copy-down 464 "<S-return>" #'+org-table-copy-down
464 "C-c C-l" #'+org-insert-link-dwim 465 "C-c C-l" #'+org-insert-link-dwim
465 "C-c C-n" #'+org-next-heading-widen 466 "C-c C-n" #'+org-next-heading-widen
466 "C-c C-p" #'+org-previous-heading-widen) 467 "C-c C-p" #'+org-previous-heading-widen
468 "C-c C-o" #'+org-open-at-point-dwim)
467 (:local-hook user-save-hook #'+org-before-save@prettify-buffer) 469 (:local-hook user-save-hook #'+org-before-save@prettify-buffer)
468 (advice-add #'org-delete-backward-char :override #'+org-delete-backward-char) 470 (advice-add #'org-delete-backward-char :override #'+org-delete-backward-char)
471 ;; (define-advice org-open-at-point (:around (fn &rest r) open-external)
472 ;; "Open links from org externally."
473 ;; (let ((browse-url-browser-function browse-url-secondary-browser-function))
474 ;; (apply fn r)))
469 (with-eval-after-load 'org 475 (with-eval-after-load 'org
470 (org-clock-persistence-insinuate) 476 (org-clock-persistence-insinuate)
471 (org-link-set-parameters "tel" :follow #'+org-tel-open)) 477 (org-link-set-parameters "tel" :follow #'+org-tel-open))
@@ -504,15 +510,18 @@
504 (+org-capture-templates-setf "tt" 510 (+org-capture-templates-setf "tt"
505 `("Today!" entry (file "todo.org") 511 `("Today!" entry (file "todo.org")
506 ,(concat "* TODO %^{Title}\n" 512 ,(concat "* TODO %^{Title}\n"
507 "DEADLINE: %t\n" 513 "DEADLINE: %t\n"
508 "\n%?"))) 514 "\n%?")))
509 (+org-capture-templates-setf "ts" 515 (+org-capture-templates-setf "ts"
510 `("Someday..." entry (file "todo.org") 516 `("Someday..." entry (file "todo.org")
511 ,(concat "* TODO %^{Title}\n" 517 ,(concat "* TODO %^{Title}\n"
512 ":PROPERTIES:\n" 518 ":PROPERTIES:\n"
513 ":CREATED: [%<%F %T>]\n" 519 ":CREATED: [%<%F %T>]\n"
514 ":END:\n" 520 ":END:\n"
515 "\n%?"))) 521 "\n%?")))
522 (+org-capture-templates-setf "l"
523 `("Link" entry (file "links.org")
524 "* %(+org-insert-link-dwim) %^g\n\n"))
516 (+org-capture-sort)) 525 (+org-capture-sort))
517 526
518(setup org-contacts 527(setup org-contacts
@@ -533,6 +542,10 @@
533 ";; ABANDON ALL HOPE YE WHO ENTER HERE\n\n") 542 ";; ABANDON ALL HOPE YE WHO ENTER HERE\n\n")
534 (add-hook 'kill-buffer-query-functions #'+scratch-immortal)) 543 (add-hook 'kill-buffer-query-functions #'+scratch-immortal))
535 544
545(setup shr
546 (:option shr-width (- fill-column 5) ; pad out for wide letters
547 shr-use-fonts t))
548
536(setup text 549(setup text
537 (:hook #'turn-on-auto-fill)) 550 (:hook #'turn-on-auto-fill))
538 551
@@ -544,7 +557,8 @@
544(setup (:straight ace-window) 557(setup (:straight ace-window)
545 (:require +ace-window) 558 (:require +ace-window)
546 (:option aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l) 559 (:option aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
547 aw-display-mode-overlay nil) 560 aw-display-mode-overlay nil
561 aw-scope 'frame)
548 (:+key "M-o" #'+ace-window-or-switch-buffer) 562 (:+key "M-o" #'+ace-window-or-switch-buffer)
549 (:face aw-mode-line-face ((t (:foreground "red")))) 563 (:face aw-mode-line-face ((t (:foreground "red"))))
550 (+ace-window-display-mode +1)) 564 (+ace-window-display-mode +1))
@@ -914,13 +928,19 @@ See also `crux-reopen-as-root-mode'."
914 (:bind "SPC" #'+elfeed-scroll-up-command 928 (:bind "SPC" #'+elfeed-scroll-up-command
915 "S-SPC" #'+elfeed-scroll-down-command) 929 "S-SPC" #'+elfeed-scroll-down-command)
916 (:hook #'reading-mode) 930 (:hook #'reading-mode)
917 (define-advice elfeed-show-entry (:after (&rest _)) 931 ;; (define-advice elfeed-show-entry (:after (&rest _))
918 "Re-flow the entry a short time after showing it." 932 ;; "Re-flow the entry a short time after showing it."
919 (run-at-time 0.1 nil #'elfeed-show-refresh)))) 933 ;; (run-at-time 0.1 nil #'elfeed-show-refresh))
934 ))
920 935
921(setup (:straight elfeed-org) 936(setup (:straight elfeed-org)
937 (:also-load +org-capture)
922 (:option rmh-elfeed-org-files (list (elfeed/ "elfeed.org" t))) 938 (:option rmh-elfeed-org-files (list (elfeed/ "elfeed.org" t)))
923 (elfeed-org)) 939 (elfeed-org)
940 (+org-capture-templates-setf "f"
941 `("Feed" entry
942 (file+olp ,(car rmh-elfeed-org-files) "Feeds")
943 "* %? %^g")))
924 944
925(setup (:straight elpher)) 945(setup (:straight elpher))
926 946
@@ -990,7 +1010,7 @@ See also `crux-reopen-as-root-mode'."
990 (:+key "M-q" #'filldent-dwim)) 1010 (:+key "M-q" #'filldent-dwim))
991 1011
992(setup (:straight flyspell-correct) 1012(setup (:straight flyspell-correct)
993 (:+also-load +flyspell-correct ) 1013 (:also-load +flyspell-correct)
994 (:option flyspell-correct--cr-key ";") 1014 (:option flyspell-correct--cr-key ";")
995 (:bind-into flyspell 1015 (:bind-into flyspell
996 "C-;" #'flyspell-correct-wrapper 1016 "C-;" #'flyspell-correct-wrapper
@@ -1041,11 +1061,12 @@ See also `crux-reopen-as-root-mode'."
1041 1061
1042(setup (:straight god-mode) 1062(setup (:straight god-mode)
1043 (setq god-mode-enable-function-key-translation nil) 1063 (setq god-mode-enable-function-key-translation nil)
1044 (:also-load +god-mode) 1064 (:require god-mode
1045 (:+key "C-M-g" #'god-local-mode) 1065 +god-mode)
1066 (:+key "C-M-g" #'god-mode-all)
1046 (:with-mode god-local-mode 1067 (:with-mode god-local-mode
1047 (:bind "i" #'+god-mode-insert 1068 (:bind "i" #'+god-mode-insert
1048 "a" #'+god-mode-append))) 1069 "a" nil)))
1049 1070
1050(setup (:straight helpful) 1071(setup (:straight helpful)
1051 (run-with-idle-timer 0.5 nil 1072 (run-with-idle-timer 0.5 nil
@@ -1260,6 +1281,7 @@ See also `crux-reopen-as-root-mode'."
1260(setup (:straight (sophomore 1281(setup (:straight (sophomore
1261 :host github 1282 :host github
1262 :repo "duckwork/sophomore.el")) 1283 :repo "duckwork/sophomore.el"))
1284 (sophomore-enable #'narrow-to-region)
1263 (sophomore-disable #'view-hello-file) 1285 (sophomore-disable #'view-hello-file)
1264 (sophomore-mode +1)) 1286 (sophomore-mode +1))
1265 1287
@@ -1288,8 +1310,8 @@ See also `crux-reopen-as-root-mode'."
1288 (:bind "t" #'titlecase-dwim))) 1310 (:bind "t" #'titlecase-dwim)))
1289 1311
1290(setup (:straight topsy) 1312(setup (:straight topsy)
1291 (:hook-into prog-mode 1313 (:hook-into ;;prog-mode
1292 circe-chat-mode) 1314 circe-chat-mode)
1293 (:when-loaded 1315 (:when-loaded
1294 (:option 1316 (:option
1295 topsy-header-line-format 1317 topsy-header-line-format
diff --git a/lisp/+init.el b/lisp/+init.el index 360a1b9..c1f3cb5 100644 --- a/lisp/+init.el +++ b/lisp/+init.el
@@ -37,41 +37,43 @@ are sorted lexigraphically."
37 nil 37 nil
38 ;; Sort function 38 ;; Sort function
39 (lambda (s1 s2) 39 (lambda (s1 s2)
40 (let ((s1 (cdr s1)) (s2 (cdr s2))) 40 (let ((s1 (cdr s1)) (s2 (cdr s2)))
41 (cond 41 (cond
42 ;; Sort everything /not/ `setup' /before/ `setup' 42 ;; Sort everything /not/ `setup' /before/ `setup'
43 ((and (+init--sexp-setup-p s1) 43 ((and (+init--sexp-setup-p s1)
44 (not (+init--sexp-setup-p s2))) 44 (not (+init--sexp-setup-p s2)))
45 nil) 45 nil)
46 ((and (+init--sexp-setup-p s2) 46 ((and (+init--sexp-setup-p s2)
47 (not (+init--sexp-setup-p s1))) 47 (not (+init--sexp-setup-p s1)))
48 t) 48 t)
49 ;; otherwise... 49 ;; otherwise...
50 (t (let ((s1-straight (+init--sexp-setup-p s1 :straight)) 50 (t (let ((s1-straight (+init--sexp-setup-p s1 :straight))
51 (s2-straight (+init--sexp-setup-p s2 :straight)) 51 (s2-straight (+init--sexp-setup-p s2 :straight))
52 (s1-require (+init--sexp-setup-p s1 :require)) 52 (s1-require (+init--sexp-setup-p s1 :require))
53 (s2-require (+init--sexp-setup-p s2 :require))) 53 (s2-require (+init--sexp-setup-p s2 :require)))
54 (cond 54 (cond
55 ;; `:straight' setups have extra processing 55 ;; `:straight' setups have extra processing
56 ((and s1-straight s2-straight) 56 ((and s1-straight s2-straight)
57 (let* ((r (rx (: ":straight" (? "-when") (* space) (? "(")))) 57 (let* ((r (rx (: ":straight" (? "-when") (* space) (? "("))))
58 (s1 (replace-regexp-in-string r "" s1)) 58 (s1 (replace-regexp-in-string r "" s1))
59 (s2 (replace-regexp-in-string r "" s2))) 59 (s2 (replace-regexp-in-string r "" s2)))
60 (string< s1 s2))) 60 (string< s1 s2)))
61 ;; `:require' setups go first 61 ;; `:require' setups go first
62 ((and s1-require (not s2-require)) t) 62 ((and s1-require (not s2-require)) t)
63 ((and s2-require (not s1-require)) nil) 63 ((and s2-require (not s1-require)) nil)
64 ;; `:straight' setups go last 64 ;; `:straight' setups go last
65 ((and s1-straight (not s2-straight)) nil) 65 ((and s1-straight (not s2-straight)) nil)
66 ((and s2-straight (not s1-straight)) t) 66 ((and s2-straight (not s1-straight)) t)
67 ;; otherwise, sort lexigraphically 67 ;; otherwise, sort lexigraphically
68 (t (string< s1 s2)))))))))))) 68 (t (string< s1 s2))))))))))))
69 69
70(defun +init-sort-then-save () 70(defun +init-sort-then-save ()
71 "Sort init.el, then save it." 71 "Sort init.el, then save it."
72 (interactive) 72 (interactive)
73 (+init-sort) 73 (+init-sort)
74 (save-buffer)) 74 (if (fboundp #'user-save-buffer)
75 (user-save-buffer)
76 (save-buffer)))
75 77
76;;; Add `setup' forms to `imenu-generic-expression' 78;;; Add `setup' forms to `imenu-generic-expression'
77 79
@@ -79,11 +81,11 @@ are sorted lexigraphically."
79 "Recognize `setup' forms in `imenu'." 81 "Recognize `setup' forms in `imenu'."
80 ;; `imenu-generic-expression' automatically becomes buffer-local when set 82 ;; `imenu-generic-expression' automatically becomes buffer-local when set
81 (setf (alist-get "Setup" imenu-generic-expression nil nil 'string-equal) 83 (setf (alist-get "Setup" imenu-generic-expression nil nil 'string-equal)
82 (list 84 (list
83 (rx (: bol (* space) 85 (rx (: bol (* space)
84 "(setup" (+ space) 86 "(setup" (+ space)
85 (group (? "(") (* nonl)))) 87 (group (? "(") (* nonl))))
86 1))) 88 1)))
87 89
88;;; Major mode 90;;; Major mode
89 91
diff --git a/lisp/+org.el b/lisp/+org.el index fc1caea..090af5a 100644 --- a/lisp/+org.el +++ b/lisp/+org.el
@@ -253,9 +253,9 @@ instead of the true count."
253 253
254;;; org-insert-link-dwim - https://xenodium.com/emacs-dwim-do-what-i-mean/ 254;;; org-insert-link-dwim - https://xenodium.com/emacs-dwim-do-what-i-mean/
255 255
256(defun +org-insert-link-dwim () 256(defun +org-insert-link-dwim (&optional interactivep)
257 "Like `org-insert-link' but with personal dwim preferences." 257 "Like `org-insert-link' but with personal dwim preferences."
258 (interactive) 258 (interactive '(t))
259 (let* ((point-in-link (org-in-regexp org-link-any-re 1)) 259 (let* ((point-in-link (org-in-regexp org-link-any-re 1))
260 (clipboard-url (when (string-match-p 260 (clipboard-url (when (string-match-p
261 (rx (sequence bos 261 (rx (sequence bos
@@ -266,25 +266,30 @@ instead of the true count."
266 (current-kill 0))) 266 (current-kill 0)))
267 (region-content (when (region-active-p) 267 (region-content (when (region-active-p)
268 (buffer-substring-no-properties (region-beginning) 268 (buffer-substring-no-properties (region-beginning)
269 (region-end))))) 269 (region-end))))
270 (cond ((and region-content clipboard-url (not point-in-link)) 270 (org-link (when clipboard-url
271 (delete-region (region-beginning) (region-end)) 271 (org-link-make-string
272 (insert (org-link-make-string clipboard-url region-content))) 272 clipboard-url
273 ((and clipboard-url (not point-in-link)) 273 (or region-content
274 (insert (org-link-make-string 274 (read-string "title: "
275 clipboard-url 275 (with-current-buffer
276 (read-string "title: " 276 (url-retrieve-synchronously
277 (with-current-buffer 277 clipboard-url)
278 (url-retrieve-synchronously 278 (dom-text
279 clipboard-url) 279 (car
280 (dom-text 280 (dom-by-tag (libxml-parse-html-region
281 (car 281 (point-min)
282 (dom-by-tag (libxml-parse-html-region 282 (point-max))
283 (point-min) 283 'title))))))))))
284 (point-max)) 284 (if interactivep
285 'title)))))))) 285 (cond ((and region-content clipboard-url (not point-in-link))
286 (t 286 (delete-region (region-beginning) (region-end))
287 (call-interactively 'org-insert-link))))) 287 (insert org-link))
288 ((and clipboard-url (not point-in-link))
289 (insert org-link))
290 (t
291 (call-interactively 'org-insert-link)))
292 org-link)))
288 293
289;;; Navigate headings with widening 294;;; Navigate headings with widening
290 295
@@ -409,5 +414,32 @@ the deletion might narrow the column."
409 (dotimes (_ fill-column) 414 (dotimes (_ fill-column)
410 (insert "-"))) 415 (insert "-")))
411 416
417;; Follow links, DWIM style
418
419(defun +org-open-at-point-dwim (&optional arg)
420 "Open thing at point, or if there isn't something, list things."
421 (interactive "P")
422 (save-excursion
423 (let* ((this-char-type (org-element-type (org-element-context)))
424 (prev-char-type (save-excursion
425 (backward-char)
426 (org-element-type (org-element-context))))
427 (types '(citation citation-reference clock comment comment-block
428 footnote-definition footnote-reference headline
429 inline-src-block inlinetask keyword link
430 node-property planning src-block timestamp))
431 (type this-char-type))
432 (when (and (memq this-char-type types) (memq prev-char-type types))
433 (backward-char)
434 (setq type prev-char-type)) ; what the fuckckckckck
435 (if (memq type types)
436 (progn (org-open-at-point arg))
437 (while (not
438 (progn
439 (org-back-to-heading)
440 (car (org-offer-links-in-entry (current-buffer) (point) 1))))
441 (org-up-heading-all 1))
442 (org-open-at-point arg)))))
443
412(provide '+org) 444(provide '+org)
413;;; +org.el ends here 445;;; +org.el ends here
diff --git a/lisp/acdw.el b/lisp/acdw.el index 9361cdf..262c15e 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -143,7 +143,7 @@ within a `with-current-buffer' form."
143 (let ((pred (or predicate t))) 143 (let ((pred (or predicate t)))
144 (dolist (buf (buffer-list)) 144 (dolist (buf (buffer-list))
145 (with-current-buffer buf 145 (with-current-buffer buf
146 (when (funcall pred buf) 146 (when (if (fboundp pred) (funcall pred buf) pred)
147 (funcall func)))))) 147 (funcall func))))))
148 148
149;; https://github.com/cstby/emacs.d/blob/main/init.el#L67 149;; https://github.com/cstby/emacs.d/blob/main/init.el#L67
@@ -176,14 +176,15 @@ surrounded by empty lines, so opening a paragraph means to make
176three blank lines, then place the point on the second one." 176three blank lines, then place the point on the second one."
177 (interactive "*") 177 (interactive "*")
178 (unless (derived-mode-p 'special-mode 'lui-mode 'comint-mode) 178 (unless (derived-mode-p 'special-mode 'lui-mode 'comint-mode)
179 ;; Go to next blank line. This /isn't/ `end-of-paragraph-text' because 179 ;; Go to next blank line. This /isn't/ `end-of-paragraph-text' because
180 ;; that's weird with org, and I'm guessing other modes too. 180 ;; that's weird with org, and I'm guessing other modes too.
181 (while (not (looking-at "^$")) 181 (while (and (not (looking-at "^$"))
182 (forward-line 1)) 182 (< (point) (point-max)))
183 (newline) 183 (forward-line 1))
184 (delete-blank-lines) 184 (newline)
185 (newline 2) 185 (delete-blank-lines)
186 (previous-line))) 186 (newline 2)
187 (previous-line)))
187 188
188(defun +split-window-then (&optional where arg) 189(defun +split-window-then (&optional where arg)
189 "Split the window into a new buffer. 190 "Split the window into a new buffer.