How to print all the defined variables in emacs?

前端 未结 3 1727
一个人的身影
一个人的身影 2020-12-18 00:30

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 pr

相关标签:
3条回答
  • 2020-12-18 01:21

    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.

    0 讨论(0)
  • 2020-12-18 01:22

    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.

    0 讨论(0)
  • 2020-12-18 01:24

    I presume (apropos-variable "." t) would show you all the variables defined at that point in time.

    edit: I presumed wrongly, it would seem.

    Interestingly, this actually shows me significantly fewer results than the auto-completions from describe-var.

    Can anyone shed light on that?

    e.g. the differences between these, when winner-mode has been enabled:

    • C-uM-x apropos-variable RET winner- RET
    • C-hv winner- TAB

    edit 2: Ah... it looks like apropos may ignore any symbol which lacks a documentation string.

    If it's possible, I suggest reassigning the accepted answer.

    0 讨论(0)
提交回复
热议问题