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.
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.
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.
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.
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.
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"
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With