about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--init.el125
-rw-r--r--lisp/acdw-apheleia.el25
-rw-r--r--lisp/acdw-circe.el15
-rw-r--r--lisp/acdw-modeline.el11
-rw-r--r--lisp/acdw-re.el4
-rw-r--r--lisp/acdw-setup.el11
-rw-r--r--lisp/acdw.el25
-rw-r--r--lisp/chd.el49
8 files changed, 161 insertions, 104 deletions
diff --git a/init.el b/init.el index a1d0f14..fff1782 100644 --- a/init.el +++ b/init.el
@@ -85,41 +85,7 @@
85 85
86 (when-let ((default-directory 86 (when-let ((default-directory
87 (expand-file-name-exists-p "pkg/" user-emacs-directory))) 87 (expand-file-name-exists-p "pkg/" user-emacs-directory)))
88 (normal-top-level-add-subdirs-to-load-path)) 88 (normal-top-level-add-subdirs-to-load-path)))
89
90 (defun acdw/sort-setups ()
91 "Sort `setup' forms in the current buffer.
92Actually sorts all forms, but based on the logic of `setup'.
93In short, DO NOT USE THIS FUNCTION!!!"
94 (save-excursion
95 (sort-sexps
96 (point-min) (point-max)
97 ;; Key function
98 nil
99 ;; Sort function
100 (lambda (s1 s2) ; oh god, this is worse.
101 (let* ((s1 (cdr s1)) (s2 (cdr s2)) ; for the strings themselves
102 (require-regexp (rx bos (* nonl) ":require"))
103 (straight-regexp (rx bos (* nonl) ":straight"))
104 (s1-require (string-match require-regexp s1))
105 (s2-require (string-match require-regexp s2))
106 (s1-straight (string-match straight-regexp s1))
107 (s2-straight (string-match straight-regexp s2)))
108 (cond
109 ;; Straight forms require some weirdness
110 ((and s1-straight s2-straight)
111 (let* ((r (rx ":straight" (? "-if") (* space) (? "(")))
112 (s1 (replace-regexp-in-string r "" s1))
113 (s2 (replace-regexp-in-string r "" s2)))
114 (string< s1 s2)))
115 ;; requires should go first
116 ((and s1-require (not s2-require)) t)
117 ((and (not s1-require) s2-require) nil)
118 ;; straights should go last
119 ((and s1-straight (not s2-straight)) nil)
120 ((and (not s1-straight) s2-straight) t)
121 ;; else, just sort em.
122 (t (string< s1 s2)))))))))
123 89
124(setup autorevert 90(setup autorevert
125 (:option global-auto-revert-non-file-buffers t 91 (:option global-auto-revert-non-file-buffers t
@@ -756,10 +722,7 @@ specific to most general, they are these:
756 722
757 (defun prog-mode@auto-fill () 723 (defun prog-mode@auto-fill ()
758 (setq-local comment-auto-fill-only-comments t) 724 (setq-local comment-auto-fill-only-comments t)
759 (turn-on-auto-fill))) 725 (turn-on-auto-fill))))
760
761 (add-hook 'after-save-hook
762 #'executable-make-buffer-file-executable-if-script-p))
763 726
764(setup repeat 727(setup repeat
765 ;; new for Emacs 28! 728 ;; new for Emacs 28!
@@ -1001,30 +964,26 @@ specific to most general, they are these:
1001(setup (:straight (apheleia 964(setup (:straight (apheleia
1002 :host github 965 :host github
1003 :repo "raxod502/apheleia")) 966 :repo "raxod502/apheleia"))
1004 967
1005 (apheleia-global-mode +1) 968 (:also-load acdw-apheleia)
1006 969 (add-hook 'before-save-hook #'apheleia-dumb-auto-format)
1007 ;; Use a dumb formatter on modes that `apheleia' doesn't work for. 970
1008 (add-hook 'before-save-hook 971 ;; Aphelia can't find prettier on Windows (though I
1009 (defun before-save@dumb-auto-format () 972 ;; installed it, I think), and it keeps trying to start
1010 (setq stupid-modes '(makefile-mode 973 ;; new processes until Emacs runs out of subprocess space.
1011 org-mode)) 974 ;; So I just enable it at home.
1012 ;; If there's no apheleia formatter for the mode, just indent the 975 (unless (acdw/system :work)
1013 ;; buffer. 976 (apheleia-global-mode +1)))
1014 (unless (or (apply #'derived-mode-p stupid-modes)
1015 (and (fboundp 'apheleia--get-formatter-command)
1016 (apheleia--get-formatter-command)))
1017 (indent-region (point-min) (point-max))))))
1018 977
1019(setup (:straight async) 978(setup (:straight async)
1020 (dired-async-mode +1)) 979 (dired-async-mode +1))
1021 980
1022(setup (:straight avy) 981(setup (:straight avy)
1023 (:global "C-'" #'avy-goto-char-timer 982 (:global "M-j" #'avy-goto-char-timer
1024 "C-c C-j" #'avy-resume) 983 "C-c C-j" #'avy-resume)
1025 984
1026 (:with-feature isearch 985 (:with-feature isearch
1027 (:bind "C-'" #'avy-isearch))) 986 (:bind "M-j" #'avy-isearch)))
1028 987
1029(setup (:straight circe) 988(setup (:straight circe)
1030 (require 'circe) 989 (require 'circe)
@@ -1085,7 +1044,8 @@ specific to most general, they are these:
1085 ((t (:inherit (modus-themes-slant)))))) 1044 ((t (:inherit (modus-themes-slant))))))
1086 1045
1087 (:bind "C-c C-p" #'circe-command-PART 1046 (:bind "C-c C-p" #'circe-command-PART
1088 "C-l" #'lui-track-jump-to-indicator) 1047 "C-l" #'lui-track-jump-to-indicator
1048 "<C-return>" #'circe-chat@set-prompt)
1089 1049
1090 (:advise circe-command-PART :after #'circe-part@kill-buffer 1050 (:advise circe-command-PART :after #'circe-part@kill-buffer
1091 circe-command-QUIT :after #'circe-quit@kill-buffer 1051 circe-command-QUIT :after #'circe-quit@kill-buffer
@@ -1096,15 +1056,7 @@ specific to most general, they are these:
1096 #'enable-circe-color-nicks 1056 #'enable-circe-color-nicks
1097 ;; #'enable-circe-display-images 1057 ;; #'enable-circe-display-images
1098 #'enable-circe-new-day-notifier 1058 #'enable-circe-new-day-notifier
1099 (defun circe-chat@set-prompt () 1059 #'circe-chat@set-prompt))
1100 (lui-set-prompt
1101 (concat
1102 (propertize
1103 (acdw-irc/margin-format (buffer-name) " " "> ")
1104 'face 'circe-prompt-face
1105 'read-only t
1106 'intangible t
1107 'cursor-intangible t))))))
1108 1060
1109 (autoload 'circe-nick-color-reset "circe-color-nicks") 1061 (autoload 'circe-nick-color-reset "circe-color-nicks")
1110 (add-hook 'modus-themes-after-load-theme-hook 1062 (add-hook 'modus-themes-after-load-theme-hook
@@ -1125,7 +1077,8 @@ specific to most general, they are these:
1125 word-wrap t 1077 word-wrap t
1126 wrap-prefix (repeat-string acdw-irc/left-margin " ") 1078 wrap-prefix (repeat-string acdw-irc/left-margin " ")
1127 line-number-mode nil 1079 line-number-mode nil
1128 column-number-mode nil) 1080 column-number-mode nil
1081 file-percentage-mode nil)
1129 1082
1130 (:hook #'enable-lui-track))) 1083 (:hook #'enable-lui-track)))
1131 1084
@@ -1296,9 +1249,8 @@ specific to most general, they are these:
1296 "Display tooltips for the current word" t) 1249 "Display tooltips for the current word" t)
1297 (autoload 'global-dictionary-tooltip-mode "dictionary" 1250 (autoload 'global-dictionary-tooltip-mode "dictionary"
1298 "Enable/disable dictionary-tooltip-mode for all buffers" t) 1251 "Enable/disable dictionary-tooltip-mode for all buffers" t)
1299 1252
1300 (:with-map lookup-map 1253 (define-key lookup-map "d" #'dictionary-search))
1301 (:bind "d" #'dictionary-search)))
1302 1254
1303(setup (:straight (dogears 1255(setup (:straight (dogears
1304 :host github 1256 :host github
@@ -1311,9 +1263,7 @@ specific to most general, they are these:
1311 elfeed-show-mode 1263 elfeed-show-mode
1312 elfeed-search-mode)) 1264 elfeed-search-mode))
1313 (:option (append dogears-ignore-modes) mode))) 1265 (:option (append dogears-ignore-modes) mode)))
1314 (:global "M-g d" dogears-go 1266 (:global "M-g d" dogears-go)
1315 "M-g M-b" dogears-back
1316 "M-g M-f" dogears-forward)
1317 (:autoload dogears-mode) 1267 (:autoload dogears-mode)
1318 (dogears-mode +1)) 1268 (dogears-mode +1))
1319 1269
@@ -1500,6 +1450,11 @@ specific to most general, they are these:
1500 (:hook-into emacs-lisp-mode 1450 (:hook-into emacs-lisp-mode
1501 lisp-interaction-mode)) 1451 lisp-interaction-mode))
1502 1452
1453(setup executable
1454 (:option executable-prefix-env t)
1455 (add-hook 'after-save-hook
1456 #'executable-make-buffer-file-executable-if-script-p))
1457
1503(setup (:straight-if exec-path-from-shell 1458(setup (:straight-if exec-path-from-shell
1504 (acdw/system :home)) 1459 (acdw/system :home))
1505 (when (daemonp) 1460 (when (daemonp)
@@ -1677,23 +1632,14 @@ When PREFIX is non-nil, open links with
1677 (link-hint--multiple (if prefix :open-secondary :open)))) 1632 (link-hint--multiple (if prefix :open-secondary :open))))
1678 1633
1679 (:option link-hint-avy-style 'post) 1634 (:option link-hint-avy-style 'post)
1680 (:global "C-;" 1635 (:global "C-j"
1681 (defun acdw/link-hint-open-link (arg) 1636 (defun acdw/link-hint-open-link (arg)
1682 "Open a link using `link-hint-open-link', prefix-aware. 1637 "Open a link using `link-hint-open-link', prefix-aware.
1683That is, a prefix argument (\\[universal-argument]) will open the 1638That is, a prefix argument (\\[universal-argument]) will open the
1684browser defined in `browse-url-secondary-browser-function'." 1639browser defined in `browse-url-secondary-browser-function'."
1685 (interactive "P") 1640 (interactive "P")
1686 (avy-with link-hint-open-link 1641 (avy-with link-hint-open-link
1687 (link-hint--one (if arg :open-secondary :open))))) 1642 (link-hint--one (if arg :open-secondary :open))))))
1688
1689 ;; Setup for different modes.
1690 ;; There has /got/ to be an easier way here!
1691 (dolist (key '(";" "o"))
1692 (:with-mode special-mode (:bind key #'link-hint-open-link))
1693 (:with-mode help-mode (:bind key #'link-hint-open-link))
1694 (:with-feature helpful (:bind key #'link-hint-open-link))
1695 (:with-mode Info-mode (:bind key #'link-hint-open-link))
1696 (:with-feature reading (:bind key #'link-hint-open-link))))
1697 1643
1698(setup (:straight lua-mode) 1644(setup (:straight lua-mode)
1699 (:file-match (rx ".lua" eos))) 1645 (:file-match (rx ".lua" eos)))
@@ -1901,7 +1847,8 @@ browser defined in `browse-url-secondary-browser-function'."
1901 "C-c C-p" #'acdw/org-previous-heading-widen 1847 "C-c C-p" #'acdw/org-previous-heading-widen
1902 "C-x n t" #'org-narrow-to-task) 1848 "C-x n t" #'org-narrow-to-task)
1903 1849
1904 (:unbind "C-'") 1850 (:unbind "C-j" ; org-return-and-maybe-indent
1851 "M-j")
1905 1852
1906 (with-eval-after-load 'org-export 1853 (with-eval-after-load 'org-export
1907 (:option (append org-export-filter-final-output-functions) 1854 (:option (append org-export-filter-final-output-functions)
@@ -2025,13 +1972,15 @@ the default is \"/\"."
2025 (global-page-break-lines-mode +1)) 1972 (global-page-break-lines-mode +1))
2026 1973
2027(setup (:straight paredit) 1974(setup (:straight paredit)
2028 ;; I don't use paredit-splice-sexp much, and it stomps on isearch.
2029 (:unbind "M-s")
2030
2031 (:bind "DEL" #'paredit-backward-delete 1975 (:bind "DEL" #'paredit-backward-delete
2032 "C-M-;" #'comment-or-uncomment-sexp 1976 "C-M-;" #'comment-or-uncomment-sexp
2033 "C-<backspace>" #'paredit-backward-kill-word 1977 "C-<backspace>" #'paredit-backward-kill-word
2034 "M-w" #'paredit-copy-as-kill) 1978 "M-w" #'paredit-copy-as-kill
1979 "RET" #'paredit-newline)
1980
1981 (:unbind "M-s" ; paredit-splice-sexp
1982 "C-j" ; paredit-newline (rebound to RET)
1983 )
2035 1984
2036 (:hook-into emacs-lisp-mode 1985 (:hook-into emacs-lisp-mode
2037 ielm-mode sly-repl-mode 1986 ielm-mode sly-repl-mode
diff --git a/lisp/acdw-apheleia.el b/lisp/acdw-apheleia.el new file mode 100644 index 0000000..1b646ef --- /dev/null +++ b/lisp/acdw-apheleia.el
@@ -0,0 +1,25 @@
1;;; acdw-apheleia.el --- bespoke apheleia junk -*- lexical-binding: t -*-
2
3;;; Commentary:
4
5;;; Code:
6
7(require 'apheleia)
8
9(defcustom apheleia-stupid-modes '(makefile-mode
10 org-mode)
11 "List of stupid modes to not use `apheleia-global-mode' on."
12 :type '(repeat function)
13 :group 'apheleia)
14
15(defun apheleia-dumb-auto-format ()
16 "Format a buffer dumbly."
17 ;; If there's no apheleia formatter for the mode, just indent the
18 ;; buffer.
19 (unless (or (apply #'derived-mode-p apheleia-stupid-modes)
20 (and (fboundp 'apheleia--get-formatter-command)
21 (apheleia--get-formatter-command)))
22 (indent-region (point-min) (point-max))))
23
24(provide 'acdw-apheleia)
25;;; acdw-apheleia ends here
diff --git a/lisp/acdw-circe.el b/lisp/acdw-circe.el index 69b10be..e85587b 100644 --- a/lisp/acdw-circe.el +++ b/lisp/acdw-circe.el
@@ -17,6 +17,21 @@
17 (let ((short-url (0x0-shorten-uri (0x0--choose-server) url))) 17 (let ((short-url (0x0-shorten-uri (0x0--choose-server) url)))
18 (circe-command-SAY short-url))) 18 (circe-command-SAY short-url)))
19 19
20;;; Hooks
21
22(defun circe-chat@set-prompt ()
23 "Set the prompt to the buffer name, shortening it."
24 (interactive) ; set interactive to unfuck the prompt when need be
25 (lui-set-prompt
26 (propertize
27 (concat
28 (acdw-irc/margin-format (buffer-name) "" ">")
29 " ")
30 'face 'circe-prompt-face
31 'read-only t
32 'intangible t
33 'cursor-intangible t)))
34
20;;; Advices 35;;; Advices
21 36
22(defun circe-part@kill-buffer (&rest _) 37(defun circe-part@kill-buffer (&rest _)
diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index 25502ec..9963309 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el
@@ -125,6 +125,10 @@ indicator in the mode-line."
125 'mouse-2 #'mode-line-widen)) 125 'mouse-2 #'mode-line-widen))
126 'mouse-face 'mode-line-highlight)))) 126 'mouse-face 'mode-line-highlight))))
127 127
128(define-minor-mode file-percentage-mode
129 "Toggle the percentage display in the mode line (File Percentage Mode)."
130 :init-value t :global t :group 'mode-line)
131
128(defun acdw-modeline/position () 132(defun acdw-modeline/position ()
129 "Displays the current cursor position in the mode-line. 133 "Displays the current cursor position in the mode-line.
130 134
@@ -140,7 +144,10 @@ is, if point < mark."
140 ((column-number-mode 144 ((column-number-mode
141 (column-number-indicator-zero-based 145 (column-number-indicator-zero-based
142 (5 " C%c") 146 (5 " C%c")
143 (5 " C%C"))))) 147 (5 " C%C")))
148 " "))
149 (file-percentage-mode
150 (7 "%p%% "))
144 ,(if (region-active-p) 151 ,(if (region-active-p)
145 (propertize (format "%s%-5d" 152 (propertize (format "%s%-5d"
146 (if (and (mark) 153 (if (and (mark)
@@ -183,7 +190,7 @@ is, if point < mark."
183(defun acdw-modeline/wc () 190(defun acdw-modeline/wc ()
184 "Display current `wc-buffer-stats'." 191 "Display current `wc-buffer-stats'."
185 (when (bound-and-true-p wc-mode) 192 (when (bound-and-true-p wc-mode)
186 (or wc-buffer-stats "[w]"))) 193 (or wc-buffer-stats " [w]")))
187 194
188(defun acdw-modeline/winum () 195(defun acdw-modeline/winum ()
189 "Show the `winum' number of the current window in the modeline. 196 "Show the `winum' number of the current window in the modeline.
diff --git a/lisp/acdw-re.el b/lisp/acdw-re.el index db46af1..1fc0a9c 100644 --- a/lisp/acdw-re.el +++ b/lisp/acdw-re.el
@@ -17,6 +17,10 @@
17;; Pulled mostly from karthinks: 17;; Pulled mostly from karthinks:
18;; https://karthinks.com/software/bridging-islands-in-emacs-1/ 18;; https://karthinks.com/software/bridging-islands-in-emacs-1/
19 19
20;; UPDATED CODE:
21;; https://github.com/karthink/.emacs.d/blob/master/init.el#L981
22;; https://github.com/karthink/.emacs.d/blob/master/lisp/reb-fix.el
23
20;;; Code: 24;;; Code:
21 25
22(defvar acdw/re-builder-positions nil 26(defvar acdw/re-builder-positions nil
diff --git a/lisp/acdw-setup.el b/lisp/acdw-setup.el index e271faa..eb4d12b 100644 --- a/lisp/acdw-setup.el +++ b/lisp/acdw-setup.el
@@ -87,5 +87,16 @@ package. This macro is not repeatable."
87 (let ((recipe (cadr sexp))) 87 (let ((recipe (cadr sexp)))
88 (if (consp recipe) (car recipe) recipe)))) 88 (if (consp recipe) (car recipe) recipe))))
89 89
90;; https://www.emacswiki.org/emacs/SetupEl
91(setup-define :load-after
92 (lambda (&rest features)
93 (let ((body `(require ',(setup-get 'feature))))
94 (dolist (feature (if (listp features)
95 (nreverse features)
96 (list features)))
97 (setq body `(with-eval-after-load ',feature ,body)))
98 body))
99 :documentation "Load the current feature after FEATURES.")
100
90(provide 'acdw-setup) 101(provide 'acdw-setup)
91;;; acdw-setup.el ends here 102;;; acdw-setup.el ends here
diff --git a/lisp/acdw.el b/lisp/acdw.el index 86443a1..792b9ef 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -93,7 +93,7 @@ features."
93 (let* ((this (car features)) 93 (let* ((this (car features))
94 (rest (cdr features))) 94 (rest (cdr features)))
95 `(with-eval-after-load ',this 95 `(with-eval-after-load ',this
96 (with-eval-after-all ,rest ,@body))))) 96 (with-eval-after-loads ,rest ,@body)))))
97 97
98(defmacro with-message (message &rest body) 98(defmacro with-message (message &rest body)
99 "Execute BODY, messaging 'MESSAGE...' before and 'MESSAGE... Done.' after." 99 "Execute BODY, messaging 'MESSAGE...' before and 'MESSAGE... Done.' after."
@@ -338,26 +338,23 @@ In short, DO NOT USE THIS FUNCTION!!!"
338 (save-excursion 338 (save-excursion
339 (sort-sexps 339 (sort-sexps
340 (point-min) (point-max) 340 (point-min) (point-max)
341 (lambda (sexp) 341 ;; Key function
342 (format "%S" (cadr sexp))) 342 nil
343 ;; Sort function
343 (lambda (s1 s2) ; oh god, this is worse. 344 (lambda (s1 s2) ; oh god, this is worse.
344 (let* ((s1 (cdr s1)) (s2 (cdr s2)) ; for the strings themselves 345 (let* ((s1 (cdr s1)) (s2 (cdr s2)) ; for the strings themselves
345 (s1-require (string-match ":require" s1)) 346 (require-regexp (rx bos (* nonl) ":require"))
346 (s2-require (string-match ":require" s2)) 347 (straight-regexp (rx bos (* nonl) ":straight"))
347 (s1-straight (string-match ":straight" s1)) 348 (s1-require (string-match require-regexp s1))
348 (s2-straight (string-match ":straight" s2)) 349 (s2-require (string-match require-regexp s2))
349 (s1-bare (not (or s1-require s1-straight))) 350 (s1-straight (string-match straight-regexp s1))
350 (s2-bare (not (or s2-require s2-straight)))) 351 (s2-straight (string-match straight-regexp s2)))
351 (cond 352 (cond
352 ;; if both are the same, sort regular style 353 ;; Straight forms require some weirdness
353 ((or (and s1-require s2-require)
354 (and s1-bare s2-bare))
355 (string< s1 s2))
356 ((and s1-straight s2-straight) 354 ((and s1-straight s2-straight)
357 (let* ((r (rx ":straight" (? "-if") (* space) (? "("))) 355 (let* ((r (rx ":straight" (? "-if") (* space) (? "(")))
358 (s1 (replace-regexp-in-string r "" s1)) 356 (s1 (replace-regexp-in-string r "" s1))
359 (s2 (replace-regexp-in-string r "" s2))) 357 (s2 (replace-regexp-in-string r "" s2)))
360 (message "'%S' '%S'" s1 s2)
361 (string< s1 s2))) 358 (string< s1 s2)))
362 ;; requires should go first 359 ;; requires should go first
363 ((and s1-require (not s2-require)) t) 360 ((and s1-require (not s2-require)) t)
diff --git a/lisp/chd.el b/lisp/chd.el new file mode 100644 index 0000000..697c134 --- /dev/null +++ b/lisp/chd.el
@@ -0,0 +1,49 @@
1;;; chd.el --- CHD customizations -*- lexical-binding: t -*-
2
3(require 'acdw-org)
4(require 'org)
5
6(defun chd/narrow-to-task (&optional point)
7 "Narrow the buffer to the task POINT is in."
8 (interactive "d")
9 (when point (goto-char point))
10 (if (called-interactively-p 'interactive)
11 (save-excursion
12 (while (not (org-entry-is-todo-p))
13 (acdw/org-previous-heading-widen 1))
14 (org-narrow-to-subtree))
15 ;; well this is dumb...
16 (while (not (org-entry-is-todo-p))
17 (acdw/org-previous-heading-widen 1))
18 (org-narrow-to-subtree)))
19
20(defun chd/clock-in ()
21 "Clock in to the current task."
22 (save-excursion
23 (chd/narrow-to-task)
24 (org-clock-in)))
25
26(defun chd/do-the-thing ()
27 "Copy the plain version of the current task and open its link."
28 (interactive)
29 (chd/narrow-to-task)
30 (save-excursion
31 ;; Prepare buffer
32 (acdw/flyspell-correct-f7) ; This is defined... elsewhere.
33
34 ;; Export the buffer and copy it
35 (pcase (org-entry-get (point-min) "EXPORTAS" t)
36 ("html" (acdw/org-export-copy-html))
37 (_ (acdw/org-export-copy)))
38
39 ;; Open the link to the doc
40 (org-back-to-heading)
41 (org-open-at-point)))
42
43;;; NOTES
44;; org-protocol: https://orgmode.org/worg/org-contrib/org-protocol.html
45;; the bit i wanna pull from TaskIQ: 'document.getElementById("preview")
46
47
48(provide 'chd)
49;;; chd.el ends here