Hi Tassilo,

Tassilo Horn <[email protected]> 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

Reply via email to