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

From: Eli Zaretskii <[email-masked]>
Date: Mon, 21 Feb 2022 16:00:12 +0200

[Please use Reply All, so that the bug tracker remains on the CC.]

> From: Corwin Brust <[email-masked]>
> Date: Mon, 21 Feb 2022 07:41:36 -0600
> 
> On Mon, Feb 21, 2022 at 6:57 AM Eli Zaretskii <[email-masked]> wrote:
> >
> > 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.)
> 
> Is there a way to disable this feature?

Why is that needed?  Turning on image-mode in an empty buffer is a
pretty strange thing to do, or at least a rare thing.

> In my case the image type won't change, I'd be fine hard-coding
> that.
> 
> >
> > 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.
> 
> I'm not sure how to avoid this error when I create a new buffer in a
> mode derived from image mode.

Can't you use ignore-errors?

> Is there an alternative you can recommend to creating my own
> "one-off" version of image mode and deriving from that?  In my case,
> I have created an SVG sketching mode and have been reusing,
> e.g. "canvas" resizing logic from image-mode for a couple of years
> without issue.
> 
> TIA for any hints.

How about delaying the mode switch until the user inserted something?