Previous Table of Contents Next


Chapter 2
Emacs Lisp: A Short Description

by Robert J. Chassell

GNU Emacs Lisp is a full-featured, platform-independent, interpreted, dynamically scoped programming language with special features for use in GNU Emacs, an integrated computational environment.1


1GNU Emacs (including Emacs Lisp) consists of freely redistributable software. This means you can use, copy, and modify it. You may redistribute the same or modified copies, giving them away or charging for the act of transferring copies, so long as you pass on to others the same rights that you have. Your rights and responsibilities are described in the GNU General Public License that comes with GNU Emacs.

Emacs Lisp is a simple, albeit complete, language. Not only does it contain the usual features of a programming language, Emacs Lisp also contains special features for use in Emacs’s extensible, integrated computational environment: features for scanning and parsing text and also for handling files, buffers, displays, and subprocesses. Moreover, editing commands are functions that can easily be called from Lisp programs; customization parameters are ordinary Lisp variables.

Most of the GNU Emacs environment is written in Emacs Lisp. The language is used by people who write extensions to Emacs, by students who are learning to program, and by programmers to create applications that use the extensive Emacs libraries.

Emacs Lisp is an interpreted language. However, it can be byte compiled to run quickly in a virtual machine. It runs on numerous platforms—more than 40 at last count.

GNU Emacs includes two debuggers, which you can use to examine the runtime stack, step through sources, display a backtrace, and the like.

The antecedents of Emacs Lisp spring from the beginnings of modern-day computing; the language was inspired by MacLisp, which grew out of MIT’s Project MAC of the 1960s. (Lisp itself was first developed in the late 1950s for research in artificial intelligence.) Emacs Lisp was also somewhat influenced by Common Lisp. However, Emacs Lisp is much simpler than Common Lisp. If you know Common Lisp you should be careful: Sometimes the simplifications are so drastic that they confuse an unwary expert in Common Lisp.

The whole GNU Emacs environment, including Emacs Lisp, was first written by Richard Stallman in the early 1980s. Since then, many people have extended the system and contributed new applications, such as Calc mode for calculus and other computations, Calendar mode for Mayan, Coptic, and more conventional calendars, W3 mode for browsing the Web, and ange-ftp for treating remote file systems as if they were local. All these additions were written in Emacs Lisp.

2.1. GNU Emacs and Emacs Lisp

You can think of GNU Emacs in at least four ways:

  As a set of programs in Emacs Lisp, with a fast running base written in C
  As a Lisp machine that runs on more than 40 different types of hardware
  As an editor
  As a general computational environment

This chapter focuses on Emacs Lisp as a programming language. However, because Emacs Lisp comes with GNU Emacs, this programming language possesses multimode user interface libraries suitable both for slow dial-up terminals and for graphical user interfaces, as well as many other libraries to help you with calendars, forms, mail, news, outlines, C and other programming, compiling, debugging, FTP, phases of the moon, Conway’s Game of Life, and a universe of libraries.2


2The most valuable references for Emacs Lisp are The GNU Emacs Lisp Reference Manual, which tells about Emacs Lisp, and the The GNU Emacs Manual, which tells about Emacs. My Programming in Emacs Lisp: An Introduction is for people who are not necessarily interested in programming, but who do want to customize or extend their computing environment. These all come with Emacs and can be read online using Info. Also, you can print these manuals yourself or order printed copies from
Free Software Foundation, Inc.
59 Temple Place, Suite 330
Boston, MA 02111-1307 USA
Telephone: +1-617-542-5942
Fax (including Japan): +1-617-542-2652
Email: gnu@gnu.org
World Wide Web: http://www.gnu.org

GNU Emacs provides two interpreters for Emacs Lisp: the Lisp interpreter and a byte-code interpreter. These are the programs on your computer that execute the code.

The Lisp interpreter reads and evaluates (that is, runs as code) the printed representations of Emacs Lisp that you are able to read. The second interpreter is automatically called by the first in the appropriate circumstances; it evaluates a special representation called byte-code that can be executed more efficiently than code you can read. Humanly readable Lisp code is converted into byte-code with a compiler.

Because the byte-compiled code is evaluated by the byte-code interpreter, instead of being executed directly by the machine’s hardware (as true compiled code is), byte-code is completely transportable from machine to machine without recompilation. It is, in the jargon, “platform independent.” It is not, however, as fast as true compiled code.


Previous Table of Contents Next