From 0e0cc7d498b212ac95f832820be426ea37fc3d85 Mon Sep 17 00:00:00 2001 From: ema2159 Date: Tue, 21 May 2019 16:03:46 -0600 Subject: [PATCH] Added new init info functionality --- README.org | 5 +++++ dashboard-widgets.el | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.org b/README.org index 2256dc2c..7b8b4ec7 100644 --- a/README.org +++ b/README.org @@ -96,6 +96,11 @@ To add icons to the widget headings and their items: (setq dashboard-set-file-icons t) #+END_SRC +To show info about the packages loaded and the init time: +#+BEGIN_SRC elisp + (setq dashboard-set-init-info t) +#+END_SRC + ** Org mode’s agenda To display today’s agenda items on the dashboard, add ~agenda~ to ~dashboard-items~: diff --git a/dashboard-widgets.el b/dashboard-widgets.el index a1913ddf..d0f12c7f 100644 --- a/dashboard-widgets.el +++ b/dashboard-widgets.el @@ -55,6 +55,10 @@ to the specified width, with aspect ratio preserved." :type 'boolean :group 'dashboard) +(defcustom dashboard-set-init-info t + "When non nil, init info will be displayed under banner." + :type 'boolean + :group 'dashboard) (defcustom dashboard-show-shortcuts t "Whether to show shortcut keys for each section." @@ -80,6 +84,10 @@ to the specified width, with aspect ratio preserved." (defvar dashboard-banner-logo-title "Welcome to Emacs!" "Specify the startup banner.") +(defvar dashboard-init-info (format "%d packages loaded in %s" + (length package-activated-list) (emacs-init-time)) + "Init info with packages loaded and init time.") + (defvar dashboard-startup-banner 'official "Specify the startup banner. Default value is `official', it displays @@ -230,7 +238,12 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer." (when title (insert (make-string (max 0 (floor (/ (- dashboard-banner-length (+ (length title) 1)) 2))) ?\ )) - (insert (format "%s\n\n" (propertize title 'face 'dashboard-banner-logo-title))))))) + (insert (format "%s\n\n" (propertize title 'face 'dashboard-banner-logo-title)))) + (when dashboard-set-init-info + (insert (make-string (max 0 (floor (/ (- dashboard-banner-length + (+ (length dashboard-init-info) 1)) 2))) ?\ )) + (insert (concat + (propertize dashboard-init-info 'face 'font-lock-comment-face))))))) (defun dashboard-get-banner-path (index) "Return the full path to banner with index INDEX."