Commit 22a46fff authored by steckerhalter's avatar steckerhalter

add advice to override use-package-always-ensure

parent f3ff315e
......@@ -5,6 +5,10 @@
If you are using [use-package](https://github.com/jwiegley/use-package) (which can help to simplify your .emacs) you can use the [quelpa](https://github.com/quelpa/quelpa) handler provided by `quelpa-use-package`.
## Installation
***Requirements**): Emacs 24.4
Assuming you have bootstrapped `quelpa`, install `quelpa-use-package` (which installs `use-package` as a dependency) and require the library:
```cl
......@@ -15,6 +19,8 @@ Assuming you have bootstrapped `quelpa`, install `quelpa-use-package` (which ins
(require 'quelpa-use-package)
```
## Usage
After that it is possible to call `use-package` with the `:quelpa` keyword:
```cl
......@@ -39,6 +45,8 @@ After that it is possible to call `use-package` with the `:quelpa` keyword:
:quelpa ((abc-mode :fetcher github :repo "mkjunker/abc-mode") :upgrade t))
```
### Conditional execution
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
......@@ -56,3 +64,19 @@ Likewise you can use `:requires` to make the installation depend on a feature be
:requires filenotify
:quelpa (magit-filenotify :fetcher github :repo "magit/magit-filenotify"))
```
### Overriding `use-package-always-ensure`
To install some packages with quelpa but use `use-package-always-ensure` to install all others from an ELPA repo `:ensure` needs to be disabled if the `:quelpa` keyword is found.
`quelpa-use-package` provides and advice for this purpose which can be activated thus:
```cl
(quelpa-use-package-activate-advice)
```
and to disable it again you can use:
```cl
(quelpa-use-package-deactivate-advice)
```
......@@ -5,7 +5,7 @@
;; Author: steckerhalter
;; URL: https://github.com/quelpa/quelpa-use-package
;; Version: 0.0.1
;; Package-Requires: ((quelpa "0") (use-package "2"))
;; Package-Requires: ((emacs "24.4") (quelpa "0") (use-package "2"))
;; Keywords: package management elpa use-package
;; This file is not part of GNU Emacs.
......@@ -33,7 +33,7 @@
;;; Requirements:
;; `quelpa' and `use-package'
;; Emacs 24.4, `quelpa' and `use-package'
;;; Code:
......@@ -75,6 +75,23 @@
body)
body)))
(defun quelpa-use-package-override-:ensure (func name-symbol keyword ensure rest state)
(let ((ensure (if (plist-member rest :quelpa)
nil
ensure)))
(funcall func name-symbol keyword ensure rest state)))
(defun quelpa-use-package-activate-advice ()
(advice-add
'use-package-handler/:ensure
:around
'quelpa-use-package-override-:ensure))
(defun quelpa-use-package-deactivate-advice ()
(advice-remove
'use-package-handler/:ensure
'quelpa-use-package-override-:ensure))
;; 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