Subject: bug#71404: 30.0.50; [WISHLIST] string-edit-mode should allow changing major mode

From: Nicholas Vollmer <[email-masked]>
Date: Fri, 07 Jun 2024 19:37:24 -0400

Eli Zaretskii <[email-masked]> writes:

>> From: Nicholas Vollmer <[email-masked]>
>> Date: Thu, 06 Jun 2024 11:50:16 -0400
>> 
>> 
>> string-edit-mode is a nice feature to have built in.
>
> It already is?  Or what do you mean by "built in" here?

Correct. It is. I was just commenting that I'm glad to see it part 
of Emacs, rather than re-implemented over and over in third-party 
packages.
That is all.
 
>> It would be nice if one could change the major mode of the 
>> editing 
>> buffer while preserving the edit/abort functionality and any 
>> buffer state necessary to make those function.
>> Any reason it couldn't be implemented as a  minor mode?
>
> In what major modes will this make sense as a minor mode?

Many. For example. If the string to edit is an elisp form, why 
shouldn't the editing buffer be emacs-lisp-mode?
If the string to edit is a message which can be formatted with 
markdown, why not markdown-mode?
(I ran into this yesterday when implementing a command for 
personal use).
I can imagine many scenarios where the major mode could be 
something other than text-mode.
It seems to me that it would make more sense for the 
"abort/finish" key bindings to be bound to  a minor mode map so 
the editing buffer can be much more flexible.
 
> IOW, I don't think I understand what you mean by "preserving the
> edit/abort functionality and buffer state", so please elaborate.

The buffer has some local state (e.g. the abort callback function, 
header-line) stored in a buffer-local variables which are not 
preserved when the major mode is changed.