8

Does something already exist to do this?

(defun good (var)
     (and (boundp 'var) var))
14

There is a macro defined in bindings.el that does exactly that:

(defmacro bound-and-true-p (var)
  "Return the value of symbol VAR if it is bound, else nil."
  `(and (boundp (quote ,var)) ,var))
9

How about this:

bound-and-true-p is a Lisp macro in `bindings.el'.

(bound-and-true-p VAR)

Return the value of symbol VAR if it is bound, else nil.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.