Subject: Re: bug#25355: 26.0.50; Provide function to non-destructively replace buffer contents

From: Philipp Stephani <[email-masked]>
Date: Sun, 07 May 2017 17:44:27 +0000

Philipp <[email-masked]> schrieb am Mi., 4. Jan. 2017 um 13:46 Uhr:

>
> There are many tools (e.g. auto-formatters) that take buffer contents,
> reformat them, and write the reformatted output somewhere.  However,
> there is no good way how to apply the modified output to the source
> buffer.  The naive way (erasing and re-inserting the buffer contents)
> loses point and markers.  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.  Ideally this would be done without any
> external tools (e.g. 'diff').
>
>
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'll send a
patch.