emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/doc/lispref ChangeLog buffers.texi


From: Chong Yidong
Subject: [Emacs-diffs] emacs/doc/lispref ChangeLog buffers.texi
Date: Sat, 04 Apr 2009 01:51:59 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Chong Yidong <cyd>      09/04/04 01:51:59

Modified files:
        doc/lispref    : ChangeLog buffers.texi 

Log message:
        * 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.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/doc/lispref/ChangeLog?cvsroot=emacs&r1=1.248&r2=1.249
http://cvs.savannah.gnu.org/viewcvs/emacs/doc/lispref/buffers.texi?cvsroot=emacs&r1=1.11&r2=1.12

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/doc/lispref/ChangeLog,v
retrieving revision 1.248
retrieving revision 1.249
diff -u -b -r1.248 -r1.249
--- ChangeLog   4 Apr 2009 01:32:57 -0000       1.248
+++ ChangeLog   4 Apr 2009 01:51:58 -0000       1.249
@@ -1,5 +1,9 @@
 2009-04-04  Chong Yidong  <address@hidden>
 
+       * 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.
+
        * files.texi (File Attributes): Move note about MS-DOS from
        Changing Files to File Attributes.
        (Create/Delete Dirs): Note that mkdir is an alias for this.

Index: buffers.texi
===================================================================
RCS file: /sources/emacs/emacs/doc/lispref/buffers.texi,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- buffers.texi        8 Jan 2009 05:28:56 -0000       1.11
+++ buffers.texi        4 Apr 2009 01:51:58 -0000       1.12
@@ -115,15 +115,13 @@
 course, that is the subroutine's purpose).  Therefore, you should
 normally use @code{set-buffer} within a @code{save-current-buffer} or
 @code{save-excursion} (@pxref{Excursions}) form that will restore the
-current buffer when your function is done.  Here is an example, the
-code for the command @code{append-to-buffer} (with the documentation
-string abridged):
+current buffer when your function is done.  Here, as an example, is a
+simplified version of the command @code{append-to-buffer}:
 
 @example
 @group
 (defun append-to-buffer (buffer start end)
-  "Append to specified buffer the text of the region.
address@hidden"
+  "Append to specified buffer the text of the region."
   (interactive "BAppend to buffer: \nr")
   (let ((oldbuf (current-buffer)))
     (save-current-buffer
@@ -157,30 +155,21 @@
 
   Do not rely on using @code{set-buffer} to change the current buffer
 back, because that won't do the job if a quit happens while the wrong
-buffer is current.  Here is what @emph{not} to do:
+buffer is current.  For instance, in the previous example, it would
+have been wrong to do this:
 
 @example
 @group
-(let (buffer-read-only
-      (obuf (current-buffer)))
-  (set-buffer @dots{})
-  @dots{}
-  (set-buffer obuf))
+  (let ((oldbuf (current-buffer)))
+    (set-buffer (get-buffer-create buffer))
+    (insert-buffer-substring oldbuf start end)
+    (set-buffer oldbuf))
 @end group
 @end example
 
 @noindent
-Using @code{save-current-buffer}, as shown here, handles quitting,
-errors, and @code{throw}, as well as ordinary evaluation.
-
address@hidden
address@hidden
-(let (buffer-read-only)
-  (save-current-buffer
-    (set-buffer @dots{})
-    @dots{}))
address@hidden group
address@hidden example
+Using @code{save-current-buffer}, as we did, handles quitting, errors,
+and @code{throw}, as well as ordinary evaluation.
 
 @defun current-buffer
 This function returns the current buffer.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]