Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 236
nomad Avatar asked Jan 20 '12 15:01

nomad


2 Answers

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 (C-x C-j 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.

like image 134
Adam Saunders Avatar answered Oct 06 '22 00:10

Adam Saunders


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).

like image 22
S. Kucherenko Avatar answered Oct 06 '22 01:10

S. Kucherenko