Encyclopedia  |   World Factbook  |   World Flags  |   Reference Tables  |   List of Lists     
   Academic Disciplines  |   Historical Timeline  |   Themed Timelines  |   Biographies  |   How-Tos     
Sponsor by The Tattoo Collection
Emacs
Main Page | See live article | Alphabetical index

Emacs

For the Apple Macintosh computer model, see eMac.

Emacs is a text editor with a comprehensive set of features that is particularly popular with programmers and other technical computer users. The original Emacs was written in 1976 by Richard Stallman, as a set of Editor MACroS for the TECO editor.

from version 21.2 of the GNU Emacs text editor, showing the GNU logo.]]
Many Emacs clones have appeared since then, but most have faded into obscurity. The definitive version of Emacs today is GNU Emacs which is also written by Richard Stallman, starting in 1984. The most popular alternative is XEmacs, which forkeded from GNU Emacs in 1991, and has synced with GNU Emacs regularly since.

The lower-case word emacs (plural emacsen) is sometimes used to mean the class of editors with behavior similar to the original Emacs. The capitalized word Emacs is often used synonymously with GNU Emacs.

Emacs is typically on one side of the editor wars (the other being vi).

Table of contents
1 Emacs history
2 Description of GNU Emacs
3 References
4 External links

Emacs history

Emacs began at the Artificial Intelligence Laboratory at MIT. Prior to its introduction, TECO was the default text editor in ITS, the operating system on the AI Lab's PDP-6 and PDP-10 computers.

Unlike modern text editors, TECO abstracted the task of typing from editing, so that modifying a document at times required writing a series of instructions in the TECO command language. This behavior is similar to the program ed, which is still in use.

Carl Mikkelsen, one of the hackers at the MIT AI Lab, added a display-editing mode to TECO, which allowed the screen display to be updated each time the user entered a keystroke. This more-intuitive behavior, which is used by most modern text editors, had been pioneered by the "E" editor written at the Stanford AI Lab. In 1974, Richard Stallman, another hacker, added a macro feature to the TECO display-editing mode. This allowed the user to define keystrokes which would perform multiple TECO commands.

The users at the AI Lab soon accumulated a large collection of custom macros. In 1976, Guy Steele began an effort to unify the many divergent macro sets. The project was completed by Stallman, who also wrote facilities for extension and self-documentation. The resulting program was called EMACS (all caps). Though built on TECO, its behavior was different enough to be considered a text editor in its own right.

"EMACS" stood for "Editor MACroS". According to Stallman, he picked the name Emacs "because < E > was not in use as an abbreviation on ITS at the time." It has also been pointed out that "Emack & Bolio's;" was the name of a popular ice cream store in Boston, within walking distance of MIT. The text-formatting program used on ITS was called BOLIO.

EMACS soon became the standard editor on ITS. It was also ported from ITS to the Tenex and TOPS-20 operating systems by Stallman and Michael McMahon.

Several Emacs-like editors were written in the following years, including EINE (EINE Is Not EMACS) and ZWEI (ZWEI Was EINE Initially) by Michael McMahon and Daniel Weinreb. In 1978, Bernard Greenberg wrote Multics Emacs at Honeywell's Cambridge Information Systems Lab. This editor was written in MacLisp, a dialect of the Lisp programming language. User-supplied extensions were also written in Lisp. The choice of Lisp provided more extensibility than ever before, and has been followed by most subsequent emacsen. Later emacsen include Hemlock, Deuce, and Fred.

Gosling Emacs, the first Emacs-like editor to run on Unix, was written by James Gosling in 1981. It was written in C and used a stripped-down version of Lisp, known as Mocklisp, as an extension language.

In 1984, Stallman began writing a new emacs implementation, GNU Emacs, which became the first program in the nascent GNU project. GNU Emacs was written in C and used Emacs Lisp for extension. The first widely distributed version of GNU Emacs was 15.34, which appeared in 1985. Like Gosling Emacs, GNU Emacs ran on Unix; however, GNU Emacs had more features, in particular a full-featured Lisp as extension language. As a result, it soon replaced Gosling Emacs as the de facto Emacs editor on Unix.

Beginning in 1991, Lucid Emacs was developed by Jamie Zawinski and others at Lucid Inc., based on an early alpha version of GNU Emacs 19. The codebases soon diverged, and the separate development teams gave up trying to merge them back into a single program. This was one of the most famous early forks of a free software program. Lucid Emacs has since been renamed XEmacs; it and GNU Emacs remain the two most popular varieties in use today.

Emacs versions used to have a "1" in front of them (1.21.3.1), but the changes made to Emacs were all considered so minor that the number would never change. Therefore, the "1" was dropped, and the version numbers made slightly simpler (21.3.1).

Description of GNU Emacs

The GNU Emacs manual describes it as "the extensible, customizable, self-documenting, real-time display editor."

User interface

Emacs stores text in objects called buffers. The user can create new buffers and dismiss unwanted ones, and several buffers can exist at the same time. Most buffers contain text loaded from text files, to be edited by the user. However, buffers can also be used for other purposes; for example, the user may create an empty buffer to store text temporarily.

Each Emacs screen (which is a single window on a windowing system, or the entire screen on a text terminal) can display one or more buffers at a time. If more than one buffer is displayed, the display area is split into multiple sections (which Emacs refers to, confusingly, as windows.) On a windowing system, multiple screens of Emacs can also be created (which Emacs refers to as frames.)

