From d2fb5b665b7e491f6f3c3c8418b75997f962e29c Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Wed, 27 Jan 2021 22:36:51 +0100 Subject: [PATCH] add use-package statistics and add it to dashboard --- settings/gui-settings.el | 22 ++++++++++++++++++++++ settings/pre-settings.el | 1 + 2 files changed, 23 insertions(+) diff --git a/settings/gui-settings.el b/settings/gui-settings.el index ecdc20f3..06a1a361 100644 --- a/settings/gui-settings.el +++ b/settings/gui-settings.el @@ -205,6 +205,28 @@ :load-path "lisp/dashboard" :delight (dashboard-mode "🅓") :config + ;; because we use `use-package' include `use-package-statistics' if computed + (defun my-dashboard-init-info () + (let ((package-count 0) (time (emacs-init-time))) + (when (bound-and-true-p package-alist) + (setq package-count (length package-activated-list))) + (when (boundp 'straight--profile-cache) + (setq package-count (+ (hash-table-size straight--profile-cache) package-count))) + ;; added case + (when use-package-compute-statistics + (setq package-count (+ (hash-table-size use-package-statistics) package-count))) + (if (zerop package-count) + (format "Emacs started in %s" time) + (format "%d packages loaded in %s" package-count time)))) + (setq dashboard-init-info (my-dashboard-init-info)) + ;; overwrite bc/ to recompute `dashboard-init-info' on refresh + (defun dashboard-insert-init-info () + "Insert init info when `dashboard-set-init-info' is t." + (when dashboard-set-init-info + (setq dashboard-init-info (my-dashboard-init-info)) ;; ADDED + (dashboard-center-line dashboard-init-info) + (insert (propertize dashboard-init-info 'face 'font-lock-comment-face)))) + "Init info with packages loaded and init time." (setq dashboard-startup-banner 'logo) (setq dashboard-set-navigator t) ;; (setq dashboard-navigator-buttons ;; Format: "(icon title help action face prefix suffix)" diff --git a/settings/pre-settings.el b/settings/pre-settings.el index 4b66adfe..5033a60f 100644 --- a/settings/pre-settings.el +++ b/settings/pre-settings.el @@ -24,6 +24,7 @@ (require 'use-package) ;; requires bind-key (setq use-package-verbose t) +(setq use-package-compute-statistics t) (use-package delight) ;; used for use-package :delight, see delight-delighted-modes ;;