Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs + clojure + find definition of function

Tags:

emacs

clojure

Problem Statement:

I am writing Clojure (and some ClojureScript) code with Lein + Emacs.

I want to be able to jump to the definition of an arbitrary function.

For example, suppose I do "C-x magic-key-stroke rect->area", then I want it to jump me to:

src/rect.clj, line 20, which has the content:
  (defn rect->area [] ... )

Question:

How do I achieve the above in Emacs / Clojure?

Edit:

I sorta lied in my original question. I'm not using clj + cljs.

I'm using cljx (https://github.com/lynaghk/cljx) , which does cljx -> clj/cljs.

As a result, a "nrepl" solution does not work as well as something that reads the source code. (I.e. I want it to jump me to the *.cljx file, not the *.clj file).


1 Answers

If you scroll to the bottom here you'll see this:

If instead you want to jump to the source of the function you can use M-., which is awesome. This works on your own functions as well as those which come from third-party libraries. Use M-, to pop the stack and return to where you were.

Does this help?

like image 162
ChrisDevo Avatar answered Sep 04 '25 16:09

ChrisDevo