From 0dec964d67eac8138c553b23a4273e343ba5f618 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 30 Aug 2021 22:17:09 -0500 Subject: Add `:straight-if' setup form --- init.el | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) (limited to 'init.el') diff --git a/init.el b/init.el index 3bec7f4..6f3ecb2 100644 --- a/init.el +++ b/init.el @@ -23,16 +23,35 @@ (require 'setup) (setup setup + ;; Install a package using `straight-use-package' (setup-define :straight (lambda (recipe) `(straight-use-package ',recipe)) - :documentation "Install RECIPE with `straight-use-package'." + :documentation + "Install RECIPE with `straight-use-package'. +This macro can be used as HEAD, and will replace itself with the +first RECIPE's package." :repeatable t :shorthand (lambda (sexp) (let ((recipe (cadr sexp))) (if (consp recipe) (car recipe) - recipe))))) + recipe)))) + ;; Install a package with straight, but only under a condition + (setup-define :straight-if + (lambda (recipe condition) + `(if ,condition + (straight-use-package ',recipe) + ,(setup-quit))) + :documentation + "Install RECIPE with `straight-use-package' when CONDITION is met. +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 + :shorthand (lambda (sexp) + (let ((recipe (cadr sexp))) + (if (consp recipe) (car recipe) recipe))))) ;;;; `no-littering' (setup (:straight no-littering) @@ -1362,8 +1381,8 @@ like a dumbass." (add-hook 'help-mode-hook #'epithet-rename-buffer) (add-hook 'occur-mode-hook #'epithet-rename-buffer)) -(setup (:straight eradio) - (:needs "mpv") +(setup (:straight-if eradio + (executable-find "mpv")) (:option eradio-player '("mpv" "--no-video" "--no-terminal") eradio-channels `(("KLSU" . @@ -1428,8 +1447,8 @@ successive invocations." (:global "C-=" er/expand-region "C-SPC" acdw/set-mark-or-expand-region)) -(setup (:straight fennel-mode) - (:needs "fennel") +(setup (:straight-if fennel-mode + (executable-find "fennel")) (autoload 'fennel-repl "fennel-mode" nil t) (add-to-list 'auto-mode-alist '("\\.fnl\\'" . fennel-mode))) @@ -1483,8 +1502,8 @@ successive invocations." (setup (:straight lacarte) (:global "" lacarte-execute-menu-command)) -(setup (:straight ledger-mode) - (:needs "ledger")) +(setup (:straight-if ledger-mode + (executable-find "ledger"))) (setup (:straight lua-mode) (add-to-list 'auto-mode-alist '("\\.lua\\'" . lua-mode))) @@ -1764,11 +1783,13 @@ successive invocations." (simple-modeline-mode +1)) -(setup (:straight sly) - (defvar acdw/lisp-bin (or (executable-find "sbcl") - (executable-find "clisp") - "")) - (:needs acdw/lisp-bin) +(setup (:straight-if sly + (progn (defvar acdw/lisp-bin + (or (executable-find "sbcl") + (executable-find "clisp") + "")) + (executable-find acdw/lisp-bin))) + (:option inferior-lisp-program acdw/lisp-bin sly-kill-without-query-p t) -- cgit 1.4.1-21-gabe81