繁体   English   中英

如何用Emacs nREPL选择/切换Leiningen配置文件?

[英]How do I choose/switch Leiningen profiles with Emacs nREPL?

我在我的leiningen项目文件中设置了:dev配置文件。 这为我的repl会话定义了:init和:init-ns设置。 如果我在emacs(Mx nrepl-jack-in)中使用光标在我的project.clj中的:dev关键字上启动nrepl,则启动repl并使用:init和:init-ns设置。 如果我将光标放在其他位置,则初始命名空间不同(测试ns,而不是用户),并且:尚未评估init。

我猜这是某种特征 ,(我更倾向于认为它现在是随机的行为),但任何人都可以解释它或指向那些这样做的文档吗? 此外,有没有办法在repl启动后更改配置文件?

谢谢

与评论者@ user7610所说的相反, cider-jack-in-with-profile中没有cider-jack-in-with-profile 苹果酒拉请求#544在这方面有点误导。

如果您希望苹果酒加载您自己的special-snowflake配置文件,请在emacs中执行此操作:

  • Mx set-variable cider-lein-parameters to eg with-profile +my-special-snowflake repl :headless

或以交互方式设置变量(因此您可以在更改之前查看它的当前值):

  • Ch, v cider-lein-parameters然后点击或点击“自定义”输入并将其设置为例如with-profile +my-special-snowflake repl :headless并应用它

除了base配置文件(为了运行nrepl和苹果酒所需要的)之外,这将导致你的下一个cider-jack-in加载my-special-snowflake配置文件。

尝试这个:

(defun start-cider-repl-with-profile ()
  (interactive)
  (letrec ((profile (read-string "Enter profile name: "))
           (lein-params (concat "with-profile +" profile " repl :headless")))
    (message "lein-params set to: %s" lein-params)
    (set-variable 'cider-lein-parameters lein-params)
    (cider-jack-in)))

测试CIDER 0.16.0(里加)

我只是在搜索相同的功能,并在clojure-emacs / nrepl.el中找到了这个未解决的问题“将参数添加到nrepl-jack-in以允许指定配置文件” https://github.com/clojure-emacs/nrepl。 EL /问题/ 327

它仍然是开放的

我在我的计算机上尝试了Jiacai Liu的函数作者(2019-04-13的GNU Emacs 26.2(build 1,x86_64-apple-darwin18.2.0,NS appkit-1671.20 Version 10.14.3(Build 18D109))。 我得到一个错误是:

eval-region: Wrong number of arguments: (1 . 1), 0

然后,我尝试elisp功能:

(defun start-cider-repl-with-profile ()
  (interactive)
  (letrec ((profile (read-string "Enter profile name: "))
           (lein-params (concat "with-profile +" profile " repl :headless")))
    (message "lein-params set to: %s" lein-params)
    (set-variable 'cider-lein-parameters lein-params)
    (cider-jack-in '())))

现在它起作用了。 谢谢Jiacai Liu!

暂无
暂无

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

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