diff options
| -rw-r--r-- | doc/lispref/buffers.texi | 39 |
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 | |||
| 1136 | indirect buffer. | 1137 | indirect 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 | ||
| 1146 | same buffer several vastly different types of text. For example, you | ||
| 1147 | may need to display a summary of the buffer text, in addition to | ||
| 1148 | letting the user access the text itself. | ||
| 1149 | |||
| 1150 | This could be implemented with multiple buffers (kept in sync when | ||
| 1151 | the user edits the text), or with narrowing (@pxref{Narrowing}). But | ||
| 1152 | these alternatives might sometimes become tedious or prohibitively | ||
| 1153 | expensive, especially if each type of text requires expensive | ||
| 1154 | buffer-global operations in order to provide correct display and | ||
| 1155 | editing commands. | ||
| 1156 | |||
| 1157 | Emacs provides another facility for such modes: you can quickly swap | ||
| 1158 | buffer text between two buffers with @code{buffer-swap-text}. This | ||
| 1159 | function is very fast because it doesn't move any text, it only | ||
| 1160 | changes the internal data structures of the buffer object to point to | ||
| 1161 | a different chunk of text. Using it, you can pretend that a group of | ||
| 1162 | two or more buffers are actually a single virtual buffer that holds | ||
| 1163 | the contents of all the individual buffers together. | ||
| 1164 | |||
| 1165 | @defun buffer-swap-text buffer | ||
| 1166 | This 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 | ||
| 1168 | indirect buffer (@pxref{Indirect Buffers}) or is a base buffer of an | ||
| 1169 | indirect buffer. | ||
| 1170 | |||
| 1171 | All the buffer properties that are related to the buffer text are | ||
| 1172 | swapped as well: the positions of point and mark, all the markers, the | ||
| 1173 | overlays, the text properties, the undo list, the value of the | ||
| 1174 | @code{enable-multibyte-characters} flag (@pxref{Text Representations, | ||
| 1175 | enable-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 | ||