]> git.eshelyaron.com Git - emacs.git/commitdiff
Stop `use-package-report` from displaying an empty buffer
authorStefan Kangas <stefankangas@gmail.com>
Sat, 12 Aug 2023 10:43:19 +0000 (12:43 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Sat, 12 Aug 2023 10:43:19 +0000 (12:43 +0200)
* 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.

lisp/use-package/use-package-core.el

index 21a831ce26d1bd7635d6ff5e764d97a2105de1e0..34c45b7aec305716feba9964d353c5bce85b4c90 100644 (file)
@@ -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)