Commit c692284d authored by steckerhalter's avatar steckerhalter

make handler respect :if, :when, :unless and :requires, add doc

parent 8af1ae9f
......@@ -29,4 +29,20 @@ After that it is possible to call `use-package` with the `:quelpa` keyword:
(use-package abc-mode :quelpa ((abc-mode :fetcher github :repo "mkjunker/abc-mode") :upgrade t)) ;recipe with plist arguments
```
Note that that the `:quelpa` keyword is added right after `:disabled` so it has preference over any other `use-package` keyword (which makes kind of sense because to do something with a package you first need to have it installed :)
Note that the `:quelpa` keyword is inserted after `:if`, `:when`, `:unless` and `:requires` so that you can make the installation of a package depend on some requirement, for example:
```cl
(use-package magit-filenotify
:when (fboundp 'file-notify-add-watch)
:quelpa (magit-filenotify :fetcher github :repo "magit/magit-filenotify")
```
In this case `magit-filenotify` is only installed if the function `file-notify-add-watch` is bound.
Likewise you can use `:requires` to make the installation depend on a feature being available:
```cl
(use-package magit-filenotify
:requires filenotify
:quelpa (magit-filenotify :fetcher github :repo "magit/magit-filenotify"))
```
......@@ -43,11 +43,12 @@
(defvar quelpa-use-package-keyword :quelpa)
;; insert `:quelpa' keyword after `:disabled'
;; insert `:quelpa' keyword after `:requires' so that quelpa only runs
;; if either `:if', `:when', `:unless' or `:requires' are satisfied
(defun quelpa-use-package-set-keyword ()
(unless (member quelpa-use-package-keyword use-package-keywords)
(setq use-package-keywords
(let* ((pos (cl-position :disabled use-package-keywords))
(let* ((pos (cl-position :requires use-package-keywords))
(head (cl-subseq use-package-keywords 0 (+ 1 pos)))
(tail (nthcdr (+ 1 pos) use-package-keywords)))
(append head (list quelpa-use-package-keyword) tail)))))
......@@ -68,10 +69,11 @@
(let ((body (use-package-process-keywords name-symbol rest state)))
;; This happens at macro expansion time, not when the expanded code is
;; compiled or evaluated.
(when args
(quelpa-use-package-set-keyword)
(apply 'quelpa args))
body))
(if args
(use-package-concat
`((apply 'quelpa ',args))
body)
body)))
;; register keyword on require
(quelpa-use-package-set-keyword)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment