From: Lars Ingebrigtsen Date: Thu, 20 Aug 2020 18:09:51 +0000 (+0200) Subject: Make image-mode give better feedback when the buffer is empty X-Git-Tag: emacs-28.0.90~6487 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ec990559180254c59d80308655b11df4223dd23d;p=emacs.git Make image-mode give better feedback when the buffer is empty * lisp/image-mode.el (image-mode): Give a less confusing message if we don't have any image data (bug#16062). Also leave the buffer in fundamental mode. --- diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 948e62e10d0..4c719f7cda2 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -612,6 +612,15 @@ Key bindings: (setq major-mode 'image-mode) (setq image-transform-resize image-auto-resize) + ;; 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)")) + (image-mode--display))) + +(defun image-mode--display () (if (not (image-get-display-property)) (progn (when (condition-case err