Search code examples
emacselispdocumentation-generationglobal

Listing all top level global variables in emacs


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-


Solution

  • 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.