Fix icons.el when icon does not exist as a file

* lisp/emacs-lisp/icons.el (icons--create): Handle the case when
ICON is a file that doesn't exists or is unreadable.  Suggested by
David Ponce <da_vid@orange.fr>.  (Bug#66846)
This commit is contained in:
Eli Zaretskii 2024-01-06 13:26:29 +02:00
parent 2a861124e8
commit 466d1c98a9

View file

@ -187,11 +187,13 @@ present if the icon is represented by an image."
merged)
(cl-defmethod icons--create ((_type (eql 'image)) icon keywords)
(let ((file (if (file-name-absolute-p icon)
icon
(and (fboundp 'image-search-load-path)
(image-search-load-path icon)))))
(and (display-images-p)
(let* ((file (if (file-name-absolute-p icon)
icon
(and (fboundp 'image-search-load-path)
(image-search-load-path icon))))
(file-exists (and (stringp file) (file-readable-p file))))
(and file-exists
(display-images-p)
(fboundp 'image-supported-file-p)
(image-supported-file-p file)
(propertize