print symbols of emacs in elisp

723 views Asked by At

How to print all the symbols in emacs using elisp.

It is possible to test wheather a lisp object is a symbol using symbolp function. But how to collect all the symbols.

Is it possible to access symbol table of emacs?

2

There are 2 answers

2
Bozhidar Batsov On BEST ANSWER

Here's one way to do it:

(require 'cl)

(loop for x being the symbols
    if (boundp x)
    collect (symbol-name x))

loop is a Common Lisp macro, that has been ported to Emacs Lisp as well. It's part of the cl package (part of the standard Emacs distribution), that you'll have to require to use it.

Another option to consider is probably:

(apropos "." t)

The apropos invokation will take significantly more time to complete, but you'll get more information about the symbols that way.

0
Sean On

Just for completeness, here's how you'd list all of the symbols without using the cl package:

Go to a newly-created buffer, and type M-:(mapatoms (lambda (s) (insert (symbol-name s) "\n")))RET. That will insert the names of all existing symbols in the buffer, one per line.