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,gmane.emacs.auctex.devel Subject: TeX-arg-key-val syntax and let go of eval (was: [elpa] externals/auctex cb0a1e6be1 72/77: Improve function calls to retrieve key=vals in style hooks) Date: Tue, 30 Aug 2022 07:33:55 +0200 Message-ID: <87bks2p8sk.fsf@gnu.org> References: <166154439039.10036.933483657788018296@vcs2.savannah.gnu.org> <20220826200639.2B668C00889@vcs2.savannah.gnu.org> <87y1vavhw4.fsf@fastmail.fm> <86y1vaqhkh.fsf@gnu.org> <871qt2i158.fsf@gnu.org> <86pmgiq1x8.fsf@gnu.org> Reply-To: auctex-devel@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="34400"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.9.0; emacs 29.0.50 Cc: Stefan Monnier , emacs-devel , auctex-devel@gnu.org To: Arash Esbati Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Aug 30 08:08:23 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 1oSuQA-0008p6-Mk for ged-emacs-devel@m.gmane-mx.org; Tue, 30 Aug 2022 08:08:23 +0200 Original-Received: from localhost ([::1]:56680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSuQ7-0007DY-GM for ged-emacs-devel@m.gmane-mx.org; Tue, 30 Aug 2022 02:08:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSuLi-0005M5-LC; Tue, 30 Aug 2022 02:03:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:52102) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSuLi-0006b7-3Q; Tue, 30 Aug 2022 02:03:46 -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=8N2/er8rnVAzqss43WCl/TfEGOXaKc34Yzy54hHOJeg=; b=XWOIpxWRvH8Av0 2ChWY40+bSPo02GEefOX7bIdnf1fA2Q4qa1Fm4zOZzLtRdjO6QM3Ltpbh3CggkP+Lt5VgwuxulKer CX5BCuCADBLuylfpb4s+MjoZ0+E0dMUruuHl9mrcx7SAf/BL/oWT7jM08KSpcFcad5uazvB164xhb WI4RQB006NSxt9qnF7sUqucNA5Bvnx4ggqWGdgu4gdmq2wmOcix/1jTijjfn2TkprvpLGN7+cNXlY Ic5+sDlVIeC314hFMurVjURr0FEavRBJwFJjzOfbG6NwjCJE5sz97Gte1HXgZiULxkPQvZ4ggG0KY i+LLgLUAc3b25AGz4IdA==; Original-Received: from auth2-smtp.messagingengine.com ([66.111.4.228]:45503) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oSuLf-0006Dn-Qx; Tue, 30 Aug 2022 02:03:43 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailauth.nyi.internal (Postfix) with ESMTP id 3291E27C0054; Tue, 30 Aug 2022 02:03:43 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 30 Aug 2022 02:03:43 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdekvddguddthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpehffgfhvfevufffrhgjkfggtgesthdtredttdertdenucfhrhhomhepvfgr shhsihhlohcujfhorhhnuceothhsughhsehgnhhurdhorhhgqeenucggtffrrghtthgvrh hnpefftdekfffhhfdvvdehkeethfdtleevledtvdejkedujeelffevfeeltdejfeetjeen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehthhhorh hnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdekieejfeekjeekgedqieef hedvleekqdhtshguhheppehgnhhurdhorhhgsehfrghsthhmrghilhdrfhhm X-ME-Proxy: Feedback-ID: ib2b94485:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 30 Aug 2022 02:03:42 -0400 (EDT) In-reply-to: <86pmgiq1x8.fsf@gnu.org> 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:294323 gmane.emacs.auctex.devel:6865 Archived-At: Arash Esbati writes: >> So what's wrong with this one? >> >> (TeX-add-style-hook >> "foo" >> (lambda () >> (TeX-add-symbols >> `("bar" (TeX-arg-key-val >> ,(lambda () >> (append (func1-returning-keyval-alist) >> (func2-returning-keyval-alist)))))))) > > If this is the best/only option, well, I'm buying it :) It's the typical lispy solution which doesn't require eval. >> That's again caught by the functionp case and can simply be >> funcalled. > > How would you then re-write `TeX-read-key-val'? In my suggested version where (TeX-arg-key-val foo) would funcall foo if it were a function (without having to wrap it in parentheses), it would be: --8<---------------cut here---------------start------------->8--- (defun TeX-read-key-val (optional key-val-alist &optional prompt) (multi-prompt-key-value (TeX-argument-prompt optional prompt "Options (k=v)") (cond ((and (functionp key-val-alist) (fboundp key-val-alist)) (funcall key-val-alist)) ((and (symbolp key-val-alist) (boundp key-val-alist)) (symbol-value key-val-alist)) ((and (listp key-val-alist) (listp (car key-val-alist))) key-val-alist) (t (error "Cannot interpret key-val-alist %S" key-val-alist))))) --8<---------------cut here---------------end--------------->8--- > And while we're at, what do we do with `TeX-arg-eval'? Nothing. It's been there since 1994 so we cannot really do anything except declaring it obsolete. But since probably nobody byte-compiles his styles and therefore might see the warning, we will never be able to get rid of it. >> I'd rather prefer to keep the DSL simple, e.g., TeX-arg-key-val >> arguments can either be a literal alist, a function of no args >> delivering an alist, or a symbol denoting an alist variable (checked in >> that order). That is, I wouldn't even distinguish functions from >> variables syntactically but prefer functions in general, e.g., >> >> (TeX-arg-key-val (LaTeX-enumitem-key-val-options)) >> >> would become >> >> (TeX-arg-key-val LaTeX-enumitem-key-val-options) >> >> where LaTeX-enumitem-key-val-options is funcalled and takes >> precedence of the variable of the same name. > > Hmm, Sorry, but I don't like this. Why taking away the clarity of > what is currently used, the variable or the function? I think having > the function call in () increases the legibility. Because it makes TeX-read-key-val easy to implement (no need to distinguish a "funcall list" from a literal alist) and the heuristics "try function, else try variable, else try literal alist" is really not hard. Also because '(TeX-arg-key-val (LaTeX-enumitem-key-val-options)) looks like normal evaluation syntax but that symmetry immediately breaks with `(TeX-arg-key-val ,(lambda () ...)) which would need to be `(TeX-arg-key-val (,(lambda () ...))) to keep symmetry. But then we're in lisp-1 land which also looks wrong. :-) >> Sorry, I know we had a discussion back then where I haven't been >> explicit enough or haven't had an informed opinion yet. :-( > > No problem, you will have to adjust all AUCTeX styles for being late > ;-) Sure, I can do that but want to achieve a consensus first. Given that I haven't written a LaTeX doc in at least 6 years and consequently my AUCTeX activities have much decreased, I'm not in a position to enforce my personal preferences. Bye, Tassilo PS: I've added auctex-devel to the Cc and set Reply-To accordingly.