Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print all the defined variables in emacs?

Tags:

emacs

M-x < TAB > prints all the defined functions.

To check a variable is defined or not evaluating the following expression, (boundp 'variable-name) C-x C-e will print t if the variable-name is defined else nill.

How to print all the defined variables in emacs.

like image 851
Talespin_Kit Avatar asked Jun 27 '11 13:06

Talespin_Kit


People also ask

How do I set variables in Emacs?

Interactively, you can set the buffer local value using C-x f. You can customize this variable. The line that says ' You can customize the variable ' indicates that this variable is a user option. C-h v is not restricted to user options; it allows non-customizable variables too.


2 Answers

Extrapolating (heavily!) what is being asked for, here is a way to get a pretty-printed alist of all buffer-local variables with their values. This is very convenient for finding out why for instance a mode isn't behaving the way one expects.

To get this listing, do:

M-x pp-eval-expression RET (buffer-local-variables) RET

Relevant portions from this list can be added almost verbatim to a .dir-locals.el file for use with multiple files.

like image 151
ack Avatar answered Sep 18 '22 11:09

ack


It's unclear exactly what you want to do with a full list of symbols, since the way in which M-x displays function names is somewhat specialized.

Assuming that you want to programmatically obtain a list of all defined symbols, here's how auto-complete.el does it:

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

Note that you can also enter M-x describe-var RET, and then press TAB to get a sorted completion list of all symbols.

like image 29
sanityinc Avatar answered Sep 19 '22 11:09

sanityinc