My Technical Notes

Thursday, 17 March 2016

ELisp: Writing and Evaluating Code

Using `ielm` Repl

You can start it by `M-x ielm` This will switch the current window to a new `ielm` buffer. This is a simple repl in which you can write statements and press `enter`.

Using a buffer (not `ielm`)

Within for example, the `*scratch*` buffer (or any other lisp buffer for that matter), we can write our code and evaluate it; evaluations are printed in the `*Messages*` buffer. If we have `*scratch*` and `*Messages*` buffers open in two separate windows, and we can evaluate the code in `*scratch*` and see the results immediately in `*Messages*`.

Keybindings for Evaluation

The following keybindings hold when we are in `Lisp Interaction` mode:

  • `C-x C-e` our cursor must be after the close-paren of the expression we want to evaluate. The result populates the minibuffer and the `*Messages*` buffer.
  • `C-M-x` will execute the "root" expression that we are currently in. Just like `C-x C-e`, it will populate the minibuffer and the `*Messages*` buffer.
  • `C-j` our cursor must be after the close-paren. This will execute the expression and populate the `*scratch*` buffer.

References

No comments: