summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2017-12-04 10:29:27 -0800
committerJohn Wiegley <johnw@newartisans.com>2017-12-04 10:29:27 -0800
commit026433a8a03133b76f1d9db9d9a7b250a5d28a13 (patch)
tree8b26181ccf09c5edd7b8df6b1c842d0097969c9b
parentfb9d1596326cf2d1c4472eabb36f50d40ca37cfb (diff)
downloademacs-026433a8a0.tar.gz
Revert "Reduce some code duplication"
-rw-r--r--up-core.el26
-rw-r--r--up-ensure.el35
2 files changed, 35 insertions, 26 deletions
diff --git a/up-core.el b/up-core.el
index 6994c632ec0..6fc8ae5a7ef 100644
--- a/up-core.el
+++ b/up-core.el
@@ -273,16 +273,6 @@ Must be set before loading use-package."
"Report MSG as an error, so the user knows it came from this package."
(error "use-package: %s" msg))
-(defun use-package-hush (f body)
- (condition-case-unless-debug err
- (macroexp-progn body)
- (error
- (if (stringp f)
- (ignore (display-warning 'use-package
- (format f (error-message-string err))
- :error))
- (funcall f err)))))
-
(defsubst use-package-concat (&rest elems)
"Delete all empty lists from ELEMS (nil or (list nil)), and append them."
(apply #'append (delete nil (delete (list nil) elems))))
@@ -1307,6 +1297,11 @@ no keyword implies `:all'."
;;; The main macro
;;
+(defsubst use-package-hush (context body)
+ `((condition-case-unless-debug err
+ ,(macroexp-progn body)
+ (error (funcall ,context err)))))
+
(defun use-package-core (name args)
(let* ((context (gensym "use-package--warning"))
(args* (use-package-normalize-keywords name args))
@@ -1409,9 +1404,14 @@ this file. Usage:
(macroexp-progn
(if (eq use-package-verbose 'errors)
(use-package-core name args)
- (use-package-hush
- (format "Failed to parse package %s: %%s" name)
- '((use-package-core name args)))))))
+ (condition-case-unless-debug err
+ (use-package-core name args)
+ (error
+ (ignore
+ (display-warning
+ 'use-package
+ (format "Failed to parse package %s: %s"
+ name (error-message-string err)) :error))))))))
(put 'use-package 'lisp-indent-function 'defun)
diff --git a/up-ensure.el b/up-ensure.el
index cd6a8533992..fa19e1d5a8e 100644
--- a/up-ensure.el
+++ b/up-ensure.el
@@ -143,22 +143,31 @@ manually updated package."
"(an unquoted symbol name)")))))))
(defun use-package-ensure-elpa (name ensure state &optional no-refresh)
- (let ((package (or (and (eq ensure t) (use-package-as-symbol name))
- ensure)))
+ (let ((package
+ (or (and (eq ensure t) (use-package-as-symbol name))
+ ensure)))
(when package
(require 'package)
(unless (package-installed-p package)
- (use-package-hush
- (format "Failed to install %s: %%s" name)
- '((when (assoc package (bound-and-true-p package-pinned-packages))
- (package-read-all-archive-contents))
- (if (assoc package package-archive-contents)
- (package-install package)
- (package-refresh-contents)
- (when (assoc package (bound-and-true-p package-pinned-packages))
- (package-read-all-archive-contents))
- (package-install package))
- t))))))
+ (condition-case-unless-debug err
+ (progn
+ (when (assoc package (bound-and-true-p
+ package-pinned-packages))
+ (package-read-all-archive-contents))
+ (if (assoc package package-archive-contents)
+ (package-install package)
+ (package-refresh-contents)
+ (when (assoc package (bound-and-true-p
+ package-pinned-packages))
+ (package-read-all-archive-contents))
+ (package-install package))
+ t)
+ (error
+ (ignore
+ (display-warning 'use-package
+ (format "Failed to install %s: %s"
+ name (error-message-string err))
+ :error))))))))
(defun use-package-handler/:ensure (name keyword ensure rest state)
(let* ((body (use-package-process-keywords name rest state)))