Listing all top level global variables in emacs

2019-06-24 15:17发布

问题:

Mostly for my own edification I'm trying to list all of the global variables loaded in the current Emacs session. What I was thinking about doing is producing an HTML file with all of the functions listed. Of course, what would also be useful is the file where the function, var, etc was defined.

Is there anything already built into emacs to help?

L-

回答1:

Something along these lines should do:

(let ((result '()))
  (mapatoms (lambda (x)
              (when (boundp x)
                (let ((file (ignore-errors
                              (find-lisp-object-file-name x 'defvar))))
                  (when file
                    (push (cons x file) result))))))
  result)

Warning: it takes a long time to finish.