diff options
| author | Chong Yidong | 2009-04-04 01:51:58 +0000 |
|---|---|---|
| committer | Chong Yidong | 2009-04-04 01:51:58 +0000 |
| commit | 9257072f4f5c49a06b7dd4ae2ab476340ae95de6 (patch) | |
| tree | 0d93a7e8fd8272bff1485d6b3d0193b1bfa895d7 | |
| parent | 8a0111611213a5baec88e60d9f6c52affd06f060 (diff) | |
| download | emacs-9257072f4f5c49a06b7dd4ae2ab476340ae95de6.tar.gz emacs-9257072f4f5c49a06b7dd4ae2ab476340ae95de6.zip | |
* buffers.texi (Current Buffer): Note that the append-to-buffer
example is no longer in synch with the latest code. Tie the two
examples together.
| -rw-r--r-- | doc/lispref/ChangeLog | 4 | ||||
| -rw-r--r-- | doc/lispref/buffers.texi | 33 |
2 files changed, 15 insertions, 22 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index bd8948862a6..ed74c25f8d8 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2009-04-04 Chong Yidong <cyd@stupidchicken.com> | 1 | 2009-04-04 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 2 | ||
| 3 | * buffers.texi (Current Buffer): Note that the append-to-buffer | ||
| 4 | example is no longer in synch with the latest code. Tie the two | ||
| 5 | examples together. | ||
| 6 | |||
| 3 | * files.texi (File Attributes): Move note about MS-DOS from | 7 | * files.texi (File Attributes): Move note about MS-DOS from |
| 4 | Changing Files to File Attributes. | 8 | Changing Files to File Attributes. |
| 5 | (Create/Delete Dirs): Note that mkdir is an alias for this. | 9 | (Create/Delete Dirs): Note that mkdir is an alias for this. |
diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi index d55ffe43b65..4ce94f6e7cf 100644 --- a/doc/lispref/buffers.texi +++ b/doc/lispref/buffers.texi | |||
| @@ -115,15 +115,13 @@ the subroutine does not change which buffer is current (unless, of | |||
| 115 | course, that is the subroutine's purpose). Therefore, you should | 115 | course, that is the subroutine's purpose). Therefore, you should |
| 116 | normally use @code{set-buffer} within a @code{save-current-buffer} or | 116 | normally use @code{set-buffer} within a @code{save-current-buffer} or |
| 117 | @code{save-excursion} (@pxref{Excursions}) form that will restore the | 117 | @code{save-excursion} (@pxref{Excursions}) form that will restore the |
| 118 | current buffer when your function is done. Here is an example, the | 118 | current buffer when your function is done. Here, as an example, is a |
| 119 | code for the command @code{append-to-buffer} (with the documentation | 119 | simplified version of the command @code{append-to-buffer}: |
| 120 | string abridged): | ||
| 121 | 120 | ||
| 122 | @example | 121 | @example |
| 123 | @group | 122 | @group |
| 124 | (defun append-to-buffer (buffer start end) | 123 | (defun append-to-buffer (buffer start end) |
| 125 | "Append to specified buffer the text of the region. | 124 | "Append to specified buffer the text of the region." |
| 126 | @dots{}" | ||
| 127 | (interactive "BAppend to buffer: \nr") | 125 | (interactive "BAppend to buffer: \nr") |
| 128 | (let ((oldbuf (current-buffer))) | 126 | (let ((oldbuf (current-buffer))) |
| 129 | (save-current-buffer | 127 | (save-current-buffer |
| @@ -157,30 +155,21 @@ beginning is current again whenever the variable is unbound. | |||
| 157 | 155 | ||
| 158 | Do not rely on using @code{set-buffer} to change the current buffer | 156 | Do not rely on using @code{set-buffer} to change the current buffer |
| 159 | back, because that won't do the job if a quit happens while the wrong | 157 | back, because that won't do the job if a quit happens while the wrong |
| 160 | buffer is current. Here is what @emph{not} to do: | 158 | buffer is current. For instance, in the previous example, it would |
| 159 | have been wrong to do this: | ||
| 161 | 160 | ||
| 162 | @example | 161 | @example |
| 163 | @group | 162 | @group |
| 164 | (let (buffer-read-only | 163 | (let ((oldbuf (current-buffer))) |
| 165 | (obuf (current-buffer))) | 164 | (set-buffer (get-buffer-create buffer)) |
| 166 | (set-buffer @dots{}) | 165 | (insert-buffer-substring oldbuf start end) |
| 167 | @dots{} | 166 | (set-buffer oldbuf)) |
| 168 | (set-buffer obuf)) | ||
| 169 | @end group | 167 | @end group |
| 170 | @end example | 168 | @end example |
| 171 | 169 | ||
| 172 | @noindent | 170 | @noindent |
| 173 | Using @code{save-current-buffer}, as shown here, handles quitting, | 171 | Using @code{save-current-buffer}, as we did, handles quitting, errors, |
| 174 | errors, and @code{throw}, as well as ordinary evaluation. | 172 | and @code{throw}, as well as ordinary evaluation. |
| 175 | |||
| 176 | @example | ||
| 177 | @group | ||
| 178 | (let (buffer-read-only) | ||
| 179 | (save-current-buffer | ||
| 180 | (set-buffer @dots{}) | ||
| 181 | @dots{})) | ||
| 182 | @end group | ||
| 183 | @end example | ||
| 184 | 173 | ||
| 185 | @defun current-buffer | 174 | @defun current-buffer |
| 186 | This function returns the current buffer. | 175 | This function returns the current buffer. |