Subject: Re: bug#54084: 28.0.91; Regression: can't create empty image buffer

From: Eli Zaretskii <[email-masked]>
Date: Mon, 21 Feb 2022 14:57:48 +0200

> From: Corwin Brust <[email-masked]>
> Date: Mon, 21 Feb 2022 02:21:32 -0600
> 
> Under Emacs -Q
> 
> 1. switch to a new buffer, e.g. C-x b *foo* RET
> 2. M-x image-mode RET
> 3. Insert the following text and press C-c C-c
> 
> <svg width="400" height="400">
>   <rect x="100" y="100" width="200" height="100"
>         fill="none" stroke="blue" stroke-width="2"/>
> </svg>
> 
> In Emacs 27.2 the outline of a rectangle is displayed as an image.
> 
> In Emacs 28.0.91 an error is emitted at step 2:
> 
> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
>   image-mode()
>   funcall-interactively(image-mode)
>   command-execute(image-mode record)
>   execute-extended-command(nil "image-mode" "image-mod")
>   funcall-interactively(execute-extended-command nil "image-mode" "image-mod")
>   command-execute(execute-extended-command)

It's a feature, see bug#16062.  (It misfired when the empty buffer
wasn't visiting a file, but I've now fixed that on the release
branch.)

> Furthermore, inserting the text and pressing C-c C-c will do nothing
> because the error interrupts the mode activation. (A subsequent M-x
> image-mode RET after pasting in the snippet works.)
> 
> Ergo, it is not possible to create an empty buffer in image-mode, as
> was possible in Emacs 27.2 and before.

You are supposed to insert the data, and then turn on image-mode.  We
don't support image-mode in empty buffers, because that makes it
impossible to detect the image type, and thus leads to complications
down the road.

Thanks.