Mercurial > emacs
comparison man/entering.texi @ 70359:a946a9fb6f9e
Many simplifications.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 03 May 2006 23:22:14 +0000 |
parents | dc2d5a6655a3 |
children | b327bddebef6 146cd8369025 |
comparison
equal
deleted
inserted
replaced
70358:41a116d81353 | 70359:a946a9fb6f9e |
---|---|
6 @chapter Entering and Exiting Emacs | 6 @chapter Entering and Exiting Emacs |
7 @cindex entering Emacs | 7 @cindex entering Emacs |
8 @cindex starting Emacs | 8 @cindex starting Emacs |
9 | 9 |
10 The usual way to invoke Emacs is with the shell command | 10 The usual way to invoke Emacs is with the shell command |
11 @command{emacs}. Emacs clears the screen and then displays an initial | 11 @command{emacs}. Emacs clears the screen, then displays an initial |
12 help message and copyright notice. Some operating systems discard all | 12 help message and copyright notice. Some operating systems discard |
13 type-ahead when Emacs starts up; they give Emacs no way to prevent | 13 your type-ahead when Emacs starts up; they give Emacs no way to |
14 this. If you ever use those systems, learn the habit of waiting for | 14 prevent this. On those systems, wait for Emacs to clear the screen |
15 Emacs to clear the screen before typing your first editing command. | 15 before you start typing. |
16 | 16 |
17 If you run Emacs from a shell window under the X Window System, run it | 17 From a shell window under the X Window System, run Emacs in the |
18 in the background with @command{emacs&}. This way, Emacs does not tie up | 18 background with @command{emacs&}. This way, Emacs won't tie up the |
19 the shell window, so you can use that to run other shell commands while | 19 shell window, so you can use it to run other shell commands while |
20 Emacs operates its own X windows. You can begin typing Emacs commands | 20 Emacs is running. You can type Emacs commands as soon as you direct |
21 as soon as you direct your keyboard input to the Emacs frame. | 21 your keyboard input to an Emacs frame. |
22 | 22 |
23 @vindex initial-major-mode | 23 @vindex initial-major-mode |
24 When Emacs starts up, it creates a buffer named @samp{*scratch*}. | 24 When Emacs starts up, it creates a buffer named @samp{*scratch*}. |
25 That's the buffer you start out in. The @samp{*scratch*} buffer uses | 25 That's the buffer you start out in. The @samp{*scratch*} buffer uses |
26 Lisp Interaction mode; you can use it to type Lisp expressions and | 26 Lisp Interaction mode; you can use it to type Lisp expressions and |
27 evaluate them, or you can ignore that capability and just write notes | 27 evaluate them. You can also ignore that capability and just write notes |
28 in it. (You can specify a different major mode for this buffer by | 28 there. You can specify a different major mode for this buffer by |
29 setting the variable @code{initial-major-mode} in your init file. | 29 setting the variable @code{initial-major-mode} in your init file. |
30 @xref{Init File}.) | 30 @xref{Init File}. |
31 | 31 |
32 It is possible to specify files to be visited, Lisp files to be | 32 It is possible to specify files to be visited, Lisp files to be |
33 loaded, and functions to be called, by giving Emacs arguments in the | 33 loaded, and functions to be called through Emacs command-line |
34 shell command line. @xref{Emacs Invocation}. But we don't recommend | 34 arguments. @xref{Emacs Invocation}. The feature exists mainly for |
35 doing this. The feature exists mainly for compatibility with other | 35 compatibility with other editors, and for scripts. |
36 editors. | |
37 | 36 |
38 Many other editors are designed to be started afresh each time you | 37 Many editors are designed to edit one file. When done with that |
39 want to edit. You edit one file and then exit the editor. The next | 38 file, you exit the editor. The next time you want to edit a file, you |
40 time you want to edit either another file or the same one, you must run | 39 must start the editor again. Working this way, it is convenient to |
41 the editor again. With these editors, it makes sense to use a | 40 use a command-line argument to say which file to edit. |
42 command-line argument to say which file to edit. | |
43 | 41 |
44 But starting a new Emacs each time you want to edit a different file | 42 It's not smart to start Emacs afresh for every file you edit. Emacs |
45 does not make sense. This would fail to take advantage of Emacs's | 43 can visit more than one file in a single editing session, and upon |
46 ability to visit more than one file in a single editing session, and | 44 exit Emacs loses valuable accumulated context, such as the kill ring, |
47 it would lose the other accumulated context, such as the kill ring, | 45 registers, undo history, and mark ring. These features are useful for |
48 registers, undo history, and mark ring, that are useful for operating | 46 operating on multiple files, or even one. If you kill Emacs after |
49 on multiple files or even one. | 47 each file, you don't take advantage of them. |
50 | 48 |
51 The recommended way to use GNU Emacs is to start it only once, just | 49 The recommended way to use GNU Emacs is to start it only once, just |
52 after you log in, and do all your editing in the same Emacs session. | 50 after you log in, and do all your editing in the same Emacs session. |
53 Each time you want to edit a different file, you visit it with the | 51 Each time you edit a file, you visit it with the existing Emacs, which |
54 existing Emacs, which eventually comes to have many files in it ready | 52 eventually has many files in it ready for editing. Usually you do not |
55 for editing. Usually you do not kill the Emacs until you are about to | 53 kill Emacs until you are about to log out. @xref{Files}, for more |
56 log out. @xref{Files}, for more information on visiting more than one | 54 information on visiting more than one file. |
57 file. | |
58 | 55 |
59 If you want to edit a file from another program and already have | 56 To edit a file from another program while Emacs is running, you can |
60 Emacs running, you can use the @command{emacsclient} program to open a | 57 use the @command{emacsclient} helper program to open a file in the |
61 file in the already running Emacs. @xref{Emacs Server}, for more | 58 already running Emacs. @xref{Emacs Server}. |
62 information on editing files with Emacs from other programs. | |
63 | 59 |
64 @ifnottex | 60 @ifnottex |
65 @raisesections | 61 @raisesections |
66 @end ifnottex | 62 @end ifnottex |
67 | 63 |
71 @cindex killing Emacs | 67 @cindex killing Emacs |
72 @cindex suspending | 68 @cindex suspending |
73 @cindex leaving Emacs | 69 @cindex leaving Emacs |
74 @cindex quitting Emacs | 70 @cindex quitting Emacs |
75 | 71 |
76 There are two commands for exiting Emacs because there are three | 72 There are two commands for exiting Emacs, and three kinds of exiting: |
77 kinds of exiting: @dfn{suspending} Emacs, @dfn{Iconifying} Emacs, and | 73 @dfn{suspending} Emacs, @dfn{Iconifying} Emacs, and @dfn{killing} |
78 @dfn{killing} Emacs. | 74 Emacs. |
79 | 75 |
80 @dfn{Suspending} means stopping Emacs temporarily and returning | 76 @dfn{Suspending} means stopping Emacs temporarily and returning |
81 control to its parent process (usually a shell), allowing you to resume | 77 control to its parent process (usually a shell), allowing you to resume |
82 editing later in the same Emacs job, with the same buffers, same kill | 78 editing later in the same Emacs job, with the same buffers, same kill |
83 ring, same undo history, and so on. This is the usual way to exit Emacs | 79 ring, same undo history, and so on. This is the usual way to exit Emacs |
108 | 104 |
109 Suspending Emacs takes you back to the shell from which you invoked | 105 Suspending Emacs takes you back to the shell from which you invoked |
110 Emacs. You can resume Emacs with the shell command @command{%emacs} | 106 Emacs. You can resume Emacs with the shell command @command{%emacs} |
111 in most common shells. On systems that don't support suspending | 107 in most common shells. On systems that don't support suspending |
112 programs, @kbd{C-z} starts an inferior shell that communicates | 108 programs, @kbd{C-z} starts an inferior shell that communicates |
113 directly with the terminal, and Emacs waits until you exit the subshell. | 109 directly with the terminal, and Emacs waits until you exit the |
114 (The way to do that is probably with @kbd{C-d} or @command{exit}, but | 110 subshell. (The way to do that is probably with @kbd{C-d} or |
115 it depends on which shell you use.) The only way on these systems to | 111 @command{exit}, but it depends on which shell you use.) On these |
116 get back to the shell from which Emacs was run (to log out, for | 112 systems, you can only get back to the shell from which Emacs was run |
117 example) is to kill Emacs. | 113 (to log out, for example) when you kill Emacs. |
118 | 114 |
119 Suspending can fail if you run Emacs under a shell that doesn't | 115 Suspending can fail if you run Emacs under a shell that doesn't |
120 support suspending programs, even if the system itself does support | 116 support suspending programs, even if the system itself does support |
121 it. In such a case, you can set the variable @code{cannot-suspend} to | 117 it. In such a case, you can set the variable @code{cannot-suspend} to |
122 a non-@code{nil} value to force @kbd{C-z} to start an inferior shell. | 118 a non-@code{nil} value to force @kbd{C-z} to start an inferior shell. |
131 a shell window. | 127 a shell window. |
132 | 128 |
133 @kindex C-x C-c | 129 @kindex C-x C-c |
134 @findex save-buffers-kill-emacs | 130 @findex save-buffers-kill-emacs |
135 To exit and kill Emacs, type @kbd{C-x C-c} | 131 To exit and kill Emacs, type @kbd{C-x C-c} |
136 (@code{save-buffers-kill-emacs}). A two-character key is used for | 132 (@code{save-buffers-kill-emacs}). A two-character key is used to make |
137 this to make it harder to type by accident. This command first offers | 133 it harder to type by accident. This command first offers to save any |
138 to save any modified file-visiting buffers. If you do not save them | 134 modified file-visiting buffers. If you do not save them all, it asks |
139 all, it asks for reconfirmation with @kbd{yes} before killing Emacs, | 135 for confirmation with @kbd{yes} before killing Emacs, since any |
140 since any changes not saved will be lost forever. Also, if any | 136 changes not saved now will be lost forever. Also, if any subprocesses are |
141 subprocesses are still running, @kbd{C-x C-c} asks for confirmation | 137 still running, @kbd{C-x C-c} asks for confirmation about them, since |
142 about them, since killing Emacs will also kill the subprocesses. | 138 killing Emacs will also kill the subprocesses. |
143 | 139 |
144 @vindex confirm-kill-emacs | 140 @vindex confirm-kill-emacs |
145 If the value of the variable @code{confirm-kill-emacs} is | 141 If the value of the variable @code{confirm-kill-emacs} is |
146 non-@code{nil}, @kbd{C-x C-c} assumes that its value is a predicate | 142 non-@code{nil}, @kbd{C-x C-c} assumes that its value is a predicate |
147 function, and calls that function. If the result is non-@code{nil}, the | 143 function, and calls that function. If the result is non-@code{nil}, the |
148 session is killed, otherwise Emacs continues to run. One convenient | 144 session is killed, otherwise Emacs continues to run. One convenient |
149 function to use as the value of @code{confirm-kill-emacs} is the | 145 function to use as the value of @code{confirm-kill-emacs} is the |
150 function @code{yes-or-no-p}. The default value of | 146 function @code{yes-or-no-p}. The default value of |
151 @code{confirm-kill-emacs} is @code{nil}. | 147 @code{confirm-kill-emacs} is @code{nil}. |
152 | 148 |
153 There is no way to resume an Emacs session once you have killed it. | 149 You can't resume an Emacs session after killing it. Emacs can, |
154 You can, however, arrange for Emacs to record certain session | 150 however, record certain session information when you kill it, such as |
155 information when you kill it, such as which files are visited, so that | 151 which files you visited, so the next time you start Emacs it will try |
156 the next time you start Emacs it will try to visit the same files and | 152 to visit the same files. @xref{Saving Emacs Sessions}. |
157 so on. @xref{Saving Emacs Sessions}. | |
158 | 153 |
159 The operating system usually listens for certain special characters | 154 The operating system usually listens for certain special characters |
160 whose meaning is to kill or suspend the program you are running. | 155 whose meaning is to kill or suspend the program you are running. |
161 @b{This operating system feature is turned off while you are in Emacs.} | 156 @b{This operating system feature is turned off while you are in Emacs.} |
162 The meanings of @kbd{C-z} and @kbd{C-x C-c} as keys in Emacs were | 157 The meanings of @kbd{C-z} and @kbd{C-x C-c} as keys in Emacs were |