4

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 Answer 1

5

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?

Sign up to request clarification or add additional context in comments.

6 Comments

Note than you need running nrepl connection for M-. to work
EDIT: I'm using cljx, which I failed to mention in my original question. Thus M-. ends up hitting the generated file, not the source file.
@user1985576 I write Clojure using IntellijIDEA and the CursiveClojure plugin (previously using LaClojure). If you check out the CursiveClojure site, cursiveclojure.com , you'll se that you can emulate an Emacs environment, but all I need to do to immediately jump to the source of any function is a mouse click while holding Ctrl.
Cursive looks awesome, and was tempted to switching a while back. However, I'm not ready to make the jump yet, and am looking for a pure-emacs solution.
@edbond why it need a running nrepl ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.