从 emacs/cider 开始,是否有更简单的方法同时使用 BOTH clj + cljs REPL?

Is there an easier way to use BOTH clj + cljs REPLs at the same time from emacs/cider?

作为 Clojurian 初学者,我可能需要一些帮助来尝试了解是否有任何方法可以解决我使用 Cider REPL 的痛点。

上下文: 我有一个全栈应用程序(后端的 limunius + 前端的 re-agent/figwheel)。 我从 emacs/Cider Repl 启动服务器,并且可以从该 REPL(非常方便)访问 运行ning 服务器的所有命名空间。

在另一个选项卡中我 运行:

lein figwheel
Figwheel: Cutting some fruit, just a sec ...
Figwheel: Validating the configuration found in project.clj
Figwheel: Configuration Valid ;)
Figwheel: Starting server at http://0.0.0.0:3449
Figwheel: Watching build - app
Compiling build :app to "target/cljsbuild/public/js/app.js" from ["src/cljs" "src/cljc" "env/dev/cljs"]...
Successfully compiled build :app to "target/cljsbuild/public/js/app.js" in 4.113 seconds.
Figwheel: Starting CSS Watcher for paths  ["resources/public/css"]
Figwheel: Starting nREPL server on port: 7002
Launching ClojureScript REPL for build: app

所有 cljs 名称空间都可以从这个 figwheel REPL/tab 访问,但它没有连接到 Cider/emacs 所以我只能复制并粘贴到那里。

有没有一种简单的方法可以在 emacs 中同时拥有两个 REPL 并在它们之间快速切换?

或者您的典型工作流程是什么?您是否同时使用后端和前端 REPL?抱歉,我刚刚开始学习,所以我需要两者:)

您绝对可以使用 CIDER 同时连接到 CLJ 和 CLJS。检查 CIDER 文档中的 Managing Connections 部分。 TL;DR: 你可以用C-c C-x c m调用cider-connect-clj&cljs.

话虽如此,对于 CLJS,我通常是一个懒惰的人,我让 figwheel 在保存时重新编译,我检查前端是否像我正在尝试做的那样。

编辑:我的设置一般是两个垂直框架,左边是代码,右边是REPL,大部分时间计算内联表达式C-c C-e和if我需要跨越多行的任何内容,我将其写在命名空间末尾的 (comment ,,,) 块上。我不经常使用 C-C C-z 在代码和 REPL 之间切换。

此外:我在 Ubuntu 18.04 中使用普通 Emacs 25,设置最少,但我遇到过使用 Spacemacs 拥有更精细工作流程的人。

当然可以!首先通过在端口 7002 (Figwheel: Starting nREPL server on port: 7002) 上打开的 cider-connect-clj 连接到 repl,然后在弹出的 repl minibuffer 中 运行 (figwheel-sidecar.repl-api/cljs-repl)。然后,您将拥有功能齐全的 cljs repl 运行ning 和 clj repl - 您可以使用 cider-switch-to-repl-buffer 在它们之间切换(在 clj 文件中时,您将被带到 clj repl,在文件中时,将被带到 cljs repl cljs 文件)