aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoam Postavsky2018-08-09 21:26:30 -0400
committerNoam Postavsky2018-09-04 18:50:15 -0400
commit425c2811641a6b8ec4549cad5f6bd15a46bc95d5 (patch)
tree18bdf8e19e80624d0c22fe6bba70e35a1e022c27
parent21637d5e5b29d5ec8fb966c0ddfbfba3eb33da38 (diff)
downloademacs-425c2811641a6b8ec4549cad5f6bd15a46bc95d5.tar.gz
emacs-425c2811641a6b8ec4549cad5f6bd15a46bc95d5.zip
Allow t as a catch-all condition-case handler (Bug#24618)
* 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.
-rw-r--r--doc/lispref/control.texi7
-rw-r--r--etc/NEWS3
-rw-r--r--src/eval.c10
3 files changed, 13 insertions, 7 deletions
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 975ab3d0759..8a6cf73af51 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -1878,9 +1878,10 @@ error occurs during @var{protected-form}.
1878Each of the @var{handlers} is a list of the form @code{(@var{conditions} 1878Each of the @var{handlers} is a list of the form @code{(@var{conditions}
1879@var{body}@dots{})}. Here @var{conditions} is an error condition name 1879@var{body}@dots{})}. Here @var{conditions} is an error condition name
1880to be handled, or a list of condition names (which can include @code{debug} 1880to be handled, or a list of condition names (which can include @code{debug}
1881to allow the debugger to run before the handler); @var{body} is one or more 1881to allow the debugger to run before the handler). A condition name of
1882Lisp expressions to be executed when this handler handles an error. 1882@code{t} matches any condition. @var{body} is one or more Lisp
1883Here are examples of handlers: 1883expressions to be executed when this handler handles an error. Here
1884are examples of handlers:
1884 1885
1885@example 1886@example
1886@group 1887@group
diff --git a/etc/NEWS b/etc/NEWS
index 1fe662ffffd..f66bcb11383 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -875,6 +875,9 @@ removed.
875** lookup-key can take a list of keymaps as argument. 875** lookup-key can take a list of keymaps as argument.
876 876
877+++ 877+++
878** 'condition-case' now accepts 't' to match any error symbol.
879
880+++
878** New function 'proper-list-p'. 881** New function 'proper-list-p'.
879Given a proper list as argument, this predicate returns its length; 882Given a proper list as argument, this predicate returns its length;
880otherwise, it returns nil. 'format-proper-list-p' is now an obsolete 883otherwise, it returns nil. 'format-proper-list-p' is now an obsolete
diff --git a/src/eval.c b/src/eval.c
index 50de60c936c..1011fc888b5 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1215,9 +1215,9 @@ Executes BODYFORM and returns its value if no error happens.
1215Each element of HANDLERS looks like (CONDITION-NAME BODY...) 1215Each element of HANDLERS looks like (CONDITION-NAME BODY...)
1216where the BODY is made of Lisp expressions. 1216where the BODY is made of Lisp expressions.
1217 1217
1218A handler is applicable to an error 1218A handler is applicable to an error if CONDITION-NAME is one of the
1219if CONDITION-NAME is one of the error's condition names. 1219error's condition names. A CONDITION-NAME of t applies to any error
1220If an error happens, the first applicable handler is run. 1220symbol. If an error happens, the first applicable handler is run.
1221 1221
1222The car of a handler may be a list of condition names instead of a 1222The car of a handler may be a list of condition names instead of a
1223single condition name; then it handles all of them. If the special 1223single condition name; then it handles all of them. If the special
@@ -1854,7 +1854,9 @@ find_handler_clause (Lisp_Object handlers, Lisp_Object conditions)
1854 for (h = handlers; CONSP (h); h = XCDR (h)) 1854 for (h = handlers; CONSP (h); h = XCDR (h))
1855 { 1855 {
1856 Lisp_Object handler = XCAR (h); 1856 Lisp_Object handler = XCAR (h);
1857 if (!NILP (Fmemq (handler, conditions))) 1857 if (!NILP (Fmemq (handler, conditions))
1858 /* t is also used as a catch-all by Lisp code. */
1859 || EQ (handler, Qt))
1858 return handlers; 1860 return handlers;
1859 } 1861 }
1860 1862