diff options
Diffstat (limited to 'init.el')
-rw-r--r-- | init.el | 125 |
1 files changed, 37 insertions, 88 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. | ||
92 | Actually sorts all forms, but based on the logic of `setup'. | ||
93 | In 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. |
1683 | That is, a prefix argument (\\[universal-argument]) will open the | 1638 | That is, a prefix argument (\\[universal-argument]) will open the |
1684 | browser defined in `browse-url-secondary-browser-function'." | 1639 | browser 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 |