Function: toolbarx-eval-function-or-symbol
toolbarx-eval-function-or-symbol is a byte-compiled function defined
in toolbar-x.el.
Signature
(toolbarx-eval-function-or-symbol OBJECT TYPE-TEST-FUNC)
Documentation
Return a cons cell (GOOD-OBJ . VAL).
GOOD-OBJ non-nil means that VAL is a valid value, according to the car of the result of TYPE-TEST-FUNCTION, that should return a cons cell in the same format as the return of this function.
If OBJECT applied to TYPE-TEST-FUNC return (GOOD-OBJ . VAL), and GOOD-OBJ is non-nil, return that. Else, check if OBJECT is a function. If so, evaluate and test again with TYPE-TEST-FUNC. If not a function or if GOOD-OBJ is again nil, test if OBJECT is a bound symbol, evaluate that and return the result of TYPE-TEST-FUNC.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/toolbar-x.el
(defun toolbarx-eval-function-or-symbol (object type-test-func)
"Return a cons cell (GOOD-OBJ . VAL).
GOOD-OBJ non-nil means that VAL is a valid value, according to
the car of the result of TYPE-TEST-FUNCTION, that should return a
cons cell in the same format as the return of this function.
If OBJECT applied to TYPE-TEST-FUNC return (GOOD-OBJ . VAL), and
GOOD-OBJ is non-nil, return that. Else, check if OBJECT is a
function. If so, evaluate and test again with TYPE-TEST-FUNC. If
not a function or if GOOD-OBJ is again nil, test if OBJECT is a
bound symbol, evaluate that and return the result of
TYPE-TEST-FUNC."
(let* ((ret (funcall type-test-func object)))
(unless (car ret)
(if (functionp object)
(progn
(setq ret (funcall type-test-func (funcall object)))
(unless (car ret)
(when (and (symbolp object) (boundp object))
(setq ret (funcall type-test-func (symbol-value object))))))
;; ok, obj is not function; try symbol
(when (and (symbolp object) (boundp object))
(setq ret (funcall type-test-func (symbol-value object))))))
ret))