通过鼠标点击跳转到Emacs中的功能定义 [英] Jump to function definition in Emacs by mouse-click
问题描述
使用Emacs + Common Lisp(SBCL)+ Slime,有没有快速的方法跳转到函数的定义(defun ...),而不键入(find-function)函数的名称?
我正在寻找类似于Eclipse中提供的解决方案:
Strg +(鼠标左键单击函数调用)。
Using Emacs + Common Lisp (SBCL) + Slime, is there a quick way to jump to the definition of a function (defun ...) without typing (find-function) the name of the function? I am looking for an similar solution as often provided in Eclipse: Strg + (left-mouse-click on function call).
推荐答案
在Emacs中:
点击要访问的定义的函数,点击 Cx 5 F
( find-function-other-frame
)。
With point on the function whose definition you want to visit, hit C-x 5 F
(find-function-other-frame
).
您还可以绑定 find-function
, find-function-other-window
或 find-function-other-frame
到鼠标按钮操作。
You can also bind find-function
, find-function-other-window
, or find-function-other-frame
to a mouse button action.
您提到了 Strg +(鼠标左键单击函数调用)例如。 Dunno什么 Strg
在这里,但你可以轻松绑定 [mouse-1]
或 down-mouse-1]
到一个在点击位置检查符号的命令,如果它是一个定义的函数,调用 find-function
它,如果它没有通常的 [mouse-1]
或 [down-mouse-1]
行为。
You mention Strg + (left-mouse-click on function call), for instance. Dunno what Strg
is here, but you can easily bind [mouse-1]
or [down-mouse-1]
to a command that checks the symbol at the click position, and if it is a defined function calls find-function
for it, and if it is not has the usual [mouse-1]
or [down-mouse-1]
behavior.
个人而言,我不想要这样的行为,但是在Emacs中很容易实现。例如:
Personally, I wouldn't want such behavior, but it is easy to achieve in Emacs. For example:
(defun my-find-func-mouse (event)
(interactive "e")
(let ((fn (save-excursion
(goto-char (posn-point (event-end event)))
(function-called-at-point))))
(unless (fboundp fn) (error "No function here"))
(find-function-do-it fn nil 'switch-to-buffer-other-window)))
(global-set-key [C-down-mouse-1] nil)
(global-set-key [C-mouse-1] #'my-find-func-mouse)
这篇关于通过鼠标点击跳转到Emacs中的功能定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!