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: Fri, 9 Apr 2021 22:26:49 +0200 Message-ID: <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=_2A1C3F29-9A56-4B7B-9D7A-3BD0DCF89340" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29936"; mail-complaints-to="usenet@ciao.gmane.io" To: 47677@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 09 22:30:49 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 1lUxmC-0007dC-8x for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 09 Apr 2021 22:30:48 +0200 Original-Received: from localhost ([::1]:60892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUxmB-0007l2-Bo for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 09 Apr 2021 16:30:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUxjW-0005MP-K9 for bug-gnu-emacs@gnu.org; Fri, 09 Apr 2021 16:28:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUxjW-00078O-Bs for bug-gnu-emacs@gnu.org; Fri, 09 Apr 2021 16:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lUxjW-0002ad-8n for bug-gnu-emacs@gnu.org; Fri, 09 Apr 2021 16:28: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: Fri, 09 Apr 2021 20:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47677 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16180000239878 (code B ref -1); Fri, 09 Apr 2021 20:28:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Apr 2021 20:27:03 +0000 Original-Received: from localhost ([127.0.0.1]:51024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lUxiZ-0002ZG-8H for submit@debbugs.gnu.org; Fri, 09 Apr 2021 16:27:03 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:53902) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lUxiY-0002Yx-42 for submit@debbugs.gnu.org; Fri, 09 Apr 2021 16:27:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUxiX-00042T-QD for bug-gnu-emacs@gnu.org; Fri, 09 Apr 2021 16:27:01 -0400 Original-Received: from mail200c50.megamailservers.eu ([91.136.10.210]:36946 helo=mail193c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUxiV-0006UZ-C3 for bug-gnu-emacs@gnu.org; Fri, 09 Apr 2021 16:27:01 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1618000012; bh=7V7CaYsY/HLO0NLw6nrj1l/2qpEOZPVaAS49V8kf90c=; h=From:Subject:Date:To:From; b=kD65qy1UlWQqaMw0GhbKNB9WA2yyrnApCCA4MqomK//YU3ggVkz52Y9MBGHZU326V KQe18xzmAMvL81vgyRPMraCG+62cWBxlmDp92trTTBut6KG+aMsdUymt8GAz1vYFYs nFZ0kyKT2kUWnCrFbxkUe68kSvt4GF6TxcHYhBo4= 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 mail193c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 139KQoVd019846 for ; Fri, 9 Apr 2021 20:26:51 +0000 X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A742F1D.6070B88B.0069, 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=PqLtkDE3 c=1 sm=1 tr=0 a=von4qPfY+hyqc0zmWf0tYQ==:117 a=von4qPfY+hyqc0zmWf0tYQ==:17 a=M51BFTxLslgA:10 a=yqP2UuPKgrWxpfcNVlMA:9 a=CjuIK1q_8ugA:10 a=mGGVe17ArwRYEn8pBrIA:9 a=B2y7HmGcmWMA:10 X-Origin-Country: SE Received-SPF: softfail client-ip=91.136.10.210; envelope-from=mattiase@acm.org; helo=mail193c50.megamailservers.eu X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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:203772 Archived-At: --Apple-Mail=_2A1C3F29-9A56-4B7B-9D7A-3BD0DCF89340 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii This patch adds the condition-case handler syntax (:success BODY) for code executed when the protected form terminates without error. BODY = is then executed with the variable bound to the result of the protected = form, and the result of BODY is then the value of the condition-case = form as usual. This plugs an annoying hole in elisp: there hasn't been any direct = access to the success continuation which forced programmers to resort to = various hacks such as tagging the returned value and then immediately = testing that tag, as in (let ((input (condition-case _ (cons 'ok (read buffer)) (end-of-file 'eof)))) (when (consp input) (use (cdr input)))) Now we can write (condition-case result (read buffer) (end-of-file 'eof) (:success (use result))) which is more concise, elegant and performant. Like all condition-case handlers (but in contrast to the protected = form), the success handler is in the tail position and the limited = self-tail-recursion of cl-labels (and named-let) works there as = expected. Details of the syntax can be changed if there is a very good reason for = it. Many other languages have more or less independently added = equivalent constructs. Common Lisp's `handler-case` has a very similar = feature (:no-error). It would be nice to give `catch` the same treatment. A particularly = flexible solution would be to add `catch` handlers to `condition-case`, = which would then be able to handle everything. Unless there is a strong = reason for doing it right away, it can be seen as a later improvement. --Apple-Mail=_2A1C3F29-9A56-4B7B-9D7A-3BD0DCF89340 Content-Disposition: attachment; filename=0001-Add-condition-case-success-handler.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Add-condition-case-success-handler.patch" Content-Transfer-Encoding: quoted-printable =46rom=20952fc7ea3878d3d71a82d669a1499aee0d1f8c55=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=0A=0AAllow=20= a=20condition-case=20handler=20on=20the=20form=20(:success=20BODY)=20to=20= be=0Aspecified=20as=20the=20success=20continuation=20of=20the=20= protected=20form,=20with=0Athe=20specified=20variable=20bound=20to=20its=20= result.=0A=0A*=20src/eval.c=20(Fcondition_case):=20Update=20the=20doc=20= string.=0A(internal_lisp_condition_case):=20Implement=20in=20= interpreter.=0A(syms_of_eval):=20Defsym=20:success.=0A*=20= lisp/emacs-lisp/bytecomp.el=20(byte-compile-condition-case):=0AImplement=20= in=20byte-compiler.=0A*=20lisp/emacs-lisp/cl-macs.el=20(cl--self-tco):=20= Allow=20self-TCO=0Afrom=20success=20handler.=0A*=20= doc/lispref/control.texi=20(Handling=20Errors):=20Update=20manual.=0A*=20= etc/NEWS:=20Announce.=0A*=20test/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|=2078=20= ++++++++++++++++++++++++++=0A=20test/lisp/emacs-lisp/cl-macs-tests.el=20=20= |=20=209=20+--=0A=207=20files=20changed,=20157=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= a0f05d8cf1..fa82e2872f=20100644=0A---=20a/etc/NEWS=0A+++=20b/etc/NEWS=0A= @@=20-2898,6=20+2898,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= 94e33a7770..3ec443e04d=20100644=0A---=20= a/test/lisp/emacs-lisp/bytecomp-tests.el=0A+++=20= b/test/lisp/emacs-lisp/bytecomp-tests.el=0A@@=20-437,6=20+437,42=20@@=20= bytecomp-tests--test-cases=0A=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(arith-error=20x))))=0A=20=20=20=20=20=20=20(list=20x=20y))=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=20)=0A=20=20=20"List=20= of=20expressions=20for=20cross-testing=20interpreted=20and=20compiled=20= code.")=0A=20=0A@@=20-1178,6=20+1214,48=20@@=20= bytecomp-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=20= bytecomp-condition-case-success=20()=0A+=20=20;;=20No=20error,=20no=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(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=20= error,=20success=20handler.=0A+=20=20(should=20(equal=20(condition-case=20= x=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,=20success=20= handler.=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=20success=20= code=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=20= x=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=20x)))=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+=0A= =20;;=20Local=20Variables:=0A=20;;=20no-byte-compile:=20t=0A=20;;=20End:=0A= diff=20--git=20a/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=_2A1C3F29-9A56-4B7B-9D7A-3BD0DCF89340--