Emacs: Evaluate Elisp Code
Here's ways to eval elisp code, roughly in order of usefulness:
Eval lisp expression to the left of cursor.
Result is placed in Messages Buffer, and temporarily displayed at bottom.
- Eval text selection.
- Eval whole buffer.
- Eval a file. It prompts for a filename.
- Eval function definition the cursor is in. (the elisp code must be well-indended, otherwise emacs may have problem finding function.) [see Emacs: narrow-to-defun, eval-defun, bug]
- Prompts you to type a emacs lisp expression.
Emacs Lisp Command Line Interface (REPL)
ielm to start emacs interactive emacs lisp shell.
I recommend working in a buffer instead of REPL.
Working in a buffer (sometimes called notebook inteface) allows you to use full editing power, and eval any expression, in any order, anytime, anywhere. [see Command Line Interface (REPL) vs Notebook Interface]