The LISP Modes

There are actually three LISP modes, listed here by their ESC x command names:

emacs-lisp-mode

Used for editing Emacs LISP code, as covered in Chapter 13 (filename .emacs or suffix .el)

lisp-mode

Used for editing LISP code intended for another LISP system (suffix .l or .lisp)

lisp-interaction-mode

Used for editing and running Emacs LISP code

All three modes have the same basic functionality; they differ only in the support they give to running LISP code.

All three LISP modes understand the basic syntax elements common to all language modes. In addition, they have various commands that apply to the more advanced syntactic concepts of S-expressions, lists, and defuns. An S-expression (or syntactic expression) is any syntactically correct LISP expression, be it an atom (number, symbol, variable, etc.) or parenthesized list. Lists are special cases of S-expressions, and defuns (function definitions) are special cases of lists. There are several commands that deal with these syntactic concepts; you will most likely become comfortable with a subset of them.

Table 12-4 shows the commands that handle S-expressions.

Table 13-4. S-expression Commands

Keystrokes

Command Name

Action

ESC C-b

backward-sexp

Move backward by one S-expression.

ESC C-f

forward-sexp

Move forward by one S-expression.

ESC C-t

transpose-sexps

Transpose the two S-expressions around the cursor.

ESC C-@

mark-sexp

Set mark to the end of the current S-expression; set ...

Get Learning GNU Emacs, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.