"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))))
;;; 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))
(macroexp-progn
(if (eq use-package-verbose 'errors)
(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))))))))
+ (use-package-hush
+ (format "Failed to parse package %s: %%s" name)
+ '((use-package-core name args)))))))
(put 'use-package 'lisp-indent-function 'defun)
"(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)
- (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))))))))
+ (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))))))
(defun use-package-handler/:ensure (name keyword ensure rest state)
(let* ((body (use-package-process-keywords name rest state)))