Report errors during deferred :config as intelligent warnings also

This commit is contained in:
John Wiegley 2017-12-03 13:12:43 -08:00
parent 8dd0f274d0
commit 8428dafcfa

View file

@ -245,6 +245,8 @@ Must be set before loading use-package."
(font-lock-add-keywords 'emacs-lisp-mode use-package-font-lock-keywords) (font-lock-add-keywords 'emacs-lisp-mode use-package-font-lock-keywords)
(defvar use-package--hush-function)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;;; Utility functions ;;; Utility functions
@ -1113,8 +1115,8 @@ deferred until the prefix key sequence is pressed."
',(use-package-as-symbol name) nil t))) ',(use-package-as-symbol name) nil t)))
(if (or (not arg) (null body)) (if (or (not arg) (null body))
body body
(list (use-package-require-after-load `((eval-after-load ',name
name (macroexp-progn body))))))) ',(funcall use-package--hush-function body)))))))
;;;; :after ;;;; :after
@ -1321,37 +1323,44 @@ no keyword implies `:all'."
;;; The main macro ;;; The main macro
;; ;;
(defun use-package-core (name args) (defun use-package-hush (name args args* expanded body)
(let ((orig-args (cl-copy-list args))) `(condition-case-unless-debug err
(setq args (use-package-normalize-keywords name args)) ,(macroexp-progn body)
(let ((body (macroexp-progn (error
(use-package-process-keywords name args (let ((msg (format "%s: %s" ',name (error-message-string err))))
(and (plist-get args :demand) ,(when (eq use-package-verbose 'debug)
(list :demand t)))))) `(progn
(if use-package-expand-minimally (setq msg (concat msg " (see the *use-package* buffer)"))
body (with-current-buffer (get-buffer-create "*use-package*")
`(condition-case-unless-debug err (goto-char (point-max))
,body (insert "-----\n" msg
(error ,(concat
(let ((msg (format "%s: %s" ',name (error-message-string err)))) "\n\n"
(when (eq use-package-verbose 'debug) (pp-to-string `(use-package ,name ,@args))
(setq msg (concat msg " (see the *use-package* buffer)"))
(with-current-buffer (get-buffer-create "*use-package*")
(goto-char (point-max))
(insert "-----\n" msg "\n\n"
(pp-to-string ',`(use-package ,name ,@orig-args))
"\n -->\n\n" "\n -->\n\n"
(pp-to-string ',`(use-package ,name ,@args)) (pp-to-string `(use-package ,name ,@args*))
"\n ==>\n\n" "\n ==>\n\n"
(pp-to-string (pp-to-string (macroexp-progn expanded))))
',(let ((use-package-verbose 'errors) (emacs-lisp-mode))))
(use-package-expand-minimally t)) (ignore (display-warning 'use-package msg :error))))))
(macroexp-progn
(use-package-process-keywords name args (defun use-package-core (name args)
(and (plist-get args :demand) (let* ((args* (use-package-normalize-keywords name args))
(list :demand t))))))) (use-package--hush-function
(emacs-lisp-mode))) (if use-package-expand-minimally
(ignore (display-warning 'use-package msg :error))))))))) #'macroexp-progn
(let ((use-package--hush-function #'macroexp-progn))
(apply-partially
#'use-package-hush name args args*
(let ((use-package-verbose 'errors)
(use-package-expand-minimally t))
(use-package-process-keywords name args*
(and (plist-get args* :demand)
(list :demand t)))))))))
(funcall use-package--hush-function
(use-package-process-keywords name args*
(and (plist-get args* :demand)
(list :demand t))))))
;;;###autoload ;;;###autoload
(defmacro use-package (name &rest args) (defmacro use-package (name &rest args)