From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#47677: [PATCH] condition-case success continuation Date: Sun, 11 Apr 2021 13:13:37 +0200 Message-ID: References: <219007D9-0FD0-4AC2-A8B0-24A0FC277AE8@acm.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_C263DC4E-AF63-46B3-9CCF-12B41A40D86F" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38212"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 47677@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 11 13:14:29 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVY2s-0009m5-Mg for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 11 Apr 2021 13:14:27 +0200 Original-Received: from localhost ([::1]:36254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lVY2r-00070j-IZ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 11 Apr 2021 07:14:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVY2Y-00070D-1c for bug-gnu-emacs@gnu.org; Sun, 11 Apr 2021 07:14:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42552) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lVY2U-0004wK-HH for bug-gnu-emacs@gnu.org; Sun, 11 Apr 2021 07:14:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lVY2U-0007YS-Bg for bug-gnu-emacs@gnu.org; Sun, 11 Apr 2021 07:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 11 Apr 2021 11:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47677 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 47677-submit@debbugs.gnu.org id=B47677.161813963029016 (code B ref 47677); Sun, 11 Apr 2021 11:14:02 +0000 Original-Received: (at 47677) by debbugs.gnu.org; 11 Apr 2021 11:13:50 +0000 Original-Received: from localhost ([127.0.0.1]:54098 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lVY2I-0007Xv-F5 for submit@debbugs.gnu.org; Sun, 11 Apr 2021 07:13:50 -0400 Original-Received: from mail1463c50.megamailservers.eu ([91.136.14.63]:42228 helo=mail268c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lVY2F-0007Xh-TE for 47677@debbugs.gnu.org; Sun, 11 Apr 2021 07:13:48 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1618139621; bh=9vDRf11UrdDTjcgnfQUh+kFaFFro9aXC/ND43V14glw=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=Pq+pjiGOiLr/xn0W+navPUWvyiyMR280IaucVDTntpdFOcm6tPAEaqoKu2wRnjhoI X8Yq8hYkIDOzGsyd0e/nag+/BOLV1OaJG6t6LVScUx7R9CwNK9WZ1A67ot+/x8H7W3 T8V7bfzPKefbLnpChZ7Pzz1W90GfCdHQSMP27O/U= Feedback-ID: mattiase@acm.or Original-Received: from stanniol.lan (c-b952e353.032-75-73746f71.bbcust.telenor.se [83.227.82.185]) (authenticated bits=0) by mail268c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 13BBDch1008561; Sun, 11 Apr 2021 11:13:40 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A742F1E.6072D9E5.000D, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=Pq7tkDE3 c=1 sm=1 tr=0 a=von4qPfY+hyqc0zmWf0tYQ==:117 a=von4qPfY+hyqc0zmWf0tYQ==:17 a=M51BFTxLslgA:10 a=iRZporoAAAAA:8 a=oSoEVI6B0U0HSzi3YrgA:9 a=CjuIK1q_8ugA:10 a=mGGVe17ArwRYEn8pBrIA:9 a=B2y7HmGcmWMA:10 a=NOBgFS-JBQ2l-kSd6-zu:22 X-Origin-Country: SE X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:203841 Archived-At: --Apple-Mail=_C263DC4E-AF63-46B3-9CCF-12B41A40D86F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 11 apr. 2021 kl. 01.52 skrev Stefan Monnier : > In the tests, you might want to add one with a lambda expression which > captures a mutated success variable, as in >=20 > (apply (condition-case res > 42 > (:success (prog1 (list (lambda (x) (+ res x)) res) > (setq res 0))))) >=20 > since this requires special handling in cconv.el. Good catch! Fixed on master. (And I've added more test cases to the = patch.) > Any particular reason you chose ;success instead of :no-error? Only a few weak reasons -- some conditions (like quit) aren't errors, = although the documentation is very inconsistent on that point. And = :success felt slightly more descriptive, and it doesn't have a negation = in the name. Names like :default, :else, :otherwise etc were rejected because they = could be interpreted as 'any other error'. It may be a bit too far over the moon though. Would = :not-a-complete-failure be better? Fits my gloomy national temperaments = (all of them) better. Still undecided! --Apple-Mail=_C263DC4E-AF63-46B3-9CCF-12B41A40D86F Content-Disposition: attachment; filename=0001-Add-condition-case-success-handler-bug-47677.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Add-condition-case-success-handler-bug-47677.patch" Content-Transfer-Encoding: quoted-printable =46rom=20dcb8b351116e1785aa5395c3d3ffefd836cac4b4=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Wed,=207=20Apr=202021=2011:31:07=20+0200=0A= Subject:=20[PATCH]=20Add=20condition-case=20success=20handler=20= (bug#47677)=0A=0AAllow=20a=20condition-case=20handler=20on=20the=20form=20= (:success=20BODY)=20to=20be=0Aspecified=20as=20the=20success=20= continuation=20of=20the=20protected=20form,=20with=0Athe=20specified=20= variable=20bound=20to=20its=20result.=0A=0A*=20src/eval.c=20= (Fcondition_case):=20Update=20the=20doc=20string.=0A= (internal_lisp_condition_case):=20Implement=20in=20interpreter.=0A= (syms_of_eval):=20Defsym=20:success.=0A*=20lisp/emacs-lisp/bytecomp.el=20= (byte-compile-condition-case):=0AImplement=20in=20byte-compiler.=0A*=20= lisp/emacs-lisp/cl-macs.el=20(cl--self-tco):=20Allow=20self-TCO=0Afrom=20= success=20handler.=0A*=20doc/lispref/control.texi=20(Handling=20Errors):=20= Update=20manual.=0A*=20etc/NEWS:=20Announce.=0A*=20= test/lisp/emacs-lisp/bytecomp-tests.el=20(bytecomp-tests--test-cases)=0A= (bytecomp-condition-case-success):=0A*=20= test/lisp/emacs-lisp/cl-macs-tests.el=20(cl-macs--labels):=0AAdd=20test=20= cases.=0A---=0A=20doc/lispref/control.texi=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20|=20=209=20++-=0A=20etc/NEWS=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=205=20= ++=0A=20lisp/emacs-lisp/bytecomp.el=20=20=20=20=20=20=20=20=20=20=20=20|=20= 28=20+++++++-=0A=20lisp/emacs-lisp/cl-macs.el=20=20=20=20=20=20=20=20=20=20= =20=20=20|=20=204=20+-=0A=20src/eval.c=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=2034=20+++++++++-=0A= =20test/lisp/emacs-lisp/bytecomp-tests.el=20|=2093=20= ++++++++++++++++++++++++++=0A=20test/lisp/emacs-lisp/cl-macs-tests.el=20=20= |=20=209=20+--=0A=207=20files=20changed,=20172=20insertions(+),=2010=20= deletions(-)=0A=0Adiff=20--git=20a/doc/lispref/control.texi=20= b/doc/lispref/control.texi=0Aindex=203388102f69..22b665bc93=20100644=0A= ---=20a/doc/lispref/control.texi=0A+++=20b/doc/lispref/control.texi=0A@@=20= -2012,7=20+2012,8=20@@=20Handling=20Errors=0A=20This=20special=20form=20= establishes=20the=20error=20handlers=20@var{handlers}=20around=0A=20the=20= execution=20of=20@var{protected-form}.=20=20If=20@var{protected-form}=20= executes=0A=20without=20error,=20the=20value=20it=20returns=20becomes=20= the=20value=20of=20the=0A-@code{condition-case}=20form;=20in=20this=20= case,=20the=20@code{condition-case}=20has=0A+@code{condition-case}=20= form=20(in=20the=20absence=20of=20a=20success=20handler;=20see=20below).=0A= +In=20this=20case,=20the=20@code{condition-case}=20has=0A=20no=20effect.=20= =20The=20@code{condition-case}=20form=20makes=20a=20difference=20when=20= an=0A=20error=20occurs=20during=20@var{protected-form}.=0A=20=0A@@=20= -2062,6=20+2063,12=20@@=20Handling=20Errors=0A=20If=20@var{var}=20is=20= @code{nil},=20that=20means=20no=20variable=20is=20bound.=20=20Then=20the=0A= =20error=20symbol=20and=20associated=20data=20are=20not=20available=20to=20= the=20handler.=0A=20=0A+@cindex=20success=20handler=0A+As=20a=20special=20= case,=20one=20of=20the=20@var{handlers}=20can=20be=20a=20list=20of=20the=0A= +form=20@code{(:success=20@var{body}@dots{})},=20where=20@var{body}=20is=20= executed=0A+with=20@var{var}=20(if=20non-@code{nil})=20bound=20to=20the=20= return=20value=20of=0A+@var{protected-form}=20when=20that=20expression=20= terminates=20without=20error.=0A+=0A=20@cindex=20rethrow=20a=20signal=0A=20= Sometimes=20it=20is=20necessary=20to=20re-throw=20a=20signal=20caught=20= by=0A=20@code{condition-case},=20for=20some=20outer-level=20handler=20to=20= catch.=20=20Here's=0Adiff=20--git=20a/etc/NEWS=20b/etc/NEWS=0Aindex=20= aaf38022c5..74d8ad0da7=20100644=0A---=20a/etc/NEWS=0A+++=20b/etc/NEWS=0A= @@=20-2922,6=20+2922,11=20@@=20arrays=20nor=20objects.=0A=20The=20= special=20events=20'dbus-event'=20and=20'file-notify'=20are=20now=20= ignored=20in=0A=20'while-no-input'=20when=20added=20to=20this=20= variable.=0A=20=0A++++=0A+**=20'condition-case'=20now=20allows=20for=20a=20= success=20handler.=0A+It=20is=20executed=20whenever=20the=20protected=20= form=20terminates=20without=20error,=0A+with=20the=20specified=20= variable=20bound=20to=20the=20returned=20value.=0A+=0A=20=0C=0A=20*=20= Changes=20in=20Emacs=2028.1=20on=20Non-Free=20Operating=20Systems=0A=20=0A= diff=20--git=20a/lisp/emacs-lisp/bytecomp.el=20= b/lisp/emacs-lisp/bytecomp.el=0Aindex=200babbbb978..ce3a759487=20100644=0A= ---=20a/lisp/emacs-lisp/bytecomp.el=0A+++=20= b/lisp/emacs-lisp/bytecomp.el=0A@@=20-4621,10=20+4621,15=20@@=20= byte-compile-unwind-protect=0A=20(defun=20byte-compile-condition-case=20= (form)=0A=20=20=20(let*=20((var=20(nth=201=20form))=0A=20=20=20=20=20=20=20= =20=20=20(body=20(nth=202=20form))=0A+=20=20=20=20=20=20=20=20=20= (handlers=20(nthcdr=203=20form))=0A=20=20=20=20=20=20=20=20=20=20(depth=20= byte-compile-depth)=0A+=20=20=20=20=20=20=20=20=20(success-handler=20= (assq=20:success=20handlers))=0A+=20=20=20=20=20=20=20=20=20= (failure-handlers=20(if=20success-handler=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(remq=20= success-handler=20handlers)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20handlers))=0A=20=20=20=20=20= =20=20=20=20=20(clauses=20(mapcar=20(lambda=20(clause)=0A=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (cons=20(byte-compile-make-tag)=20clause))=0A-=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(nthcdr=203=20form)))=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20failure-handlers))=0A=20=20=20=20=20=20=20=20=20=20(endtag=20= (byte-compile-make-tag)))=0A=20=20=20=20=20= (byte-compile-set-symbol-position=20'condition-case)=0A=20=20=20=20=20= (unless=20(symbolp=20var)=0A@@=20-4650,6=20+4655,27=20@@=20= byte-compile-condition-case=0A=20=0A=20=20=20=20=20(byte-compile-form=20= body)=20;;=20byte-compile--for-effect=0A=20=20=20=20=20(dolist=20(_=20= clauses)=20(byte-compile-out=20'byte-pophandler))=0A+=0A+=20=20=20=20= (when=20success-handler=0A+=20=20=20=20=20=20(let=20((success-body=20= (cdr=20success-handler)))=0A+=20=20=20=20=20=20=20=20(cond=0A+=20=20=20=20= =20=20=20=20=20((null=20var)=0A+=20=20=20=20=20=20=20=20=20=20= (byte-compile-discard)=0A+=20=20=20=20=20=20=20=20=20=20= (byte-compile-body=20success-body=20byte-compile--for-effect))=0A+=20=20=20= =20=20=20=20=20=20(lexical-binding=0A+=20=20=20=20=20=20=20=20=20=20(let=20= ((byte-compile--lexical-environment=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20byte-compile--lexical-environment))=0A+=20=20=20=20=20=20=20= =20=20=20=20=20(push=20(cons=20var=20(1-=20byte-compile-depth))=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= byte-compile--lexical-environment)=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (byte-compile-body=20success-body=20byte-compile--for-effect)=0A+=20=20=20= =20=20=20=20=20=20=20=20=20(byte-compile-discard=201=20'preserve-tos)))=0A= +=20=20=20=20=20=20=20=20=20(t=0A+=20=20=20=20=20=20=20=20=20=20(let=20= ((byte-compile-bound-variables=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20byte-compile-bound-variables))=0A+=20=20=20=20=20=20=20=20=20= =20=20=20(byte-compile-dynamic-variable-bind=20var)=0A+=20=20=20=20=20=20= =20=20=20=20=20=20(byte-compile-body=20success-body=20= byte-compile--for-effect)=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (byte-compile-out=20'byte-unbind=201))))))=0A+=0A=20=20=20=20=20= (byte-compile-goto=20'byte-goto=20endtag)=0A=20=0A=20=20=20=20=20(while=20= clauses=0Adiff=20--git=20a/lisp/emacs-lisp/cl-macs.el=20= b/lisp/emacs-lisp/cl-macs.el=0Aindex=2068211ec410..b7e5be95bc=20100644=0A= ---=20a/lisp/emacs-lisp/cl-macs.el=0A+++=20b/lisp/emacs-lisp/cl-macs.el=0A= @@=20-2144,7=20+2144,9=20@@=20cl--self-tco=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20((and=20`(condition-case=20,err-var=20,bodyform=20.=20= ,handlers)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (guard=20(not=20(eq=20err-var=20var))))=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20=20`(condition-case=20,err-var=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(progn=20(setq=20,retvar=20,bodyform)=20nil)=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20,(if=20(assq=20:success=20= handlers)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20bodyform=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20`(progn=20(setq=20,retvar=20,bodyform)=20nil))=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20.=20,(mapcar=20(lambda=20(h)=0A=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(cons=20(car=20h)=20(funcall=20opt-exps=20(cdr=20h))))=0A=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= handlers)))=0Adiff=20--git=20a/src/eval.c=20b/src/eval.c=0Aindex=20= ddaa8edd81..41c4cd1637=20100644=0A---=20a/src/eval.c=0A+++=20= b/src/eval.c=0A@@=20-1301,7=20+1301,7=20@@=20DEFUN=20("condition-case",=20= Fcondition_case,=20Scondition_case,=202,=20UNEVALLED,=200,=0A=20=20=20=20= =20=20=20=20doc:=20/*=20Regain=20control=20when=20an=20error=20is=20= signaled.=0A=20Executes=20BODYFORM=20and=20returns=20its=20value=20if=20= no=20error=20happens.=0A=20Each=20element=20of=20HANDLERS=20looks=20like=20= (CONDITION-NAME=20BODY...)=0A-where=20the=20BODY=20is=20made=20of=20Lisp=20= expressions.=0A+or=20(:success=20BODY),=20where=20the=20BODY=20is=20made=20= of=20Lisp=20expressions.=0A=20=0A=20A=20handler=20is=20applicable=20to=20= an=20error=20if=20CONDITION-NAME=20is=20one=20of=20the=0A=20error's=20= condition=20names.=20=20Handlers=20may=20also=20apply=20when=20non-error=0A= @@=20-1323,6=20+1323,10=20@@=20DEFUN=20("condition-case",=20= Fcondition_case,=20Scondition_case,=202,=20UNEVALLED,=200,=0A=20Then=20= the=20value=20of=20the=20last=20BODY=20form=20is=20returned=20from=20the=20= `condition-case'=0A=20expression.=0A=20=0A+The=20special=20handler=20= (:success=20BODY)=20is=20invoked=20if=20BODYFORM=20terminated=0A+without=20= signalling=20an=20error.=20=20BODY=20is=20then=20evaluated=20with=20VAR=20= bound=20to=0A+the=20value=20returned=20by=20BODYFORM.=0A+=0A=20See=20= also=20the=20function=20`signal'=20for=20more=20info.=0A=20usage:=20= (condition-case=20VAR=20BODYFORM=20&rest=20HANDLERS)=20=20*/)=0A=20=20=20= (Lisp_Object=20args)=0A@@=20-1346,16=20+1350,21=20@@=20= internal_lisp_condition_case=20(Lisp_Object=20var,=20Lisp_Object=20= bodyform,=0A=20=0A=20=20=20CHECK_SYMBOL=20(var);=0A=20=0A+=20=20= Lisp_Object=20success_handler=20=3D=20Qnil;=0A+=0A=20=20=20for=20= (Lisp_Object=20tail=20=3D=20handlers;=20CONSP=20(tail);=20tail=20=3D=20= XCDR=20(tail))=0A=20=20=20=20=20{=0A=20=20=20=20=20=20=20Lisp_Object=20= tem=20=3D=20XCAR=20(tail);=0A-=20=20=20=20=20=20clausenb++;=0A=20=20=20=20= =20=20=20if=20(!=20(NILP=20(tem)=0A=20=09=20=20=20=20=20||=20(CONSP=20= (tem)=0A=20=09=09=20&&=20(SYMBOLP=20(XCAR=20(tem))=0A=20=09=09=20=20=20=20= =20||=20CONSP=20(XCAR=20(tem))))))=0A=20=09error=20("Invalid=20condition=20= handler:=20%s",=0A=20=09=20=20=20=20=20=20=20SDATA=20(Fprin1_to_string=20= (tem,=20Qt)));=0A+=20=20=20=20=20=20if=20(EQ=20(XCAR=20(tem),=20= QCsuccess))=0A+=09success_handler=20=3D=20XCDR=20(tem);=0A+=20=20=20=20=20= =20else=0A+=09clausenb++;=0A=20=20=20=20=20}=0A=20=0A=20=20=20/*=20The=20= first=20clause=20is=20the=20one=20that=20should=20be=20checked=20first,=20= so=20it=0A@@=20-1369,7=20+1378,8=20@@=20internal_lisp_condition_case=20= (Lisp_Object=20var,=20Lisp_Object=20bodyform,=0A=20=20=20Lisp_Object=20= volatile=20*clauses=20=3D=20alloca=20(clausenb=20*=20sizeof=20*clauses);=0A= =20=20=20clauses=20+=3D=20clausenb;=0A=20=20=20for=20(Lisp_Object=20tail=20= =3D=20handlers;=20CONSP=20(tail);=20tail=20=3D=20XCDR=20(tail))=0A-=20=20= =20=20*--clauses=20=3D=20XCAR=20(tail);=0A+=20=20=20=20if=20(!EQ=20(XCAR=20= (XCAR=20(tail)),=20QCsuccess))=0A+=20=20=20=20=20=20*--clauses=20=3D=20= XCAR=20(tail);=0A=20=20=20for=20(ptrdiff_t=20i=20=3D=200;=20i=20<=20= clausenb;=20i++)=0A=20=20=20=20=20{=0A=20=20=20=20=20=20=20Lisp_Object=20= clause=20=3D=20clauses[i];=0A@@=20-1409,6=20+1419,23=20@@=20= internal_lisp_condition_case=20(Lisp_Object=20var,=20Lisp_Object=20= bodyform,=0A=20=0A=20=20=20Lisp_Object=20result=20=3D=20eval_sub=20= (bodyform);=0A=20=20=20handlerlist=20=3D=20oldhandlerlist;=0A+=20=20if=20= (!NILP=20(success_handler))=0A+=20=20=20=20{=0A+=20=20=20=20=20=20if=20= (NILP=20(var))=0A+=09return=20Fprogn=20(success_handler);=0A+=0A+=20=20=20= =20=20=20Lisp_Object=20handler_var=20=3D=20var;=0A+=20=20=20=20=20=20if=20= (!NILP=20(Vinternal_interpreter_environment))=0A+=09{=0A+=09=20=20result=20= =3D=20Fcons=20(Fcons=20(var,=20result),=0A+=09=09=20=20=20=20=20=20=20= Vinternal_interpreter_environment);=0A+=09=20=20handler_var=20=3D=20= Qinternal_interpreter_environment;=0A+=09}=0A+=0A+=20=20=20=20=20=20= ptrdiff_t=20count=20=3D=20SPECPDL_INDEX=20();=0A+=20=20=20=20=20=20= specbind=20(handler_var,=20result);=0A+=20=20=20=20=20=20return=20= unbind_to=20(count,=20Fprogn=20(success_handler));=0A+=20=20=20=20}=0A=20= =20=20return=20result;=0A=20}=0A=20=0A@@=20-4381,6=20+4408,7=20@@=20= syms_of_eval=20(void)=0A=20=20=20defsubr=20(&Sthrow);=0A=20=20=20defsubr=20= (&Sunwind_protect);=0A=20=20=20defsubr=20(&Scondition_case);=0A+=20=20= DEFSYM=20(QCsuccess,=20":success");=0A=20=20=20defsubr=20(&Ssignal);=0A=20= =20=20defsubr=20(&Scommandp);=0A=20=20=20defsubr=20(&Sautoload);=0Adiff=20= --git=20a/test/lisp/emacs-lisp/bytecomp-tests.el=20= b/test/lisp/emacs-lisp/bytecomp-tests.el=0Aindex=20= a11832d805..69543320a7=20100644=0A---=20= a/test/lisp/emacs-lisp/bytecomp-tests.el=0A+++=20= b/test/lisp/emacs-lisp/bytecomp-tests.el=0A@@=20-444,6=20+444,49=20@@=20= bytecomp-tests--test-cases=0A=20=20=20=20=20=20=20=20(arith-error=20= (prog1=20(lambda=20(y)=20(+=20y=20x))=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(setq=20x=2010))))=0A=20=20=20=20=20=20= 4)=0A+=0A+=20=20=20=20;;=20No=20error,=20no=20success=20handler.=0A+=20=20= =20=20(condition-case=20x=0A+=20=20=20=20=20=20=20=20(list=2042)=0A+=20=20= =20=20=20=20(error=20(cons=20'bad=20x)))=0A+=20=20=20=20;;=20Error,=20no=20= success=20handler.=0A+=20=20=20=20(condition-case=20x=0A+=20=20=20=20=20=20= =20=20(/=201=200)=0A+=20=20=20=20=20=20(error=20(cons=20'bad=20x)))=0A+=20= =20=20=20;;=20No=20error,=20success=20handler.=0A+=20=20=20=20= (condition-case=20x=0A+=20=20=20=20=20=20=20=20(list=2042)=0A+=20=20=20=20= =20=20(error=20(cons=20'bad=20x))=0A+=20=20=20=20=20=20(:success=20(cons=20= 'good=20x)))=0A+=20=20=20=20;;=20Error,=20success=20handler.=0A+=20=20=20= =20(condition-case=20x=0A+=20=20=20=20=20=20=20=20(/=201=200)=0A+=20=20=20= =20=20=20(error=20(cons=20'bad=20x))=0A+=20=20=20=20=20=20(:success=20= (cons=20'good=20x)))=0A+=20=20=20=20;;=20Verify=20that=20the=20success=20= code=20is=20not=20subject=20to=20the=20error=20handlers.=0A+=20=20=20=20= (condition-case=20x=0A+=20=20=20=20=20=20=20=20(list=2042)=0A+=20=20=20=20= =20=20(error=20(cons=20'bad=20x))=0A+=20=20=20=20=20=20(:success=20(/=20= (car=20x)=200)))=0A+=20=20=20=20;;=20Check=20variable=20scoping=20on=20= success.=0A+=20=20=20=20(let=20((x=202))=0A+=20=20=20=20=20=20= (condition-case=20x=0A+=20=20=20=20=20=20=20=20=20=20(list=20x)=0A+=20=20= =20=20=20=20=20=20(error=20(list=20'bad=20x))=0A+=20=20=20=20=20=20=20=20= (:success=20(list=20'good=20x))))=0A+=20=20=20=20;;=20Check=20variable=20= scoping=20on=20failure.=0A+=20=20=20=20(let=20((x=202))=0A+=20=20=20=20=20= =20(condition-case=20x=0A+=20=20=20=20=20=20=20=20=20=20(/=201=200)=0A+=20= =20=20=20=20=20=20=20(error=20(list=20'bad=20x))=0A+=20=20=20=20=20=20=20= =20(:success=20(list=20'good=20x))))=0A+=20=20=20=20;;=20Check=20capture=20= of=20mutated=20result=20variable.=0A+=20=20=20=20(funcall=0A+=20=20=20=20= =20(condition-case=20x=0A+=20=20=20=20=20=20=20=20=203=0A+=20=20=20=20=20= =20=20(:success=20(prog1=20(lambda=20(y)=20(+=20y=20x))=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20x=2010))))=0A+=20=20=20= =20=204)=0A=20=20=20=20=20)=0A=20=20=20"List=20of=20expressions=20for=20= cross-testing=20interpreted=20and=20compiled=20code.")=0A=20=0A@@=20= -1185,6=20+1228,56=20@@=20bytecomp-string-vs-docstring=0A=20=20=20(let=20= ((lexical-binding=20t))=0A=20=20=20=20=20(should=20(equal=20(funcall=20= (byte-compile=20'(lambda=20(x)=20"foo"))=20'dummy)=20"foo"))))=0A=20=0A= +(ert-deftest=20bytecomp-condition-case-success=20()=0A+=20=20;;=20No=20= error,=20no=20success=20handler.=0A+=20=20(should=20(equal=20= (condition-case=20x=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(list=2042)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(error=20(cons=20'bad=20x)))=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20'(42)))=0A+=20=20;;=20Error,=20no=20success=20handler.=0A= +=20=20(should=20(equal=20(condition-case=20x=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(/=201=200)=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(error=20(cons=20'bad=20x)))=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20'(bad=20arith-error)))=0A+=20= =20;;=20No=20error,=20success=20handler.=0A+=20=20(should=20(equal=20= (condition-case=20x=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(list=2042)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(error=20(cons=20'bad=20x))=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(:success=20(cons=20'good=20x)))=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20'(good=2042)))=0A+=20=20;;=20Error,=20= success=20handler.=0A+=20=20(should=20(equal=20(condition-case=20x=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(/=201=200)=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(error=20(cons=20= 'bad=20x))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (:success=20(cons=20'good=20x)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20'(bad=20arith-error)))=0A+=20=20;;=20Verify=20that=20the=20= success=20code=20is=20not=20subject=20to=20the=20error=20handlers.=0A+=20= =20(should-error=20(condition-case=20x=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(list=2042)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(error=20(cons=20'bad=20x))=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(:success=20(/=20(car=20x)=200)))=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20:type=20'arith-error)=0A+=20= =20;;=20Check=20variable=20scoping.=0A+=20=20(let=20((x=202))=0A+=20=20=20= =20(should=20(equal=20(condition-case=20x=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(list=20x)=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(error=20(list=20'bad=20x))=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (:success=20(list=20'good=20x)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20'(good=20(2))))=0A+=20=20=20=20(should=20(equal=20= (condition-case=20x=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(/=201=200)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(error=20(list=20'bad=20x))=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(:success=20(list=20'good=20= x)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20'(bad=20= (arith-error)))))=0A+=20=20;;=20Check=20capture=20of=20mutated=20result=20= variable.=0A+=20=20(should=20(equal=20(funcall=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(condition-case=20x=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=203=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(:success=20(prog1=20(lambda=20(y)=20= (+=20y=20x))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20x=2010))))=0A+=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=204)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=2014)))=0A+=0A=20;;=20Local=20Variables:=0A=20;;=20= no-byte-compile:=20t=0A=20;;=20End:=0Adiff=20--git=20= a/test/lisp/emacs-lisp/cl-macs-tests.el=20= b/test/lisp/emacs-lisp/cl-macs-tests.el=0Aindex=205c3e603b92..f4e2e46a01=20= 100644=0A---=20a/test/lisp/emacs-lisp/cl-macs-tests.el=0A+++=20= b/test/lisp/emacs-lisp/cl-macs-tests.el=0A@@=20-630,12=20+630,13=20@@=20= cl-macs--labels=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(and=20xs=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (progn=20(setq=20n1=20(1+=20n))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(len2=20(cdr=20xs)=20n1))))))=0A-=20=20=20=20=20=20=20=20=20;;=20= Tail=20call=20in=20error=20handler.=0A+=20=20=20=20=20=20=20=20=20;;=20= Tail=20calls=20in=20error=20and=20success=20handlers.=0A=20=20=20=20=20=20= =20=20=20=20(len3=20(xs=20n)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(if=20xs=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (condition-case=20nil=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(/=201=200)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(arith-error=20(len3=20(cdr=20xs)=20(1+=20n))))=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (condition-case=20k=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(/=201=20(logand=20n=201))=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(arith-error=20(len3=20(cdr=20xs)=20= (1+=20n)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(:success=20(len3=20(cdr=20xs)=20(+=20n=20k))))=0A=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20n)))=0A=20=20=20=20=20=20=20(should=20= (equal=20(len=20nil=200)=200))=0A=20=20=20=20=20=20=20(should=20(equal=20= (len2=20nil=200)=200))=0A--=20=0A2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_C263DC4E-AF63-46B3-9CCF-12B41A40D86F--