25.9. Lisp Interaction Buffers

The buffer *scratch* which is selected when Emacs starts up is provided for evaluating Lisp expressions interactively inside Emacs.

The simplest way to use the *scratch* buffer is to insert Lisp expressions and type C-j after each expression. This command reads the Lisp expression before point, evaluates it, and inserts the value in printed representation before point. The result is a complete typescript of the expressions you have evaluated and their values.

The *scratch* buffer's major mode is Lisp Interaction mode, which is the same as Emacs-Lisp mode except for the binding of C-j.

The rationale for this feature is that Emacs must have a buffer when it starts up, but that buffer is not useful for editing files since a new buffer is made for every file that you visit. The Lisp interpreter typescript is the most useful thing I can think of for the initial buffer to do. Type M-x lisp-interaction-mode to put the current buffer in Lisp Interaction mode.

An alternative way of evaluating Emacs Lisp expressions interactively is to use Inferior Emacs-Lisp mode, which provides an interface rather like Shell mode (Section 31.15.3) for evaluating Emacs Lisp expressions. Type M-x ielm to create an *ielm* buffer which uses this mode.