From cb9d91d65c07ea775ce027bc25b6fe13348afb38 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 20 Mar 2017 16:54:35 -0400 Subject: [PATCH] Move bootstrap lib into core-lib --- core/autoload/bootstrap.el | 46 -------------------------------------- core/core-lib.el | 46 +++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 47 deletions(-) delete mode 100644 core/autoload/bootstrap.el diff --git a/core/autoload/bootstrap.el b/core/autoload/bootstrap.el deleted file mode 100644 index 7422ccbe0..000000000 --- a/core/autoload/bootstrap.el +++ /dev/null @@ -1,46 +0,0 @@ -;;; ../core/autoload/bootstrap.el - -(defvar doom-bootstraps nil - "TODO") - -;;;###autoload -(defmacro def-bootstrap! (name &rest forms) - (declare (indent defun)) - `(push (cons ',name - (lambda () - (cl-flet ((sh (lambda (&rest args) (apply 'doom-sh args))) - (sh& (lambda (&rest args) (apply 'doom-async-sh args))) - (sudo (lambda (&rest args) (apply 'doom-sudo args))) - (fetch (lambda (&rest args) (apply 'doom-fetch args))) - (message (lambda (&rest args) - (apply 'message (format "[%s] %s" ,(symbol-name name) (car args)) - (cdr args))))) - (with-demoted-errors "BOOTSTRAP ERROR: %s" - ,@forms)))) - doom-bootstraps)) - -;;;###autoload -(defun doom/bootstrap (ids) - "Bootstraps a module, if it has a bootstrapper. Bootstraps are expected to be -recipes for setting up the external dependencies of a module by, for instance, -using the OS package manager to install them, or retrieving them from a repo -using `doom-fetch'." - (interactive - (list (list (completing-read "Bootstrap: " (mapcar 'car doom-bootstraps) nil t)))) - (doom-initialize-packages t) - ;; Error out if any of the bootstraps don't exist or aren't valid functions. - ;; If something goes wrong, it's likely we don't want to continue. - (let ((err-not-found (cl-remove-if (lambda (id) (assq id doom-bootstraps)) ids)) - (err-not-func (cl-remove-if (lambda (id) (functionp (cdr (assq id doom-bootstraps)))) ids))) - (when (or (and err-not-found - (message "ERROR: These bootstraps don't exist: %s" err-not-found)) - (and err-not-func - (message "ERROR: These bootstraps were invalid: %s" err-not-func))) - (error "There were errors. Aborting."))) - (dolist (id ids) - (let ((bootstrap (assq id doom-bootstraps))) - (message "[%s] BOOTSTRAP START" id) - (with-demoted-errors (format "[%s] ERROR: %%s" id) - (unless (funcall (cdr bootstrap)) - (message "[%s] DONE (already bootstrapped)" id)))))) - diff --git a/core/core-lib.el b/core/core-lib.el index d28973085..396faa6d3 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -211,7 +211,6 @@ Body forms can access the hook's arguments through the let-bound variable ;; concise, do-what-I-mean front-facing configuration, believe it or not. ;; ;; Plus, it can benefit from byte-compilation. - (defmacro def-setting! (keyword arglist &optional docstring &rest forms) "Define a setting macro. Like `defmacro', this should return a form to be executed when called with `set!'. FORMS are not evaluated until `set!' calls it." @@ -233,5 +232,50 @@ executed when called with `set!'. FORMS are not evaluated until `set!' calls it. (when doom-debug-mode (message "No setting found for %s" keyword))))) + +;; Provides a means of installing external dependencies. +(defvar doom-bootstraps nil + "TODO") + +(defmacro def-bootstrap! (name &rest forms) + "TODO" + (declare (indent defun)) + `(push (cons ',name + (lambda () + (cl-flet ((sh (lambda (&rest args) (apply 'doom-sh args))) + (sh& (lambda (&rest args) (apply 'doom-async-sh args))) + (sudo (lambda (&rest args) (apply 'doom-sudo args))) + (fetch (lambda (&rest args) (apply 'doom-fetch args))) + (message (lambda (&rest args) + (apply 'message (format "[%s] %s" ,(symbol-name name) (car args)) + (cdr args))))) + ,@forms))) + doom-bootstraps)) + +(defun doom/bootstrap (ids) + "Bootstraps a module, if it has a bootstrapper. Bootstraps are expected to be +recipes for setting up the external dependencies of a module by, for instance, +using the OS package manager to install them, or retrieving them from a repo +using `doom-fetch'." + (interactive + (list (list (completing-read "Bootstrap: " (mapcar 'car doom-bootstraps) nil t)))) + (doom-initialize-packages t) + ;; Error out if any of the bootstraps don't exist or aren't valid functions. + ;; If something goes wrong, it's likely we don't want to continue. + (let ((err-not-found (cl-remove-if (lambda (id) (assq id doom-bootstraps)) ids)) + (err-not-func (cl-remove-if (lambda (id) (functionp (cdr (assq id doom-bootstraps)))) ids)) + (debug-on-error t)) + (when (or (and err-not-found + (message "ERROR: These bootstraps don't exist: %s" err-not-found)) + (and err-not-func + (message "ERROR: These bootstraps were invalid: %s" err-not-func))) + (error "There were errors. Aborting.")) + (dolist (id ids) + (let ((bootstrap (assq id doom-bootstraps))) + (message "[%s] BOOTSTRAP START" id) + (with-demoted-errors (format "[%s] ERROR: %%s" id) + (unless (funcall (cdr bootstrap)) + (message "[%s] DONE (already bootstrapped)" id))))))) + (provide 'core-lib) ;;; core-lib.el ends here