emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC]: replace-region-contents


From: Stefan Monnier
Subject: Re: [RFC]: replace-region-contents
Date: Sat, 02 Feb 2019 10:42:00 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> ;; in subr-x.el (or wherever you please)
> (defun replace-region-contents (beg end extract-fn inject-fn)
>   "Replace the region between BEG and END using EXTRACT-FN and INJECT-FN.
>
> The current buffer is narrowed to the region between BEG and END,
> then EXTRACT-FN is called in order to extract some value.
> Thereafter, INJECT-FN is called with that value in a temporary
> buffer which it should populate.

Why two functions instead of just one?

Also, I think the docstring should hint at the fact that this is meant
for cases where the before and after text share significant parts (so
there's a chance of meaningfully preserving markers).  It might do that
simply be referring to `replace-buffer-contents`.

>       (atomic-change-group

Why?  AFAICT the buffer is not modified until we get to calling
replace-buffer-contents which already has (or should have) the
atomicity property.


        Stefan


PS: BTW, maybe replace-buffer-contents should be changed so it
interprets a string argument as the text to use as replacement rather
than as a buffer name.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]