Hi Tassilo, Tassilo Horn <[email protected]> writes:
> Arash Esbati <[email protected]> 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 :) > > It's the typical lispy solution which doesn't require eval. > >>> That's again caught by the functionp case and can simply be >>> funcalled. >> >> How would you then re-write `TeX-read-key-val'? > > In my suggested version where (TeX-arg-key-val foo) would funcall foo if > it were a function (without having to wrap it in parentheses), it would > be: > > (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 (functionp key-val-alist) > (fboundp 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))))) Sorry for my late response. I started changing `TeX-read-key-val' and our styles acc. to discussion above and I think we're still not there. In the example above, (TeX-add-style-hook "foo" (lambda () (TeX-add-symbols `("bar" (TeX-arg-key-val ,(lambda () (append (func1-returning-keyval-alist) (func2-returning-keyval-alist)))))))) the part ",(lambda () (append ..." is turned into a "(closure (t) nil (append ..." and then the `fboundp' check in `TeX-read-key-val' gets upset. I suggest to write `TeX-read-key-val' 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 ((or (and (symbolp key-val-alist) (fboundp 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))))) WDYT? >> And while we're at, what do we do with `TeX-arg-eval'? > > Nothing. Ok. Best, Arash
