A friendlier error message from image-mode in an empty buffer

* lisp/image-mode.el (image-mode): Handle the case where the empty
buffer doesn't visit a file  (Bug#54084)
This commit is contained in:
Eli Zaretskii 2022-02-21 14:51:37 +02:00
parent b7a651ba37
commit b38223a844

View file

@ -621,9 +621,11 @@ Key bindings:
;; Bail out early if we have no image data.
(if (zerop (buffer-size))
(funcall (if (called-interactively-p 'any) 'error 'message)
(if (file-exists-p buffer-file-name)
"Empty file"
"(New file)"))
(if (stringp buffer-file-name)
(if (file-exists-p buffer-file-name)
"Empty file"
"(New file)")
"Empty buffer"))
(image-mode--display)))
(defun image-mode--display ()