Emacs: Evaluate Elisp Code
To evaluate a single lisp expression, move your cursor to the right of the last closing parenthesis, and Alt+x
eval-last-sexp 【Ctrl+x Ctrl+e】.
To evaluate all elisp code in a text selection, Alt+x
Here's ways to eval elisp code, roughly in order of usefulness:
eval-last-sexp→ eval lisp expression to the left of cursor.
eval-defun→ eval function definition block the cursor is in. (the elisp code must be well-indended, otherwise emacs may have problem finding function.)
eval-region→ eval text selection.
eval-buffer→ eval whole buffer.
load-file→ eval a file. It prompts.
eval-expression→ prompts you to type code.
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.
Emacs Lisp Basics
If you have a question, put $5 at patreon and message me.