diff options
author | Case Duckworth | 2022-04-20 10:47:36 -0500 |
---|---|---|
committer | Case Duckworth | 2022-04-20 10:47:36 -0500 |
commit | d31baf887e3e4632d589ba67a992f02fdc39a596 (patch) | |
tree | 4bdec8e3588006e4fff396372406166b79c62c7e | |
parent | bleh (diff) | |
parent | Enhance :straight setup form (diff) | |
download | emacs-d31baf887e3e4632d589ba67a992f02fdc39a596.tar.gz emacs-d31baf887e3e4632d589ba67a992f02fdc39a596.zip |
Merge branch 'main' of tildegit.org:acdw/emacs
-rw-r--r-- | init.el | 132 | ||||
-rw-r--r-- | lisp/+setup.el | 133 |
2 files changed, 150 insertions, 115 deletions
diff --git a/init.el b/init.el index 0653796..4e353df 100644 --- a/init.el +++ b/init.el | |||
@@ -117,7 +117,8 @@ | |||
117 | pulse-delay 0.5 | 117 | pulse-delay 0.5 |
118 | pulse-iterations 1) | 118 | pulse-iterations 1) |
119 | (dolist (command '(+ace-window-or-switch-buffer | 119 | (dolist (command '(+ace-window-or-switch-buffer |
120 | pop-mark pop-global-mark)) | 120 | pop-mark pop-global-mark |
121 | Info-history-back Info-history-forward)) | ||
121 | (add-to-list '+pulse-location-commands command)) | 122 | (add-to-list '+pulse-location-commands command)) |
122 | (+ensure-after-init #'+pulse-location-mode)) | 123 | (+ensure-after-init #'+pulse-location-mode)) |
123 | 124 | ||
@@ -264,7 +265,7 @@ | |||
264 | 265 | ||
265 | (setup dired | 266 | (setup dired |
266 | (:also-load dired-x +dired) | 267 | (:also-load dired-x +dired) |
267 | (:also-straight dired+) | 268 | (:straight dired+) |
268 | (:option dired-recursive-copies 'always | 269 | (:option dired-recursive-copies 'always |
269 | dired-recursive-deletes 'always | 270 | dired-recursive-deletes 'always |
270 | dired-create-destination-dirs 'always | 271 | dired-create-destination-dirs 'always |
@@ -554,14 +555,13 @@ | |||
554 | :build (:not autoloads) | 555 | :build (:not autoloads) |
555 | :files (:defaults | 556 | :files (:defaults |
556 | "lisp/*.el" | 557 | "lisp/*.el" |
557 | ("etc/styles/" "etc/styles/*"))) | 558 | ("etc/styles/" "etc/styles/*")))) |
558 | (org-contrib | 559 | (:straight (org-contrib |
559 | :type git :host nil | 560 | :type git :host nil |
560 | :repo "https://git.sr.ht/~bzg/org-contrib")) | 561 | :repo "https://git.sr.ht/~bzg/org-contrib")) |
561 | ;; DO NOT load system-installed org !!! | 562 | ;; DO NOT load system-installed org !!! |
562 | (setq load-path (cl-remove-if (lambda (path) | 563 | (setq load-path |
563 | (string-match-p "lisp/org\\'" path)) | 564 | (cl-remove-if (lambda (path) (string-match-p "lisp/org\\'" path)) load-path)) |
564 | load-path)) | ||
565 | (:also-load +org) | 565 | (:also-load +org) |
566 | (:option org-adapt-indentation nil | 566 | (:option org-adapt-indentation nil |
567 | org-auto-align-tags t | 567 | org-auto-align-tags t |
@@ -671,13 +671,13 @@ | |||
671 | ;; `compose-region' returns t. | 671 | ;; `compose-region' returns t. |
672 | ("^[ \t]*\\([-]\\) " | 672 | ("^[ \t]*\\([-]\\) " |
673 | (0 ;; (progn (compose-region (match-beginning 1) (match-end 1) "–") 'fixed-pitch) | 673 | (0 ;; (progn (compose-region (match-beginning 1) (match-end 1) "–") 'fixed-pitch) |
674 | 'fixed-pitch t)) | 674 | 'fixed-pitch t)) |
675 | ("^[ \t]*\\([+]\\) " | 675 | ("^[ \t]*\\([+]\\) " |
676 | (0 ;; (progn (compose-region (match-beginning 1) (match-end 1) "¬") 'fixed-pitch) | 676 | (0 ;; (progn (compose-region (match-beginning 1) (match-end 1) "¬") 'fixed-pitch) |
677 | 'fixed-pitch t)) | 677 | 'fixed-pitch t)) |
678 | ("^[ \t]+\\([*]\\) " | 678 | ("^[ \t]+\\([*]\\) " |
679 | (0 ;; (progn (compose-region (match-beginning 1) (match-end 1) "→") 'fixed-pitch) | 679 | (0 ;; (progn (compose-region (match-beginning 1) (match-end 1) "→") 'fixed-pitch) |
680 | 'fixed-pitch t)) | 680 | 'fixed-pitch t)) |
681 | ;; Fancy numbered lists (well, monospaced) | 681 | ;; Fancy numbered lists (well, monospaced) |
682 | ("^[ \t]*\\(\\(?:[0-9]+\\|[A-Za-z]\\)[.)]\\) " 0 'fixed-pitch t) | 682 | ("^[ \t]*\\(\\(?:[0-9]+\\|[A-Za-z]\\)[.)]\\) " 0 'fixed-pitch t) |
683 | ;; Make leading org-heading stars fixed-pitch | 683 | ;; Make leading org-heading stars fixed-pitch |
@@ -773,12 +773,6 @@ | |||
773 | :unnarrowed t)) | 773 | :unnarrowed t)) |
774 | (+org-capture-sort)) | 774 | (+org-capture-sort)) |
775 | 775 | ||
776 | (setup org-contacts (:quit) | ||
777 | (:require) | ||
778 | (:also-straight org-vcard) ; for importing Vcard files | ||
779 | (:option org-contacts-matcher "contact") ; Contacts are tagged "contact" | ||
780 | ) | ||
781 | |||
782 | (setup org-export | 776 | (setup org-export |
783 | (:also-load ox-md) | 777 | (:also-load ox-md) |
784 | (:option org-export-coding-system 'utf-8-unix | 778 | (:option org-export-coding-system 'utf-8-unix |
@@ -902,7 +896,7 @@ They are completed by \"M-x TAB\" only in Tramp debug buffers." | |||
902 | (:with-mode adaptive-wrap-prefix-mode | 896 | (:with-mode adaptive-wrap-prefix-mode |
903 | (:hook-into visual-column-mode))) | 897 | (:hook-into visual-column-mode))) |
904 | 898 | ||
905 | (setup (:straight-when affe | 899 | (setup (:straight affe |
906 | (or (executable-find "rg") | 900 | (or (executable-find "rg") |
907 | (and (executable-find "find") | 901 | (and (executable-find "find") |
908 | (executable-find "grep")))) | 902 | (executable-find "grep")))) |
@@ -947,9 +941,9 @@ They are completed by \"M-x TAB\" only in Tramp debug buffers." | |||
947 | (setf (alist-get ?. avy-dispatch-alist) #'avy-action-embark))) | 941 | (setf (alist-get ?. avy-dispatch-alist) #'avy-action-embark))) |
948 | 942 | ||
949 | (setup (:straight bbdb) | 943 | (setup (:straight bbdb) |
944 | (:straight bbdb-vcard) | ||
950 | (:require bbdb-autoloads | 945 | (:require bbdb-autoloads |
951 | bbdb) | 946 | bbdb) |
952 | (:also-straight bbdb-vcard) | ||
953 | (bbdb-initialize 'gnus 'message)) | 947 | (bbdb-initialize 'gnus 'message)) |
954 | 948 | ||
955 | (setup (:straight (bongo :type git | 949 | (setup (:straight (bongo :type git |
@@ -1331,7 +1325,8 @@ They are completed by \"M-x TAB\" only in Tramp debug buffers." | |||
1331 | (setf (alist-get 'consult-notmuch vertico-multiform-commands) '(buffer) | 1325 | (setf (alist-get 'consult-notmuch vertico-multiform-commands) '(buffer) |
1332 | (alist-get 'consult-notmuch-tree vertico-multiform-commands) '(buffer)))) | 1326 | (alist-get 'consult-notmuch-tree vertico-multiform-commands) '(buffer)))) |
1333 | 1327 | ||
1334 | (setup (:straight corfu) (:quit "Turns out, I actually like minibuffer completion better.") | 1328 | (setup (:straight corfu |
1329 | :quit "Turns out, I actually like minibuffer completion better.") | ||
1335 | (+with-ensure-after-init | 1330 | (+with-ensure-after-init |
1336 | (corfu-global-mode +1))) | 1331 | (corfu-global-mode +1))) |
1337 | 1332 | ||
@@ -1408,7 +1403,7 @@ See also `crux-reopen-as-root-mode'." | |||
1408 | (setup (:straight dumb-jump) | 1403 | (setup (:straight dumb-jump) |
1409 | (add-hook 'xref-backend-functions #'dumb-jump-xref-activate)) | 1404 | (add-hook 'xref-backend-functions #'dumb-jump-xref-activate)) |
1410 | 1405 | ||
1411 | (setup (:straight-when ebuku | 1406 | (setup (:straight ebuku |
1412 | (executable-find "buku")) | 1407 | (executable-find "buku")) |
1413 | (:option ebuku-display-on-startup 'recent | 1408 | (:option ebuku-display-on-startup 'recent |
1414 | ebuku-recent-count 100)) | 1409 | ebuku-recent-count 100)) |
@@ -1532,12 +1527,13 @@ See also `crux-reopen-as-root-mode'." | |||
1532 | (setup (:straight eshell-syntax-highlighting) | 1527 | (setup (:straight eshell-syntax-highlighting) |
1533 | (:hook-into eshell-mode)) | 1528 | (:hook-into eshell-mode)) |
1534 | 1529 | ||
1535 | ;; (setup (:straight eshell-vterm) | 1530 | (setup (:straight eshell-vterm |
1536 | ;; (:load-after eshell) | 1531 | :quit) |
1537 | ;; (defalias 'eshell/v 'eshell-exec-visual) | 1532 | (:load-after eshell) |
1538 | ;; (eshell-vterm-mode +1)) | 1533 | (defalias 'eshell/v 'eshell-exec-visual) |
1534 | (eshell-vterm-mode +1)) | ||
1539 | 1535 | ||
1540 | (setup (:straight-when exec-path-from-shell | 1536 | (setup (:straight exec-path-from-shell |
1541 | (eq system-type 'gnu/linux)) | 1537 | (eq system-type 'gnu/linux)) |
1542 | (require 'exec-path-from-shell) | 1538 | (require 'exec-path-from-shell) |
1543 | (dolist (var '("SSH_AUTH_SOCK" | 1539 | (dolist (var '("SSH_AUTH_SOCK" |
@@ -1601,7 +1597,7 @@ See also `crux-reopen-as-root-mode'." | |||
1601 | 'notmuch-message) | 1597 | 'notmuch-message) |
1602 | (:hook-into notmuch-show-mode)) | 1598 | (:hook-into notmuch-show-mode)) |
1603 | 1599 | ||
1604 | (setup (:straight-when (forge | 1600 | (setup (:straight (forge |
1605 | :host github :repo "magit/forge") | 1601 | :host github :repo "magit/forge") |
1606 | (eq system-type 'gnu/linux)) | 1602 | (eq system-type 'gnu/linux)) |
1607 | (require 'forge) | 1603 | (require 'forge) |
@@ -1627,10 +1623,10 @@ See also `crux-reopen-as-root-mode'." | |||
1627 | :files ("elisp/*.el" "doc/*" "geiser-pkg.el") | 1623 | :files ("elisp/*.el" "doc/*" "geiser-pkg.el") |
1628 | :pre-build ("make" "-Cdoc" "geiser.info") | 1624 | :pre-build ("make" "-Cdoc" "geiser.info") |
1629 | :host gitlab | 1625 | :host gitlab |
1630 | :repo "emacs-geiser/geiser") | 1626 | :repo "emacs-geiser/geiser")) |
1631 | geiser-chicken | 1627 | (:straight geiser-chicken) |
1632 | macrostep-geiser | 1628 | (:straight macrostep-geiser) |
1633 | scheme-complete) | 1629 | (:straight scheme-complete) |
1634 | (:require +chicken) | 1630 | (:require +chicken) |
1635 | (setf (alist-get "\\.scm\\'" auto-mode-alist nil nil #'string=) | 1631 | (setf (alist-get "\\.scm\\'" auto-mode-alist nil nil #'string=) |
1636 | 'scheme-mode) | 1632 | 'scheme-mode) |
@@ -1641,7 +1637,8 @@ See also `crux-reopen-as-root-mode'." | |||
1641 | :host github :repo "magit/git-modes")) | 1637 | :host github :repo "magit/git-modes")) |
1642 | (:require git-modes)) | 1638 | (:require git-modes)) |
1643 | 1639 | ||
1644 | (setup (:straight god-mode) (:quit "I could never get the hang of this.") | 1640 | (setup (:straight god-mode |
1641 | :quit "I could never get the hang of this.") | ||
1645 | (setq god-mode-enable-function-key-translation nil) | 1642 | (setq god-mode-enable-function-key-translation nil) |
1646 | (:require god-mode | 1643 | (:require god-mode |
1647 | +god-mode) | 1644 | +god-mode) |
@@ -1690,8 +1687,15 @@ See also `crux-reopen-as-root-mode'." | |||
1690 | (paredit-forward-delete arg)))) | 1687 | (paredit-forward-delete arg)))) |
1691 | (global-hungry-delete-mode +1)) | 1688 | (global-hungry-delete-mode +1)) |
1692 | 1689 | ||
1690 | (setup (:straight i3wm-config-mode | ||
1691 | (executable-find "i3"))) | ||
1692 | |||
1693 | (setup (:straight info+) | 1693 | (setup (:straight info+) |
1694 | (:load-after info)) | 1694 | (:load-after info) |
1695 | (:option Info-fontify-isolated-quote-flag nil | ||
1696 | Info-fontify-quotations nil | ||
1697 | Info-saved-history-file (.etc "info-history")) | ||
1698 | (add-hook 'Info-mode-hook #'Info-variable-pitch-text-mode)) | ||
1695 | 1699 | ||
1696 | (setup (:straight isearch-mb) | 1700 | (setup (:straight isearch-mb) |
1697 | ;; This complicatedness is an attempt to make it easier to add and | 1701 | ;; This complicatedness is an attempt to make it easier to add and |
@@ -1748,7 +1752,7 @@ See also `crux-reopen-as-root-mode'." | |||
1748 | :host github :repo "duckwork/keepassxc-shim.el")) | 1752 | :host github :repo "duckwork/keepassxc-shim.el")) |
1749 | (keepassxc-shim-activate)) | 1753 | (keepassxc-shim-activate)) |
1750 | 1754 | ||
1751 | (setup (:straight-when keychain-environment | 1755 | (setup (:straight keychain-environment |
1752 | (executable-find "keychain")) | 1756 | (executable-find "keychain")) |
1753 | (keychain-refresh-environment)) | 1757 | (keychain-refresh-environment)) |
1754 | 1758 | ||
@@ -1759,11 +1763,7 @@ See also `crux-reopen-as-root-mode'." | |||
1759 | '(buffer grid (vertico-sort-function . vertico-sort-length-alpha))))) | 1763 | '(buffer grid (vertico-sort-function . vertico-sort-length-alpha))))) |
1760 | 1764 | ||
1761 | (setup (:straight (lin :host gitlab :repo "protesilaos/lin")) | 1765 | (setup (:straight (lin :host gitlab :repo "protesilaos/lin")) |
1762 | (require 'lin) | 1766 | (lin-global-mode +1)) |
1763 | (+with-ensure-after-init | ||
1764 | (dolist (hook lin-foreign-hooks) | ||
1765 | (add-hook hook #'hl-line-mode) | ||
1766 | (add-hook hook #'lin-mode)))) | ||
1767 | 1767 | ||
1768 | (setup (:straight link-hint) | 1768 | (setup (:straight link-hint) |
1769 | (:require +link-hint) | 1769 | (:require +link-hint) |
@@ -1841,7 +1841,8 @@ See also `crux-reopen-as-root-mode'." | |||
1841 | #'hl-line-mode | 1841 | #'hl-line-mode |
1842 | #'lin-mode)) | 1842 | #'lin-mode)) |
1843 | 1843 | ||
1844 | (setup (:straight md4rd) (:quit "Janky a.f.") | 1844 | (setup (:straight md4rd |
1845 | :quit) | ||
1845 | ;; `md4rd' is ... a bit janky, tbh. But I'm including this here so I have it. | 1846 | ;; `md4rd' is ... a bit janky, tbh. But I'm including this here so I have it. |
1846 | ;; TODO: enable opening Reddit links in md4rd | 1847 | ;; TODO: enable opening Reddit links in md4rd |
1847 | (:also-load _md4rd) | 1848 | (:also-load _md4rd) |
@@ -1939,7 +1940,8 @@ See also `crux-reopen-as-root-mode'." | |||
1939 | (:when-loaded | 1940 | (:when-loaded |
1940 | (notmuch-bookmarks-mode +1))) | 1941 | (notmuch-bookmarks-mode +1))) |
1941 | 1942 | ||
1942 | (setup (:straight notmuch-labeler) (:quit "This is buggy") | 1943 | (setup (:straight notmuch-labeler |
1944 | :quit "Buggy") | ||
1943 | (:load-after notmuch)) | 1945 | (:load-after notmuch)) |
1944 | 1946 | ||
1945 | (setup (:straight ol-notmuch)) | 1947 | (setup (:straight ol-notmuch)) |
@@ -1980,9 +1982,7 @@ See also `crux-reopen-as-root-mode'." | |||
1980 | (:also-load +org-drawer-list)) | 1982 | (:also-load +org-drawer-list)) |
1981 | 1983 | ||
1982 | (setup (:straight org-mime) | 1984 | (setup (:straight org-mime) |
1983 | (:option org-mime-export-ascii 'utf-8)) | 1985 | (:option org-mime-export-ascii 'utf-8) |
1984 | |||
1985 | (setup (:straight org-mime) | ||
1986 | (add-hook 'message-mode-hook | 1986 | (add-hook 'message-mode-hook |
1987 | (defun org-mime-setup@message-mode () | 1987 | (defun org-mime-setup@message-mode () |
1988 | (local-set-key (kbd "C-c M-o") 'org-mime-htmlize))) | 1988 | (local-set-key (kbd "C-c M-o") 'org-mime-htmlize))) |
@@ -2053,17 +2053,13 @@ See also `crux-reopen-as-root-mode'." | |||
2053 | lisp-interaction-mode | 2053 | lisp-interaction-mode |
2054 | scheme-mode)) | 2054 | scheme-mode)) |
2055 | 2055 | ||
2056 | (setup (:straight pdf-tools) | 2056 | (setup (:straight pdf-tools |
2057 | (or (executable-find "gcc") | ||
2058 | (executable-find "g++"))) | ||
2059 | (setf (alist-get "\\.pdf\\'" auto-mode-alist nil nil #'equal) | ||
2060 | #'pdf-view-mode) | ||
2057 | (pdf-tools-install)) | 2061 | (pdf-tools-install)) |
2058 | 2062 | ||
2059 | ;; (setup (:straight-when pdf-tools | ||
2060 | ;; ;; Ensure we can build `pdf-tools' | ||
2061 | ;; (or (executable-find "gcc") | ||
2062 | ;; (executable-find "g++"))) | ||
2063 | ;; (setf (alist-get "\\.pdf\\'" auto-mode-alist nil nil #'equal) | ||
2064 | ;; #'pdf-view-mode) | ||
2065 | ;; (pdf-tools-install t)) | ||
2066 | |||
2067 | (setup (:straight (plancat | 2063 | (setup (:straight (plancat |
2068 | :host github | 2064 | :host github |
2069 | :repo "duckwork/plancat.el" | 2065 | :repo "duckwork/plancat.el" |
@@ -2157,7 +2153,7 @@ See also `crux-reopen-as-root-mode'." | |||
2157 | (alert-add-rule :category "slack" | 2153 | (alert-add-rule :category "slack" |
2158 | :style 'ignore))) | 2154 | :style 'ignore))) |
2159 | 2155 | ||
2160 | (setup (:straight-when sly | 2156 | (setup (:straight sly |
2161 | (defvar +lisp-bin (executable-find "sbcl"))) | 2157 | (defvar +lisp-bin (executable-find "sbcl"))) |
2162 | (:also-load sly-autoloads | 2158 | (:also-load sly-autoloads |
2163 | +sly) | 2159 | +sly) |
@@ -2199,7 +2195,7 @@ See also `crux-reopen-as-root-mode'." | |||
2199 | (auto-save-visited-mode -1) | 2195 | (auto-save-visited-mode -1) |
2200 | (super-save-mode +1)) | 2196 | (super-save-mode +1)) |
2201 | 2197 | ||
2202 | (setup (:straight-when systemd | 2198 | (setup (:straight systemd |
2203 | (executable-find "systemd")) | 2199 | (executable-find "systemd")) |
2204 | (:option systemd-man-function 'woman)) | 2200 | (:option systemd-man-function 'woman)) |
2205 | 2201 | ||
@@ -2266,9 +2262,10 @@ See also `crux-reopen-as-root-mode'." | |||
2266 | (:require) | 2262 | (:require) |
2267 | (:hook-into text-mode prog-mode)) | 2263 | (:hook-into text-mode prog-mode)) |
2268 | 2264 | ||
2269 | (setup (:straight unfill)) ;; XXX: Is this necessary with changes to filldent? | 2265 | (setup (:straight unfill)) |
2270 | 2266 | ||
2271 | (setup (:straight valign) (:quit "Doesn't work with narrowed tables.") | 2267 | (setup (:straight valign |
2268 | :quit "Doesn't work with narrowed tables.") | ||
2272 | (:option valign-fancy-bar t) | 2269 | (:option valign-fancy-bar t) |
2273 | (:hook-into org-mode | 2270 | (:hook-into org-mode |
2274 | markdown-mode)) | 2271 | markdown-mode)) |
@@ -2322,21 +2319,22 @@ See also `crux-reopen-as-root-mode'." | |||
2322 | (setup (:straight vlf) | 2319 | (setup (:straight vlf) |
2323 | (:require vlf-setup)) | 2320 | (:require vlf-setup)) |
2324 | 2321 | ||
2322 | (setup (:straight vterm | ||
2323 | (and module-file-suffix | ||
2324 | (executable-find "cmake")) | ||
2325 | :quit) | ||
2326 | (:also-load +vterm) | ||
2327 | (:option vterm-always-compile-module t | ||
2328 | vterm-buffer-name-string "vterm: %s" | ||
2329 | vterm-max-scrollback 100000 ; max allowed by vterm-module.h | ||
2330 | ) | ||
2331 | (advice-add 'counsel-yank-pop-action :around | ||
2332 | #'+vterm-counsel-yank-pop-action)) | ||
2333 | |||
2325 | (setup (:straight (vundo | 2334 | (setup (:straight (vundo |
2326 | :host github | 2335 | :host github |
2327 | :repo "casouri/vundo"))) | 2336 | :repo "casouri/vundo"))) |
2328 | 2337 | ||
2329 | ;; (setup (:straight-when vterm | ||
2330 | ;; (and module-file-suffix | ||
2331 | ;; (executable-find "cmake"))) | ||
2332 | ;; (:also-load +vterm) | ||
2333 | ;; (:option vterm-always-compile-module t | ||
2334 | ;; vterm-buffer-name-string "vterm: %s" | ||
2335 | ;; vterm-max-scrollback 100000 ; max allowed by vterm-module.h | ||
2336 | ;; ) | ||
2337 | ;; (advice-add 'counsel-yank-pop-action :around | ||
2338 | ;; #'+vterm-counsel-yank-pop-action)) | ||
2339 | |||
2340 | (setup (:straight web-mode) | 2338 | (setup (:straight web-mode) |
2341 | (setf (alist-get (rx "." (or "htm" "html" "phtml" "tpl.php" | 2339 | (setf (alist-get (rx "." (or "htm" "html" "phtml" "tpl.php" |
2342 | "asp" "gsp" "jsp" "ascx" "aspx" | 2340 | "asp" "gsp" "jsp" "ascx" "aspx" |
diff --git a/lisp/+setup.el b/lisp/+setup.el index 02d2f09..db59223 100644 --- a/lisp/+setup.el +++ b/lisp/+setup.el | |||
@@ -23,6 +23,7 @@ | |||
23 | (require 'el-patch) | 23 | (require 'el-patch) |
24 | (require 'setup) | 24 | (require 'setup) |
25 | (require 'straight) | 25 | (require 'straight) |
26 | (require 'cl-lib) | ||
26 | 27 | ||
27 | (defun +setup-warn (message &rest args) | 28 | (defun +setup-warn (message &rest args) |
28 | "Warn the user that something bad happened in `setup'." | 29 | "Warn the user that something bad happened in `setup'." |
@@ -66,57 +67,93 @@ If PATH does not exist, abort the evaluation." | |||
66 | ;;; Straight.el | 67 | ;;; Straight.el |
67 | 68 | ||
68 | (with-eval-after-load 'straight | 69 | (with-eval-after-load 'straight |
69 | (setup-define :also-straight | 70 | (defun setup--straight-handle-arg (arg var) |
70 | (lambda (recipe) `(setup (:straight ,recipe))) | 71 | (cond |
71 | :documentation | 72 | ((and (boundp var) (symbol-value var)) t) |
72 | "Install RECIPE with `straight-use-package', after loading FEATURE." | 73 | ((keywordp arg) (set var t)) |
73 | :repeatable t | 74 | ((functionp arg) (set var nil) (funcall arg)) |
74 | :after-loaded t) | 75 | ((listp arg) (set var nil) (eval arg :lexical)))) |
75 | |||
76 | (defun +setup-straight-shorthand (sexp) | ||
77 | "Shorthand for `:straight' and other local macros." | ||
78 | (let ((recipe (cadr sexp))) | ||
79 | (or (car-safe recipe) recipe))) | ||
80 | 76 | ||
81 | (setup-define :straight | 77 | (setup-define :straight |
82 | (lambda (recipe) | 78 | (lambda (recipe &rest predicates) |
83 | `(unless (ignore-errors (straight-use-package ',recipe) t) | 79 | (let* ((skp (make-symbol "straight-keyword-p")) |
84 | (+setup-warn ":straight error: %S" ',recipe) | 80 | (straight-use-p |
85 | ,(setup-quit))) | 81 | (cl-every (lambda (f) (setup--straight-handle-arg f skp)) |
86 | :documentation | 82 | predicates)) |
87 | "Install RECIPE with `straight-use-package'. | 83 | (form `(unless (and ,straight-use-p |
88 | This macro can be used as HEAD, and will replace itself with the | 84 | (condition-case e |
89 | first RECIPE's package." | 85 | (straight-use-package ',recipe) |
90 | :repeatable t | 86 | (error |
91 | :shorthand #'+setup-straight-shorthand) | 87 | (+setup-warn ":straight error: %S" |
92 | 88 | ',recipe) | |
93 | (setup-define :straight-after | 89 | ,(setup-quit)) |
94 | (lambda (recipe feature) | 90 | (:success t))) |
95 | `(with-eval-after-load ,feature | 91 | (defun setup--straight-handle-arg (arg var) |
96 | (setup (:straight ,recipe)))) | 92 | (cond |
97 | :indent 1 | 93 | ((and (boundp var) (symbol-value var)) t) |
98 | :documentation | 94 | ((keywordp arg) (set var t)) |
99 | "Install RECIPE with `straight-use-package', after FEATURE. | 95 | ((functionp arg) (set var nil) (funcall arg)) |
100 | This macro can be used as HEAD, and will replace itself with the | 96 | ((listp arg) (set var nil) (eval arg :lexical)))) |
101 | first RECIPE's package." | 97 | |
102 | :shorthand #'+setup-straight-shorthand) | 98 | (setup-define :straight |
103 | 99 | (lambda (recipe &rest predicates) | |
104 | (setup-define :straight-when | 100 | (let* ((skp (make-symbol "straight-keyword-p")) |
105 | (lambda (recipe condition) | 101 | (straight-use-p |
106 | `(if ,condition | 102 | (cl-every (lambda (f) (setup--straight-handle-arg f skp)) |
107 | (unless (ignore-errors (straight-use-package ',recipe) t) | 103 | predicates)) |
108 | (+setup-warn ":straight error: %S" ',recipe) | 104 | (form `(unless (and ,straight-use-p |
109 | ,(setup-quit)) | 105 | (condition-case e |
110 | (message "Setup: :straight-when returned nil %S" ',recipe) | 106 | (straight-use-package ',recipe) |
111 | ,(setup-quit))) | 107 | (error |
112 | :documentation | 108 | (+setup-warn ":straight error: %S" |
113 | "Install RECIPE with `straight-use-package' when CONDITION is met. | 109 | ',recipe) |
114 | If CONDITION is false, or if `straight-use-package' fails, stop | 110 | ,(setup-quit)) |
115 | evaluating the body. This macro can be used as HEAD, and will | 111 | (:success t))) |
116 | replace itself with the RECIPE's package." | 112 | ,(setup-quit)))) |
117 | :repeatable 2 | 113 | ;; Keyword arguments --- :quit is special and should short-circuit |
114 | (if (memq :quit predicates) | ||
115 | (setq form `,(setup-quit)) | ||
116 | ;; Otherwise, handle the rest of them ... | ||
117 | (when-let ((after (cadr (memq :after predicates)))) | ||
118 | (setq form `(with-eval-after-load ,(if (eq after t) | ||
119 | (setup-get 'feature) | ||
120 | after) | ||
121 | ,form)))) | ||
122 | ;; Finally ... | ||
123 | form)) | ||
124 | :documentation "Install RECIPE with `straight-use-package'. | ||
125 | If PREDICATES are given, only install RECIPE if all of them return non-nil. | ||
126 | The following keyword arguments are also recognized: | ||
127 | - :quit --- immediately stop evaluating. Good for commenting. | ||
128 | - :after FEATURE --- only install RECIPE after FEATURE is loaded. | ||
129 | If FEATURE is t, install RECIPE after the current feature." | ||
130 | :repeatable nil | ||
131 | :indent 1 | ||
132 | :shorthand (lambda (sexp) | ||
133 | (let ((recipe (cadr sexp))) | ||
134 | (or (car-safe recipe) recipe)))) ,(setup-quit)))) | ||
135 | ;; Keyword arguments --- :quit is special and should short-circuit | ||
136 | (if (memq :quit predicates) | ||
137 | (setq form `,(setup-quit)) | ||
138 | ;; Otherwise, handle the rest of them ... | ||
139 | (when-let ((after (cadr (memq :after predicates)))) | ||
140 | (setq form `(with-eval-after-load ,(if (eq after t) | ||
141 | (setup-get 'feature) | ||
142 | after) | ||
143 | ,form)))) | ||
144 | ;; Finally ... | ||
145 | form)) | ||
146 | :documentation "Install RECIPE with `straight-use-package'. | ||
147 | If PREDICATES are given, only install RECIPE if all of them return non-nil. | ||
148 | The following keyword arguments are also recognized: | ||
149 | - :quit --- immediately stop evaluating. Good for commenting. | ||
150 | - :after FEATURE --- only install RECIPE after FEATURE is loaded. | ||
151 | If FEATURE is t, install RECIPE after the current feature." | ||
152 | :repeatable nil | ||
118 | :indent 1 | 153 | :indent 1 |
119 | :shorthand #'+setup-straight-shorthand)) | 154 | :shorthand (lambda (sexp) |
155 | (let ((recipe (cadr sexp))) | ||
156 | (or (car-safe recipe) recipe))))) | ||
120 | 157 | ||
121 | 158 | ||
122 | ;;; Redefines of `setup' forms | 159 | ;;; Redefines of `setup' forms |