Start up Emacs by typing 'emacs' at your shell prompt. Emacs is an editor, but it is also a customizable program development environment. Many people do all their work from Emacs, including filesystem traversal, editing, reading and composing mail and news, debugging, surfing the Web, etc. Emacs can be started either of two modes: a window mode or a non-window mode. You can force Emacs to start up in the non-window mode by giving the command:
emacs -nwIn the non-window mode, the editor opens up in the same window from which the 'emacs' command is given. In the window mode, a separate window opens up with Emacs. Of course, Emacs does not interpret your mouse clicks in the non-window mode. You can start Emacs in the window mode by the command:
emacsor better yet
emacs &which creates a new process to run Emacs, permitting you to type commands in the old window while Emacs is running.
For starting Emacs in the window mode, it is essential that the environment variable DISPLAY is set correctly. Normally DISPLAY is set correctly if you are using Emacs from the same machine on which you logged in. However if you've logged in to a different machine (e.g. you log in to a Solaris machine by using the rlogin command) then your DISPLAY won't be set. In this case even the command 'emacs' would start Emacs in the non-Window mode. For example suppose you are on the machine 'foobar' which is not a Solaris machine and you log in to the machine 'verm' for using Java. Then to set your DISPLAY on verm correctly, give the following series of commands:
foobar%xhost +verm #this will allow verm to use foobar's screen
foobar%rlogin verm #login to verm
verm%setenv DISPLAY foobar:0 #set the DISPLAY from verm
If you have problems with this protocol, ask the labbies for help.
Emacs manages a collection of buffers, some of which are visible on the screen and some which may be hidden. A buffer is the object holding the text from a file or some other information, such as interaction with a program being run from Emacs. The blank line below the reverse-video status line is called the echo area (when Emacs uses it to display messages) or the minibuffer (when you use it for specifying complex commands). Most Emacs commands have a long form starting with M-x and a short keystroke sequence (a keyboard accelerator). For instance, you can edit a file in its own buffer by doing any of:
- M-x find-file RET:
- Type M-x, then type "find-file", then finally press the return key
- C-x C-f:
- C-x is control-x: hold down the control key, press and release x, let up on the control key
- using Menu:
- select the "Open File..." item from the "Files" pull-down menu, then type the filename and press
the return key
M-x is the Meta-x keystroke, which you type by holding down the Meta key (the diamond next to the space bar), pressing and releasing x, then letting up on the Meta key. On some machines lacking a Meta key, the Alt key works as a Meta key. If you don't have an Alt key (or it doesn't work as a Meta key), then you can type ESC x instead (press and release the escape key, then press and release x) of M-x.
The universal quit command in Emacs is C-g; it almost always aborts the current command. Frequently, pressing ESC three times will also abort the current comment and/or quit the current mode.
Emacs is extensively documented; it is very easy to get help or to learn more about it. The keystroke C-h invokes help in Emacs; you follow it by another key to indicate what kind of help you want. To learn more about what sorts of things you can type after the first C-h, type a second one: C-h C-h. Some particularly useful help keystrokes are:
- C-h t
- run an Emacs tutorial
- C-h i
- invoke the Info documentation system
- C-h m
- get documentation on the current mode (such as C++ mode)
- C-h a
- get a list of commands relating to a word you type ("apropos")
Of course, you can just use the pull-down menus if you prefer; most of Emacs's functionality is available from them. The place to start looking for help is on the ``Help'' menu.
The tutorials directory, ~comp212/tutorials/01/, contains a copy of the quick reference card for Emacs, emacs-19.34-refcard.ps.
You might want to learn about multiple windows in Emacs, switching among windows and buffers, incremental searching, marking regions, the Dired directory editor, indenting C/C++ code, spell-checking, Emacs's command and filename completion facilities, and command shells within Emacs.
Info is an on-line documentation browsing system which contains documentation for many of the tools used in Comp 212. When you have a question about how to use a program or what its output means, consider using Info to find the answer.
You can invoke Info from within Emacs by typing C-h i or M-x info. You are presented with a menu of more than a dozen different manuals which you may browse. You're best off typing ``h'' in order to get a primer for first-time users of Info. You can use the mouse (middle button) to select bold-faced items, or you can use keystrokes to navigate the hypertext documentation.
You can type q to quit viewing the Info buffer; or use ordinary Emacs buffer manipulation commands (such as C-x b, M-x switch-to-buffer, or the ``Buffers'' menu).