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

Skip to content

Restore Emacs 26 support #409

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 1 commit into from
Nov 17, 2022
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
11 changes: 9 additions & 2 deletions dashboard-widgets.el
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,13 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer."
"Return the full path to banner with index INDEX."
(concat dashboard-banners-directory (format "%d.txt" index)))

(defun dashboard--image-supported-p (img)
"Return non-nil if IMG exists and is a supported image type."
;; In Emacs 29.1 we could use `image-supported-file-p'. However:
;; - We need to support Emacs 26.
;; - That function will only look at filenames, this one will inspect the file data itself.
(and (file-exists-p img) (ignore-errors (image-type-available-p (image-type img)))))

(defun dashboard-choose-banner ()
"Return a plist specifying the chosen banner based on `dashboard-startup-banner'."
(pcase dashboard-startup-banner
Expand All @@ -539,14 +546,14 @@ If MESSAGEBUF is not nil then MSG is also written in message buffer."
dashboard-startup-banner
(message "could not find banner %s, use default instead" dashboard-startup-banner)
(dashboard-get-banner-path 1))))
((pred image-supported-file-p)
((pred dashboard--image-supported-p)
(list :image dashboard-startup-banner
:text (dashboard-get-banner-path 1)))
(_
(message "unsupported file type %s" (file-name-nondirectory dashboard-startup-banner))
(list :text (dashboard-get-banner-path 1)))))
(`(,img . ,txt)
(list :image (if (and (file-exists-p img) (image-supported-file-p img))
(list :image (if (dashboard--image-supported-p img)
img
(message "could not find banner %s, use default instead" img)
dashboard-banner-official-png)
Expand Down