The emacs editor was prototyped as a series of extension commands or macros for the late 1960s text editor TECO (Text Editor and COrrector). Its acronymic name, Editor MACroS, reflects this origin, although there have been many humorous reinterpretations, including ESCAPE META ALT CONTROL SHIFT, Emacs Makes All Computing Simple, and the unkind translation Eight Megabytes And Constantly Swapping.
Over time emacs has grown and evolved through more than 20 major revisions to the mainstream GNU version. The emacs editor, which is coded in C, contains a complete Lisp interpreter and fully supports the X Window System and mouse interaction. The original TECO macros are long gone, but emacs is still very much a work in progress. There are plans to support variable-width fonts, wide character sets, and the world's major languages as well as to move emacs in the direction of a WYSIWYG (what you see is what you get) word processor and make it easier for beginners to use.
The emacs editor has always been considerably more than a text editor. Not having been developed originally in a UNIX environment, it does not adhere to the UNIX philosophy. Whereas a UNIX utility is typically designed to do one thing and to be used in conjunction with other utilities, emacs is designed to "do it all." Taking advantage of the underlying programming language (Lisp), emacs users tend to customize and extend the editor rather than to use existing utilities or create new general-purpose tools. Instead they share their ~/.emacs (customization) files.
Well before the emergence of the X Window System, Stallman put a great deal of thought and effort into designing a window-oriented work environment, and he used emacs as his research vehicle. Over time he built facilities within emacs for reading and composing email messages, reading and posting netnews, giving shell commands, compiling programs and analyzing error messages, running and debugging these programs, and playing games. Eventually it became possible to enter the emacs environment and not come out all day, switching from window to window and from file to file. If you had only an ordinary serial, character-based terminal, emacs gave you tremendous leverage.
In an X Window System environment, or on the Mac OS X desktop, emacs does not need to control the whole display. Instead, it usually operates only one or two windows. The original work environment is still available and is covered in this chapter.
As a language-sensitive editor, emacs has special features that you can turn on to help edit text, nroff, TeX, Lisp, C, Fortran, and so on. These feature sets are called modes, but they are not related in any way to the Command mode and Input mode found in vi, vim, and other editors. Because you never need to switch emacs between Input and Command modes, emacs is a modeless editor.
emacs Versus vim
Like vim, emacs is a display editor: It displays on the screen the text you are editing and changes the display as you type each command or insert new text. Unlike vim, emacs does not require you to keep track of whether you are in Command mode or Insert mode: Commands always use CONTROL or other special keys. The emacs editor inserts ordinary characters into the text you are editing (as opposed to using ordinary characters as commands), another trait of modeless editing. For many people this approach is convenient and natural.
Like vim, emacs has a rich, extensive command set for moving about in the buffer and altering text. This command set is not "cast in concrete"you can change or customize commands at any time. Literally any key can be coupled (bound) to any command so as to match a particular keyboard better or just to fulfill a personal whim. Usually key bindings are set in the .emacs startup file, but they can also be changed interactively during a session. All the key bindings described in this chapter are standard on current GNU emacs versions, which also support many visual, mouse-oriented capabilities that are not covered here.
Caution: Too many key bindings
If you change too many key bindings, you may produce a command set that you will not remember or that will make it impossible for you to get back to the standard bindings again in the same session.
Finally, and very unlike vim, emacs allows you to use Lisp to write new commands or override old ones. Stallman calls this feature online extensibility, but it would take a gutsy Lisp guru to write and debug a new command while editing live text. It is much more common to add a few extra debugged commands to the .emacs file, where they are loaded when emacs starts up. Experienced emacs users often write modes, or environments, that are conditionally loaded by emacs for specific tasks.
Tip: The screen and emacs windows
In this chapter, the term screen denotes a character-based terminal screen or a terminal emulator window in a graphical environment. The term window refers to an emacs window within a screen.