Xah Lee, , …,
This page shows you how to evaluate emacs lisp code.
To evaluate a single lisp expression, move your cursor to the right of the last closing parenthesis, and call eval-last-sexp 【Ctrl+x Ctrl+e】.
To evaluate a text selection, call eval-region.
Here's a list of other ways, roughly in order of usefulness:
| Command Name | Acting Area | Key |
|---|---|---|
| eval-last-sexp | the complete lisp expression to the left of cursor | 【Ctrl+x Ctrl+e】 |
| eval-defun | the function definition block (defun) the cursor is in. (your cursor needs to be near top level.) | 【Ctrl+Alt+x】 (only when in lisp modes) |
| eval-region | text selection | ◇ |
| eval-buffer | whole file in current window | ◇ |
| load-file | promps you for a file name | ◇ |
| eval-expression | promps you to type code | ◇ |
For commands that do not have a key, you can assign them a key, or you can give them a alias for convenience, e.g. “eb” for eval-buffer.
Also, emacs has a interactive emacs lisp shell: 【Alt+x ielm】. You might find it useful. I never liked programing in a shell interface, so i never used ielm. I prefer a notebook-style interface, i always code elisp in a new empty file.
blog comments powered by Disqus