• Stars
    star
    167
  • Rank 226,635 (Top 5 %)
  • Language
    Emacs Lisp
  • License
    Other
  • Created about 8 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Run an inferior Julia REPL in a terminal inside Emacs

julia-repl: run an inferior Julia REPL in Emacs

MELPA build

This is a minor mode for interacting with a Julia REPL running inside Emacs. The julia process is started in an ANSI terminal (term), which allows text formatting and colors, and interaction with the help system and the debugger.

It is recommended that you use this minor mode with julia-mode.

screenshot

Installation and loading

Please make sure you have at least Emacs 25. The term code changed a bit since Emacs 24, and the package does not support that and earlier versions. For example, Ubuntu has had Emacs 25 since 18.04LTS.

Place this in your Emacs initialization files (eg .emacs):

(add-to-list 'load-path path-to-julia-repl)
(require 'julia-repl)
(add-hook 'julia-mode-hook 'julia-repl-mode) ;; always use minor mode

If you want to use a Julia executable other than julia in your path, see below.

If you are experiencing problems with Unicode characters in the Julia REPL, try setting the relevant coding/language environment, eg

(set-language-environment "UTF-8")

Usage

M-x julia-repl, or C-c C-z from a buffer in which the julia-repl minor mode is active starts a new inferior Julia process. The keys below can be used to interact with this process.

key action
C-c C-a activate if there is a Project.toml in parent directories
C-u C-c C-a activate home project
C-c C-b send whole buffer to REPL (using include)
C-u C-c C-b send whole buffer to REPL (directly)
C-c C-c send region (when applicable) or line to REPL
C-c C-d invoke @doc on symbol
C-c C-e invoke @edit on region (when applicable) or line
C-c C-l list methods of a function
C-c C-m expand macro
C-c C-p change directory to that of the buffer
C-c C-s prompt for buffer name suffix
C-c C-t send whole buffer to REPL (using Revise.includet)
C-c C-v prompt for Julia executable
C-c C-z raise the REPL or create a new one (or switch back from REPL – only in vterm backend)
C-RET send line to REPL (without bracketed paste)

All actions that send something to the REPL terminate with a newline, triggering evaluation. If you want to avoid sending a newline (eg maybe because you want to edit an expression), use prefix arguments (C-- or C-u, currently both have the same effect). This of course does not apply to C-c C-b.

All commands send code using bracketed paste. When Julia is waiting for input, control characters like ^[[200~ may show up in your buffer, this is innocuous. If you input takes a long time to evaluate, you can step through it line-by-line with C-RET.

Options for this package are exposed via the customize interface (M-x customize-group julia).

Environment variables

You can set environment variables directly from your init.el in Emacs, eg

(setenv "JULIA_NUM_THREADS" "4")

Buffer-local inferior REPL and Julia executable

The minor mode allows the user to select a particular Julia executable and optionally a different inferior buffer for each source code buffer. This allows running two versions (eg stable and master) of Julia simultaneously, and/or running multiple inferior REPLs of the same Julia version. A typical use case is trying out something quickly, without changing the state of the current process.

Julia executables

Set julia-repl-executable-records to a list of keys and executables. For example,

(setq julia-repl-executable-records
      '((default "julia")                  ; in the executable path
        (master "~/src/julia-git/julia"))) ; compiled from the repository

provides two executables. The first entry is always the default (it can have any other key).

Use C-c C-v to select one of these (julia-repl-prompt-executable). You can also set the value of julia-repl-executable-key directly to a key in the julia-repl-executable-records, eg using file variables, but make sure you select a correct value.

The name of the inferior buffer will reflect your choice: the default is *julia* (indicator omitted), while the master executable would map to *julia-master*, and so on.

Executable suffix

You can also set a suffix for the inferior buffer, if you want multiple ones in parallel. This can be a number, which will show up as <number>, or a symbol, which appears as -symbol.

It is recommended that you use C-c C-s (julia-repl-prompt-inferior-buffer-name-suffix), which prompts for a string by default. Prefix arguments modify it like this:

  • numerical prefixes select that integer: eg C-3 C-c C-s set the suffix to 3.

  • the negative prefix picks the next unused integer: eg C- C-c C-s sets the suffix to 4 if 1, 2, 3 are in use.

Switches

Switches to the julia process can be provided in the global variable julia-repl-switches, for example

(setq julia-repl-switches "-p 4")

The function julia-repl-prompt-switches will prompt for new switches, you can bind it to a key.

File local variables

If you are using the same settings for a specific file, consider using file variables. For example, if you use add-file-local-variable to create a block at the end of the Julia source file similar to

# Local Variables:
# julia-repl-executable-key: master
# julia-repl-inferior-buffer-name-suffix: tests
# julia-repl-switches: "-p 4"
# End:

then the next time you open a REPL, it will have the name *julia-master-tests*, and 4 worker processes.

Terminal backends

julia-repl can use the terminal in different ways. The default is ansi-term, which is included in Emacs, but it is recommended that you use vterm via emacs-libvterm (it is not the default since you need to install an extra package and the binary).

Some hints on interacting with term

Note some keybindings for term:

  1. C-x C-j switches to line mode, where you can kill/yank, move around the buffer, use standard Emacs keybindings,
  2. C-c C-k switches back to char mode,
  3. for scrolling, use S-<prior> and S-<next>.

See the help of term for more.

Using vterm

vterm is now the recommended backend, but for now you have to enable it explicitly because dependencies need to be available. In the long run it is hoped that it will replace ansi-term as the default backend for this package, fixing many outstanding issues.

  1. Install emacs-libvterm and make sure you have a working installation (eg M-x vterm) should start a terminal

  2. Evaluate (julia-repl-set-terminal-backend 'vterm) in your config file after you load julia-repl, but before you use it (and of course vterm should be loaded at some point). Switching terminal backends with already running Julia processes is not supported.

  3. You may want to (setq vterm-kill-buffer-on-exit nil) to prevent the buffers associated with terminated Julia processes being killed automatically. This allows you to retain output and see error messages if the process does not start.

  4. You can also install EmacsVterm.jl package, which improves integration between Julia REPL and Emacs.

Using the @edit macro

The @edit macro can be called with C-c C-e when the julia-repl-mode minor mode is enabled. The behavior depends on the value of the JULIA_EDITOR envoronment variable in the Julia session. The command julia-repl-set-julia-editor is provided to conveniently control this from emacs.

To use "emacsclient" as a default in each Julia REPL you open in emacs, add the following code to your ~/.julia/config/startup.jl:

if haskey(ENV, "INSIDE_EMACS")
    ENV["JULIA_EDITOR"] = "emacsclient"
end

If you cannot edit your startup.jl, you can configure the editor in each repl after starting it with:

(add-hook 'julia-repl-hook #'julia-repl-use-emacsclient)

More colors

Julia uses more colors than the ones supported by term by default. To get the full range of colors, use eterm-256color, available from MELPA.

Note for Windows users

ansi-term is not supported on some (most?) Windows versions of Emacs. It has been confirmed to work with Emacs running in Cygwin. You can test whether your version works with M-x ansi-term; if this errors then this package will not work for you.

Cygwin may require some rewriting of paths for include to work. After loading this package, customize the rewrite rules as

(setq julia-repl-path-rewrite-rules julia-repl-cygwin-path-rewrite-rules)

as a reasonable default, or write custom rules for julia-repl-path-rewrites.

Limitations

See the issues.

Comparison to ESS

A well-known alternative is ESS, which also supports Julia. ESS is however based on comint, which does not allow a fully functioning terminal and therefore does not support the Julia REPL modes (shell, Pkg, debuggers...) and features. julia-repl is instead based on term, and so gets all the features from Julia's native REPL for free.

More Repositories

1

DynamicHMC.jl

Implementation of robust dynamic Hamiltonian Monte Carlo methods (NUTS) in Julia.
Julia
240
star
2

lla

Lisp Linear Algebra
Common Lisp
88
star
3

TransformVariables.jl

Transformations to contrained variables from ℝⁿ.
Julia
65
star
4

MultistartOptimization.jl

Multistart optimization methods in Julia.
Julia
62
star
5

let-plus

destructuring extension of let*
Common Lisp
47
star
6

PkgSkeleton.jl

Generate Julia package skeletons using a simple template system
Julia
46
star
7

DefaultApplication.jl

Julia package for opening a file with the default application determined by the OS.
Julia
43
star
8

LaTeXTabulars.jl

Write tabular data from Julia in LaTeX format.
Julia
42
star
9

LogDensityProblems.jl

A common framework for implementing and using log densities for inference.
Julia
39
star
10

DynamicHMCExamples.jl

Examples for Bayesian inference using DynamicHMC.jl and related packages.
Jupyter Notebook
37
star
11

array-operations

Common Lisp library that facilitates working with Common Lisp arrays.
Common Lisp
36
star
12

BrowseTables.jl

Julia package for browsing tables that that implement the Tables.jl interface as HTML.
Julia
29
star
13

MarkdownTables.jl

Lightweigth package to print a table that implements the Tables.jl interface in Markdown.
Julia
26
star
14

cl-colors

Simple color library for Common Lisp
Common Lisp
25
star
15

cl-random

Random variates for Common Lisp
Common Lisp
25
star
16

SpectralKit.jl

Building blocks of spectral methods for Julia.
Julia
22
star
17

MCMCDiagnostics.jl

Markov Chain Monte Carlo convergence diagnostics in Julia
Julia
21
star
18

skeleton.jl

Julia script for creating new packages quickly.
Julia
20
star
19

cl-num-utils

Numerical utilities, the successor of cl-numlib
Common Lisp
20
star
20

cl-slice

Array slices for Common Lisp
Common Lisp
18
star
21

ContinuousTransformations.jl

Continuous transformations from ℝ or ℝⁿ to various open sets
Julia
17
star
22

cl-bayesian

Common Lisp routines for Bayesian estimation and analysis.
Common Lisp
14
star
23

TrustRegionMethods.jl

Trust region methods for nonlinear systems of equations in Julia.
Julia
14
star
24

cl-data-frame

Data frames for Common Lisp
Common Lisp
13
star
25

ContinuousTimeMarkov.jl

Julia package for Markov chains in continuous time.
Julia
12
star
26

LogDensityProblemsAD.jl

AD backends for LogDensityProblems.jl.
Julia
12
star
27

EponymTuples.jl

Julia package for deconstructing dispatch on NamedTuples.
Julia
12
star
28

texlive-julia-minimal-docker

minimal docker setup for texlive and Julia
Shell
10
star
29

ffa

ABANDONWARE Foreign friendly arrays
Common Lisp
10
star
30

trivial-project-pathname

A very simple Common Lisp library for resolving pathnames relative to some directory, usually the sources.
Common Lisp
10
star
31

PushVectors.jl

workaround for julia#24909
Julia
9
star
32

AutoAligns.jl

Julia
9
star
33

cl-flexplot

A PGF/LaTeX based plotting library for Common Lisp.
Common Lisp
9
star
34

HighestDensityRegions.jl

Julia library for calculating Highest Density Regions
Julia
8
star
35

xarray

DEPRECATED A generalized interface for array-like objects with views
Common Lisp
8
star
36

latex-table

Pretty latex tables from Lisp matrices and vectors.
Common Lisp
7
star
37

ParametricFunctions.jl

Parametric function families.
Julia
6
star
38

Fretboards.jl

Julia package for visualizing chords on the guitar fretboard.
Julia
6
star
39

cl-rmath

Common Lisp wrapper for libRmath.
Common Lisp
6
star
40

ObjectPools.jl

An implementation of user-managed object pools in Julia.
Julia
6
star
41

PermaProgress.jl

Julia package for progress metering using the file system.
Julia
6
star
42

ihs-beamer

LaTeX Beamer template for the Institute of Advanced Studies, Vienna
TeX
5
star
43

RoguePkg.jl

Test, benchmark, and Pkg.dir for local packages outside ~/.julia
Julia
5
star
44

StrFs.jl

Julia packages for strings with fixed maximum number of bytes.
Julia
5
star
45

array-operations-old

DEPRECATED, OLD VERSION [Array operations (formerly part of FFA)]
Common Lisp
5
star
46

AltDistributions.jl

Implementations for some distributions using a consistent API and AD-friendly code.
Julia
5
star
47

tpapp-utils

Utilities used by my libraries.
Common Lisp
5
star
48

cl-jags

Interface to the Gibbs sampler JAGS from Common Lisp.
Common Lisp
5
star
49

FunctionalTables.jl

Julia package for working with (potentially large) columns of data.
Julia
5
star
50

SortedVectors.jl

Lightweight wrapper to declare that a vector is sorted.
Julia
5
star
51

tpapp.github.io-source-pre-2022

Source for tpapp.github.io.
Julia
5
star
52

SensitivityAnalysis.jl

Julia package for numerical sensitivity analysis.
Julia
4
star
53

cmdstan-docker

Docker container with CmdStan installed.
Dockerfile
4
star
54

StanSamples.jl

Read samples from CmdStan into vectors of the appropriate Julia type.
Julia
4
star
55

HiddenMarkovChains.jl

Hidden Markov Chain calculations in Julia
Julia
4
star
56

StataDTAFiles.jl

read and write Stata DTA files from Julia
Julia
4
star
57

LargeColumns.jl

Handle large columns (vectors of equal length) with bits types in Julia using mmap.
Julia
4
star
58

data-omnivore

Read tabular data into data frames
Common Lisp
3
star
59

TransformedLogDensities.jl

Create a log density for the LogDensityProblems.jl API using TransformVariables.jl
Julia
3
star
60

Miter.jl

A Julia plotting package using the PGF Basic Layer Core.
Julia
3
star
61

EconFunctions.jl

Julia implementation for some commonly used functions in economics.
Julia
3
star
62

StanRun.jl

Run Stan samples from Julia.
Julia
3
star
63

FlatViews.jl

Julia package for flat views of nested collections.
Julia
3
star
64

StanDump.jl

Julia library for dumping data to be read by Stan.
Julia
3
star
65

FlexDates.jl

Dates with arbitrary integer types and epochs.
Julia
3
star
66

NonhomotheticCES.jl

Julia package for calculations with non-homothetic preferences.
Julia
3
star
67

extended-reals

Extended real numbers for Common Lisp
Common Lisp
3
star
68

HamiltonianABC.jl

Hamiltonian Approximate Bayesian Computation for Julia.
Julia
2
star
69

StochasticDurations.jl

Julia library for working with continuous time simulations.
Julia
2
star
70

Squeezing.jl

Convenient syntax for removing singleton dimensions from array reductions.
Julia
2
star
71

AlgebraResultTypes.jl

result type calculations for algebraic operations
Julia
2
star
72

PkgBugDemo.jl

self-contained repo for demonstrating a bug
Julia
2
star
73

MCMCSamples.jl

Julia package that defines a container format for Markov Chain Monte Carlo samples
Julia
2
star
74

TKPappKitchenSink.jl

Code that I use, but did not move into its own library (yet).
Julia
2
star
75

StanRun-OLD.jl

Julia library for running Stan.
Julia
2
star
76

tpapp.github.io

personal website
HTML
2
star
77

MultiBroadcast.jl

Utilities for broadcasting functions with multiple values in Julia
Julia
2
star
78

cl-print-debug

Common Lisp debug library using print statements
Common Lisp
2
star
79

IndirectLikelihood.jl

Framework for indirect likelihood estimation.
Julia
2
star
80

unicode-math-input

Emacs input method for entering unicode math symbols with LaTeX macros.
Emacs Lisp
2
star
81

MCMC_LR_Tests.jl

Likelihood ratio test for comparing MCMC sample means to a known value.
Julia
2
star
82

consistent-local-continuous

Continuous-time demonstration of the "Exact Present Solution" method in Julia
Julia
2
star
83

IndentWrappers.jl

Wrapper type for indentation management for plain text printing.
Julia
1
star
84

BinaryFileVectors.jl

Julia package for collecting and mapping vectors of binary data on disk.
Julia
1
star
85

HiddenPoisson.jl

Simulate a hidden state model in continuous time with Poisson shocks.
Julia
1
star
86

borgmatic-config-hardcopy

Print borgmatic configuration and ssh key as a hardcopy (also as QR code)
Shell
1
star
87

univariate-decompositions

Decomposing deviations from a trend.
Common Lisp
1
star
88

buffer-unique-id

Generating strings that are unique in an Emacs buffer.
Emacs Lisp
1
star
89

RaggedData.jl

Library for collating and indexing ragged data.
Julia
1
star
90

ESS-julia-extensions

Emacs Lisp
1
star
91

PackedASCIITypes.jl

Julia package for short ASCII strings
Julia
1
star
92

HDF5Logging.jl

Log to HDF5 files from Julia.
Julia
1
star
93

ColumnSummaries.jl

Simple summaries of raw data before parsing and analysis
Julia
1
star
94

AMDB.jl

AMDB analysis. For internal use at the IHS until cleaned up.
Julia
1
star
95

NestedViews.jl

Lazy combination and splitting of arrays.
Julia
1
star
96

SEDF.jl

Specification and Julia implementation of the Simple Externalized Data Format
Julia
1
star
97

TextTableRows.jl

Julia library for parsing recalcitrant data in text format.
Julia
1
star
98

DOIHS.jl

Dynamic Optimization 2 course at the Institute for Advanced Studies, Vienna.
Julia
1
star
99

AMDB_old.jl

Old code for working with the AMDB. Now outdated, see AMDB.jl
Julia
1
star
100

SerializeTables.jl

An experiment with serializing and compressing tables.
Julia
1
star