Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add the navigator below the banner with the customized buttons. #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ To modify heading icons with another icon from all-the-icons octicons:
(bookmarks . "book")))
#+END_SRC

To show navigator below the banner:
#+BEGIN_SRC emacs-lisp
(setq dashboard-set-navigator t)
#+END_SRC

To customize the buttons of the navigator like this:
#+BEGIN_SRC emacs-lisp
;; Format: "icon title help action face prefix suffix"
(setq dashboard-navigator-buttons
`((,(all-the-icons-octicon "mark-github" :height 1.1 :v-adjust 0.0)
"Homepage"
"Browse homepage"
(lambda (&rest _) (browse-url "homepage")))
("★" "Star" "Show stars" (lambda (&rest _) (show-stars)) 'warning)
("?" "Help" "?/h" #'show-help nil "<" ">")))
#+END_SRC

To show info about the packages loaded and the init time:
#+BEGIN_SRC elisp
(setq dashboard-set-init-info t)
Expand Down
54 changes: 53 additions & 1 deletion dashboard-widgets.el
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ to the specified width, with aspect ratio preserved."
:type 'boolean
:group 'dashboard)

(defcustom dashboard-set-navigator nil
"When non nil, a navigator will be displayed under the banner."
:type 'boolean
:group 'dashboard)

(defcustom dashboard-set-init-info t
"When non nil, init info will be displayed under banner."
"When non nil, init info will be displayed under the banner."
:type 'boolean
:group 'dashboard)

Expand Down Expand Up @@ -88,6 +93,13 @@ to the specified width, with aspect ratio preserved."
(defvar dashboard-banner-logo-title "Welcome to Emacs!"
"Specify the startup banner.")

(defvar dashboard-navigator-buttons nil
"Specify the navigator buttons.
The format is: 'icon title help action face prefix suffix'.

Example:
'((\"☆\" \"Star\" \"Show stars\" (lambda (&rest _) (show-stars)) 'warning \"[\" \"]\"))")

(defvar dashboard-init-info
;; Check if package.el was loaded and if package loading was enabled
(if (bound-and-true-p package-enable-at-startup)
Expand Down Expand Up @@ -176,6 +188,11 @@ If nil it is disabled. Possible values for list-type are:
"Face used for the banner title."
:group 'dashboard)

(defface dashboard-navigator
'((t (:inherit font-lock-keyword-face)))
"Face used for the havigator."
:group 'dashboard)

(defface dashboard-heading
'((t (:inherit font-lock-keyword-face)))
"Face used for widget headings."
Expand Down Expand Up @@ -365,8 +382,43 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer."
(if (image-type-available-p (intern (file-name-extension banner)))
(dashboard-insert-image-banner banner)
(dashboard-insert-ascii-banner-centered banner))
(dashboard-insert-navigator)
(dashboard-insert-init-info)))))

(defun dashboard-insert-navigator ()
"Insert Navigator of the dashboard."
(when (and dashboard-set-navigator dashboard-navigator-buttons)
(dolist (btn dashboard-navigator-buttons)
(let* ((icon (car btn))
(title (or (cadr btn) ""))
(help (or (cadr (cdr btn)) ""))
(action (or (cadr (cddr btn)) #'ignore))
(face (or (cadr (cddr (cdr btn))) 'dashboard-navigator))
(prefix (or (cadr (cddr (cddr btn))) (propertize "[" 'face face)))
(suffix (or (cadr (cddr (cddr (cdr btn)))) (propertize "]" 'face face))))
(widget-create 'item
:tag (concat
(when icon
(concat
(propertize icon 'face `(:inherit
,(get-text-property 0 'face icon)
:inherit
,face))
(propertize " " 'face 'variable-pitch)))
(propertize title 'face face))
:help-echo help
:action action
:mouse-face 'highlight
:button-prefix prefix
:button-suffix suffix
:format "%[%t%]")
(insert " ")))
(let* ((width (current-column)))
(beginning-of-line)
(dashboard-center-line (make-string width ?\s))
(end-of-line))
(insert "\n\n")))

(defmacro dashboard-insert-section (section-name list list-size shortcut action &rest widget-params)
"Add a section with SECTION-NAME and LIST of LIST-SIZE items to the dashboard.
SHORTCUT is the keyboard shortcut used to access the section.
Expand Down