Emacs major mode for an interactive Julia shell
julia-shell-mode provides a comfortable Julia REPL
in an interactive Emacs buffer. Some of the features include TAB completion
through the Emacs completion system and easy interaction between a
julia-mode
editing buffer and a live julia-shell REPL.
To start a julia-shell, simply do
M-x run-juliaTo query Julia for completions of the current command on the prompt, simply hit
TAB. This supports LaTeX substitutions, just like the native Julia shell. For
example, hitting TAB after
julia> y + \DeltaCompletes to
julia> y + Δjust like in the native Julia REPL.
When not substituting LaTeX letters, julia-shell will open a buffer with
suggestions on how to complete the current command using Emacs' completion
system. Simply press TAB to get a list of suggestions. For example, pressing
TAB after
julia> hisFirst completes to
julia> histAnd pressing TAB again opens up a new *Completions* buffer with the
following suggestions:
Click on a completion to select it.
In this buffer, type RET to select the completion near point.
Possible completions are:
hist hist2D
hist2d histrange
You can use the function julia-shell-run-region-or-line to send the current
region to the Julia interpreter. If the region is not active, this function
will send the current line.
Another handy function is julia-shell-save-and-go: Save the current buffer
and evaluate it in the Julia shell using evalfile().
Put the following code in your .emacs, init.el, or equivalent:
(add-to-list 'load-path "path-to-julia-shell-mode")
(require 'julia-shell)where "path-to-julia-shell-mode" should be the location of this
archive. Since the alias to run-julia overrides julia-mode's command, make
sure to include these line after requiring julia-mode.
To interact with julia-shell from
julia-mode,
add the following code to your init.el:
(defun my-julia-mode-hooks ()
(require 'julia-shell-mode))
(add-hook 'julia-mode-hook 'my-julia-mode-hooks)
(define-key julia-mode-map (kbd "C-c C-c") 'julia-shell-run-region-or-line)
(define-key julia-mode-map (kbd "C-c C-s") 'julia-shell-save-and-go)This mode borrows heavily from MATLAB-emacs and hopes to replicate the comfortable MATLAB shell experience using Julia. Thanks!
Furthermore, thanks to the devs of the original julia.el for laying the foundation of this, especially the neat LaTeX substitutions.
