emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [elpa] externals/auctex cb0a1e6be1 72/77: Improve function calls to


From: Arash Esbati
Subject: Re: [elpa] externals/auctex cb0a1e6be1 72/77: Improve function calls to retrieve key=vals in style hooks
Date: Sat, 27 Aug 2022 09:19:42 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50

Tassilo Horn <tsdh@gnu.org> writes:

> 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.

Actually, I changed all AUCTeX styles to have a function which returns a
keyval-alist for the ones which are populated dynamically.  Maintaining
a single variable for this kind of stuff was a mess.

So take fancyvrb.el for example which has a variable
`LaTeX-fancyvrb-key-val-options'[1] (which can declared by defconst now)
and a function `LaTeX-fancyvrb-key-val-options'[2] which returns the
current keyvals.

So my last requirement was to be able to do something like this:

(TeX-add-style-hook
 "foo"
 (lambda ()
   (TeX-add-symbols
    '("bar" (TeX-arg-key-val
             (append (func1-returning-keyval-alist)
                     (func2-returning-keyval-alist)))))))

And this didn't work with the (apply head tail) version.  Any other
suggestion how to implement this in `TeX-arg-key-val' is highly welcome.
I was reluctant to use eval in the first place since I knew that Stefan
will complain :-) but I didn't see any other possibility.

Best, Arash

Footnotes:
[1]  http://git.savannah.gnu.org/cgit/auctex.git/tree/style/fancyvrb.el#n74

[2]  http://git.savannah.gnu.org/cgit/auctex.git/tree/style/fancyvrb.el#n127



reply via email to

[Prev in Thread] Current Thread [Next in Thread]