Microsoft Store
 

Emacs


 

:This article is about the text editor. For the Apple Macintosh computer model, see eMac.

Features

The remainder of this article discusses GNU Emacs and XEmacs, the only incarnations of Emacs that are widely used today. We will use the term "Emacs" to refer to both programs, as they have very similar features; XEmacs started as a fork of GNU Emacs, and subsequent versions have remained more or less compatible with GNU Emacs.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

In spite of—or perhaps because of—its venerable background, Emacs is one of the most powerful and versatile text editors in existence. It should be noted that it is primarily a text editor, not a word processor; its huge feature set is geared toward helping the user to manipulate pieces of text, rather than manipulating the font of the characters or printing documents (though Emacs can do these as well). Emacs brings a host of features to bear on the seemingly-simple task of text editing, ranging from commands to manipulate words and paragraphs (deleting them, moving them, moving through them, and so forth), to syntax highlighting for making source code easier to read, to executing "keyboard macros" for performing arbitrary batches of editing commands defined by the user.

Related Topics:
Word processor - Font - Word - Paragraph - Syntax highlighting - Source code

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

The rich variety of features found in Emacs is a result of its unusual design. Almost all of the functionality in the editor, ranging from basic editing operations such as the insertion of characters into a document to the configuration of the user interface, is controlled by a dialect of the Lisp programming language known as Emacs Lisp. In this Lisp environment, variables and even entire functions can be modified on the fly, without having to recompile or even restart the editor. As a result, the behavior of Emacs can be modified almost without limit, either directly by the user, or (more commonly) by loading bodies of Emacs Lisp code known variously as "libraries", "packages", or "extensions".

Related Topics:
Lisp programming language - Emacs Lisp - Variables - Functions

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Emacs contains a large number of Emacs Lisp libraries, and more "third-party" libraries can be found on the Internet. Many libraries implement computer programming aids, reflecting Emacs' popularity among programmers. Emacs can be used as an Integrated Development Environment (IDE), allowing programmers to edit, compile, and debug their code within a single interface. Other libraries perform more unusual functions. A few examples are listed below:

Related Topics:
Internet - Integrated Development Environment - Compile - Debug

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

  • Calc, a powerful numerical calculator
  • Calendar-mode, for keeping appointment calendars and diaries
  • Doctor, an implementation of ELIZA that performs basic Rogerian psychotherapy
  • Dunnet, a text adventure
  • Emerge, for comparing files and combining them
  • Emacs/W3, a web browser
  • ERC, an IRC client
  • Gnus, a full-featured newsreader and email client
  • Info, an online help-browser
  • Tetris
  • The downside to Emacs' Lisp-based design is a performance overhead resulting from loading and interpreting the Lisp code. On the systems in which Emacs was first implemented, Emacs was often noticeably slower than rival text editors. 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, and Eventually Mallocs All Computer Storage. However, modern computers are fast enough that Emacs is seldom felt to be slow. In fact, Emacs starts up more quickly than most modern word processors.

    Related Topics:
    Interpreting - Megabyte - Malloc

    ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Platforms

Emacs is one of the most portable non-trivial computer programs in the world. It runs on a wide variety of operating systems, including most Unix-like systems (GNU/Linux, the various BSDs, Solaris, and AIX, etc.), MS-DOS, Microsoft Windows, OpenVMS, and Mac OS X.

Related Topics:
Portable - Operating system - Unix - GNU/Linux - BSDs - Solaris - AIX - MS-DOS - Microsoft Windows - OpenVMS - Mac OS X

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Emacs runs on both text terminals and graphical user interface (GUI) environments. On Unix-like operating systems, Emacs uses the X Window System to produce its GUI, either directly or using a "widget toolkit" such as Motif, LessTif, or GTK+. Emacs can also use the native graphical systems of Mac OS X (using the Carbon interface) and Microsoft Windows. The graphical interface provides menubars, toolbars, scrollbars, and context menus.

Related Topics:
Text terminals - Graphical user interface - Unix - X Window System - Motif - LessTif - GTK+ - Carbon - Microsoft Windows - Menubar - Toolbar - Scrollbar - Context menu

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Editing modes

