Subject: bug#47677: [PATCH] condition-case success continuation

From: Mattias Engdegård <[email-masked]>
Date: Thu, 22 Apr 2021 15:58:10 +0200

21 apr. 2021 kl. 16.13 skrev Stefan Kangas <[email-masked]>:

> Should this be closed, or is there more to do here?

There's the business of fixing `catch` in the same way. (A new bug could be opened for it, but since it's intimately related we might as well do it here.) As mentioned, `catch` has three problems:

- no way to execute code when a throw is caught
- no way to execute code when the body terminates normally
- no way to catch both throws and errors

since neither `catch` nor `condition-case` compose with themselves or each other.
For example, it would be useful to have `pcase` match both the value of an expression as well as throws and errors from it.

Here is a proper patch, essentially a polished version of the previously posted diff. It adds `condition-case` clauses on the form

((:catch TAG-EXPR) BODY...)

where TAG-EXPR is evaluated before the protected form to a tag value, and BODY is executed when that tag is thrown, with the variable bound to the thrown value.