]> git.eshelyaron.com Git - emacs.git/commit
(replace-region-contents): Improve and promote (bug#76313)
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 28 Mar 2025 04:46:53 +0000 (00:46 -0400)
committerEshel Yaron <me@eshelyaron.com>
Mon, 31 Mar 2025 08:39:04 +0000 (10:39 +0200)
commitdb2f934f4a3b1c4b2ee4d287f9468c22690d49e0
tree52e9b1ba60c72f306b8309cc65a98e6a5eb5a9a3
parent3c253010643c426b3ba64f8f8905a3fabd1ed768
(replace-region-contents): Improve and promote (bug#76313)

Swap the role of `replace-region-contents` and `replace-buffer-contents`,
so `replace-region-contents` is the main function, implemented in C,
and `replace-buffer-contents` is a mere wrapper (marked as obsolete).
Also remove the need to rely on narrowing and on describing the
new text as a function.
Finally, allow MAX-SECS==0 to require a cheap replacement, and
add an INHERIT argument.

* src/editfns.c: Include `coding.h`.
(Freplace_region_contents): Rename from `Freplace_buffer_contents`.
Change calling convention to that of `replace-region-contents`.
Add more options for the SOURCE argument.  Add INHERIT argument.
Skip the costly algorithm if MAX-SECS is 0.
* src/insdel.c (replace_range): Allow NEW to be a buffer.

* lisp/subr.el (replace-buffer-contents): New implementation.
* lisp/emacs-lisp/subr-x.el (replace-region-contents): Delete.

* doc/lispref/text.texi (Replacing): Document new API for
`replace-region-contents`.  Remove documentation of
`replace-buffer-contents`.

* test/src/editfns-tests.el (replace-buffer-contents-1)
(replace-buffer-contents-2, replace-buffer-contents-bug31837):
Use `replace-region-contents`.
(editfns--replace-region): Delete.
(editfns-tests--replace-region): Use `replace-region-contents`.
Adds tests for new types of SOURCE args.

(cherry picked from commit 7c82cc8b975175aebbad1c43ec1cd98b3232f482)
doc/lispref/text.texi
lisp/emacs-lisp/subr-x.el
lisp/subr.el
src/coding.c
src/editfns.c
src/insdel.c
test/src/editfns-tests.el