Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: how to find a variable by its value?

Tags:

emacs

elisp

I have some value and know that some Emacs variable holds it. How to find, which variable has this value in it? The value can be a symbol, integer or string, and the variable may hold the value itself, but a list which contains a value.

Example. A variable default-directory contains string "/var/www/". I have that string, but i suddenly forgot the variable's name. How do i search through variables and find that default-directory contains that string?

Is there some builtin function for that, or the only solution is custom elisp snippet?

like image 279
Mirzhan Irkegulov Avatar asked Mar 19 '12 13:03

Mirzhan Irkegulov


People also ask

What does setq do in emacs?

setq does not evaluate symbol ; it sets the symbol that you write. We say that this argument is automatically quoted. The ' q ' in setq stands for “quoted”. The value of the setq form is the value of the last form .

Are there variables in Lisp?

There are actually two kinds of variables in Common Lisp, called lexical (or static) variables and special (or dynamic) variables. At any given time either or both kinds of variable with the same name may have a current value.

How do you declare a variable in Elisp?

To define a customizable variable, you should use defcustom (which calls defvar as a subroutine). See Variable Definitions. This special form defines symbol as a variable. Note that symbol is not evaluated; the symbol to be defined should appear explicitly in the defvar form.


2 Answers

M-x apropos-value RET ^"/var/www/"$ RET

like image 172
yibe Avatar answered Sep 20 '22 08:09

yibe


The required command is apropos-value.

like image 24
event_jr Avatar answered Sep 19 '22 08:09

event_jr