Entering and Exiting Emacs
**************************

While using Emacs you should be familiar with the following three terms:

Buffer
     A buffer is a region of memory holding characters. It is the basic editing unit; one buffer corresponds to one piece of text being edited. You can have multiple buffers but you can edit only one buffer at any one time. For more information, see Buffers (XEmacs User's Manual).

File
     A file is a region of disk space holding characters. Emacs edits a file by reading it into a buffer, editing that buffer and writing out the buffer back to the file. To save your work permanently you have to write it to a file. So after you load and work with a file, you have to save it back.

Windows
     A window is a rectangular region in which a buffer is displayed. You can open multiple windows with multiple buffers and edit them by selecting the corresponding buffer. Initially, when you start emacs, it will automatically open up a window for you.

Entering Emacs
==============

To enter Emacs type xemacs and press the Return key at the shell i.e. xemacs RET. This will bring up an emacs window with *scratch* as the default buffer because Emacs must always have a buffer to work on. Then choose the Open... option from the File menu on the menubar at the top of the frame. It will prompt you to enter a filename. After you enter the filename, Emacs will read that file into the current buffer. You can also type :

     xemacs <filename> RET

directly which will bring up an Emacs frame with the filename as the buffer.

Emacs Frame
===========

When you run XEmacs under X, a menu bar on top of the Emacs frame provides access to pull-down menus of file, edit, and help-related commands. The menus only provide convenient shortcuts, the options that they provide are available via key commands. You can invoke those commands from the keyboard also. For many of the options, their corresponding key commands are displayed right besides them. The five default menus on the menubar that you will see on the frame are File, Edit, Options, Buffers and Help. See XEmacs Pull-down Menus (XEmacs User's Manual), for detailed information on the functions provided by the pull-down menus.

The Emacs frame has a rectangle shaped box at the extreme right and you can drag it up or down to scroll the window accordingly. Clicking on the arrows also serves the same purpose.

The last line in your window is the Mode line which will give you a description of what's going on in that particular window. See Mode Line, for more information. Below the mode line is the Echo area. Emacs uses this area to interact with the user. See Echo Area.

If you wish to open another file in a new window after you enter XEmacs, select Open in New Frame... from the File menu, which will prompt you for a filename and open a new window with that filename as the current buffer. If you want to open a new file in the same window, select Open.. from the File menu. You need to enter XEmacs only once, you can edit multiple files by opening several other frames or by switching between buffers.

Exiting Emacs
=============

There are two commands for exiting Emacs, one for suspending Emacs and the other for killing Emacs. Suspending means stopping Emacs temporarily and returning control to the shell, allowing you to resume editing later in the same Emacs job, with the same files, same kill ring, same undo history, and so on.  This is the usual way to exit.  Killing Emacs means destroying the Emacs job.  You can run Emacs again later, but you will get a fresh Emacs; there is no way to resume the same editing session after it has been killed.

C-z
     Suspend Emacs (suspend-emacs).  If used under the X window system, this command will shrink the X window containing the Emacs frame to an icon. Clicking on the icon will resume that Emacs process again. See Exiting Emacs (XEmacs User's Manual).

C-x C-c
     Kill Emacs (save-buffers-kill-emacs). You can also select Exit Emacs option from the File menu to kill that Emacs process. If you haven't saved the file, Emacs will ask you if you wish to save the file before killing that process.

The Mode Line
=============

When you enter XEmacs, each text window's last line is a mode line which describes what is going on in that window. Normally, the mode line looks like :

     --CH-XEmacs: BUF     (MAJOR MINOR)----POS------

This gives information about the buffer being displayed in the window: the buffer's name, what major and minor modes are in use, whether the buffer's text has been changed, and how far down the buffer you are currently looking.

The CH contains :

**
     if the text in the buffer has been edited

--
     if the text in the buffer has not been edited

%%
     if the buffer is a read-only-buffer i.e. it cannot be edited

BUF is the name of the window's chosen buffer. If you are editing a file (which is the selected buffer), the file name appears in BUF.  See Buffers (XEmacs User's Manual).

POS contains :

All
     if your entire file is visible on the screen.

Top
     if you are looking at the beginning of the file.

Bot
     if you are looking at the end of the file.

NN%
     NN will be a number corresponding to the percentage of the file above the top of the screen, for example 52, which means that 52% of the file is above the top of the screen.

MAJOR is the name of the major mode in effect in the buffer.  At any time, each buffer is in one and only one major mode. The available major modes include Fundamental mode (the least specialized), Text mode, Lisp mode, and C mode.  See Major Modes (XEmacs User's Manual), for details on how the modes differ and how you select one.

MINOR is a list of some of the minor modes that are turned on in the window's chosen buffer.  For example, Fill means that Auto Fill mode is on which means that lines are broken automatically when they become too wide. See Minor Modes (XEmacs User's Manual), for more information on various minor modes and how to enable them.

You can also display time in the mode line. See The Mode Line (XEmacs User's Manual), for more information regarding the mode line.

The Echo Area
=============

The line at the bottom of the frame (below the mode line) is the echo area.  Emacs uses this area to communicate with you:

  * The echo area will print out the characters that you type. For example, if you choose the Open... option from the File menu you might get the following in the echo area:

          Find file: /usr/lib/x11/

     Now you need to give a file name to open, for example if the file name is myfile, you will type myfile after /usr/lib/x11/ and press the Return key. If you pause for more than a second while typing, you will see the characters that you type in the echo area.

  * The echo area also prints error messages. For example, if you misspell usr and type /urs/lib/x11/myfile RETURN in the above example you might get an error message. Since Emacs will not be able to find the /urs directory, the echo area will say:

          error--> Opening directory: no such file or directory, /urs/lib/x11/myfile

     This error message will be accompanied by a beep. Some XEmacs commands will print informative messages in the echo area. See The Echo Area (XEmacs User's Manual), for more information on the echo area.