• Stars
    star
    111
  • Rank 304,499 (Top 7 %)
  • Language
    Emacs Lisp
  • Created almost 8 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

semantic code search for emacs lisp

elisp-refs

Coverage Status MELPA

elisp-refs is an intelligent code search for Emacs lisp.

It can find references to functions, macros or variables. Unlike a dumb text search, elisp-refs actually parses the code, so it's never confused by comments or variables with the same name as functions.

screenshot

This is particularly useful for finding all the places a function is used, or finding examples of usage.

Interested readers may enjoy my blog post: Searching A Million Lines Of Lisp.

Installation

Install from MELPA (recommended) or just add elisp-refs to your load-path.

Commands available

  • elisp-refs-function (find function calls)
  • elisp-refs-macro (find macro calls)
  • elisp-refs-variable (find variable references)
  • elisp-refs-special (find special form calls)
  • elisp-refs-symbol (find all references to a symbol)

These command search all the files currently loaded in your Emacs instance.

If called with a prefix, you can limit search results to specific directories. For example:

C-u M-x elisp-refs-macro RET pcase RET ~/.emacs.d/elpa/magit-20160927.510 RET

will search for uses of pcase in magit:

filtering screenshot

Semantic analysis

elisp-refs has street smarts: given (defun foo (bar) (baz)), it understands that bar is a variable and baz is a function.

