From 26ba0d89edfe047dd69985c7164c9082e733fabc Mon Sep 17 00:00:00 2001 From: Jason Dufair Date: Thu, 28 Feb 2019 08:04:13 -0500 Subject: [PATCH 1/6] Add shortcut indicators to sections --- README.org | 3 +++ dashboard-widgets.el | 9 +++++---- dashboard.el | 5 +++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index 4a05761e..974bf306 100644 --- a/README.org +++ b/README.org @@ -66,6 +66,9 @@ To update the banner or banner title ;; Content is not centered by default. To center, set (setq dashboard-center-content t) + +;; To show shortcut "jump" indicators for each section, set +(setq dashboard-show-shortcuts t) #+END_SRC To customize which widgets are displayed, you can use the following snippet diff --git a/dashboard-widgets.el b/dashboard-widgets.el index df5b8990..67c21038 100644 --- a/dashboard-widgets.el +++ b/dashboard-widgets.el @@ -155,9 +155,10 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer." "Insert a page break line in dashboard buffer." (dashboard-append dashboard-page-separator)) -(defun dashboard-insert-heading (heading) - "Insert a widget HEADING in dashboard buffer." - (insert (propertize heading 'face 'dashboard-heading-face))) +(defun dashboard-insert-heading (heading &optional shortcut) + "Insert a widget HEADING in dashboard buffer, adding SHORTCUT if provided." + (insert (propertize heading 'face 'dashboard-heading-face)) + (if shortcut (insert (format " (%s)" shortcut)))) ;; ;; BANNER @@ -272,7 +273,7 @@ SHORTCUT is the keyboard shortcut used to access the section. ACTION is theaction taken when the user activates the widget button. WIDGET-PARAMS are passed to the \"widget-create\" function." `(progn - (dashboard-insert-heading ,section-name) + (dashboard-insert-heading ,section-name (if dashboard-show-shortcuts ,shortcut)) (when (dashboard-insert-section-list ,section-name (dashboard-subseq ,list 0 list-size) diff --git a/dashboard.el b/dashboard.el index 4ef94345..dde70913 100644 --- a/dashboard.el +++ b/dashboard.el @@ -67,6 +67,11 @@ :type 'boolean :group 'dashboard) +(defcustom dashboard-show-shortcuts nil + "Whether to show shortcut keys for each section." + :type 'boolean + :group 'dashboard) + (defconst dashboard-buffer-name "*dashboard*" "Dashboard's buffer name.") From caf15331ef1a9e5e7797ae297d880bce28fc5381 Mon Sep 17 00:00:00 2001 From: Jason Dufair Date: Thu, 28 Feb 2019 08:18:41 -0500 Subject: [PATCH 2/6] Satisfy linter --- dashboard-widgets.el | 1 + 1 file changed, 1 insertion(+) diff --git a/dashboard-widgets.el b/dashboard-widgets.el index 67c21038..193ab6c0 100644 --- a/dashboard-widgets.el +++ b/dashboard-widgets.el @@ -273,6 +273,7 @@ SHORTCUT is the keyboard shortcut used to access the section. ACTION is theaction taken when the user activates the widget button. WIDGET-PARAMS are passed to the \"widget-create\" function." `(progn + (eval-when-compile (defvar dashboard-show-shortcuts)) (dashboard-insert-heading ,section-name (if dashboard-show-shortcuts ,shortcut)) (when (dashboard-insert-section-list ,section-name From 595b23e1ef436b4cdc4e1934c13e036ec6b7207d Mon Sep 17 00:00:00 2001 From: Jason Dufair Date: Thu, 28 Feb 2019 15:48:22 -0500 Subject: [PATCH 3/6] Move defcustom to widgets file --- dashboard-widgets.el | 6 +++++- dashboard.el | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dashboard-widgets.el b/dashboard-widgets.el index 193ab6c0..fdcb7011 100644 --- a/dashboard-widgets.el +++ b/dashboard-widgets.el @@ -44,6 +44,11 @@ to the specified width, with aspect ratio preserved." :type 'integer :group 'dashboard) +(defcustom dashboard-show-shortcuts nil + "Whether to show shortcut keys for each section." + :type 'boolean + :group 'dashboard) + (defconst dashboard-banners-directory (concat (file-name-directory (locate-library "dashboard")) @@ -273,7 +278,6 @@ SHORTCUT is the keyboard shortcut used to access the section. ACTION is theaction taken when the user activates the widget button. WIDGET-PARAMS are passed to the \"widget-create\" function." `(progn - (eval-when-compile (defvar dashboard-show-shortcuts)) (dashboard-insert-heading ,section-name (if dashboard-show-shortcuts ,shortcut)) (when (dashboard-insert-section-list ,section-name diff --git a/dashboard.el b/dashboard.el index dde70913..4ef94345 100644 --- a/dashboard.el +++ b/dashboard.el @@ -67,11 +67,6 @@ :type 'boolean :group 'dashboard) -(defcustom dashboard-show-shortcuts nil - "Whether to show shortcut keys for each section." - :type 'boolean - :group 'dashboard) - (defconst dashboard-buffer-name "*dashboard*" "Dashboard's buffer name.") From 6d2e267e5686b32857a34d03a6162bde75703774 Mon Sep 17 00:00:00 2001 From: Jason Dufair Date: Thu, 28 Feb 2019 21:46:30 -0500 Subject: [PATCH 4/6] Default showing shortcuts to t --- dashboard-widgets.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashboard-widgets.el b/dashboard-widgets.el index fdcb7011..c5e28317 100644 --- a/dashboard-widgets.el +++ b/dashboard-widgets.el @@ -44,7 +44,7 @@ to the specified width, with aspect ratio preserved." :type 'integer :group 'dashboard) -(defcustom dashboard-show-shortcuts nil +(defcustom dashboard-show-shortcuts t "Whether to show shortcut keys for each section." :type 'boolean :group 'dashboard) From a28f0aee7e0472aaf424063e9dfd97a7a588f19a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Mart=C3=ADnez?= Date: Fri, 1 Mar 2019 08:40:14 -0500 Subject: [PATCH 5/6] Apply suggestions from code review Update docs to reflect jump indicators are enabled by default Co-Authored-By: jkdufair --- README.org | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 974bf306..2dc31fb4 100644 --- a/README.org +++ b/README.org @@ -67,8 +67,8 @@ To update the banner or banner title ;; Content is not centered by default. To center, set (setq dashboard-center-content t) -;; To show shortcut "jump" indicators for each section, set -(setq dashboard-show-shortcuts t) +;; To disable shortcut "jump" indicators for each section, set +(setq dashboard-show-shortcuts nil) #+END_SRC To customize which widgets are displayed, you can use the following snippet From 790085b0147bb958ed720ddeccd158971185b2d4 Mon Sep 17 00:00:00 2001 From: Jason Dufair Date: Fri, 1 Mar 2019 09:23:18 -0500 Subject: [PATCH 6/6] Don't show indicator if section is empty --- dashboard-widgets.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dashboard-widgets.el b/dashboard-widgets.el index c5e28317..63b8e9b8 100644 --- a/dashboard-widgets.el +++ b/dashboard-widgets.el @@ -278,7 +278,8 @@ SHORTCUT is the keyboard shortcut used to access the section. ACTION is theaction taken when the user activates the widget button. WIDGET-PARAMS are passed to the \"widget-create\" function." `(progn - (dashboard-insert-heading ,section-name (if dashboard-show-shortcuts ,shortcut)) + (dashboard-insert-heading ,section-name + (if (and ,list dashboard-show-shortcuts) ,shortcut)) (when (dashboard-insert-section-list ,section-name (dashboard-subseq ,list 0 list-size)