summaryrefslogtreecommitdiff
path: root/lisp/use-package/use-package.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/use-package/use-package.el')
-rw-r--r--lisp/use-package/use-package.el108
1 files changed, 91 insertions, 17 deletions
diff --git a/lisp/use-package/use-package.el b/lisp/use-package/use-package.el
index 7b4fa7152fa..e8acf5271f2 100644
--- a/lisp/use-package/use-package.el
+++ b/lisp/use-package/use-package.el
@@ -123,7 +123,7 @@ become available:
`use-package--foo--pre-config-hook'
`use-package--foo--post-config-hook'
-This way, you can add to these hooks before evalaution of a
+This way, you can add to these hooks before evaluation of a
`use-package` declaration, and exercise some control over what
happens.
@@ -158,6 +158,8 @@ the user specified."
:defines
:functions
:defer
+ :custom
+ :custom-face
:init
:after
:demand
@@ -290,7 +292,7 @@ found."
"Attempt to find and jump to the `use-package' form that loaded
PACKAGE. This will only find the form if that form actually
required PACKAGE. If PACKAGE was previously required then this
-function will jump to the file that orginally required PACKAGE
+function will jump to the file that originally required PACKAGE
instead."
(interactive (list (completing-read "Package: " features)))
(let* ((package (if (stringp package) (intern package) package))
@@ -677,11 +679,12 @@ If the package is installed, its entry is removed from
use-package--deferred-packages)
(if packages
(list
- (completing-read
- "Select package: "
- packages
- nil
- 'require-match)
+ (intern
+ (completing-read
+ "Select package: "
+ packages
+ nil
+ 'require-match))
:interactive)
(user-error "No packages with deferred installation"))))
(let ((spec (gethash name use-package--deferred-packages)))
@@ -736,17 +739,21 @@ If the package is installed, its entry is removed from
;; bypassed.
(member context '(:byte-compile :ensure :config))
(y-or-n-p (format "Install package %S?" package))))
- (with-demoted-errors (format "Cannot load %s: %%S" name)
- (when (assoc package (bound-and-true-p package-pinned-packages))
- (package-read-all-archive-contents))
- (if (assoc package package-archive-contents)
- (progn (package-install package) t)
+ (condition-case-unless-debug err
(progn
- (package-refresh-contents)
- (when (assoc package (bound-and-true-p
- package-pinned-packages))
+ (when (assoc package (bound-and-true-p package-pinned-packages))
(package-read-all-archive-contents))
- (package-install package))))))))
+ (cond ((assoc package package-archive-contents)
+ (package-install package)
+ t)
+ (t
+ (package-refresh-contents)
+ (when (assoc package
+ (bound-and-true-p package-pinned-packages))
+ (package-read-all-archive-contents))
+ (package-install package))))
+ (error (message "Error: Cannot load %s: %S" name err)
+ nil))))))
(defun use-package-handler/:ensure (name keyword ensure rest state)
(let* ((body (use-package-process-keywords name rest
@@ -1401,6 +1408,69 @@ deferred until the prefix key sequence is pressed."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
+;;; :custom
+;;
+
+(defun use-package-normalize/:custom (name-symbol keyword args)
+ "Normalize use-package custom keyword."
+ (cond
+ ((and (= (length args) 1)
+ (listp (car args))
+ (listp (car (car args))))
+ (car args))
+ ((and (= (length args) 1)
+ (listp (car args)))
+ args)
+ (t
+ (use-package-error
+ (concat label " a (<symbol> <value> [comment])"
+ " or list of these")))))
+
+(defun use-package-handler/:custom (name keyword args rest state)
+ "Generate use-package custom keyword code."
+ (let ((body (use-package-process-keywords name rest state)))
+ (use-package-concat
+ (mapcar (lambda (def)
+ (let ((variable (nth 0 def))
+ (value (nth 1 def))
+ (comment (nth 2 def)))
+ (unless (and comment (stringp comment))
+ (setq comment (format "Customized with use-package %s" name)))
+ `(customize-set-variable (quote ,variable) ,value ,comment)))
+ args)
+ body)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; :custom-face
+;;
+
+(defun use-package-normalize/:custom-face (name-symbol keyword arg)
+ "Normalize use-package custom-face keyword."
+ (let ((error-msg (format "%s wants a (<symbol> <face-spec>) or list of these" name-symbol)))
+ (unless (listp arg)
+ (use-package-error error-msg))
+ (dolist (def arg arg)
+ (unless (listp def)
+ (use-package-error error-msg))
+ (let ((face (nth 0 def))
+ (spec (nth 1 def)))
+ (when (or (not face)
+ (not spec)
+ (> (length arg) 2))
+ (use-package-error error-msg))))))
+
+(defun use-package-handler/:custom-face (name keyword args rest state)
+ "Generate use-package custom-face keyword code."
+ (let ((body (use-package-process-keywords name rest state)))
+ (use-package-concat
+ (mapcar (lambda (def)
+ `(custom-set-faces (quote ,def)))
+ args)
+ body)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
;;; :diminish
;;
@@ -1409,10 +1479,12 @@ deferred until the prefix key sequence is pressed."
SYMBOL
(SYMBOL . STRING)"
(cond
+ ((not arg)
+ (list (use-package-as-mode name)))
((symbolp arg)
(list arg))
((stringp arg)
- (list (cons (intern (concat (use-package-as-string name) "-mode")) arg)))
+ (list (cons (use-package-as-mode name) arg)))
((and (consp arg) (stringp (cdr arg)))
(list arg))
((and (not recursed) (listp arg) (listp (cdr arg)))
@@ -1544,6 +1616,8 @@ this file. Usage:
:load-path Add to the `load-path' before attempting to load the package.
:diminish Support for diminish.el (if installed).
:delight Support for delight.el (if installed).
+:custom Call `customize-set-variable' with each variable definition.
+:custom-face Call `customize-set-faces' with each face definition.
:ensure Loads the package using package.el if necessary.
:pin Pin the package to an archive."
(declare (indent 1))