| |
Editing With EmacsEmacs is a screen editor in the public domain. It is usable with virtually any type of keyboard because it depends exclusively on control sequences as editing commands, and therefore needs no special function or editing keys. Emacs also allows you a great deal of flexibility in customizing your editing sessions to your own needs, binding control sequences to keys, and so forth. It includes a number of modes as well, each useful for a different language or function. Currently, UMBC is offering emacs in version 20.4.1, with several extensions originating locally. Every effort has been made to maintain a consistent interface across the wide variety of machines at UMBC; however, in view of hardware and software limitations, some systems are lacking certain emacs functions. Nevertheless, the features common to all systems should make emacs a powerful and valuable tool to Unix users. Getting StartedTo get started in emacs, you should follow its built-in tutorial, which covers all the fundamental emacs operations and points you toward help in learning advanced features. Invoke the editor by entering emacs at the system prompt. To access the tutorial, type the sequence <CTRL/h t>. This is a standard control sequence, followed by the character t. (Note that emacs uses C-h to depict the sequence in its associated documentation, and continues this format throughout. Therefore, in regard to emacs usage only, control sequences and similar notations will be shown in this alternative form in subsequent references.) You may go through the tutorial interactively, you may save your tutorial session in a file for subsequent printing, or you may do both. In order to save the file, however, you must make at least one change, such as inserting a blank space or a blank line. Then type C-x C-c. You will be asked if you wish to save the file. Respond y and the file TUTORIAL will be written to your default directory. Some Special Things To NoteThe tutorial often refers to a meta key, or to a key labeled edit. If you are using an SGI workstation, the alt key functions as meta. Note that while esc appears on different places on different hardware, C-[ is always equivalent to esc and can be used in its place. Therefore, esc-a gives the same result as C-[ a. Also, note that holding down esc can cause emacs to send multiple escape characters, and thus go into a special mode. To abort this, enter C-g. In general, C-g is a very useful command to know, since the many possibilities that emacs offers can be confusing, and C-g will always bail you out of trouble. There is an internal design conflict between emacs and certain systems with regard to the C-s and C-q sequences. All computers use C-s and C-q for flow control, to freeze and unfreeze the screen. Unfortunately, emacs uses C-s for the isearch-forward (incremental search) function, which conflicts with the hardware's operation. If you type C-s and your screen freezes, then your system is interpreting this sequence as a terminal control signal. To unfreeze the screen, type C-q. All of the emacs programs at UMBC have been modified so that C-\ performs C-s and C-^ performs C-q. As a result, any time you need to use C-s in emacs, you can type C-\ instead. This is also true for C-q. Type C-^ instead, provided, that is, that your keyboard is capable of C-^. If it isn't, you will have to use the extended command facility within emacs to perform commands that are bound to C-q. Fortunately, C-q is a rarely used command, so this is only a minor problem at worst. Finally, be sure to remember that under Unix, only one version of a file with a given name can exist in the same directory. Thus if you edit an existing file and write it to disk, the older version of the file will be deleted. If you believe you may need both, it is safest to copy the old file under another name before invoking the editor. Getting HelpAll of the on-line emacs help functions begin with the sequence C-h. Some of the help features (and their associated keystrokes) are:
To leave help and resume your editing, the command is C-G. Comprehensive emacs documentation is available in the OIT technical library. Inquire at Print Dispatch, ECS 019. Some Essential KeystrokesSee the end of this chapter for access to the the emacs Reference Card, a summary of emacs commands and their functions. Below is a subset of some of the most frequently used functions.
Recovering From A System CrashShould you be in the midst of an editing session when a system crash occurs, emacs provides a means of recovering the work you had been doing. Invoke the editor, and then use the meta-x command followed by the name of the file you had been editing when the crash occurred. To illustrate, if you are editing markets at the time of a system failure, at your next login type emacs, and once inside the editor, enter meta-x markets to have your edited file restored. Xemacs---A Version for X-WindowsXemacs is a version of emacs designed for X-Windows. It provides the functionality of emacs with the ease of use of pull-down menus. Regular emacs will also run in an X-Window. Emacs Reference CardUse the URL http://www.geek-girl.com/emacs/refcard.html for access to the emacs Reference Card, a summary of useful emacs commands and their functions. Once you have experience with the on-line tutorial, this information should serve as a ready reference for future use. Other useful URLS for emacs are at |