Appendix B. Lisp Quick Reference

This appendix summarizes general Lisp syntax as used in Emacs, and some important Lisp functions. It does not summarize Emacs-specific features such as buffers, hook variables, keymaps, modes, and so on. For a complete Emacs Lisp reference, see The GNU Emacs Lisp Reference Manual. Details on obtaining it are in Appendix E.

Basics

A Lisp expression is a unit of data that can be evaluated. The expression may be composed of subexpressions, as in the cases of lists and vectors.

Every Lisp expression has a way to produce a value when evaluated. Most kinds of expression are self-evaluating, which means that they are their own value.

A Lisp expression can be treated as literal data instead of being evaluated. Non-self-evaluating expressions must be quoted in order to use them as literals and prevent them from being evaluated.

The symbol nil denotes falsehood. It is exactly the same object as the empty list, (). Every other Lisp object denotes truth, but the symbol t is reserved to mean truth anyway.

Emacs Lisp (unlike some other dialects of Lisp) is case-sensitive.

Data Types

Numbers

Emacs Lisp supports integers and floating-point numbers. They’re written in just the way you’d expect: as a string of base-10 digits with an optional leading minus sign and optional decimal point. Some functions that operate on numbers are:

(numberp x)

Test whether x is a number.

(integerp x)

Test whether x is an integer.

(zerop ...

Get Writing GNU Emacs Extensions now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.