]> git.eshelyaron.com Git - emacs.git/commitdiff
Document 'replace-buffer-contents' in the manual.
authorPhilipp Stephani <phst@google.com>
Sun, 24 Sep 2017 17:32:16 +0000 (19:32 +0200)
committerPhilipp Stephani <phst@google.com>
Sun, 24 Sep 2017 17:32:16 +0000 (19:32 +0200)
* doc/lispref/text.texi (Replacing): New node.

doc/lispref/text.texi
etc/NEWS

index a7d10797cd0013ed7bceeb9c99b49ffac02d271e..baa3c708e90fc34c9572d95f2658217762da888d 100644 (file)
@@ -54,6 +54,8 @@ the character after point.
 * Registers::        How registers are implemented.  Accessing the text or
                        position stored in a register.
 * 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.
 * Base 64::          Conversion to or from base 64 encoding.
 * 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.
 @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
 @section Dealing With Compressed Data
 
index 34561acae5670679e15319b81b370544d6ed05b0..fc4531f0e85d50175868a57708466f487152aa2e 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
 line.
 
----
 ** New command 'replace-buffer-contents'.
 This command replaces the contents of the accessible portion of the
 current buffer with the contents of the accessible portion of a