【问题标题】:how do I jump to a function definition in emacs when using slime?使用 slime 时如何跳转到 emacs 中的函数定义?
【发布时间】:2014-07-18 06:13:18
【问题描述】:

我已经使用https://github.com/thephoeron/slime-pack 安装了 slime,并且想进一步探索一下 common-lisp。

如何在 emacs 中访问特定函数的源代码?

例如,如果我有一个函数:

(type-of 1)

又想访问type-of的源码,怎么办?

【问题讨论】:

  • 我不使用您引用的库,但我确实经常使用M-x find-function。那对你有用吗?还有find-function-other-windowfind-function-other-frame
  • 我遇到了错误Directory /usr/bin/src/code 不存在,请创建它?` 但是在我使用 Emacs 的包管理器安装 Slime 后它就可以工作了。

标签: emacs common-lisp


【解决方案1】:

.

它调用函数:slime-edit-definition

要跳转到 lisp 实现中的函数,您可能需要做一些额外的事情来指向源代码。在 SBCL 中,您必须 sb-ext:set-sbcl-source-location.sbclrc 中的正确位置:

(sb-ext:set-sbcl-source-location "/path/to/sbcl/")

您可以在 Emacs 中使用 C-xC-f ~/.sbclrc 编辑 .sbclrc

【讨论】:

  • 如果您自己构建 SBCL,源位置会自动设置。
  • 这只有在你加载的文件中定义了函数时才有效。如果您想使用通过 C-x e 从源发送到 REPL 的定义来执行此操作,您将获得 Error: DEFINITION-SOURCE of function FOO-BAR did not contain meaningful information.
  • 但是,怎么跳回去?
  • META 逗号让你跳回
  • 链接到the Slime doc :)
猜你喜欢
  • 2011-01-23
  • 2011-05-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-07
  • 1970-01-01
  • 1970-01-01
  • 2010-10-12
相关资源
最近更新 更多