From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arash Esbati Newsgroups: gmane.emacs.devel Subject: Re: [elpa] externals/auctex cb0a1e6be1 72/77: Improve function calls to retrieve key=vals in style hooks Date: Mon, 29 Aug 2022 21:34:27 +0200 Message-ID: <86pmgiq1x8.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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4413"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 Cc: Stefan Monnier , emacs-devel@gnu.org To: Tassilo Horn Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 29 21:38:03 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 1oSkaB-0000uZ-0O for ged-emacs-devel@m.gmane-mx.org; Mon, 29 Aug 2022 21:38:03 +0200 Original-Received: from localhost ([::1]:35326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oSka9-0003xv-Ho for ged-emacs-devel@m.gmane-mx.org; Mon, 29 Aug 2022 15:38:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSkWy-0001bH-Pw for emacs-devel@gnu.org; Mon, 29 Aug 2022 15:34:44 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:48942) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSkWy-000870-G4; Mon, 29 Aug 2022 15:34:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=d2h5oUmEmwLxJ4zWKLCzyaqzht1IPBmaCzeY08st3Yk=; b=Byj+4923+aAhy8dCZOny ac7Vmk4bp98n0+m/9ultdpssE6yDy0Oy6+qFgZ493FNj0URlx0H1rekvIPH9U5K42SJfEdKn6ELqy C+E/u6yMNiGmmWBZwoybz5NEUqCV6D999SLzf4UOWKUkaiYhpVQcdjGi746YlXCaScOS+hskeVXM7 I+YSTaoGk1AAg+1vTF9yX3lji9KoPKmVWIUrXipBYmlH95cFd+QA+tVYQVOzzMw3CXPswmMF3lbgv 1er1XplJ8JcQh4wqc67H5S0DvFdLqebiM8UMWWatxMkduvzstfjLZE+I6zh3jX+8oZ9VGAygl6OD+ y7z456gmvWgjjQ==; Original-Received: from pd9fb77f7.dip0.t-ipconnect.de ([217.251.119.247]:53548 helo=MUTANT) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oSkWw-0006fo-8p; Mon, 29 Aug 2022 15:34:43 -0400 In-Reply-To: <871qt2i158.fsf@gnu.org> (Tassilo Horn's message of "Sat, 27 Aug 2022 09:25:44 +0200") 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:294304 Archived-At: Tassilo Horn 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 :) > That's again caught by the functionp case and can simply be funcalled. How would you then re-write `TeX-read-key-val'? It currently looks like this: (defun TeX-read-key-val (optional key-val-alist &optional prompt) "Prompt for keys and values in KEY-VAL-ALIST and return them. If OPTIONAL is non-nil, indicate in the prompt that we are reading an optional argument. KEY-VAL-ALIST is an alist. The car of each element should be a string representing a key and the optional cdr should be a list with strings to be used as values for the key. KEY-VAL-ALIST can be a symbol or a function call returning an alist. Use PROMPT as the prompt string." (multi-prompt-key-value (TeX-argument-prompt optional prompt "Options (k=v)") (cond ((and (symbolp key-val-alist) (boundp key-val-alist)) (symbol-value key-val-alist)) ((and (listp key-val-alist) (symbolp (car key-val-alist)) (fboundp (car key-val-alist))) (if (> (length key-val-alist) 1) (eval key-val-alist t) (funcall (car key-val-alist)))) (t key-val-alist)))) And while we're at, what do we do with `TeX-arg-eval'? > 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. > 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 ;-) Best, Arash