Next: , Previous: Transposition, Up: Text

32.23 Replacing Buffer Text

You can use the following function to replace the text of one buffer with the text of another buffer:

— Command: replace-buffer-contents source

This function replaces the accessible portion of the current buffer with the accessible portion of the buffer source. source may either be a buffer object or the name of a buffer. When 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 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 delete-region and insert-buffer-substring would destroy these properties. However, the latter combination is typically faster. See Deletion, and Insertion.