Re: "Buttons" in a message buffer that evaluate to plain text?

Michael Heerdegen via Users list for the GNU Emacs text editor <[email protected]>
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
Tim Landscheidt <[email protected]> writes:

> One minor flaw: Replacing the button's "label" (i. e., the
> text "[ ENTHALTUNG ]", etc.) will move point to either the
> beginning or the end of the replaced text.  Aside from
> replace-region-contents I also tried delete-char/insert with
> overwrite-mode set to 'overwrite-mode-textual, but the
> latter does not seem to have any effect to turn insert into
> a "replace".
>
> While I probably could do some arithmetics with point or
> mark myself

That's what I do (for point, I don't handle the mark).

> any (in my case hypothetical) marker would still be moved.
>
> How can I actually replace the character/text at point
> without deleting and inserting?

I dunno - maybe none?  `replace-region-contents' has been improved
recently, see bug#76313 for the discussion.  I have not investigated,
but I guess this question has been thought about.  If you are
interested, you could have a look at what other kinds of button
implementations do - the customize buttons and widgets for example.

Side note: there is the nontrivial case of point's old position being
outside the button when the new text is smaller than the replaced text.


Michael.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.