1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#+TITLE: Interactive Reverse Variable Search in Emacs
#+DATE: 2020-09-16T00:04:06-04:00
#+DRAFT: true
#+DESCRIPTION:
#+TAGS[]: emacs
#+KEYWORDS[]:
#+SLUG:
#+SUMMARY:
I don't remember where I read it, but while I was first learning about
how elisp works, someone had mentioned the fact that it could perform
reverse variable searches. I remember thinking that idea was
incredibly interesting.
I'd tried looking that capability at the time and coming up short.
Every link I'd looked at only talked about reverse I-search and xref
capabilities. I pretty soon after forgot about it.
The thought crossed my mind again today, out of the blue, and I
decided that I would once and for all get to the bottom of it. I
stumbled across the answer in [[https://github.com/lepisma/til-emacs][this]] github repo which contains various
Emacs tips. Apparently this reverse variable search is performed
through the =apropos-value= command. I had to say, I was quite
disappointed with the result.
The command provides a lackluster interface to say the least, with the
only input being the ability to enter a search string in the
minibuffer. It's results are also fairly disappointing, often not even
returning a result, with the error message =condition-case: Apparently
circular structure being printed=. When the results do appear, they
are usually hard to understand, with the search term being deep in a
list.
To quench my thirst for an interactive reverse variable lookup that
provided accurate results, I decided to make my own. I called it
[[https://github.com/dantecatalfamo/helm-atoms][helm-atoms]]. It's both completely interactive, using the [[https://emacs-helm.github.io/helm/][helm]]
completion and narrowing framework, and incredibly fast.
The way it works is quite simple.
There's a function in Emacs called =mapatoms=, which takes a function as
one of its parameters. Without a second parameter, it traverses Emacs'
standard =obarray=, which is a table which holds most of the interned
symbols in Emacs. If you're curious about how symbols and interning
work in Emacs, you can check out the info page on [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Symbols.html][Creating and
Interning Symbols]].
|