There is a way! The problem with using term is that term doesn't understand some of the escape sequences Julia sends, which causes term to put a bunch of extra prompts on the screen that make it unusable.
This method should also work for more or less any REPL or terminal application you could want to run.
There is a ridiculously useful terminal application called screen that can come to rescue! While my favorite use of screen is to create sessions detachable from a terminal or ssh session (meaning that you can ssh into a computer, run a screen session, detach it, close the ssh connection, and your process will keep running), it also happens to solve our problem here by translating julia's messages into a language term can understand.
Install screen (e.g. "sudo apt-get install screen" in Ubuntu)
Then run screen inside term, and run julia inside screen. Observe: It works perfectly! You can run "screen julia" to make a screen session immediately open julia.
Here's some code you can add to your .emacs file to create a command (julia-repl) to launch a julia in a screen in a term and bind it to a key combination ("C-x j" - you can of course edit it to be whatever combination you prefer):
(defun julia-repl ()
"Runs Julia in a screen session in a `term' buffer."
(interactive)
(require 'term)
(let ((termbuf (apply 'make-term "Julia REPL" "screen" nil (split-string-and-unquote "julia"))))
(set-buffer termbuf)
(term-mode)
(term-char-mode)
(switch-to-buffer termbuf)))
(global-set-key (kbd "C-x j") 'julia-repl)
Here is some more useful code - I'm using Google Drive links because otherwise it would be really long:
I strongly recommend the following to make C-x
the default escape char for giving emacs commands, rather that C-c
:
(setq term-escape-char [24])
This emulates the ESS command Michael mentioned, except that it doesn't load variables (you can presumably do that pretty straightforwardly from the REPL):
https://drive.google.com/file/d/0B7M8PPMhKHOLeWU2SVF4NjZKRVU/view?usp=sharing
(there was a bug in the original version I uploaded, but it is now fixed)
This mode allows one to enter a sort of shell mode within the REPL by automatically sending semicolons. Default keybinding set to C-x ;
. You exit the mode by pressing C-x ;
again or by hitting backspace at the prompt.
https://drive.google.com/file/d/0B7M8PPMhKHOLTWFfRmtTUXUtN2c/view?usp=sharing
Note: The (setq term-escape char [24]) at the beginning causes C-x to become the escape key instead of C-c. I think that's much better to use, but if you don't want it, don't set it, and use a different hotkey for this mode.