Change `:straight-if` to `:straight-when`

`:straight-when` is a more accurate representation of what it's doing.  I also
found out that I could change its indentation, which I did.
This commit is contained in:
Case Duckworth 2021-10-05 14:22:18 -05:00
parent 24fee83cc0
commit 66ecd92944
3 changed files with 66 additions and 63 deletions

124
init.el
View File

@ -974,18 +974,18 @@ specific to most general, they are these:
:repo "willvaughn/emacs-0x0")) :repo "willvaughn/emacs-0x0"))
(:option 0x0-default-server 'ttm)) (:option 0x0-default-server 'ttm))
(setup (:straight-if affe (setup (:straight-when affe
(and (or (executable-find "fd") (and (or (executable-find "fd")
(executable-find "find")) (executable-find "find"))
(executable-find "rg"))) (executable-find "rg")))
;; Keys are bound in `acdw/sensible-grep' and `acdw/sensible-find' ;; Keys are bound in `acdw/sensible-grep' and `acdw/sensible-find'
(:option affe-regexp-compiler (:option affe-regexp-compiler
(defun affe-orderless-regexp-compiler (input _type) (defun affe-orderless-regexp-compiler (input _type)
(setq input (orderless-pattern-compiler input)) (setq input (orderless-pattern-compiler input))
(cons input (lambda (str) (orderless--highlight input str)))))) (cons input (lambda (str) (orderless--highlight input str))))))
(setup (:straight-if ahk-mode (setup (:straight-when ahk-mode
(acdw/system :work))) (acdw/system :work)))
(setup (:straight alert) (setup (:straight alert)
(:option alert-default-style (acdw/system (:option alert-default-style (acdw/system
@ -1221,10 +1221,10 @@ specific to most general, they are these:
(crux-reopen-as-root-mode +1)) (crux-reopen-as-root-mode +1))
(setup (:straight-if (define-repeat-map (setup (:straight-when (define-repeat-map
:host nil :host nil
:repo "https://tildegit.org/acdw/define-repeat-map.el") :repo "https://tildegit.org/acdw/define-repeat-map.el")
(acdw/system :home)) (acdw/system :home))
(require 'define-repeat-map ; just for me (require 'define-repeat-map ; just for me
(acdw/dir (acdw/dir
@ -1448,8 +1448,8 @@ specific to most general, they are these:
(add-hook hook #'epithet-rename-buffer))) (add-hook hook #'epithet-rename-buffer)))
;; TODO: look into emms or something related for this ;; TODO: look into emms or something related for this
(setup (:straight-if eradio (setup (:straight-when eradio
(executable-find "mpv")) (executable-find "mpv"))
(:option (:option
eradio-player '("mpv" "--no-video" "--no-terminal") eradio-player '("mpv" "--no-video" "--no-terminal")
eradio-channels `(("KLSU" . eradio-channels `(("KLSU" .
@ -1491,16 +1491,16 @@ specific to most general, they are these:
(:hook-into emacs-lisp-mode (:hook-into emacs-lisp-mode
lisp-interaction-mode)) lisp-interaction-mode))
(setup (:straight-if exec-path-from-shell (setup (:straight-when exec-path-from-shell
(acdw/system :home)) (acdw/system :home))
(when (daemonp) (when (daemonp)
(exec-path-from-shell-initialize))) (exec-path-from-shell-initialize)))
(setup (:straight expand-region) (setup (:straight expand-region)
(:global "C-=" #'er/expand-region)) (:global "C-=" #'er/expand-region))
(setup (:straight-if fennel-mode (setup (:straight-when fennel-mode
(executable-find "fennel")) (executable-find "fennel"))
(:autoload (fennel-repl :interactive t)) (:autoload (fennel-repl :interactive t))
(:file-match (rx ".fnl" eos))) (:file-match (rx ".fnl" eos)))
@ -1517,8 +1517,8 @@ specific to most general, they are these:
(flyspell-correct-move 0 :forward :rapid)))) (flyspell-correct-move 0 :forward :rapid))))
(:unbind "C-;" "C-," "C-." "C-M-i"))) (:unbind "C-;" "C-," "C-." "C-M-i")))
(setup (:straight-if forge (setup (:straight-when forge
(acdw/system :home)) (acdw/system :home))
;; make sure to read Info manual with Forge (and Ghub) for setup ;; make sure to read Info manual with Forge (and Ghub) for setup
;; instructions. ;; instructions.
(with-eval-after-load 'magit (with-eval-after-load 'magit
@ -1531,26 +1531,26 @@ specific to most general, they are these:
(:option gcmh-idle-delay 'auto) (:option gcmh-idle-delay 'auto)
(gcmh-mode +1)) (gcmh-mode +1))
(setup (:straight-if geiser (setup (:straight-when geiser
(progn (progn
(defvar acdw/schemes (defvar acdw/schemes
(let (schemes) (let (schemes)
(dolist (scheme '(("scheme" . geiser-chez) ; chez (dolist (scheme '(("scheme" . geiser-chez) ; chez
("petite" . geiser-chez) ; petite ("petite" . geiser-chez) ; petite
("csi" . geiser-chez) ; chicken ("csi" . geiser-chez) ; chicken
("gsi" . geiser-gambit) ("gsi" . geiser-gambit)
("gosh" . geiser-gauche) ("gosh" . geiser-gauche)
("guile" . geiser-guile) ("guile" . geiser-guile)
("kawa" . geiser-kawa) ("kawa" . geiser-kawa)
("mit-scheme" . geiser-mit) ("mit-scheme" . geiser-mit)
("racket" . geiser-racket) ("racket" . geiser-racket)
("stklos" . geiser-stklos))) ("stklos" . geiser-stklos)))
(when-let (binary (executable-find (car scheme))) (when-let (binary (executable-find (car scheme)))
(push binary schemes) (push binary schemes)
;; and install the proper helper package ;; and install the proper helper package
(straight-use-package (cdr scheme)))) (straight-use-package (cdr scheme))))
(nreverse schemes))) (nreverse schemes)))
acdw/schemes)) acdw/schemes))
(:file-match (rx ".rkt" eos) (:file-match (rx ".rkt" eos)
(rx ".scm" eos))) (rx ".scm" eos)))
@ -1637,8 +1637,8 @@ specific to most general, they are these:
(setup (:straight lacarte) (setup (:straight lacarte)
(:global "<f10>" #'lacarte-execute-menu-command)) (:global "<f10>" #'lacarte-execute-menu-command))
(setup (:straight-if ledger-mode (setup (:straight-when ledger-mode
(executable-find "ledger"))) (executable-find "ledger")))
(setup (:straight link-hint) (setup (:straight link-hint)
;; Browse web URLs with a browser with a prefix argument. ;; Browse web URLs with a browser with a prefix argument.
@ -2110,10 +2110,10 @@ the default is \"/\"."
lisp-interaction-mode lisp-interaction-mode
scheme-mode)) scheme-mode))
(setup (:straight-if (pdf-tools (setup (:straight-when (pdf-tools
:host github :host github
:repo "vedang/pdf-tools") :repo "vedang/pdf-tools")
(acdw/system :home)) (acdw/system :home))
(:file-match (rx ".pdf" eos)) (:file-match (rx ".pdf" eos))
(pdf-loader-install)) (pdf-loader-install))
@ -2200,16 +2200,16 @@ the default is \"/\"."
(simple-modeline-mode +1)) (simple-modeline-mode +1))
(setup (:straight-if sly (setup (:straight-when sly
(progn (progn
(defvar acdw/lisps (defvar acdw/lisps
(let (lisps) (let (lisps)
(dolist (lisp '("sbcl" ; TODO: add more lisps (dolist (lisp '("sbcl" ; TODO: add more lisps
"clisp")) "clisp"))
(when-let (binary (executable-find lisp)) (when-let (binary (executable-find lisp))
(push binary lisps))) (push binary lisps)))
(nreverse lisps))) (nreverse lisps)))
acdw/lisps)) acdw/lisps))
(:also-load sly-autoloads) (:also-load sly-autoloads)
(:straight clhs) (:straight clhs)
@ -2289,8 +2289,8 @@ the default is \"/\"."
(auto-save-visited-mode -1) (auto-save-visited-mode -1)
(super-save-mode +1)) (super-save-mode +1))
(setup (:straight-if systemd (setup (:straight-when systemd
(executable-find "systemd"))) (executable-find "systemd")))
(setup (:straight (topsy (setup (:straight (topsy
:host github :host github
@ -2404,8 +2404,8 @@ If used with a numeric prefix argument N, N backticks will be inserted."
(setup (:straight visual-regexp) (setup (:straight visual-regexp)
(:global "M-%" #'vr/query-replace)) (:global "M-%" #'vr/query-replace))
(setup (:straight-if vterm (setup (:straight-when vterm
(acdw/system :home)) (acdw/system :home))
(:straight (eshell-vterm (:straight (eshell-vterm
:host github :host github
:repo "iostapyshyn/eshell-vterm")) :repo "iostapyshyn/eshell-vterm"))
@ -2461,11 +2461,13 @@ If used with a numeric prefix argument N, N backticks will be inserted."
(setup (:straight xr)) (setup (:straight xr))
(setup (:straight-if ytel (setup (:straight-when ytel
(executable-find "mpv")) (executable-find "mpv"))
(:also-load acdw-ytel)
;; This might need to be changed depending on whether the instance goes down. ;; This might need to be changed depending on whether the instance goes down.
(:option ytel-invidious-api-url "https://invidious.snopyta.org") (:option ytel-invidious-api-url "https://invidious.snopyta.org")
(:bind "v" #'acdw/ytel-current-video-link (:hook #'hl-line-mode)
(:bind "v" #'acdw/ytel-watch
"w" #'acdw/ytel-copy-link)) "w" #'acdw/ytel-copy-link))
(setup (:straight zzz-to-char) (setup (:straight zzz-to-char)

View File

@ -72,7 +72,7 @@ first RECIPE's package."
(car recipe) (car recipe)
recipe)))) recipe))))
(setup-define :straight-if (setup-define :straight-when
(lambda (recipe condition) (lambda (recipe condition)
`(if ,condition `(if ,condition
(straight-use-package ',recipe) (straight-use-package ',recipe)
@ -83,6 +83,7 @@ If CONDITION is false, stop evaluating the body. This macro can
be used as HEAD, and will replace itself with the RECIPE's be used as HEAD, and will replace itself with the RECIPE's
package. This macro is not repeatable." package. This macro is not repeatable."
:repeatable nil :repeatable nil
:indent 1
:shorthand (lambda (sexp) :shorthand (lambda (sexp)
(let ((recipe (cadr sexp))) (let ((recipe (cadr sexp)))
(if (consp recipe) (car recipe) recipe)))) (if (consp recipe) (car recipe) recipe))))

View File

@ -352,7 +352,7 @@ In short, DO NOT USE THIS FUNCTION!!!"
(cond (cond
;; Straight forms require some weirdness ;; Straight forms require some weirdness
((and s1-straight s2-straight) ((and s1-straight s2-straight)
(let* ((r (rx ":straight" (? "-if") (* space) (? "("))) (let* ((r (rx ":straight" (? "-when") (* space) (? "(")))
(s1 (replace-regexp-in-string r "" s1)) (s1 (replace-regexp-in-string r "" s1))
(s2 (replace-regexp-in-string r "" s2))) (s2 (replace-regexp-in-string r "" s2)))
(string< s1 s2))) (string< s1 s2)))