1. Home
  2. Computing & Technology
  3. Linux
Linux / Unix Command: emacs
Command Library

NAME

emacs - GNU project Emacs  

SYNOPSIS

emacs [ command-line switches ] [ files ... ]
 

DESCRIPTION

GNU Emacs is a version of Emacs, written by the author of the original (PDP-10) Emacs, Richard Stallman.
The primary documentation of GNU Emacs is in the GNU Emacs Manual, which you can read on line using Info, a subsystem of Emacs. Please look there for complete and up-to-date documentation. This man page is updated only when someone volunteers to do so; the Emacs maintainers' priority goal is to minimize the amount of time this man page takes away from other more useful projects.
The user functionality of GNU Emacs encompasses everything other Emacs editors do, and it is easily extensible since its editing commands are written in Lisp.

Emacs has an extensive interactive help facility, but the facility assumes that you know how to manipulate Emacs windows and buffers. CTRL-h (backspace or CTRL-h) enters the Help facility. Help Tutorial (CTRL-h t) requests an interactive tutorial which can teach beginners the fundamentals of Emacs in a few minutes. Help Apropos (CTRL-h a) helps you find a command given its functionality, Help Character (CTRL-h c) describes a given character's effect, and Help Function (CTRL-h f) describes a given Lisp function specified by name.

Emacs's Undo can undo several steps of modification to your buffers, so it is easy to recover from editing mistakes.

GNU Emacs's many special packages handle mail reading (RMail) and sending (Mail), outline editing (Outline), compiling (Compile), running subshells within Emacs windows (Shell), running a Lisp read-eval-print loop (Lisp-Interaction-Mode), and automated psychotherapy (Doctor).

There is an extensive reference manual, but users of other Emacses should have little trouble adapting even without a copy. Users new to Emacs will be able to use basic features fairly rapidly by studying the tutorial and using the self-documentation features.

Emacs Options

The following options are of general interest:

file
Edit file.
+number
Go to the line specified by number (do not insert a space between the "+" sign and the number).
-q
Do not load an init file.
-u user
Load user's init file.
-t file
Use specified file as the terminal instead of using stdin/stdout. This must be the first argument specified in the command line.

The following options are lisp-oriented (these options are processed in the order encountered):

-f function
Execute the lisp function function.
-l file
Load the lisp code in the file file.

The following options are useful when running Emacs as a batch editor:

-batch
Edit in batch mode. The editor will send messages to stderr. This option must be the first in the argument list. You must use -l and -f options to specify files to execute and functions to call.
-kill
Exit Emacs while in batch mode.

Using Emacs with X

Emacs has been tailored to work well with the X window system. If you run Emacs from under X windows, it will create its own X window to display in. You will probably want to start the editor as a background process so that you can continue using your original window.

Emacs can be started with the following X switches:

-name name
Specifies the name which should be assigned to the initial Emacs window. This controls looking up X resources as well as the window title.
-title name
Specifies the title for the initial X window.
-r
Display the Emacs window in reverse video.
-i
Use the "kitchen sink" bitmap icon when iconifying the Emacs window.
-font font, -fn font
Set the Emacs window's font to that specified by font. You will find the various X fonts in the /usr/lib/X11/fonts directory. Note that Emacs will only accept fixed width fonts. Under the X11 Release 4 font-naming conventions, any font with the value "m" or "c" in the eleventh field of the font name is a fixed width font. Furthermore, fonts whose name are of the form widthxheight are generally fixed width, as is the font fixed. See xlsfonts(1) for more information.

When you specify a font, be sure to put a space between the switch and the font name.

-bw pixels
Set the Emacs window's border width to the number of pixels specified by pixels. Defaults to one pixel on each side of the window.
-ib pixels
Set the window's internal border width to the number of pixels specified by pixels. Defaults to one pixel of padding on each side of the window.

-geometry geometry
Set the Emacs window's width, height, and position as specified. The geometry specification is in the standard X format; see X(1) for more information. The width and height are specified in characters; the default is 80 by 24.

-fg color
On color displays, sets the color of the text.

See the file /usr/lib/X11/rgb.txt for a list of valid color names.

-bg color
On color displays, sets the color of the window's background.
-bd color
On color displays, sets the color of the window's border.
-cr color
On color displays, sets the color of the window's text cursor.
-ms color
On color displays, sets the color of the window's mouse cursor.
-d displayname, -display displayname
Create the Emacs window on the display specified by displayname. Must be the first option specified in the command line.
-nw
Tells Emacs not to use its special interface to X. If you use this switch when invoking Emacs from an xterm(1) window, display is done in that window. This must be the first option specified in the command line.

You can set X default values for your Emacs windows in your .Xresources file (see xrdb(1)). Use the following format:

emacs.keyword:value

where value specifies the default value of keyword. Emacs lets you set default values for the following keywords:

font (class Font)
Sets the window's text font.
reverseVideo (class ReverseVideo)
If reverseVideo's value is set to on, the window will be displayed in reverse video.
bitmapIcon (class BitmapIcon)
If bitmapIcon's value is set to on, the window will iconify into the "kitchen sink."
borderWidth (class BorderWidth)
Sets the window's border width in pixels.
internalBorder (class BorderWidth)
Sets the window's internal border width in pixels.
foreground (class Foreground)
For color displays, sets the window's text color.
background (class Background)
For color displays, sets the window's background color.
borderColor (class BorderColor)
For color displays, sets the color of the window's border.
cursorColor (class Foreground)
For color displays, sets the color of the window's text cursor.
pointerColor (class Foreground)
For color displays, sets the color of the window's mouse cursor.
geometry (class Geometry)
Sets the geometry of the Emacs window (as described above).
title (class Title)
Sets the title of the Emacs window.
iconName (class Title)
Sets the icon name for the Emacs window icon.

If you try to set color values while using a black and white display, the window's characteristics will default as follows: the foreground color will be set to black, the background color will be set to white, the border color will be set to grey, and the text and mouse cursors will be set to black.

Using the Mouse

The following lists the mouse button bindings for the Emacs window under X11.


MOUSE BUTTON                     FUNCTION


left                             Set point.


middle                           Paste text.


right                            Cut text into X cut buffer.


SHIFT-middle                     Cut text into X cut buffer.


SHIFT-right                      Paste text.


CTRL-middle                      Cut text into X cut buffer and kill it.


CTRL-right                       Select this window, then split it into
two windows. Same as typing CTRL-x 2.

CTRL-SHIFT-left                  X buffer menu--hold the buttons and keys
down, wait for menu to appear, select buffer, and release. Move mouse out of menu and release to cancel.

CTRL-SHIFT-middle                X help menu--pop up index card menu for
Emacs help.

CTRL-SHIFT-right                 Select window with mouse, and delete all
other windows. Same as typing CTRL-x 1.

 

MANUALS

You can order printed copies of the GNU Emacs Manual from the Free Software Foundation, which develops GNU software. See the file ORDERS for ordering information.
Your local Emacs maintainer might also have copies available. As with all software and publications from FSF, everyone is permitted to make and distribute copies of the Emacs manual. The TeX source to the manual is also included in the Emacs source distribution.

 

SEE ALSO

X(1), xlsfonts(1), xterm(1), xrdb(1)  

Important: Use the man command (% man) to see how a command is used on your particular computer.

>> Linux/Unix Command Library

>> Shell Command Library

Explore Linux
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Linux

©2009 About.com, a part of The New York Times Company.

All rights reserved.