1.7.4 How Emacs Chooses a Default Directory
When you use any command that asks for a filename (such as C-x C-f), Emacs displays a default directory in the minibuffer and asks you to type the rest of the filename. How does Emacs choose the default directory? The default directory is taken from the buffer that the cursor is currently in. If you are editing a file in your home directory when you type C-x C-f, Emacs assumes you want to edit another file in your home directory. If you are editing the file /sources/macros/html.macs then Emacs makes the default directory /sources/macros . If you want to find a file in another directory, edit the default directory that Emacs displays.
To save the file you are editing, type C-x C-s. Emacs writes the file. To let you know that the file was saved, it puts the message Wrote filename in the minibuffer. If you haven't made any changes to the file, Emacs puts the message No changes need to be saved
in the minibuffer. You can also get to this option by pressing the diskette on the toolbar or choosing Save (current buffer) from the File menu.
If you decide to save something you've typed in the *scratch*
buffer by typing C-x C-s, Emacs asks you for a filename. After you give it a filename, Emacs changes the mode line accordingly.
A related command is write-file( C-x C-w). It is the Emacs equivalent of the Save As option found on many applications' File menus. The write-filecommand asks you to type a new filename in the minibuffer. However, if you just press Enterinstead of typing a new filename, write-filesaves the file with its old name—just as C-x C-swould have done. (It does ask if you want to replace the current file with the one in this buffer, however.)
The write-filecommand is useful for editing files that you do not have permission to change. Use the find-filecommand to get the file you want into a buffer, and then use write-fileto create your own private version, with a different name or path. This maneuver allows you to copy the file to one that you own and can change. Of course, the original file is not affected.
To quit Emacs, type C-x C-cor close it like you would any other application. If you have made changes to a buffer, Emacs asks you if you want to save them. [9]If you type y, Emacs writes the file, then exits. If you type n, Emacs asks you to confirm that you want to abandon the changes you made by typing yesor noin full. If you type no, your normal Emacs session continues just as if you never attempted to exit. If you type yes, you exit Emacs and the changes you made during this session do not become permanent. Leaving without saving changes can be useful if you make changes you didn't intend to make.
By the way, Emacs is picky about whether you type yor yes. Sometimes it wants one, sometimes the other. If it asks for a y, you can sometimes get away with typing yesbut not vice versa. If it beeps and displays, Please answer yes or no
, you didn't enter the whole word and it wants you to.
Emacs has extensive online help, which is discussed further in Chapter 14 Chapter 14. The Help System Emacs has the most comprehensive help facility of any text editor—and one of the best such facilities of any program at all. In fact, the Emacs help facilities probably cut down the time it took for us to write this book by an order of magnitude, and they can help you immeasurably in your ongoing quest to learn more about Emacs. In this chapter, we describe Emacs help in the following areas: • The tutorial. • The help key ( C-h ) and Help menu, which allow you to get help on a wide variety of topics. • The help facilities of complex commands like query-replace and dired . • Navigating Emacs manuals and using the info documentation reader. • Completion , in which Emacs helps you finish typing names of functions, variables, filenames, and more. Completion not only saves you time and helps you complete names of functions you know about but can help you discover new commands and variables.
. You can enter help through the lifesaver icon on the toolbar or through the Help menu. Either method will show you a help menu, described later in this section. To enter help using the keyboard, press C-h. Pressing C-h ?gives you a list of options. Pressing C-h tstarts a tutorial that is an excellent introduction to Emacs.
To get information about the meaning of a keystroke combination, press C-h kfor describe-key. For example, if you type C-h k C-x i, Emacs displays a description of the insert-filecommand, which is bound to C-x i. Pressing C-h f(for describe-function) asks Emacs to describe a function (really just a command name, such as find-file). Essentially, C-h kand C-h fgive you the same information; the difference is that with C-h k, you press a key whereas with C-h f, you type a command name.
Assume you want to find out about what C-x idoes.
Type: C-h k

Asking for help about a keyboard command.
Type: C-x i

Emacs splits the screen to display help.
A few things to notice: the window is now split into two parts because you're looking at two separate buffers. Each buffer has its own mode line. The lower buffer is the *Help*
buffer; it contains the information about the insert-filecommand. Emacs keeps the cursor in the dickens
buffer because there's no good reason for you to edit the *Help*
buffer.
You might also notice that in the text describing this command, Emacs calls the cursor point . This term is used throughout Emacs to refer to the cursor; you're bound to encounter it.
To make the *Help*
buffer disappear, press C-x 1(we cover this command in Chapter 4).
You can also use the Help menu to access help commands quickly, and you can get there either through the menu or through the lifesaver on the toolbar. On this menu, you find options we've discussed here: Emacs Tutorial, Describe → Describe Key, and Describe → Describe Function. It includes a host of interesting options, including access to the Emacs frequently asked questions (FAQ) file, a new search feature, and even an Emacs psychiatrist (you might tell it something like "Emacs is driving me over the edge today"). There's an interface to Info, Emacs's online documentation. Simply choose Read the Emacs Manual to start Info.
In this section, we've given a very brief introduction to a few of the paths you can take in the help system. There are many more help facilities; they are described thoroughly in Chapter 14 Chapter 14. The Help System Emacs has the most comprehensive help facility of any text editor—and one of the best such facilities of any program at all. In fact, the Emacs help facilities probably cut down the time it took for us to write this book by an order of magnitude, and they can help you immeasurably in your ongoing quest to learn more about Emacs. In this chapter, we describe Emacs help in the following areas: • The tutorial. • The help key ( C-h ) and Help menu, which allow you to get help on a wide variety of topics. • The help facilities of complex commands like query-replace and dired . • Navigating Emacs manuals and using the info documentation reader. • Completion , in which Emacs helps you finish typing names of functions, variables, filenames, and more. Completion not only saves you time and helps you complete names of functions you know about but can help you discover new commands and variables.
. The help features we've described here should be enough to get you started; if you want to learn more, jump ahead to Chapter 14 Chapter 14. The Help System Emacs has the most comprehensive help facility of any text editor—and one of the best such facilities of any program at all. In fact, the Emacs help facilities probably cut down the time it took for us to write this book by an order of magnitude, and they can help you immeasurably in your ongoing quest to learn more about Emacs. In this chapter, we describe Emacs help in the following areas: • The tutorial. • The help key ( C-h ) and Help menu, which allow you to get help on a wide variety of topics. • The help facilities of complex commands like query-replace and dired . • Navigating Emacs manuals and using the info documentation reader. • Completion , in which Emacs helps you finish typing names of functions, variables, filenames, and more. Completion not only saves you time and helps you complete names of functions you know about but can help you discover new commands and variables.
.
Читать дальше