[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: TeX-arg-key-val syntax and let go of eval
From: |
Arash Esbati |
Subject: |
Re: TeX-arg-key-val syntax and let go of eval |
Date: |
Tue, 18 Oct 2022 08:55:14 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 |
Hi Tassilo,
Tassilo Horn <tsdh@gnu.org> writes:
> The first clause can be simplified to just (functionp key-val-alist).
> I don't know why I've had the fboundp there in the first place.
And I now remember why I had it (in a wrong way, anyway): I looked
through the places where `TeX-arg-key-val' is used and it seems that I
have only touch newfloat.el if we write the function like this:
(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 (listp key-val-alist)
(symbolp (car key-val-alist))
(fboundp (car key-val-alist)))
(funcall (car key-val-alist)))
((functionp 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)))))
So we can do things like:
(TeX-add-style-hook
"newfloat"
(lambda ()
(TeX-add-symbols
'("DeclareFloatingEnvironment"
[TeX-arg-key-val (LaTeX-newfloat-key-val-options)]
(...))
`("newfloatsetup"
(TeX-arg-key-val
,(lambda ()
(append '(("chapterlistsgap"))
(if (< (LaTeX-largest-level) 2)
'(("within" ("chapter" "section" "none")))
'(("within" ("section" "none")))))))))
TeX-dialect)
That is, we can have this (which is still my preference, btw)
'("macro" (TeX-arg-key-val (named-function)))
where named-function has no args, and
`("macro" (TeX-arg-key-val ,(lambda () ...)))
where ... is more complex stuff.
So this is my final proposal reg. getting rid of eval, I think :) WDYT.
Best, Arash
- Re: TeX-arg-key-val syntax and let go of eval, Arash Esbati, 2022/10/17
- Re: TeX-arg-key-val syntax and let go of eval, Tassilo Horn, 2022/10/17
- Re: TeX-arg-key-val syntax and let go of eval,
Arash Esbati <=
- Re: TeX-arg-key-val syntax and let go of eval, Tassilo Horn, 2022/10/18
- Re: TeX-arg-key-val syntax and let go of eval, Arash Esbati, 2022/10/19
- Re: TeX-arg-key-val syntax and let go of eval, Tassilo Horn, 2022/10/19
- Re: TeX-arg-key-val syntax and let go of eval, Tassilo Horn, 2022/10/20
- Re: TeX-arg-key-val syntax and let go of eval, Arash Esbati, 2022/10/21