From bcf56eff2122f582fb4116b7c00f7754d94bbad7 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 6 May 2022 10:20:36 -0500 Subject: Remove redundancy --- lisp/+setup.el | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) (limited to 'lisp/+setup.el') diff --git a/lisp/+setup.el b/lisp/+setup.el index db59223..194baa8 100644 --- a/lisp/+setup.el +++ b/lisp/+setup.el @@ -88,50 +88,7 @@ If PATH does not exist, abort the evaluation." ',recipe) ,(setup-quit)) (:success t))) -(defun setup--straight-handle-arg (arg var) - (cond - ((and (boundp var) (symbol-value var)) t) - ((keywordp arg) (set var t)) - ((functionp arg) (set var nil) (funcall arg)) - ((listp arg) (set var nil) (eval arg :lexical)))) - -(setup-define :straight - (lambda (recipe &rest predicates) - (let* ((skp (make-symbol "straight-keyword-p")) - (straight-use-p - (cl-every (lambda (f) (setup--straight-handle-arg f skp)) - predicates)) - (form `(unless (and ,straight-use-p - (condition-case e - (straight-use-package ',recipe) - (error - (+setup-warn ":straight error: %S" - ',recipe) - ,(setup-quit)) - (:success t))) - ,(setup-quit)))) - ;; Keyword arguments --- :quit is special and should short-circuit - (if (memq :quit predicates) - (setq form `,(setup-quit)) - ;; Otherwise, handle the rest of them ... - (when-let ((after (cadr (memq :after predicates)))) - (setq form `(with-eval-after-load ,(if (eq after t) - (setup-get 'feature) - after) - ,form)))) - ;; Finally ... - form)) - :documentation "Install RECIPE with `straight-use-package'. -If PREDICATES are given, only install RECIPE if all of them return non-nil. -The following keyword arguments are also recognized: -- :quit --- immediately stop evaluating. Good for commenting. -- :after FEATURE --- only install RECIPE after FEATURE is loaded. - If FEATURE is t, install RECIPE after the current feature." - :repeatable nil - :indent 1 - :shorthand (lambda (sexp) - (let ((recipe (cadr sexp))) - (or (car-safe recipe) recipe)))) ,(setup-quit)))) + ,(setup-quit)))) ;; Keyword arguments --- :quit is special and should short-circuit (if (memq :quit predicates) (setq form `,(setup-quit)) -- cgit 1.4.1-21-gabe81 From 144e5244d2076eac0e0216a0b09f39a21a9c8dbf Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 6 May 2022 10:20:46 -0500 Subject: Demote errors more better-er --- lisp/+setup.el | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'lisp/+setup.el') diff --git a/lisp/+setup.el b/lisp/+setup.el index 194baa8..d5a3a77 100644 --- a/lisp/+setup.el +++ b/lisp/+setup.el @@ -29,23 +29,37 @@ "Warn the user that something bad happened in `setup'." (display-warning 'setup (format message args))) +(defun +setup-wrap-to-demote-errors (body name) + "Wrap BODY in a `with-demoted-errors' block. +This behavior is prevented if `setup-attributes' contains the +symbol `without-error-demotion'. + +This function differs from `setup-wrap-to-demote-errors' in that +it includes the NAME of the setup form in the warning output." + (if (memq 'without-error-demotion setup-attributes) + body + `(with-demoted-errors ,(format "Error in setup form on line %d (%s): %%S" + (line-number-at-pos) + name) + ,body))) + (setup-define :quit 'setup-quit :documentation "Quit the current `setup' form. Good for commenting.") (setup-define :face - (lambda (face spec) - `(custom-set-faces (list ,face ,spec 'now "Customized by `setup'."))) + (lambda (face spec) + `(custom-set-faces (list ,face ,spec 'now "Customized by `setup'."))) :documentation "Customize FACE with SPEC using `custom-set-faces'." :repeatable t) (setup-define :load-after - (lambda (&rest features) - (let ((body `(require ',(setup-get 'feature)))) - (dolist (feature (nreverse features)) - (setq body `(with-eval-after-load ',feature ,body))) - body)) + (lambda (&rest features) + (let ((body `(require ',(setup-get 'feature)))) + (dolist (feature (nreverse features)) + (setq body `(with-eval-after-load ',feature ,body))) + body)) :documentation "Load the current feature after FEATURES.") (setup-define :load-from -- cgit 1.4.1-21-gabe81 From a8e71fa8c7be3840ce7063e3c09dc51f7119308c Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 6 May 2022 10:21:02 -0500 Subject: Add straight :needs --- lisp/+setup.el | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lisp/+setup.el') diff --git a/lisp/+setup.el b/lisp/+setup.el index d5a3a77..919e312 100644 --- a/lisp/+setup.el +++ b/lisp/+setup.el @@ -126,6 +126,13 @@ The following keyword arguments are also recognized: (let ((recipe (cadr sexp))) (or (car-safe recipe) recipe))))) +(setup-define :needs + (lambda (executable) + `(unless (executable-find ,executable) + ,(setup-quit))) + :documentation "If EXECUTABLE is not in the path, stop here." + :repeatable 1) + ;;; Redefines of `setup' forms -- cgit 1.4.1-21-gabe81