From: Stefan Kangas Date: Sat, 12 Aug 2023 10:43:19 +0000 (+0200) Subject: Stop `use-package-report` from displaying an empty buffer X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a4171e94667eb9e75053e77c092cdd57a0377bc0;p=emacs.git Stop `use-package-report` from displaying an empty buffer * lisp/use-package/use-package-core.el (use-package-report): Signal user-error if there are no statistics to display, instead of showing an empty buffer. --- diff --git a/lisp/use-package/use-package-core.el b/lisp/use-package/use-package-core.el index 21a831ce26d..34c45b7aec3 100644 --- a/lisp/use-package/use-package-core.el +++ b/lisp/use-package/use-package-core.el @@ -1039,15 +1039,23 @@ meaning: Configured :config has been processed (the package is loaded!) Initialized :init has been processed (load status unknown) Prefaced :preface has been processed - Declared the use-package declaration was seen" + Declared the use-package declaration was seen + +Customize the user option `use-package-compute-statistics' to +enable gathering statistics." (interactive) - (with-current-buffer (get-buffer-create "*use-package statistics*") - (setq tabulated-list-entries - (mapcar #'use-package-statistics-convert - (hash-table-keys use-package-statistics))) - (use-package-statistics-mode) - (tabulated-list-print) - (display-buffer (current-buffer)))) + (let ((statistics (hash-table-keys use-package-statistics))) + (unless statistics + (if use-package-compute-statistics + (user-error "No use-package statistics available") + (user-error (concat "Customize `use-package-compute-statistics'" + " to enable reporting")))) + (with-current-buffer (get-buffer-create "*use-package statistics*") + (setq tabulated-list-entries + (mapcar #'use-package-statistics-convert statistics)) + (use-package-statistics-mode) + (tabulated-list-print) + (display-buffer (current-buffer))))) (defvar use-package-statistics-status-order '(("Declared" . 0)