Document 'replace-buffer-contents' in the manual.

* doc/lispref/text.texi (Replacing): New node.
This commit is contained in:
Philipp Stephani 2017-09-24 19:32:16 +02:00
parent 00e4e3e9d2
commit d93301242f
2 changed files with 24 additions and 1 deletions

View file

@ -54,6 +54,8 @@ the character after point.
* Registers:: How registers are implemented. Accessing the text or * Registers:: How registers are implemented. Accessing the text or
position stored in a register. position stored in a register.
* Transposition:: Swapping two portions of a buffer. * Transposition:: Swapping two portions of a buffer.
* Replacing:: Replacing the text of one buffer with the text
of another buffer.
* Decompression:: Dealing with compressed data. * Decompression:: Dealing with compressed data.
* Base 64:: Conversion to or from base 64 encoding. * Base 64:: Conversion to or from base 64 encoding.
* Checksum/Hash:: Computing cryptographic hashes. * Checksum/Hash:: Computing cryptographic hashes.
@ -4328,6 +4330,28 @@ is non-@code{nil}, @code{transpose-regions} does not do this---it leaves
all markers unrelocated. all markers unrelocated.
@end defun @end defun
@node Replacing
@section Replacing Buffer Text
You can use the following function to replace the text of one buffer
with the text of another buffer:
@deffn Command replace-buffer-contents source
This function replaces the accessible portion of the current buffer
with the accessible portion of the buffer @var{source}. @var{source}
may either be a buffer object or the name of a buffer. When
@code{replace-buffer-contents} succeeds, the text of the accessible
portion of the current buffer will be equal to the text of the
accessible portion of the @var{source} buffer. This function attempts
to keep point, markers, text properties, and overlays in the current
buffer intact. One potential case where this behavior is useful is
external code formatting programs: they typically write the
reformatted text into a temporary buffer or file, and using
@code{delete-region} and @code{insert-buffer-substring} would destroy
these properties. However, the latter combination is typically
faster. @xref{Deletion}, and @ref{Insertion}.
@end deffn
@node Decompression @node Decompression
@section Dealing With Compressed Data @section Dealing With Compressed Data

View file

@ -578,7 +578,6 @@ Negative prefix arg flips the direction of selection. Also,
defun are selected unless they are separated from the defun by a blank defun are selected unless they are separated from the defun by a blank
line. line.
---
** New command 'replace-buffer-contents'. ** New command 'replace-buffer-contents'.
This command replaces the contents of the accessible portion of the This command replaces the contents of the accessible portion of the
current buffer with the contents of the accessible portion of a current buffer with the contents of the accessible portion of a