From unknown Sat Aug 16 13:03:46 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#25355 <25355@debbugs.gnu.org> To: bug#25355 <25355@debbugs.gnu.org> Subject: Status: 26.0.50; Provide function to non-destructively replace buffer contents Reply-To: bug#25355 <25355@debbugs.gnu.org> Date: Sat, 16 Aug 2025 20:03:46 +0000 retitle 25355 26.0.50; Provide function to non-destructively replace buffer= contents reassign 25355 emacs submitter 25355 Philipp
There are many tools (e.g. auto-formatters) that take buffer contents,
reformat them, and write the reformatted output somewhere.=C2=A0 However, there is no good way how to apply the modified output to the source
buffer.=C2=A0 The naive way (erasing and re-inserting the buffer contents)<= br> loses point and markers.=C2=A0 Therefore there should be a function
(e.g. `replace-buffer-contents') that calculates a minimal diff between=
the old and the new contents and uses editing operations (insert,
delete, etc.) to apply the diff.=C2=A0 Ideally this would be done without a= ny
external tools (e.g. 'diff').
> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sun, 07 May 2017 17:44:27 +0000
>
> FYI, I've now implemented this based on libmba (http:= //www.ioplex.com/~miallen/libmba/). Unless there are
> concerns importing part of that library into the Emacs source tree, I&= #39;ll send a patch.
I'm not sure I understand what you mean by "importing part of that=
library".=C2=A0 Are you going to ask the author to sign legal papers assigning copyright to the FSF?
P.S. Doesn't GNU Diff have code to do this?=C2=A0
> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sun, 07 May 2017 18:21:35 +0000
> Cc: 25355@d= ebbugs.gnu.org
>
> I guess we can just use the library as-is? It's MIT-licensed.
What do you mean by "use"?=C2=A0 Treat it as an optional library,= like we
do with image support and GnuTLS?=C2=A0 I thought you wanted this feature to be present in every Emacs, not only Emacs linked against that
library.
>=C2=A0 P.S. Doesn't GNU Diff have code to do this?
>
> Sure, but it's not a library.
Why do you need a library, if you want the code to become part of
Emacs?
The advantage of Diff is that I think the situation with copyright
assignment will be much easier there ;-)
> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Sun, 07 May 2017 18:45:07 +0000
> Cc: 25355@d= ebbugs.gnu.org
>
>=C2=A0 What do you mean by "use"? Treat it as an optional lib= rary, like we
>=C2=A0 do with image support and GnuTLS? I thought you wanted this feat= ure
>=C2=A0 to be present in every Emacs, not only Emacs linked against that=
>=C2=A0 library.
>
> I just want to link it statically by adding the required source files = to the source tree, like we do for e.g.
> oldXmenu.
That means we need legal papers, AFAIU.