Skip to content

Commit 7ccb32f

Browse files
committed
[Doc] Document the find references functionality
1 parent db2ead4 commit 7ccb32f

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
2.23 MB
Loading

doc/modules/ROOT/pages/usage/misc_features.adoc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,42 @@ kbd:[M-x] `cider-scratch` command. This is a great way to play
1414
around with some code without having to create source files or pollute
1515
the REPL buffer and is very similar to Emacs's own `+*scratch*+` buffer.
1616

17+
== Find References
18+
19+
NOTE: The functionality is based on https://metaredux.com/posts/2019/12/11/hard-cider-find-usages.html[ideas from this article] and was
20+
introduced in CIDER 0.22.
21+
22+
There are two ways to use find references in CIDER:
23+
24+
* `cider-xref-fn-refs` (kbd:[C-c C-? r]) shows the usages of the function at point in a dedicated buffer
25+
* `cider-xref-fn-refs-select` (kbd:[C-c C-? C-r]) shows the usages in the minibuffer
26+
27+
Here's how they look in action:
28+
29+
image::cider_find_usages.gif[CIDER Find References]
30+
31+
Keep in mind the following limitations:
32+
33+
- This works only for Clojure
34+
- It's powered by runtime state analysis, which means it will show only data for loaded namespaces (like most of CIDER's functionality)
35+
- It doesn't (currently) find usages in lambdas
36+
- It doesn't give us the precise locations where something is used, we only know that it's used
37+
38+
On the bright side:
39+
40+
- It's super fast
41+
- It doesn't require any static code analysis
42+
- It's still more reliable than `grep`
43+
44+
The functionality is not perfect, but at least it's there if you need it. As a bonus you get a quick way to navigate to
45+
all of the functions used by some function using `cider-xref-fn-deps` (`C-c C-? d`) and `cider-xref-fn-deps-select` (`C-c C-? C-d`).
46+
Those are pretty handy if you don't want to jump to the source of some function to see what it refers to internally.
47+
48+
Don't forget you also have a couple of third-party alternative:
49+
50+
- The much more sophisticated AST-powered "find usages" provided by `clj-refactor.el`
51+
- https://github.com/bbatsov/projectile[Projectile's] "grep in project" (`projectile-grep`, typically bound to `C-c p g`)
52+
1753
== Reloading Code
1854

1955
While Clojure's and CIDER's interactive programming style means you'll

0 commit comments

Comments
 (0)