]> git.eshelyaron.com Git - emacs.git/commitdiff
Allow t as a catch-all condition-case handler (Bug#24618)
authorNoam Postavsky <npostavs@gmail.com>
Fri, 10 Aug 2018 01:26:30 +0000 (21:26 -0400)
committerNoam Postavsky <npostavs@gmail.com>
Tue, 4 Sep 2018 22:50:15 +0000 (18:50 -0400)
* src/eval.c (find_handler_clause): Accept a handler of t as always
matching.
(Fcondition_case):
* doc/lispref/control.texi (Handling Errors): Document this.
* etc/NEWS: Announce it.

doc/lispref/control.texi
etc/NEWS
src/eval.c

index 975ab3d0759d2696fd8de306961fdf7dd3ac7b8d..8a6cf73af516d6f7da6f3c7f2ac21042df6438ec 100644 (file)
@@ -1878,9 +1878,10 @@ error occurs during @var{protected-form}.
 Each of the @var{handlers} is a list of the form @code{(@var{conditions}
 @var{body}@dots{})}.  Here @var{conditions} is an error condition name
 to be handled, or a list of condition names (which can include @code{debug}
-to allow the debugger to run before the handler); @var{body} is one or more
-Lisp expressions to be executed when this handler handles an error.
-Here are examples of handlers:
+to allow the debugger to run before the handler).  A condition name of
+@code{t} matches any condition.  @var{body} is one or more Lisp
+expressions to be executed when this handler handles an error.  Here
+are examples of handlers:
 
 @example
 @group
index 1fe662ffffde43b5d2e76152cecdd4d17c96627f..f66bcb113834fc6676a6ba228dfed253fd65eb22 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -874,6 +874,9 @@ removed.
 
 ** lookup-key can take a list of keymaps as argument.
 
++++
+** 'condition-case' now accepts 't' to match any error symbol.
+
 +++
 ** New function 'proper-list-p'.
 Given a proper list as argument, this predicate returns its length;
index 50de60c936c7ca41cac1537287a1d957a3ff2239..1011fc888b547c69ef120f072f75faffe67d305f 100644 (file)
@@ -1215,9 +1215,9 @@ Executes BODYFORM and returns its value if no error happens.
 Each element of HANDLERS looks like (CONDITION-NAME BODY...)
 where the BODY is made of Lisp expressions.
 
-A handler is applicable to an error
-if CONDITION-NAME is one of the error's condition names.
-If an error happens, the first applicable handler is run.
+A handler is applicable to an error if CONDITION-NAME is one of the
+error's condition names.  A CONDITION-NAME of t applies to any error
+symbol.  If an error happens, the first applicable handler is run.
 
 The car of a handler may be a list of condition names instead of a
 single condition name; then it handles all of them.  If the special
@@ -1854,7 +1854,9 @@ find_handler_clause (Lisp_Object handlers, Lisp_Object conditions)
   for (h = handlers; CONSP (h); h = XCDR (h))
     {
       Lisp_Object handler = XCAR (h);
-      if (!NILP (Fmemq (handler, conditions)))
+      if (!NILP (Fmemq (handler, conditions))
+          /* t is also used as a catch-all by Lisp code.  */
+          || EQ (handler, Qt))
        return handlers;
     }