The key is to just pretend "what I don't know won't hurt me" and use what you find useful. The more you use it, the more you'll learn. Emacs has a very extensive help system, so it's possible to learn as you go.
For the purposes of this class, you shouldn't have to learn too much about it, and I recommend you don't spend too much time trying to figure out the intricacies of emacs -- if you need to know something and can't figure it out quickly, ask.
For those who want to become emacs gurus, a good place to start is the O'Reilly book "Learning GNU Emacs", which should be available at the bookstore.
If Alt has not been so configured, the Escape key can be used instead, by punching it before the modified key. For example, instead of typing M-x, one can type Esc, release the key, and then type x.
Lots of emacs functions take two keystrokes to complete. For example, to exit emacs, use C-x C-c (Control-X followed by Control-C).
After logging onto an instructional unix server, you run emacs by simply typing the following into an xterm:
emacs &
Figure 1 A small emacs window
The minibuffer is a small buffer which emacs uses to report error conditions to you, and to prompt you for information when necessary.
The cursor indicates where your text will appear when you type. You can reposition it using the mouse.
Buffers are the basic unit in emacs. Each file you edit has its own buffer. There can also be buffers for other purposes -- for example the minibuffer is used for emacs-user interactions; you can have a buffer in which you're running a Minischeme or Lisp interpreter; etc. At any given time, your emacs session will have multiple buffers around, although only a few may be visible at a given time.
Each buffer has an associated mode with it which controls the behavior of everything you do in it. For example, if you edit a file with the .ml extension, emacs will realize that this is an ML file, and will put you in SML mode, which knows how ML programs should be indented. Similarly, if you open a .c file, or a .cl file, its buffer will be in C-mode or Common Lisp mode, respectively, and know the syntax of that language. In addition to the indentation rules changing based on the buffer's mode, Control-key sequences may have different actions, additional pull-down menus will typically be added, and different sorts of syntax checks will be done for you (like balancing parenthesis in Lisp).
The *scratch* buffer is just that -- scratch space for you to type anything you want without associating a file with it.
The other thing you'll want to know is how to exit. Use C-x C-c. Lisp will prompt you if you haven't saved all of your buffers, or if you've left any processes (like a Lisp or ML interpreter) running.
To save a file, use C-x C-s. If there have been any changes, the file will be written to disk. To save it under a different filename, use C-x C-w (write file). You'll be prompted for a new name, and the buffer will be renamed (although the original file will still exist on disk).
To move forward or back word-by-word, use M-f and M-b. Note that Meta is acting as an intensifier: this is also works with a number of other commands such a backspace or delete. Speaking of delete, the key for it is C-d; on most systems the Delete key does the same thing as backspace.
To jump to the beginning of a screen line use C-a (First letter in the alphabet). To jump to the end of the line, use C-e.
To move more quickly, use C-v to move down a screenful, and M-v to move up a screenful. Use C-< to move to the beginning of a buffer and C-> to move to the end.
Otherwise, you have to mark the region by moving to one end of it and hitting C-SPACE. Emacs will respond with "Mark set". Then move to the other end and do whatever operation you want. This is pretty important: emacs always has a notion of where the last mark was set. The area between the mark and the point (or cursor) is known as a region. Thus, it always has a notion of the current region: namely, everything between "the mark" and your cursor. This can be a problem if you accidentally hit "delete" for example, because half of your file will disappear without you understanding why. Thank goodness for undo. (read on...)
To cut a region, mark it and type C-w. Pasting is done using C-y (yank). To copy a region instead of cutting it, use M-w.
Another way to cut text in emacs is to use C-k (kill). This takes out the text between the cursor and the end of the line. If there is no text, then it takes out the linefeed and moves the next line up. Lines that you kill accumulate and can be yanked. Hence another way to cut and paste a few lines is to C-k a few times to kill the lines you want to cut, move to where you want to put the just-killed lines, and then yank (C-y).
Emacs has infinite undo. Invoke it with C-/ (on some systems you have to use C-x u instead). Emacs keeps track of all changes made to a buffer since it was opened, so if you mess up you can almost always undo until things get back to a safe state.
When you start emacs up, you'll typically only see one buffer and the minibuffer. You can view multiple buffers at once, however, and this can be useful for viewing multiple files simultaneously. C-x 2 will divide a buffer window in half vertically giving you two buffers, each with their own status bar (note that you don't hold down Control while typing 2 here). Move between the buffers using C-x C-o or the mouse. Similarly, you can cut a buffer horizontally using C-x 3.
To hide the buffer your cursor's in, use C-x 0. Or to make the buffer your cursor's in fill up the whole window again, use C-x 1.
To view all the buffers in an emacs session, use C-x C-b. To switch to a different buffer, use C-x b and emacs will prompt you for its name.
Normally when you are not viewing a buffer, it's still there though it's not visible. To really drop one from your emacs session, use C-x k and supply the name. If it's modified, emacs will check with you before killing it. This can be useful if you need to get rid of a bunch of changes to a file.
You'll notice that emacs uses buffers to report information to you. These are typically surrounded with *'s to show that they don't have files associated with them. An example is the previously mentioned scratch buffer (*scratch*). You can switch between them or kill them just like any other buffer.
You can also call functions that are unbound by using M-x. This allows you to type the name of the function, which will then be executed. For example, C-v is bound to the "scroll-up" function. You could therefore also scroll up using M-x scroll-up.
To replace all occurrences of a string in a buffer, use M-x replace-string. To replace some instances of a string, use M-x query-replace and you'll be prompted at every location of the string.