diff doc/lispref/control.texi @ 106731:79fa2d910b72

Avoid dubious uses of save-excursions. * doc/lispref/positions.texi (Excursions): Recommend the use of save-current-buffer if applicable. * doc/lispref/text.texi (Clickable Text): Fix the example code which used save-excursion in a naive way which sometimes preserves point and sometimes not. * doc/lispref/variables.texi (Creating Buffer-Local): * doc/lispref/os.texi (Session Management): * doc/lispref/display.texi (GIF Images): * doc/lispref/control.texi (Cleanups): Use (save|with)-current-buffer. * doc/misc/gnus.texi (Posting Styles): Use with-current-buffer. * doc/misc/calc.texi (Defining Simple Commands): Prefer save-current-buffer.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 04 Jan 2010 13:18:38 -0500
parents 12ca674f1a3c
children 1d1d5d9bd884
line wrap: on
line diff
--- a/doc/lispref/control.texi	Mon Jan 04 12:38:20 2010 -0500
+++ b/doc/lispref/control.texi	Mon Jan 04 13:18:38 2010 -0500
@@ -1255,9 +1255,8 @@
 
 @smallexample
 @group
-(save-excursion
-  (let ((buffer (get-buffer-create " *temp*")))
-    (set-buffer buffer)
+(let ((buffer (get-buffer-create " *temp*")))
+  (with-current-buffer buffer
     (unwind-protect
         @var{body-form}
       (kill-buffer buffer))))
@@ -1269,7 +1268,7 @@
 (current-buffer))} and dispense with the variable @code{buffer}.
 However, the way shown above is safer, if @var{body-form} happens to
 get an error after switching to a different buffer!  (Alternatively,
-you could write another @code{save-excursion} around @var{body-form},
+you could write a @code{save-current-buffer} around @var{body-form},
 to ensure that the temporary buffer becomes current again in time to
 kill it.)