• Emacs Lisp 56.2%
  • Roff 41.7%
  • Makefile 1.8%
  • Shell 0.3%
Find a file
2023-06-25 20:28:31 +02:00
AGPL-3 Update license files 2020-06-29 11:26:37 -03:00
COPYING Fix typo in COPYING 2020-11-05 19:10:59 -03:00
eltr Load lemmington server when running the REPL 2023-06-25 20:28:31 +02:00
eltr-test.el Use SPDX identifiers 2020-10-22 13:14:31 -03:00
eltr.1 Add a manpage, for fun. 2020-07-02 19:19:25 -03:00
eltr.el Change default elt-colorize 2023-06-24 18:04:07 +02:00
eltr.texi Enhancements to the manual 2023-04-24 23:33:37 -03:00
example.el Use SPDX identifiers 2020-10-22 13:14:31 -03:00
fdl.texi Add fld.texi 2020-10-26 20:45:01 -03:00
GFDL-1.3 Update license files 2020-06-29 11:26:37 -03:00
Makefile Use SPDX identifiers 2020-10-22 13:14:31 -03:00
README.md Add license badge 2021-05-02 10:13:30 -03:00
screenshot.png New screenshot 2020-07-02 15:56:39 -03:00

ELTR: Emacs Lisp Terminal REPL

License

ELTR is a simple REPL which runs on the command line. I have written as a toy project because I wanted to see how far one could push Emacs into becoming similar to other languages with REPLs. I thought I'd just call IELM, but it won't run in batch mode. Then, a simple (while t (princ (format "%s\n" (eval (read))))) wouldn't work really well either: it has a fixed prompt, which is a long string ("Lisp expression:"), and would stop on errors. With that as a start, I ended up with this.

ELTR running

There is a similar project on GihtHub: emacsrepl

This REPL, unlike IELM and emacsrepl, accepts more than one expression in each user input.

Using ELTR

To start the REPL, type the following in the command line:

emacs --batch -l eltr.el -f eltr

Or, if you want to install it,

make install

Then just use eltr to start it. You probably want to use it with rlwrap.

ELTR passes its arguments to Emacs, so you can do

eltr -l my-file.el

and it will be equivalent to

emacs -l my-file.el  --batch -l eltr.el -f eltr

so you can use functions and variables from whatever files you'd like. The -Q, -q and other arguments should also work; however, see that -Q may prevent Emacs from finding eltr.el.

You can use ,q to quit the REPL.

There are several variables that can be set after ELTR is running, to change its behavior -- they are documented in the manual. Some of these are:

  • eltr-prompt-prefix: prompt to be displayed when asking for user input
  • eltr-result-prefix: prefix to be displayed before showing evaluation result
  • eltr-echo-input: flag that tells wether the input should be echoed before eval
  • eltr-echo-input-prefix: default prefix to input echo
  • eltr-history-size: the number of expressions that ELTR will remember, and that the user can refer to with ,,e and ,,v

The following labels can be used in the prefix and suffix variables:

$(nexpr) -- sequential index of inputs and results $(tvalue) -- the type of the returned result

The default prefixes and suffix are listed below.

variable default value
eltr-prompt-prefix "$(nexpr)> "
eltr-echo-input-prefix ";;"
eltr-result-prefix "$(nexpr)=> "
eltr-result-suffix "\n ( $(tvalue) )"

Inside Emacs

Although ELTR was designed to run on a terminal, you can run eltr in interactive mode inside a running Emacs with M-x eltr. The interaction will be done in the minibuffer. You may need to use

(require 'eltr)

When running in interactive mode, the input and output will be done in the minibuffer. In order to give you time to see the output, ELTR will wait for a key to be pressed. In batch mode, it will just print the output and ask for the next expression.

Within Emacs, you can also set the configuration variables using Emacs' usual configuration interface (M-x customize-group eltr).

Readline and history

I recommend using rlwrap. It is possible to add readline-like capability to eltr, but using it with rlwrap works fine on the command line.

You can refer to previous expressions and returned values using ,,eNN for expression of number NN and ,,vNN for the returned value of number NN.

License

ELTR is distributed under the GNU Affero GPL license -- version 3 or, at your option, a later version.

The manual is released under the GNU Free Documentation License -- version 1.3 or at your option, a later version.