Reputation: 35301
How can one list all the globally defined variables (ideally with their global-scope values) for the current Emacs session?
Upvotes: 0
Views: 47
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