]> code.delx.au - gnu-emacs/blobdiff - doc/lispref/control.texi
Miscellanous cleanups in preparation for the merge.
[gnu-emacs] / doc / lispref / control.texi
index db88a74487d4638288ab0844889eeb0bc62e692c..b6fdb9dbcbd11bd01c6a5b248be3af832f404440 100644 (file)
@@ -1,7 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001, 2002,
-@c   2003, 2004, 2005, 2006, 2007  Free Software Foundation, Inc.
+@c Copyright (C) 1990-1995, 1998-1999, 2001-2011  Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @setfilename ../../info/control
 @node Control Structures, Variables, Evaluation, Top
@@ -15,6 +14,7 @@ We control the order of execution of these forms by enclosing them in
 control when, whether, or how many times to execute the forms they
 contain.
 
+@cindex textual order
   The simplest order of execution is sequential execution: first form
 @var{a}, then form @var{b}, and so on.  This is what happens when you
 write several forms in succession in the body of a function, or at top
@@ -803,7 +803,7 @@ error message is the @sc{car} of @var{data} (that must be a string).
 Subcategories of @code{file-error} are handled specially.
 
 The number and significance of the objects in @var{data} depends on
-@var{error-symbol}.  For example, with a @code{wrong-type-arg} error,
+@var{error-symbol}.  For example, with a @code{wrong-type-argument} error,
 there should be two objects in the list: a predicate that describes the type
 that was expected, and the object that failed to fit that type.
 
@@ -891,7 +891,9 @@ establishing an error handler, with the special form
 
 @noindent
 This deletes the file named @var{filename}, catching any error and
-returning @code{nil} if an error occurs.
+returning @code{nil} if an error occurs@footnote{
+Actually, you should use @code{ignore-errors} in such a simple case;
+see below.}.
 
   The @code{condition-case} construct is often used to trap errors that
 are predictable, such as failure to open a file in a call to
@@ -1020,9 +1022,23 @@ error description.
 
 If @var{var} is @code{nil}, that means no variable is bound.  Then the
 error symbol and associated data are not available to the handler.
+
+@cindex rethrow a signal
+Sometimes it is necessary to re-throw a signal caught by
+@code{condition-case}, for some outer-level handler to catch.  Here's
+how to do that:
+
+@smallexample
+  (signal (car err) (cdr err))
+@end smallexample
+
+@noindent
+where @code{err} is the error description variable, the first argument
+to @code{condition-case} whose error condition you want to re-throw.
+@xref{Definition of signal}.
 @end defspec
 
-@defun error-message-string error-description
+@defun error-message-string error-descriptor
 This function returns the error message string for a given error
 descriptor.  It is useful if you want to handle an error by printing the
 usual error message for that error.  @xref{Definition of signal}.
@@ -1089,6 +1105,24 @@ including those signaled with @code{error}:
 @end group
 @end smallexample
 
+@defmac ignore-errors body@dots{}
+This construct executes @var{body}, ignoring any errors that occur
+during its execution.  If the execution is without error,
+@code{ignore-errors} returns the value of the last form in @var{body};
+otherwise, it returns @code{nil}.
+
+Here's the example at the beginning of this subsection rewritten using
+@code{ignore-errors}:
+
+@smallexample
+@group
+  (ignore-errors
+   (delete-file filename))
+@end group
+@end smallexample
+@end defmac
+
+
 @node Error Symbols
 @subsubsection Error Symbols and Condition Names
 @cindex error symbol
@@ -1235,9 +1269,8 @@ make sure to kill it before finishing:
 
 @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))))
@@ -1249,7 +1282,7 @@ You might think that we could just as well write @code{(kill-buffer
 (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.)
 
@@ -1285,7 +1318,3 @@ quit, and the quit happens immediately after the function
 @code{ftp-setup-buffer} returns but before the variable @code{process} is
 set, the process will not be killed.  There is no easy way to fix this bug,
 but at least it is very unlikely.
-
-@ignore
-   arch-tag: 8abc30d4-4d3a-47f9-b908-e9e971c18c6d
-@end ignore