如何获得所有已定义变量(及其值)的完整列表?

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

如何列出当前 Emacs 会话的所有全局定义的变量(最好带有它们的全局范围值)?

查看 describe-variableobarray 的源代码,似乎以下内容应该可以满足您的需求。

(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))