简体   繁体   English

如何重复Clojure REPL中的最后一行?

[英]How can I repeat the last line in the Clojure REPL?

In bash or Ruby's IRB, I can run a command or evaluate an expression, then use the up arrow on my keyboard to edit and rerun the same code. 在bash或Ruby的IRB中,我可以运行命令或计算表达式,然后使用键盘上的向上箭头编辑并重新运行相同的代码。 (This may be something I have configured, but I don't think so.) (这可能是我配置的内容,但我不这么认为。)

This doesn't work for me in the Clojure REPL; 这在Clojure REPL中对我不起作用; I just see ^[[A typed when I press the up arrow. 我只看到^[[A当我按下向上箭头时输入。

Is there a way to "retype" the last line? 有没有办法“重新输入”最后一行?

As mentioned in comments rlwrap is picking up where a native Clojure REPL is not "doing it", including arrow navigation, history and more. 正如评论中所提到的, rlwrap正在拾取原生Clojure REPL不是“正在做”的地方,包括箭头导航,历史记录等。

However most (if not all) of the time Clojure is used together with lein , which has a built in REPL. 然而,大多数(如果不是全部)时间Clojure与lein一起使用, lein具有内置的REPL。 Every time a Clojure REPL is needed, you can do: 每次需要Clojure REPL时,您都可以:

lein repl

You don't necessarily need to have a project to start it, it can be started from anywhere (given that you have lein in your PATH ) and has many other very nice properties, which rlwrap won't give you. 你不一定需要有一个项目来启动它,它可以从任何地方启动(假设你在你的PATHlein )并且有许多其他非常好的属性, rlwrap不会给你。

To name a few: 仅举几例:

  • If you run it form under the root of your project, it will load project's classpath, so you can interact with all the libs and code of your project. 如果在项目的根目录下运行它,它将加载项目的类路径,因此您可以与项目的所有库和代码进行交互

  • It will also start an nREPL which you can connect to from anywhere (local/remote) including your favorite IDE/editors that are "nREPL capable". 它还将启动一个nREPL ,您可以从任何地方(本地/远程)连接,包括您喜欢的“nREPL能力”的IDE /编辑器。 This would allow (for example) vim or emacs to use that REPL you started with lein repl to evaluate, compile, navigate (source) right from the editor. 这将允许(例如) vimemacs使用您使用lein repl启动的REPL来直接从编辑器进行评估,编译,导航(源代码)。

  • Before it starts it reads and "obeys" ~/.lein/profiles.clj , where you can configure your sessions with pretty much anything you want: gpg keys, repl-options, dependencies, plugins, etc.. which will be loaded/configured on the lein repl 在它开始之前,它会读取并“服从” ~/.lein/profiles.clj ,您可以在其中配置几乎任何您想要的会话:gpg密钥,repl-options,依赖项,插件等...将被加载/在lein repl上配置

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

相关问题 如何在REPL中显示Clojure中函数的定义? - How can I display the definition of a function in Clojure at the REPL? 如何与Qt Jambi一起使用Clojure REPL? - How can I use the Clojure REPL together with Qt Jambi? 如何在repl中加载新的clojure库 - How can new clojure libraries be loaded in the repl 如何在Scala REPL中访问最后的结果? - How can I access the last result in Scala REPL? 如何从Clojure命令行应用程序中放入一个repl? - How to drop into a repl from within a Clojure command line application? 如何从leiningen或boot启动Clojure 1.8中的套接字REPL? - How can I start a socket REPL in Clojure 1.8 from leiningen or boot? Clojure repl-如何确保:reload-all确实会重新加载所有必需的名称空间? - Clojure repl - how can I insure that :reload-all does indeed reload all required namespaces? 如何在 Clojure pedestal repl 中重新加载代码以实现快速开发工作流程? - How can I reload code in a Clojure pedestal repl for a quick development workflow? 使用clojure.main / repl时,如何获得类似readline / rlwrap的功能? - How can I get readline/rlwrap-like functionality when using clojure.main/repl? Vim和Clojure,我可以将Slimv或VimClojure与ritz或其他REPL一起使用吗? - Vim and Clojure, can I use Slimv or VimClojure with ritz or another REPL?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM