[Top][All Lists]

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

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

From: Tassilo Horn
Subject: Re: [elpa] externals/auctex cb0a1e6be1 72/77: Improve function calls to retrieve key=vals in style hooks
Date: Fri, 26 Aug 2022 23:17:37 +0200
User-agent: mu4e 1.9.0; emacs 29.0.50

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> 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.
> FWIW, I don't understand exactly how the above code is "linked" to the
> definition of `TeX-arg-key-val` (which in my code takes two arguments
> rather than one).

Yes, all TeX-arg-* functions have OPTIONAL as first arg but that's
implicit.  If you use it them parentheses, it's mandatory (optional is
nil) whereas when you use it with brackets it's optional.  Brackets
because that's how optional arguments are written in TeX.  So you could
also have

  `("bar" [TeX-arg-key-val ,(lambda () (append alist1 alist2))])

if it was \bar[key1=val1, key2=val2] instead of \bar{key1=val1,

> I tried to trace through the code, but it's a bit less obvious than
> needed for my little head.

Hehe, I agree... with the non-obviousness, of course, not the size of
your head. :-)


reply via email to

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