elisp-refs understands the following forms:

  • defun defsubst defmacro cl-defun
  • lambda
  • let let*
  • funcall apply
  • sharp quoted expressions (e.g. #'some-func)

Limitations

elisp-refs understands elisp special forms, and a few common macros. However, it cannot understand arbitrary macros.

Therefore elisp-refs will assume that (other-macro (foo bar)) is a function call to foo. If this is incorrect, you may wish to use the command elisp-refs-symbol to find all references to the foo symbol.

If other-macro is a common macro, please consider submitting a patch to elisp-refs--function-p to make elisp-refs smarter.

elisp-refs also does not support indirect calls.

;; Since we do a simple syntax tree walk, this isn't treated as a
;; call to foo.
(let ((x (symbol-function 'foo)))
  (funcall x))

;; Similarly, indirect function calls are not treated as
;; function calls.
(defun call-func (x)
  (funcall x))
(call-func 'foo)

;; However, if you use sharp quoting, elisp-refs knows it's a function
reference!
(call-func #'foo)

Running tests

You can run the tests with:

$ cask install
$ cask exec ert-runner

Performance

elisp-refs is CPU-intensive elisp and has been carefully optimised. You can run the benchmark script with:

$ cask install
$ ./bench.sh

New features are carefully measured to ensure performance does not get worse.

See elisp-refs-bench.el for more details.

Alternative Projects

xref-find-references: This command is included in Emacs 25.1, but it's based on a text search. It is confused by comments and strings, and cannot distinguish between functions and variables.

xrefs-find-references is also line oriented, so it does not show the whole sexp that matched your search. Since it requires text files, it doesn't search built-in .el.gz files.

TAGS: It is possible to record function references in TAGS files. Whilst universal-ctags (formerly known as exuberant-ctags) does provide the ability to find references, it is not supported in its lisp parser.

etags, the TAGS implementation shipped with Emacs, cannot find references (to my knowledge).

el-search allows you to search for arbitrary forms in elisp files. It's slower, but a much more general tool. Its design greatly influenced elisp-refs.

elisp-slime-nav finds definitions, not references. It's a great complementary tool.

More Repositories

1

difftastic

a structural diff that understands syntax πŸŸ₯🟩
Rust
15,946
star
2

helpful

A better Emacs *help* buffer
Emacs Lisp
972
star
3

deadgrep

fast, friendly searching with ripgrep and Emacs
Emacs Lisp
671
star
4

ag.el

An Emacs frontend to The Silver Searcher
Emacs Lisp
521
star
5

babyc

A toy C compiler
C
496
star
6

bfc

An industrial-grade brainfuck compiler
Rust
479
star
7

suggest.el

discover elisp functions that do what you want
Emacs Lisp
344
star
8

emacs-refactor

language-specific refactoring in Emacs
Emacs Lisp
341
star
9

ht.el

The missing hash table library for Emacs
Emacs Lisp
235
star
10

refine

interactive value editing in emacs lisp
Emacs Lisp
85
star
11

tco.el

Tail call optimisation in Emacs lisp
Emacs Lisp
76
star
12

pyimport

Manage Python imports from Emacs!
Emacs Lisp
73
star
13

mustache.el

A mustache templating library for Emacs
Emacs Lisp
68
star
14

elisp-def

Find Emacs Lisp definitions
Emacs Lisp
61
star
15

propcheck

Quickcheck/hypothesis style testing for elisp
Emacs Lisp
59
star
16

.emacs.d

My emacs configuration
Emacs Lisp
52
star
17

pip-requirements.el

Major mode for editing pip requirements files
Emacs Lisp
51
star
18

tree-sitter-elisp

tree-sitter grammar for emacs lisp
C
46
star
19

loop.el

friendly imperative loop structures for Emacs lisp
Emacs Lisp
36
star
20

simpla-vortaro

Inteligenta vortaro de Esperanto / An intelligent Esperanto dictionary
Python
34
star
21

python-info

The python manual in texinfo format, particularly for Emacs users
Makefile
31
star
22

Brainfrack

BF implementations in different languages
Smalltalk
29
star
23

bison-mode

Emacs major mode for Bison/Jison, Yacc and Lex grammars
Emacs Lisp
27
star
24

garden

an interactive programming language
Rust
26
star
25

company-try-hard

Get all completions from company-mode backends
Emacs Lisp
24
star
26

Minimal-scheme

A simple scheme interpreter in Python
Python
23
star
27

logstash-conf.el

Emacs major mode for editing logstash configuration files
Emacs Lisp
21
star
28

trifle

A friendly lisp with a focus on interactivity and collaboration
Python
21
star
29

django-test-mixins

Additional assertions and test conveniences for testing django sites
Python
19
star
30

linkdoc

Rust tool for finding dead links on a site
Rust
14
star
31

cask-mode

Major mode for editing Cask files
Emacs Lisp
12
star
32

flymake-jshint.el

JSHint with flymake for Emacs
Emacs Lisp
12
star
33

emacsbench

Benchmarking Emacs itself
C
12
star
34

Blackjack

Simple blackjack simulator in Haskell
Haskell
11
star
35

flycheck-title

show flycheck errors in the frame title
Emacs Lisp
11
star
36

flycheck-pyflakes

flycheck support for pyflakes
Emacs Lisp
10
star
37

flycheck-pkg-config

Configure flycheck using pkg-config
Emacs Lisp
10
star
38

dotfiles

Configuration files for unix utilities
Shell
10
star
39

ReVo-utilities

a few handy scripts to work with XML dumps from ReVo
XSLT
10
star
40

Lython

Toy Lisp to Python compiler
Python
9
star
41

ez-query-replace

query-replace in Emacs with smarts and history!
Emacs Lisp
9
star
42

mal_pharo

A Make A Lisp implementation in Pharo
Smalltalk
8
star
43

FuzzyBranch

git-checkout with fuzzy branch names
Haskell
7
star
44

peval

partial evaluator for elisp
Emacs Lisp
6
star
45

wilfred.github.com

My personal blog
HTML
6
star
46

versor

Mirror of https://sourceforge.net/projects/emacs-versor/
Emacs Lisp
5
star
47

django-function-cache

Cache (memoize) a function's output using Django's caching API
Python
5
star
48

elisp-complete

Emacs Lisp
5
star
49

metawiki

Proof-of-concept self-hosting metawiki
JavaScript
5
star
50

line-numbers

accessing line numbers by string offsets
Rust
4
star
51

the_end_times

comparing programming language implementation performance
Ruby
4
star
52

autotoc

Generate and insert tables of contents in markdown files
Clojure
4
star
53

elisp-fu

Emacs Lisp
4
star
54

oosh

Object Oriented Shell
Python
4
star
55

company-smart-elisp

a contextual company backend for elisp
Emacs Lisp
4
star
56

podkastaro

Podcast aggregator, targeted at Esperanto radio
PHP
3
star
57

gameboy_emulator

Rust code following along with http://imrannazar.com/GameBoy-Emulation-in-JavaScript
Rust
3
star
58

HandyBot

IRC Bot in Clojure
Clojure
3
star
59

with-namespace.el

interoperable elisp namespaces
Emacs Lisp
3
star
60

advent-of-code

Racket
2
star
61

not-quite-modal.el

Modal-inspired movement in Emacs
Emacs Lisp
2
star
62

srch

Emacs Lisp
2
star
63

sudoku

A sudoku solver in CoffeeScript
CSS
2
star
64

userinfo

cross-platform user details library in Rust
Rust
2
star
65

nmap-service

A service for telling clients what ports they have open
Python
2
star
66

smart-eval.el

helpful eval and re-eval for elisp
Emacs Lisp
2
star
67

Jeweled

A Bejeweled bot
Python
2
star
68

elisp-index

Emacs Lisp
2
star
69

Picky

An opinionated wiki
JavaScript
2
star
70

expenses

Categorising and analysing personal expenses
Python
1
star
71

ButlerBot

Haskell news email bot
Haskell
1
star
72

syntax-cafe

programming languages to suit all tastes
TypeScript
1
star
73

podkastaro2

Nova versio de Podkastaro, uzanta Django-n
Python
1
star
74

commonmark-extract-text

extract plain text from commonmark/markdown source
JavaScript
1
star
75

hubot-tube-status

A hubot script for getting the current tube status
CoffeeScript
1
star
76

bf_bench

BF implementation benchmarking
Brainfuck
1
star
77

rustls.el

Emacs Lisp
1
star
78

emailomatic

web scraper for collecting interesting events to attend
Clojure
1
star
79

sooty

a dumb lisp with a handwritten GC
Rust
1
star
80

chrome_crash_example

JavaScript
1
star
81

parsimonious

Simple command line calculator using hand written parser
Java
1
star
82

commonmark-wikiwords

Convert WikiWords to links in commonmark source
JavaScript
1
star
83

zorklike

a text adventure game inspired web page
JavaScript
1
star
84

is_my_internet_filtered

A website that tests whether any content is being filtered
JavaScript
1
star
85

dumb-code-quick

more tests, less code
TypeScript
1
star
86

blog-comments

a simple blog comments system in Clojure
Clojure
1
star