for use by extension packages, indicates keywords that, if used without
`:demand`, cause deferred loading (as if `:defer t` had been specified).
+- The `:ensure` keyword now accepts a specific pinning sub-keyword. For
+ example:
+
+ ``` elisp
+ (use-package foo
+ :pin "elpa")
+ ```
+
+ This ensure the package `foo` is installed from `"elpa"`.
+
+ ``` elisp
+ (use-package foo
+ :ensure bar
+ :ensure (quux :pin "melpa"))
+ ```
+
+ This says that `foo` ensures that `bar` is installed, as well as `quux` from
+ `"melpa"`. It does *not* ensure that `foo` is installed, because explicit
+ `:ensure` keywords were given.
+
- New `:hook` keyword.
- New `:catch` keyword. If `t` or `nil`, it enables (the default, see
t
(use-package-only-one (symbol-name keyword) args
#'(lambda (label arg)
- (cond
- ((symbolp arg)
- (list arg))
- ((and (listp arg) (cl-every #'symbolp arg))
- arg)
- (t
- (use-package-error
- (concat ":ensure wants an optional package name "
- "(an unquoted symbol name)"))))))))
+ (pcase arg
+ ((pred symbolp)
+ (list arg))
+ (`(,(and pkg (pred symbolp))
+ :pin ,(and repo (or (pred stringp)
+ (pred symbolp))))
+ (list (cons pkg repo)))
+ (_
+ (use-package-error
+ (concat ":ensure wants an optional package name "
+ "(an unquoted symbol name), or (<symbol> :pin <string>)"))))))))
(defun use-package-ensure-elpa (name args state &optional no-refresh)
(dolist (ensure args)
ensure)))
(when package
(require 'package)
+ (when (consp package)
+ (use-package-pin-package (car package) (cdr package))
+ (setq package (car package)))
(unless (package-installed-p package)
(condition-case-unless-debug err
(progn
(require 'foo nil nil)))))
(ert-deftest use-package-test/:ensure-14 ()
+ (match-expansion
+ (use-package ess-site
+ :ensure ess1
+ :ensure ess2
+ :ensure (ess3 :pin "melpa-unstable")
+ :pin melpa-stable)
+ `(progn
+ (use-package-pin-package 'ess-site "melpa-stable")
+ (use-package-ensure-elpa 'ess-site
+ '(ess1 ess2
+ (ess3 . "melpa-unstable"))
+ 'nil)
+ (require 'ess-site nil nil))))
+
+(ert-deftest use-package-test/:ensure-15 ()
(let ((use-package-always-ensure t))
(match-expansion
- (use-package foo :ensure bar :ensure (quux bow))
+ (use-package foo
+ :pin "elpa"
+ :ensure bar
+ :ensure (quux :pin "melpa"))
`(progn
- (use-package-ensure-elpa 'foo '(bar quux bow) 'nil)
+ (use-package-pin-package 'foo "elpa")
+ (use-package-ensure-elpa 'foo
+ '(bar
+ (quux . "melpa"))
+ 'nil)
(require 'foo nil nil)))))
(ert-deftest use-package-test/:if-1 ()
(bind-key "f" #'w3m-lnum-print-this-url w3m-y-prefix-map nil)
(bind-key "t" #'w3m-print-this-url w3m-y-prefix-map nil)))))
-(ert-deftest use-package-test/506 ()
- (match-expansion
- (use-package ess-site
- :ensure ess
- :pin melpa-stable)
- `(progn
- (use-package-pin-package 'ess-site "melpa-stable")
- (use-package-ensure-elpa 'ess-site
- '(ess)
- 'nil)
- (require 'ess-site nil nil))))
-
(ert-deftest use-package-test/538 ()
(match-expansion
(use-package mu4e
:config
(config))
`(progn
- (unless
- (fboundp 'mu4e)
+ (unless (fboundp 'mu4e)
(autoload #'mu4e "mu4e" nil t))
(eval-after-load 'mu4e
- '(progn
- (config)
- t))
+ '(progn (config) t))
(ignore
- (bind-keys :package mu4e
- ("<f9>" . mu4e))))))
+ (bind-keys :package mu4e ("<f9>" . mu4e))))))
;; Local Variables:
;; indent-tabs-mode: nil