buffers in GNU Emacs
source code in GNU Emacs code from GNU Emacs
Commands In its normal editing mode, GNU Emacs behaves like common text editors by allowing the user to
type text with the keyboard and move the editing point with
arrow keys.
Escape key sequences or pressing the
control key and/or the
meta key,
alt key or
super keys in conjunction with a regular key produces
modified keystrokes that invoke functions from the Emacs Lisp environment. Commands such as save-buffer and save-buffers-kill-emacs combine multiple modified keystrokes. Some GNU Emacs commands work by invoking external programs, such as
ispell for
spell-checking and the
GNU Compiler Collection (GCC) for program
compilation. Emacs also supports "inferior processes," long-lived
child processes that interact with the editor. This is used to implement , running a
Unix shell as inferior process, as well as
read–eval–print loop (REPL) modes for various programming languages. Emacs' support for external processes makes it suitable for interactive programming along the lines of
Interlisp or
Smalltalk. Users who prefer the widely used
IBM Common User Access keyboard shortcut layout can use , a package that originally was a third-party add-on but has been included in GNU Emacs since version 22.
Minibuffer Emacs uses the "minibuffer," normally the bottommost line, to display messages and request information, functions that are often performed by
dialog boxes in
GUI editors. The minibuffer holds information such as text to target in a search or the name of a file to read or save. When applicable,
command-line completion is available using the tab and space keys.
File management and display Emacs keeps text in
data structures known as
buffers. Buffers may or may not be displayed onscreen, and all buffer features are accessible by both
Emacs Lisp programs and the user interface. The user can create new buffers and dismiss unwanted ones, and many buffers can exist at the same time, limited only by available memory. Emacs can be configured to save the list of open buffers on exit, and reopen this list when it is restarted. Some buffers contain text loaded from
text files, which the user can edit and save back to permanent storage. These buffers are said to be "visiting" files. Buffers also serve to display other data, such as the output of Emacs commands,
dired directory listings, documentation strings displayed by the "help" library and notification messages that in other editors would be displayed in a
dialog box. Some of these notifications are displayed briefly in the minibuffer, and GNU Emacs provides a buffer that keeps a history of the most recent notifications of this type. When the minibuffer is used for output from Emacs, it is called the "echo area". Longer notifications are displayed in buffers of their own. The maximum length of messages that will be displayed in the minibuffer is, of course, configurable. Buffers can also serve as input and output areas for an external process such as a
shell or
REPL. Buffers which Emacs creates on its own are typically named with
asterisks on each end, to distinguish from user buffers. The list of open buffers is itself displayed in this type of buffer. Most Emacs key sequences remain functional in any buffer. For example, the standard Ctrl-s isearch function can be used to search filenames in dired buffers, and the file list can be saved to a text file just as any other buffer. Dired buffers can be switched to a writable mode, in which filenames and attributes can be edited textually; when the buffer is saved, the changes are written to the filesystem. This allows multiple files to be renamed using the search and replace features of Emacs. When so equipped, Emacs displays
image files in buffers. Emacs is binary safe and 8-bit clean. Emacs can split the editing area into separate non-overlapping sections called "windows," a feature that has been available since 1975, predating the graphical user interface in common use. In Emacs terminology, "windows" are similar to what other systems call "
frames" or "
panes" a rectangular portion of the program's display that can be updated and interacted with independently. Each Emacs window has a
status bar called the "mode line" displayed by default at the bottom edge of the window. Emacs windows are available both in text-terminal and graphical modes and allow more than one buffer, or several parts of a buffer, to be displayed at once. Common applications are to display a
dired buffer along with the contents of files in the current directory (there are special modes to make the file buffer follow the file highlighted in dired), to display the
source code of a program in one window while another displays a
shell buffer with the results of compiling the program, to run a debugger along with a shell buffer running the program, to work on code while displaying a
man page or other documentation (possibly loaded over the
World Wide Web using one of Emacs' built-in web browsers) or simply to display multiple files for editing at once such as a header along with its implementation file for C-based languages. In addition, there is , a minor mode that chains windows to display non-overlapping portions of a buffer. Using , a single file can be displayed in multiple side-by-side windows that update appropriately when scrolled. In addition, Emacs supports "narrowing" a buffer to display only a portion of a file, with top/bottom of buffer navigation functionality and buffer size calculations reflecting only the selected range. Emacs windows are
tiled and cannot appear "above" or "below" their companions. Emacs can launch multiple "frames", which are displayed as individual
windows in a graphical environment. On a text terminal, multiple frames are displayed stacked filling the entire terminal, and can be switched using the standard Emacs commands.
Major modes GNU Emacs can display or edit a variety of different types of text and adapts its behavior by entering
add-on modes called "major modes". There are major modes for many different purposes including editing ordinary text files, the
source code of many
markup and
programming languages, as well as displaying
web pages,
directory listings and other system info. Each major mode involves an Emacs Lisp program that extends the editor to behave more conveniently for the specified type of text. Major modes typically provide some or all of the following common features: • Syntax highlighting ("font lock"): combinations of fonts and colors, termed "faces," that differentiate between document elements such as
keywords and
comments. • Automatic indentation to maintain consistent formatting within a file. • The automatic insertion of elements required by the structure of the document, such as spaces, newlines, and parentheses. • Special editing commands, such as commands to jump to the beginning or the end of a function while editing a programming file or commands to validate documents or insert closing tags while working with markup languages such as
XML.
Minor modes The use of "minor modes" enables further customization. A GNU Emacs editing buffer can use only one major mode at a time, but multiple minor modes can operate simultaneously. These may operate directly on documents, as in the way the major mode for the C programming language defines a separate minor mode for each of its popular
indent styles, or they may alter the editing environment. Examples of the latter include a mode that adds the ability to undo changes to the window configuration and one that performs on-the-fly syntax checking. There is also a minor mode that allows multiple major modes to be used in a single file, for convenience when editing a document in which multiple programming languages are embedded.
"Batch mode" GNU Emacs supports the capability to use it as an interpreter for the
Emacs Lisp language without displaying the text editor user interface. In batch mode, user configuration is not loaded and the terminal
interrupt characters C-c and C-z will have their usual effect of exiting the program or suspending execution instead of invoking Emacs keybindings. GNU Emacs has
command line options to specify either a file to load and execute, or an Emacs Lisp function may be passed in from the command line. Emacs will start up, execute the passed-in file or function, print the results, then exit. The
shebang line #!/usr/bin/emacs --script allows the creation of standalone scripts in Emacs Lisp. == Manuals ==