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