summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2015-03-18 20:56:45 -0500
committerJohn Wiegley <johnw@newartisans.com>2015-03-18 20:56:45 -0500
commit2778e85a39bd111ac884fd11bf1b41fd80288a06 (patch)
tree2c4c323c86e2888bece2b30f782dcf6b971eb273
parent19ab94cf39809dc1aebce053962930b6c6ab6c4d (diff)
downloademacs-2778e85a39.tar.gz
macroexpand nested uses of use-package in :init and :config
-rw-r--r--lisp/use-package/use-package.el45
1 files changed, 42 insertions, 3 deletions
diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el
index 4d30ffe3ca3..d352afd7581 100644
--- a/lisp/use-package/use-package.el
+++ b/lisp/use-package/use-package.el
@@ -105,8 +105,43 @@ then your byte-compiled init file is as minimal as possible."
:type 'boolean
:group 'use-package)
-(eval-when-compile
- (defvar use-package-expand-minimally))
+(defvar use-package-extra-keywords nil
+ "A list of extra keywords to be accepted in the use-package form.")
+
+(defconst use-package-phases
+ '(setup-load-path
+ pre-compile-load
+ preface
+ setup-autoloads
+ register-load-on-idle
+ declare-functions
+ init
+ register-eval-after-load
+ deferred-config
+ package-load
+ config
+ wrapup)
+ "A list of phases that capture the sequence of `use-package'.
+This is used by `use-package-add-keywords' in order to register
+new keywords, and to specify when their handler should be
+called.
+Each phase registers a `before-' and `after-' counterpart, so
+that you can register new keywords as follows:
+
+ (use-package-add-keywords :ensure 'after-preface)
+
+Which is identical to saying:
+
+ (use-package-add-keywords :ensure 'before-setup-autoloads)
+
+The reason for duplicating the sequence points with redundant
+before and after monikers is to make keyword-adding resilient to
+the creation of new phases in future.")
+
+(defun use-package-add-keywords (&rest args)
+ (let ((keywords (cl-remove-if #'(lambda (x) (not (keywordp args)))))
+ (phases (cl-remove-if #'(lambda (x) (keywordp args))))))
+ )
(defun use-package-progn (body)
(if (= (length body) 1)
@@ -183,7 +218,11 @@ ARGS is a list of forms, so `((foo))' if only `foo' is being called."
"Given a list of forms, return it wrapped in `progn'."
(unless (listp (car args))
(use-package-error (concat label " wants a sexp or list of sexps")))
- args)
+ (mapcar #'(lambda (form)
+ (if (and (consp form)
+ (eq (car form) 'use-package))
+ (macroexpand form)
+ form)) args))
(defsubst use-package-normalize-value (label arg)
"Normalize a value."