简体   繁体   中英

Scala REPL in Emacs

I like to do my Scala development in Emacs, and from time to time, I use the REPL to test out snippets of code or to load and test some code I've just written. I'm using Scala 2.9.1, and I've noticed that when I open the REPL in a terminal buffer, things are substantially broken. In particular, I am unable to remove any characters from the current line, and cannot move the cursor backward on the current line. This is highly frustrating as any time I mistype something, I have to begin the command anew. I was wondering if anyone else is having this problem using the Scala REPL under Emacs, and if anyone has a potential solution.

I find that rlwrap (readline wrapper) plays well with emacs' ansi-term and scala. Just call "rlwrap scala", and you'll have the usual bash line editing, as well as history, working properly. As a bonus, your history will span multiple invocations of scala, so you won't lose everything you've typed after exiting the Scala REPL.

If rlwrap doesn't work for you, just switching to line-mode in ansi-term (Cx Cj by default) will allow you to use emacs-style editing on the line, but without the shell niceties like history and completion.

Ensime has already been mentioned, so I'll just second that as a great option if you don't mind the setup involved.

You may install ENSIME and follow instructions . I don't know about your way to invoke REPL, but REPL called from ENSIME works (it allows moving the cursor backward and deleting symbols, I've checked).

You could try using the ammonite repl , amm . I can confirm tab completion works in the emacs ansi-term . This is true for its default mode (based on stty) or you can use JLine3 with amm . Note that the Dotty (tentative Scala 3) repl, dotr , is also based on amm and also has working tab-completion in ansi-term .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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