aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/buffers.texi39
1 files changed, 39 insertions, 0 deletions
diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index 56e952a44a6..4d12185726c 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -30,6 +30,7 @@ not be displayed in any windows.
30* Creating Buffers:: Functions that create buffers. 30* Creating Buffers:: Functions that create buffers.
31* Killing Buffers:: Buffers exist until explicitly killed. 31* Killing Buffers:: Buffers exist until explicitly killed.
32* Indirect Buffers:: An indirect buffer shares text with some other buffer. 32* Indirect Buffers:: An indirect buffer shares text with some other buffer.
33* Swapping Text:: Swapping text between two buffers.
33* Buffer Gap:: The gap in the buffer. 34* Buffer Gap:: The gap in the buffer.
34@end menu 35@end menu
35 36
@@ -1136,6 +1137,44 @@ to the current buffer. If @var{buffer} is not indirect, the value is
1136indirect buffer. 1137indirect buffer.
1137@end defun 1138@end defun
1138 1139
1140@node Swapping Text
1141@section Swapping Text Between Two Buffers
1142@cindex swap text between buffers
1143@cindex virtual buffers
1144
1145 Specialized modes sometimes need to let the user access from the
1146same buffer several vastly different types of text. For example, you
1147may need to display a summary of the buffer text, in addition to
1148letting the user access the text itself.
1149
1150 This could be implemented with multiple buffers (kept in sync when
1151the user edits the text), or with narrowing (@pxref{Narrowing}). But
1152these alternatives might sometimes become tedious or prohibitively
1153expensive, especially if each type of text requires expensive
1154buffer-global operations in order to provide correct display and
1155editing commands.
1156
1157 Emacs provides another facility for such modes: you can quickly swap
1158buffer text between two buffers with @code{buffer-swap-text}. This
1159function is very fast because it doesn't move any text, it only
1160changes the internal data structures of the buffer object to point to
1161a different chunk of text. Using it, you can pretend that a group of
1162two or more buffers are actually a single virtual buffer that holds
1163the contents of all the individual buffers together.
1164
1165@defun buffer-swap-text buffer
1166This function swaps text between the current buffer and its argument
1167@var{buffer}. It signals an error if one of the two buffers is an
1168indirect buffer (@pxref{Indirect Buffers}) or is a base buffer of an
1169indirect buffer.
1170
1171All the buffer properties that are related to the buffer text are
1172swapped as well: the positions of point and mark, all the markers, the
1173overlays, the text properties, the undo list, the value of the
1174@code{enable-multibyte-characters} flag (@pxref{Text Representations,
1175enable-multibyte-characters}), etc.
1176@end defun
1177
1139@node Buffer Gap 1178@node Buffer Gap
1140@section The Buffer Gap 1179@section The Buffer Gap
1141 1180