Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to invoke an interactive elisp interpreter in Emacs?

Right now I write expressions in the *scratch* buffer and test them by evaluating with C-x C-e. I would really appreciate having an interactive interpreter like SLIME or irb, in which I could test Emacs Lisp expressions.

like image 930
Michał Kwiatkowski Avatar asked Sep 28 '08 03:09

Michał Kwiatkowski


People also ask

How do I run Elisp in Emacs?

In a fresh Emacs window, type ESC-x lisp-interaction-mode . That will turn your buffer into a LISP terminal; pressing Ctrl+j will feed the s-expression that your cursor (called "point" in Emacs manuals' jargon) stands right behind to LISP, and will print the result.

Is Emacs a Lisp interpreter?

Emacs Lisp is a dialect of the Lisp programming language used as a scripting language by Emacs (a text editor family most commonly associated with GNU Emacs and XEmacs). It is used for implementing most of the editing functionality built into Emacs, the remainder being written in C, as is the Lisp interpreter.

What does interactive do in Lisp?

The "call" to `interactive' is actually a declaration rather than a function; it tells `call-interactively' how to read arguments to pass to the function. When actually called, `interactive' just returns nil. The argument of `interactive' is usually a string containing a code letter followed by a prompt.

Is Emacs an interpreter?

Emacs comes with an interpreter and a whole GUI frontend for its interpreter, not merely a terminal interpreter with a prompt. That's why you are able to evaluate any Emacs Lisp code ANYWHERE. If you only use Emacs as a text editor, that's fine for using a subset of it.


2 Answers

It's easy to evaluate Lisp expressions in Inferior Emacs-Lisp Mode:

M-x ielm 

You can read more about this feature in the Emacs manual section on "Lisp Interaction"

like image 119
Greg Mattes Avatar answered Sep 18 '22 19:09

Greg Mattes


Eshell is another option for an interactive Elisp interpreter.

M-x eshell 

Not only is it a command shell like bash (or cmd.exe if on Windows) but you can also interactively write and execute Elisp code.

~ $ ls foo.txt bar.txt ~ $ (+ 1 1) 2 
like image 30
Ray Avatar answered Sep 21 '22 19:09

Ray