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

Skip to content

Make icon display predicate customizeable #442

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
Mar 12, 2023
Merged
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
21 changes: 18 additions & 3 deletions dashboard-widgets.el
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,23 @@ Example:
:type 'string
:group 'dashboard)

(defcustom dashboard-display-icons-p #'display-graphic-p
"Predicate to determine whether dashboard should show icons.
Can be nil to not show icons and any truthy value to show them. When set
to a function the result of the function will be interpreted as the
predicate value."
:type '(choice (function :tag "Predicate function")
(boolean :tag "Predicate value"))
:group 'dashboard)

(defun dashboard-display-icons-p ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document this function? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, just added a simple docstring.

"Assert whether to show icons based on the `dashboard-display-icons-p' variable."
(if (functionp dashboard-display-icons-p)
(funcall dashboard-display-icons-p)
dashboard-display-icons-p))

(defcustom dashboard-footer-icon
(if (and (display-graphic-p)
(if (and (dashboard-display-icons-p)
(or (fboundp 'all-the-icons-fileicon)
(require 'all-the-icons nil 'noerror)))
(all-the-icons-fileicon "emacs"
Expand Down Expand Up @@ -459,7 +474,7 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer."

(defun dashboard-insert-heading (heading &optional shortcut)
"Insert a widget HEADING in dashboard buffer, adding SHORTCUT if provided."
(when (and (display-graphic-p) dashboard-set-heading-icons)
(when (and (dashboard-display-icons-p) dashboard-set-heading-icons)
;; Try loading `all-the-icons'
(unless (or (fboundp 'all-the-icons-octicon)
(require 'all-the-icons nil 'noerror))
Expand Down Expand Up @@ -729,7 +744,7 @@ to widget creation."
(let ((tag ,@rest))
(insert "\n ")

(when (and (display-graphic-p)
(when (and (dashboard-display-icons-p)
dashboard-set-file-icons
(or (fboundp 'all-the-icons-icon-for-dir)
(require 'all-the-icons nil 'noerror)))
Expand Down