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

Skip to content

Allow section headings to be customized #316

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 4 commits into from
Jul 18, 2021
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
7 changes: 7 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ To add your own custom widget is pretty easy, define your widget's callback func
(add-to-list 'dashboard-items '(custom) t)
#+END_SRC

To modify the widget heading name:
#+BEGIN_SRC elisp
(setq dashboard-item-names '(("Recent Files:" . "Recently opened files:")
("Agenda for today:" . "Today's agenda:")
("Agenda for the coming week:" . "Agenda:"))
#+END_SRC

To add icons to the widget headings and their items:
#+BEGIN_SRC elisp
(setq dashboard-set-heading-icons t)
Expand Down
22 changes: 22 additions & 0 deletions dashboard-widgets.el
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,18 @@ value is nil, that item's shortcut is disbaled. See
:type '(repeat (alist :key-type symbol :value-type string))
:group 'dashboard)

(defcustom dashboard-item-names nil
"Association list of item heading names.
When an item is nil or not present, the default name is used.
Will be of the form `(default-name . new-name)'.
Possible values for default-name are:
\"Recent Files:\" \"Bookmarks:\" \"Agenda for today:\",
\"Agenda for the coming week:\" \"Registers:\" \"Projects:\"."
:type '(alist :key-type string :value-type string)
:options '("Recent Files:" "Bookmarks:" "Agenda for today:"
"Agenda for the coming week:" "Registers:" "Projects:")
:group 'dashboard)

(defcustom dashboard-items-default-length 20
"Length used for startup lists with otherwise unspecified bounds.
Set to nil for unbounded."
Expand Down Expand Up @@ -438,6 +450,16 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer."
(insert " "))

(insert (propertize heading 'face 'dashboard-heading))

;; Turn the inserted heading into an overlay, so that we may freely change
;; its name without breaking any of the functions that expect the default name.
;; If there isn't a suitable entry in `dashboard-item-names',
;; we fallback to using HEADING. In that case we still want it to be an
;; overlay to maintain consistent behavior (such as the point movement)
;; between modified and default headings.
(let ((ov (make-overlay (- (point) (length heading)) (point) nil t)))
(overlay-put ov 'display (or (cdr (assoc heading dashboard-item-names)) heading))
(overlay-put ov 'face 'dashboard-heading))
(when shortcut (insert (format " (%s)" shortcut))))

(defun dashboard-center-line (string)
Expand Down