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#42147: 28.0.50; pure vs side-effect-free, missing optimizations? Date: Sun, 26 Jul 2020 11:05:45 +0200 Message-ID: <81F989D1-3CC4-450B-89D6-E9C16F766277@acm.org> References: <3A9CC2A3-8307-47B2-8D80-795C0AF020E1@acm.org> <0433A879-C98D-4B1A-B85C-A15DA9289099@acm.org> <1621669100.2102667.1593639091621@mail.yahoo.com> <33C2E2C8-16A6-47A9-B3A4-8A5F43648E04@acm.org> <51FE77F3-CA05-459A-9601-9E1EEBC1E2FE@acm.org> <1213DD41-01F9-4605-8D32-D750B6CE2B35@acm.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.15\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_7CD49673-F51C-4244-97ED-4AC16210C311" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30192"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Philipp Stephani , Paul Eggert , Andrea Corallo , 42147@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 26 11:07:14 2020 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 1jzccj-0007kj-B1 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jul 2020 11:07:13 +0200 Original-Received: from localhost ([::1]:52656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jzcci-0003eF-7b for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Jul 2020 05:07:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jzccY-0003dr-ML for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 05:07:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40238) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jzccX-0000m0-R2 for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 05:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jzccX-0004HW-LX for bug-gnu-emacs@gnu.org; Sun, 26 Jul 2020 05:07:01 -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, 26 Jul 2020 09:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42147 X-GNU-PR-Package: emacs Original-Received: via spool by 42147-submit@debbugs.gnu.org id=B42147.159575436416389 (code B ref 42147); Sun, 26 Jul 2020 09:07:01 +0000 Original-Received: (at 42147) by debbugs.gnu.org; 26 Jul 2020 09:06:04 +0000 Original-Received: from localhost ([127.0.0.1]:51784 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jzcbc-0004GH-0b for submit@debbugs.gnu.org; Sun, 26 Jul 2020 05:06:04 -0400 Original-Received: from mail1438c50.megamailservers.eu ([91.136.14.38]:43506 helo=mail263c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jzcbX-0004Fk-U0 for 42147@debbugs.gnu.org; Sun, 26 Jul 2020 05:06:03 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1595754350; bh=z6V1ROhWTX6PSm9CNPX6yDD+G3AhP2O3qLbflQ8p+jo=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=OzaE8GJV4gQg9Ode2E4Z1/r63YeZiVAlIxdktK3J2DU1fAgAPz1U4tqmlGY63JfrU Et5K7nO7HmM7pQwmIVy7KpxR4iIQf/+cmwtAJfi6LXxvoBgwbHcjppGon3UD98Q9Wx bNi09g+tNSpdbKSXd7FQBVQfcn+1OsKpxFOmejso= Feedback-ID: mattiase@acm.or Original-Received: from stanniol.lan (c-4e4ae655.032-75-73746f71.bbcust.telenor.se [85.230.74.78]) (authenticated bits=0) by mail263c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 06Q95kZa015327; Sun, 26 Jul 2020 09:05:48 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3445.104.15) X-CTCH-RefID: str=0001.0A782F21.5F1D476E.000A:SCFSTAT68638221, ss=1, re=-4.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: -4.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=e6d4tph/ c=1 sm=1 tr=0 a=klNLuyVZdLUgl+K5Uafb2A==:117 a=klNLuyVZdLUgl+K5Uafb2A==:17 a=M51BFTxLslgA:10 a=iRZporoAAAAA:8 a=yH5Vgya-m5LGbCV1YtEA:9 a=CjuIK1q_8ugA:10 a=ENOmLqmOUNYA:10 a=IC-H6EgDmPjHCZcLhs4A:9 a=B2y7HmGcmWMA:10 a=NOBgFS-JBQ2l-kSd6-zu:22 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:183566 Archived-At: --Apple-Mail=_7CD49673-F51C-4244-97ED-4AC16210C311 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii 26 juli 2020 kl. 00.30 skrev Stefan Monnier : > But yes, it's a problem because `C-h o kbd RET` says explicitly that it > doesn't change the match data :-( Motivation enough for them to save the match data then. What about the attached patch? --Apple-Mail=_7CD49673-F51C-4244-97ED-4AC16210C311 Content-Disposition: attachment; filename=0001-Preserve-match-data-in-kbd-and-package-get-version.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Preserve-match-data-in-kbd-and-package-get-version.patch" Content-Transfer-Encoding: quoted-printable =46rom=20ba851b70be4211695937fa7fbac7ee38bbbfa4aa=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Sun,=2026=20Jul=202020=2010:51:42=20+0200=0A= Subject:=20[PATCH]=20Preserve=20match=20data=20in=20'kbd'=20and=20= 'package-get-version'=0A=0A*=20lisp/emacs-lisp/package.el=20= (package-get-version):=0A*=20lisp/subr.el=20(kbd):=20Preserve=20match=20= data,=20since=20these=20functions=20are=0Adeclared=20pure=20(see=20= discussion=20in=20bug#42147).=0A---=0A=20lisp/emacs-lisp/package.el=20|=20= 39=20+++++++++++++++++++-------------------=0A=20lisp/subr.el=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20|=20=207=20+++----=0A=202=20files=20= changed,=2023=20insertions(+),=2023=20deletions(-)=0A=0Adiff=20--git=20= a/lisp/emacs-lisp/package.el=20b/lisp/emacs-lisp/package.el=0Aindex=20= e6f54d206d..b87f568650=20100644=0A---=20a/lisp/emacs-lisp/package.el=0A= +++=20b/lisp/emacs-lisp/package.el=0A@@=20-3936,25=20+3936,26=20@@=20= package-get-version=0A=20=20=20=20=20=20=20=20=20=20(or=20(if=20(boundp=20= 'byte-compile-current-file)=20byte-compile-current-file)=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20=20load-file-name=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20buffer-file-name)))=0A-=20=20=20=20(cond=0A-=20=20=20=20=20= ((null=20file)=20nil)=0A-=20=20=20=20=20;;=20Packages=20are=20normally=20= installed=20into=20directories=20named=20"-",=0A-=20=20=20=20=20= ;;=20so=20get=20the=20version=20number=20from=20there.=0A-=20=20=20=20=20= ((string-match=20= "/[^/]+-\\([0-9]\\(?:[0-9.]\\|pre\\|beta\\|alpha\\|snapshot\\)+\\)/[^/]+\\= '"=20file)=0A-=20=20=20=20=20=20(match-string=201=20file))=0A-=20=20=20=20= =20;;=20For=20packages=20run=20straight=20from=20the=20an=20elpa.git=20= clone,=20there's=20no=0A-=20=20=20=20=20;;=20"-"=20in=20the=20= directory=20name,=20so=20we=20have=20to=20fetch=20the=20version=0A-=20=20= =20=20=20;;=20the=20hard=20way.=0A-=20=20=20=20=20(t=0A-=20=20=20=20=20=20= (let*=20((pkgdir=20(file-name-directory=20file))=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20(pkgname=20(file-name-nondirectory=20= (directory-file-name=20pkgdir)))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20= (mainfile=20(expand-file-name=20(concat=20pkgname=20".el")=20pkgdir)))=0A= -=20=20=20=20=20=20=20=20(when=20(file-readable-p=20mainfile)=0A-=20=20=20= =20=20=20=20=20=20=20(require=20'lisp-mnt)=0A-=20=20=20=20=20=20=20=20=20= =20(with-temp-buffer=0A-=20=20=20=20=20=20=20=20=20=20=20=20= (insert-file-contents=20mainfile)=0A-=20=20=20=20=20=20=20=20=20=20=20=20= (or=20(lm-header=20"package-version")=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(lm-header=20"version")))))))))=0A+=20=20=20=20= (save-match-data=20=20=20=20=20=20=20=20=20=20=20=20;=20Since=20the=20= function=20is=20declared=20pure.=0A+=20=20=20=20=20=20(cond=0A+=20=20=20=20= =20=20=20((null=20file)=20nil)=0A+=20=20=20=20=20=20=20;;=20Packages=20= are=20normally=20installed=20into=20directories=20named=20= "-",=0A+=20=20=20=20=20=20=20;;=20so=20get=20the=20version=20= number=20from=20there.=0A+=20=20=20=20=20=20=20((string-match=20= "/[^/]+-\\([0-9]\\(?:[0-9.]\\|pre\\|beta\\|alpha\\|snapshot\\)+\\)/[^/]+\\= '"=20file)=0A+=20=20=20=20=20=20=20=20(match-string=201=20file))=0A+=20=20= =20=20=20=20=20;;=20For=20packages=20run=20straight=20from=20the=20an=20= elpa.git=20clone,=20there's=20no=0A+=20=20=20=20=20=20=20;;=20"-"=20= in=20the=20directory=20name,=20so=20we=20have=20to=20fetch=20the=20= version=0A+=20=20=20=20=20=20=20;;=20the=20hard=20way.=0A+=20=20=20=20=20= =20=20(t=0A+=20=20=20=20=20=20=20=20(let*=20((pkgdir=20= (file-name-directory=20file))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(pkgname=20(file-name-nondirectory=20(directory-file-name=20pkgdir)))=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(mainfile=20= (expand-file-name=20(concat=20pkgname=20".el")=20pkgdir)))=0A+=20=20=20=20= =20=20=20=20=20=20(when=20(file-readable-p=20mainfile)=0A+=20=20=20=20=20= =20=20=20=20=20=20=20(require=20'lisp-mnt)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20(with-temp-buffer=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (insert-file-contents=20mainfile)=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(or=20(lm-header=20"package-version")=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(lm-header=20"version"))))))))))=0A=20=0A=20=0C= =0A=20;;;;=20Quickstart:=20precompute=20activation=20actions=20for=20= faster=20start=20up.=0Adiff=20--git=20a/lisp/subr.el=20b/lisp/subr.el=0A= index=2010c37e9413..70a6ec7ab2=20100644=0A---=20a/lisp/subr.el=0A+++=20= b/lisp/subr.el=0A@@=20-891,10=20+891,9=20@@=20kbd=0A=20`edmacro-mode').=0A= =20=0A=20For=20an=20approximate=20inverse=20of=20this,=20see=20= `key-description'."=0A-=20=20;;=20Don't=20use=20a=20defalias,=20since=20= the=20`pure'=20property=20is=20true=20only=20for=0A-=20=20;;=20the=20= calling=20convention=20of=20`kbd'.=0A-=20=20(read-kbd-macro=20keys))=0A= -(put=20'kbd=20'pure=20t)=0A+=20=20(declare=20(pure=20t))=0A+=20=20;;=20= A=20pure=20function=20is=20expected=20to=20preserve=20the=20match=20= data.=0A+=20=20(save-match-data=20(read-kbd-macro=20keys)))=0A=20=0A=20= (defun=20undefined=20()=0A=20=20=20"Beep=20to=20tell=20the=20user=20this=20= binding=20is=20undefined."=0A--=20=0A2.21.1=20(Apple=20Git-122.3)=0A=0A= --Apple-Mail=_7CD49673-F51C-4244-97ED-4AC16210C311--