簡體   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