Emacs adapts its behavior to the type of text it is editing by entering editing modes called "major modes". Major modes are defined for ordinary text files, source code for many programming languages, HTML documents, TeX and LaTeX documents, and many other types of text. Each major mode tweaks certain Emacs Lisp variables to make Emacs behave more conveniently for the particular type of text. In particular, they usually implement syntax highlighting, using different fonts or colors to display keywords, comments, and so forth. Major modes also provide special editing commands; for example, major modes for programming languages usually define commands to jump to the beginning and the end of a function.

Related Topics:
Source code - Programming language - HTML - TeX - LaTeX - Syntax highlighting - Keyword - Comment

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

The behavior of Emacs can be further customized using "minor modes". While only one major mode can be associated with a buffer at a time, multiple minor modes can be simultaneously active. For example, the major mode for the C programming language defines a different minor mode for each of the popular indent styles.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Customization

Most users of Emacs customize the editor to suit their needs. There are three primary ways to customize Emacs. The first is the customize extension, which allows the user to set common customization variables, such as the colour scheme, using a graphical interface. This is intended for Emacs beginners who do not want to work with Emacs Lisp code.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

The second is to collect keystrokes into macros and replay them to automate complex, repetitive tasks. This is often done on an ad-hoc basis and each macro discarded after use, although macros can be saved and invoked at need.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

The third method for customizing Emacs is using Emacs Lisp. Usually, user-supplied Emacs Lisp code is stored in a file called .emacs, which is loaded when Emacs starts up. The .emacs file is often used to set variables and key bindings different from the default setting, and to define new commands that the user finds convenient. Many advanced users have .emacs files hundreds of lines long, with idiosyncratic customizations that cause Emacs to diverge wildly from the default behavior.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

If a body of Emacs Lisp code is generally useful, it is often packaged as a library and distributed to other users. Many such third-party libraries can be found on the Internet; for example, there is a library called for editing . There is even a Usenet newsgroup, , which is used for posting new libraries. Some third-party libraries eventually make their way into Emacs, thus becoming a "standard" library.

Related Topics:
Usenet - Newsgroup

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Documentation

The first Emacs included a powerful help library that can display the documentation for every single command, variable, and internal function. (It may have originated this technique.) Because of this, Emacs was described as "self-documenting". (This term does not mean that Emacs writes its own documentation, but rather that it presents its own documentation to the user.) This feature makes Emacs' documentation very accessible. For example, the user can find out about the command bound to a particular keystroke simply by entering C-h k (which runs the command describe-key), followed by the keystroke. Each function included a documentation string, specifically to be used for showing to the

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

user on request. The practice of giving functions documentation strings subsequently spread to various programming

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

languages such as Lisp and Java.

Related Topics:
Lisp - Java

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

The Emacs help system is useful not only for beginners, but also for advanced users writing Emacs Lisp code. If the documentation for a function or variable is not enough, the help system can be used to browse the Emacs Lisp source code for both built-in libraries and installed third-party libraries. It is therefore very convenient to program in Emacs Lisp using Emacs itself.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Apart from the built-in documentation, Emacs has an unusually long, detailed and well-written manual. An electronic copy of the GNU Emacs Manual, written by Richard Stallman, is included with GNU Emacs and can be viewed with the built-in Info browser. XEmacs has a similar manual, which forked from the GNU Emacs Manual at the same time as the XEmacs software. Two other manuals, the Emacs Lisp Reference Manual by Bill Lewis, Richard Stallman, and Dan Laliberte, and Programming in Emacs Lisp by Robert Chassell, are also included. Apart from the electronic versions, all three manuals are also available in book form, published by the Free Software Foundation.

Related Topics:
Manual - Info - Free Software Foundation

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Emacs also has a built-in tutorial. When Emacs is started with no file to edit, it displays instructions for performing simple editing commands and invoking the tutorial.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Internationalization

Emacs supports the editing of text written in many human languages. There is support for many alphabets, scripts, writing systems, and cultural conventions. Emacs provides spell checking for many languages by calling external programs such as ispell. Many encoding systems, including UTF-8, are supported. XEmacs version 21.5 has full Unicode support, and similar support for GNU Emacs is being developed. However, the Emacs user interface is in English, and has not been translated into any other language.

Related Topics:
Human languages - Ispell - Encoding systems - UTF-8 - Unicode

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

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

~ ~ ~ ~ ~ ~ ~ ~ ~ ~