如何从 Emacs 中自动加载 leiningen repl?
我正在使用 Emacs,与 Leiningen 的 swank 集成。每次我需要开始使用 .clj 文件时,我都必须:
- 从控制台运行
emacs pack/my-ns.clj
。 - 输入
Mx lein-swank
。 - 编译缓冲区。
- 在 Clojure REPL 中更改命名空间,即输入
(in-ns 'pack.my-ns)
。
如何自动执行此过程以从控制台运行类似 emacs-clj pack/my-ns.clj
并让我的环境准备好使用?
I'm using Emacs, integrated with Leiningen's swank. Each time I need to start working with .clj file I have to:
- Run
emacs pack/my-ns.clj
from console. - Type
M-x lein-swank
. - Compile buffer.
- In Clojure REPL change namespace, i.e. type
(in-ns 'pack.my-ns)
.
How can I automate this process to just run from console something like emacs-clj pack/my-ns.clj
and get my environment ready to use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有你提出的问题的答案,但你应该能够在 Clojure 文件中用
Cc Mp
替换第四步,然后 emacs 应该提示你想要什么命名空间与自动检测到的文件的名称空间一起使用,因此您只需按 Enter 键即可。Cc Mp
映射到slime-repl-set-package
。更新:
刚刚偶然发现
I don't have an answer to the question you posed, but you should be able to replace your 4th step with
C-c M-p
while in your Clojure file and then emacs should prompt you as to what namespace you want to be in with the namespace of the file auto-detected so you can simply hit enter.C-c M-p
maps toslime-repl-set-package
.Update:
Just stumbled across this. Should be able to take what is said in that answer and modify it so upon initial connection to swank files get compiled. Could also set it up to automatically switch to namespace and make the repl buffer active.
Swank 在启动时应该自动加载 project.clj 中 :repl-init-script 指向的命名空间,因此如果您想将其设置为起始命名空间,这应该可以帮助您开始。
Swank should automatically load the namespace pointed to by :repl-init-script in project.clj when it starts, so if you want to set that to your starting namespace, that should get you started.