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

View File

@ -72,7 +72,7 @@ first RECIPE's package."
(car recipe)
recipe))))
(setup-define :straight-if
(setup-define :straight-when
(lambda (recipe condition)
`(if ,condition
(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
package. This macro is not repeatable."
:repeatable nil
:indent 1
:shorthand (lambda (sexp)
(let ((recipe (cadr sexp)))
(if (consp recipe) (car recipe) recipe))))

View File

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