简体   繁体   English

emacs + clojure +找到函数的定义

[英]emacs + clojure + find definition of function

Problem Statement: 问题陈述:

I am writing Clojure (and some ClojureScript) code with Lein + Emacs. 我正在用Lein + Emacs编写Clojure(和一些ClojureScript)代码。

I want to be able to jump to the definition of an arbitrary function. 我希望能够跳转到任意函数的定义。

For example, suppose I do "Cx magic-key-stroke rect->area", then I want it to jump me to: 例如,假设我做“Cx magic-key-stroke rect-> area”,那么我想让它跳到:

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

Question: 题:

How do I achieve the above in Emacs / Clojure? 如何在Emacs / Clojure中实现上述目标?

Edit: 编辑:

I sorta lied in my original question. 我在原来的问题中撒了谎。 I'm not using clj + cljs. 我没有使用clj + cljs。

I'm using cljx ( https://github.com/lynaghk/cljx ) , which does cljx -> clj/cljs. 我正在使用cljx( https://github.com/lynaghk/cljx ),它执行cljx - > clj / cljs。

As a result, a "nrepl" solution does not work as well as something that reads the source code. 因此,“nrepl”解决方案不能像读取源代码那样有效。 (Ie I want it to jump me to the *.cljx file, not the *.clj file). (即我希望它跳转到* .cljx文件,而不是* .clj文件)。

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. 如果您想要跳转到函数的源,您可以使用M-。,这很棒。 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. 使用M-弹出堆栈并返回到原来的位置。

Does this help? 这有帮助吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM