From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: [elpa] externals/auctex cb0a1e6be1 72/77: Improve function calls to retrieve key=vals in style hooks Date: Fri, 26 Aug 2022 22:47:47 +0200 Message-ID: <87y1vavhw4.fsf@fastmail.fm> References: <166154439039.10036.933483657788018296@vcs2.savannah.gnu.org> <20220826200639.2B668C00889@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15325"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.9.0; emacs 29.0.50 Cc: emacs-devel@gnu.org To: Stefan Monnier , Arash Esbati Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Aug 26 23:03:17 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oRgU0-0003qt-WF for ged-emacs-devel@m.gmane-mx.org; Fri, 26 Aug 2022 23:03:17 +0200 Original-Received: from localhost ([::1]:38334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRgTz-0001hc-QO for ged-emacs-devel@m.gmane-mx.org; Fri, 26 Aug 2022 17:03:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRgSQ-0000r0-22 for emacs-devel@gnu.org; Fri, 26 Aug 2022 17:01:38 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:57436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRgSO-0004BN-Pi; Fri, 26 Aug 2022 17:01:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-reply-to:Date:Subject:To:From: References; bh=LbRcBCW8NYRcLhZ2R3jbP2ac+CHFrZTHIasIXu5I25E=; b=F3vfVAY8GYRluv MliXllPlBuUUqzivXPXKV5KGI56emDRs9OLQACCeh4/VfwGTxJsjv6or14EQvlJ2h/m62dh5j93Fo YeAwT5dbObQy9zPGdIuwNanOlOotANjDGmfOxgdyorZ/mMrSsioVR66y+LW4F4N//C1/YRDsimkW7 5EcaEmFRDBS33SkJDXJpAsuoHmgfnUA7sFeAhVKgh0Gy6eZiP+kHKGeoUBcuOck/7OFZuwXGX/lMD hB+9q8PzSGpM+dqBj0g9IHBdfoE6v0g94Y3J8V21jLuuQa1lcykLsxE1J+a+TN5pNKRoY9L+cqpYp LhjWwD+nNh8enXslfzVw==; Original-Received: from auth2-smtp.messagingengine.com ([66.111.4.228]:46749) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRgSN-0007ds-42; Fri, 26 Aug 2022 17:01:35 -0400 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailauth.nyi.internal (Postfix) with ESMTP id 8464627C0054; Fri, 26 Aug 2022 17:01:34 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 26 Aug 2022 17:01:34 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdejhedgudehhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpehffgfhvfevufffjgfkgggtsehttdertddtredtnecuhfhrohhmpefvrghs shhilhhoucfjohhrnhcuoehtshguhhesghhnuhdrohhrgheqnecuggftrfgrthhtvghrnh epudejtdehuddvleffjeekteegvdehleehvdeufefhueekkeekhedvgfeggeffvefgnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhrnh domhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqkeeijeefkeejkeegqdeifeeh vdelkedqthhsughhpeepghhnuhdrohhrghesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Feedback-ID: ib2b94485:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 26 Aug 2022 17:01:33 -0400 (EDT) In-reply-to: X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:294164 Archived-At: Stefan Monnier writes: Hi Stefan & Arash, > Tassilo Horn [2022-08-26 16:06:39] wrote: >> Improve function calls to retrieve key=vals in style hooks >> >> * latex.el (TeX-read-key-val): Improve call of functions as >> argument of `TeX-arg-key-val' inside style hooks. > [...] >> (fboundp (car key-val-alist))) >> - (let ((head (car key-val-alist)) >> - (tail (cdr key-val-alist))) >> - (apply head tail))) >> + (if (> (length key-val-alist) 1) >> + (eval key-val-alist t) >> + (funcall (car key-val-alist)))) >> (t > > FWIW, replacing `apply` with `eval` is not an "Improve"ment in my book > :-) It means now that `key-val-alist` contains code represented as > data (i.e. code to which flymake, the compiler, the eager > macroexpander, etc... don't have access) whereas it previously only > contains values (which can't contain code that needs macroexpansion, > for example). That's true. I've searched the auctex lists and found out that Arash made this change because he wanted to make it possible for styles to do stuff like (TeX-add-style-hook "foo" (lambda () (TeX-add-symbols '("bar" (TeX-arg-key-val (append alist1 alist2)))))) where (append alist1 alist2) is what's being evaled. Arash, wouldn't (TeX-add-style-hook "foo" (lambda () (TeX-add-symbols `("bar" (TeX-arg-key-val ,(append alist1 alist2)))))) be just as good? I guess no because IIRC the context was that alist1 and alist2 might be populated dynamically (by parsing the document) so we need to take the values at the time the \bar macro is inserted. So probably (TeX-add-style-hook "foo" (lambda () (TeX-add-symbols `("bar" (TeX-arg-key-val ,(lambda () (append alist1 alist2))))))) would be the right thing which works without eval, right? It's a bit longer but I wouldn't mind. Wrapping code in a lambda to be evaluated later is a common concept. Bye, Tassilo