The user issues editing commands by entering keystrokes. In addition to the usual commands for inserting and deleting text, Emacs provides a host of more exotic commands, such as moving the editing point to the next sentence, opening all files in a directory, and performing a search-and-replace operation. Most of these commands can be activated with a combination of keystrokes. Recent versions of Emacs also provide graphical menus for the most common commands. (Most commands, even seemingly-simple ones such as typing a to insert the character a, are actually calls to Emacs Lisp functions, as described below.)

The graphical interface of GNU Emacs can use either plain X toolkit, Lesstif, or Gtk+ to provide menubars, context menus, and a point and click interaction. Whenever possible, the key bindings for the commands are listed in the graphical menu so that new users can learn the shortcuts as they explore Emacs.

Emacs supports many encoding systems, including UTF-8. A version with full Unicode support is currently being developed.

For visually impaired and blind users there is a subsystem called Emacspeak which may be loaded. It allows the editor to be used through audio feedback only.

Customization

The low-level source code of Emacs is written in the C programming language. This includes the display engine, as well as an interpreter for Emacs Lisp (a dialect of the Lisp programming language). The majority of the editing code is written in Emacs Lisp. At run-time, the interpreter loads and evaluates (executes) this Lisp code.

The user can extend and customize the Lisp code from within Emacs itself. Emacs provides extensive facilities to support this, including commands for looking up the documentation of loaded functions and variables (this is known as self-documentation.) By re-evaluating the user-supplied Lisp code, the behavior of Emacs can be modified "on the fly", without having to recompile or even restart the editor. Lisp is a good choice of language for this purpose, because it allows functions to be treated as data.

As a result, it is very easy to add custom functionality to Emacs. Emacs includes many standard extensions, such as Emacs/W3, a web browser; Gnus, a tool for reading e-mail and Usenet discussions; an implementation of the game Tetris; and Doctor, an implementation of ELIZA that performs basic Rogerian psychotherapy. In addition, Emacs can serve as an IDE, allowing programmers to edit, compile, and debug their code from within a single interface. This wide range of capabilities has led to several jokes of the form: "Emacs is a wonderful operating system; it just needs a better text editor."

Emacs also includes many of what it calls major modes to help with the editing of different types of text files. Typically, these file types are source code in various programming and markup languages. A major mode will usually allow the contents of a file to be colored and highlighted, based on the language's syntax and typographical conventions. This feature is commonly called syntax highlighting. For example, the major mode for editing C programs knows that comments in C begin with /* and end with */. This allows it to display comments in a different color than the executable parts of the program. It knows what the language's reserved words are, enabling it to display those in another color. It knows about the language's block structure, which allows it to automatically indent a line, based on how deeply nested the line is.

Within a major mode, there may be several minor modes that further customize Emacs' behaviour with respect to that major mode. For example, the major mode for C programs has a minor mode for each of the popular indent styles used in C.

The downside to Emacs' design is a performance overhead from loading and interpreting the Lisp code. Several joke acronyms allude to this: Eight Megabytes And Constantly Swapping (from the days when eight megabytes was a lot of memory), Emacs Makes A Computer Slow, Emacs Munches All Computer Storage and Escape-Meta-Alt-Control-Shift. (The last refers to the perceived complexity of some of its default keyboard shortcuts; similarly, Even a Master of Arts Comes Simpler.) Modern computers generally have enough memory and processor power, compared to the systems on which Emacs was first implemented, that this issue is largely moot. Nevertheless, this is a frequent point raised by Emacs' detractors during editor wars. Emacs' devotees offer Emacs Makes All Computing Simple as another meaning of the name.

There are two other methods for customizing Emacs, though neither is as flexible as writing Emacs Lisp code. Firstly, Emacs provides commands for recording keyboard macros, which are commands that stand for a sequence of keystrokes. Secondly, the "Customize" package, included in recent versions of Emacs, allows users to set common customization variables using a graphical interface.

Internals

The contents of buffers are stored as a contiguous sequence of characters divided by a gap, known as the buffer gap, where the editing point resides. Changes are made to the buffer by moving the gap and/or altering the characters next to the gap. This design allows most editing operations to be very efficient, as not much memory has to be modified. The competing form of storage for documents is to store each line of the document in a small buffer.

See Emacs Lisp for a description of the Emacs Lisp interpreter.

Distribution

Emacs is free software, distributed under the terms of the GNU GPL.

The source code and binaries are available via FTP from the GNU project website (below.) They are also widely available from other sites on the Internet. Vendors of Unices (both free and proprietary) frequently provide Emacs bundled in the operating system.

Emacs runs on a large number of platforms, including GNU/Linux, FreeBSD, and most Unices, Mac OS, and Microsoft Windows.

Development

Emacs is part of the GNU project, and is under active development. Several, but not all, of the developers are affiliated with the Free Software Foundation (FSF).

Until 1999, Emacs development was relatively closed, to the point where it was used as an example of the "Cathedral" development style in The Cathedral and the Bazaar. The project has since adopted a public development mailing list and anonymous CVS access. As with all GNU projects, it remains policy to accept significant code contributions only if the copyright holder assigns the code's copyright to FSF, although one exception was made to this policy for the MULE (MULtilingual Extension) code [1] since the copyright holder is the Japanese government and copyright assignment was not possible. This does not apply to bug fixes or minor code contributions. This policy is intended to facilitate copyleft enforcement, so that FSF can defend the software in a court case if one arises.

As of 2004, the latest release of GNU Emacs is version 21.3. Development takes place in a single CVS trunk, which is at version 21.3.50. The current maintainer is Richard Stallman.

References

External links