Only emit the debugging context text once

This commit is contained in:
John Wiegley 2017-12-03 22:54:34 -08:00
parent 35b975563c
commit f08f8a7ba9

View file

@ -1324,44 +1324,54 @@ no keyword implies `:all'."
;;; The main macro ;;; The main macro
;; ;;
(defun use-package-hush (name args args* expanded body) (defsubst use-package-hush (context body)
`((condition-case-unless-debug err `((condition-case-unless-debug err
,(macroexp-progn body) ,(macroexp-progn body)
(error (error (,context err)))))
(let ((msg (format "%s: %s" ',name (error-message-string err))))
,(when (eq use-package-verbose 'debug) (defun use-package-core (name args)
`(progn (let ((context (gensym "use-package--warning"))
(setq msg (concat msg " (see the *use-package* buffer)")) (args* (use-package-normalize-keywords name args))
(with-current-buffer (get-buffer-create "*use-package*") (use-package--hush-function #'identity))
(goto-char (point-max)) (if use-package-expand-minimally
(insert "-----\n" msg (funcall use-package--hush-function
(use-package-process-keywords name args*
(and (plist-get args* :demand)
(list :demand t))))
`((cl-flet
((,context
(err)
(let ((msg (format "%s: %s" ',name
(error-message-string err))))
,(when (eq use-package-verbose 'debug)
`(progn
(setq msg (concat msg " (see the *use-package* buffer)"))
(with-current-buffer (get-buffer-create "*use-package*")
(goto-char (point-max))
(insert
"-----\n" msg
,(concat ,(concat
"\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 `(use-package ,name ,@args*)) (pp-to-string `(use-package ,name ,@args*))
"\n ==>\n\n" "\n ==>\n\n"
(pp-to-string (macroexp-progn expanded)))) (pp-to-string
(emacs-lisp-mode)))) (macroexp-progn
(ignore (display-warning 'use-package msg :error))))))) (let ((use-package-verbose 'errors)
(use-package-expand-minimally t))
(defun use-package-core (name args) (use-package-process-keywords name args*
(let* ((args* (use-package-normalize-keywords name args)) (and (plist-get args* :demand)
(use-package--hush-function (list :demand t))))))))
(if use-package-expand-minimally (emacs-lisp-mode))))
#'identity (ignore (display-warning 'use-package msg :error)))))
(let ((use-package--hush-function #'identity)) ,(let ((use-package--hush-function
(apply-partially (apply-partially #'use-package-hush context)))
#'use-package-hush name args args* (macroexp-progn
(let ((use-package-verbose 'errors) (funcall use-package--hush-function
(use-package-expand-minimally t)) (use-package-process-keywords name args*
(use-package-process-keywords name args* (and (plist-get args* :demand)
(and (plist-get args* :demand) (list :demand t)))))))))))
(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)