kjo
kjo

Reputation: 35301

How to get a comprehensive listing of all defined variables (and their values)?

How can one list all the globally defined variables (ideally with their global-scope values) for the current Emacs session?

Upvotes: 0

Views: 47

Answers (1)

coredump
coredump

Reputation: 38789

Looking at the source code for describe-variable and obarray, it seems that the following should give you what you want.

(defun global-bindings ()
  (let (res)
    (mapatoms (lambda (vv)
                (when (and (boundp vv)
                           (not (keywordp vv))
                           (get vv 'variable-documentation))
                  (push (cons vv (symbol-value vv)) res))))
    res))

Upvotes: 4

Related Questions