Merge from emacs--rel--22
[bpt/emacs.git] / doc / emacs / entering.texi
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 2001, 2002, 2003,
3 @c 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @iftex
6 @chapter Entering and Exiting Emacs
7
8 This chapter explains how to enter Emacs, and how to exit it.
9 @end iftex
10
11 @ifnottex
12 @raisesections
13 @end ifnottex
14
15 @node Entering Emacs, Exiting, Commands, Top
16 @section Entering Emacs
17 @cindex entering Emacs
18 @cindex starting Emacs
19
20 The usual way to invoke Emacs is with the shell command
21 @command{emacs}. From a terminal window running in the X Window
22 System, you can also run Emacs in the background with
23 @command{emacs&}; this way, Emacs won't tie up the terminal window, so
24 you can use it to run other shell commands.
25
26 @cindex startup screen
27 When Emacs starts up, the initial frame displays a special buffer
28 named @samp{*GNU Emacs*}. This buffer contains @dfn{links} to common
29 tasks that might be useful to beginning users. For instance,
30 activating the @samp{Emacs Tutorial} link opens the Emacs tutorial;
31 this does the same thing as the command @kbd{C-h t}
32 (@code{help-with-tutorial}). To activate a link, either move point
33 onto it and type @kbd{@key{RET}}, or click on it with @kbd{mouse-1}
34 (the left mouse button).
35
36 Using a command line argument, you can tell Emacs to visit one or
37 more specific files as soon as it starts up. For example,
38 @command{emacs foo.txt} starts Emacs with a buffer displaying the
39 contents of the file @samp{foo.txt}. This feature exists mainly for
40 compatibility with other editors, which are designed to edit one file
41 at a time: once you are done with that file, you exit the editor, and
42 start it again the next time you need it.
43
44 Using Emacs in this way---starting it afresh each time you want to
45 edit a file---is unnecessary and wasteful. Emacs can visit more than
46 one file in a single editing session, and exiting the Emacs session
47 loses valuable accumulated context, such as the kill ring, registers,
48 undo history, and mark ring. These features, described later in the
49 manual, are useful for performing edits across multiple files, or
50 continuing edits to a single file.
51
52 The recommended way to use Emacs is to start it only once, just
53 after you log in, and do all your editing in the same Emacs session.
54 Each time you edit a file, visit it with the existing Emacs, which
55 eventually has many files in it ready for editing. @xref{Files}, for
56 more information on visiting more than one file.
57
58 To edit a file from another program while Emacs is running, you can
59 use the @command{emacsclient} helper program to open a file in the
60 already running Emacs. @xref{Emacs Server}.
61
62 Emacs accepts other command line arguments that tell it to load
63 certain Lisp files, call certain functions, and so forth. These
64 features exist mainly for advanced users. @xref{Emacs Invocation}.
65
66 @node Exiting, Basic, Entering Emacs, Top
67 @section Exiting Emacs
68 @cindex exiting
69 @cindex killing Emacs
70 @cindex leaving Emacs
71 @cindex quitting Emacs
72
73 @table @kbd
74 @item C-x C-c
75 Kill Emacs (@code{save-buffers-kill-emacs}).
76 @item C-z
77 Suspend Emacs (@code{suspend-emacs}) or iconify a frame
78 (@code{iconify-or-deiconify-frame}).
79 @end table
80
81 @kindex C-x C-c
82 @findex save-buffers-kill-emacs
83 @dfn{Killing} Emacs means terminating the Emacs program. To do
84 this, type @kbd{C-x C-c} (@code{save-buffers-kill-emacs}). A
85 two-character key is used to make it harder to type by accident. If
86 there are any modified file-visiting buffers when you type @kbd{C-x
87 C-c}, Emacs first offers to save these buffers. If you do not save
88 them all, it asks for confirmation again, since the unsaved changes
89 will be lost. Emacs also asks for confirmation if any subprocesses
90 are still running, since killing Emacs will also kill the subprocesses
91 (@pxref{Shell}).
92
93 Emacs can, optionally, record certain session information when you
94 kill it, such as the files you were visiting at the time. This
95 information is then available the next time you start Emacs.
96 @xref{Saving Emacs Sessions}.
97
98 @vindex confirm-kill-emacs
99 If the value of the variable @code{confirm-kill-emacs} is
100 non-@code{nil}, @kbd{C-x C-c} assumes that its value is a predicate
101 function, and calls that function. If the result of the function call
102 is non-@code{nil}, the session is killed, otherwise Emacs continues to
103 run. One convenient function to use as the value of
104 @code{confirm-kill-emacs} is the function @code{yes-or-no-p}. The
105 default value of @code{confirm-kill-emacs} is @code{nil}.
106
107 @cindex minimizing a frame
108 @cindex iconifying
109 @cindex suspending
110 You can ``exit'' Emacs in two other ways. On a graphical display,
111 you can @dfn{iconify} (or @dfn{minimize}) an Emacs frame; depending on
112 the window system, this either replaces the Emacs frame with a tiny
113 ``icon'' or conceals the frame entirely (@pxref{Frames}). On a
114 text-only terminal, you can @dfn{suspend} Emacs; this means stopping
115 the Emacs program temporarily, returning control to its parent process
116 (usually a shell).
117
118 @kindex C-z
119 @findex iconify-or-deiconify-frame
120 @findex suspend-emacs
121 On a graphical display, @kbd{C-z} runs the command
122 @code{iconify-or-deiconify-frame}, which iconifies the selected Emacs
123 frame. On a text terminal, @kbd{C-z} runs the command
124 @code{suspend-emacs}, which suspends Emacs.
125
126 After iconifying or suspending Emacs, you can return to it and
127 continue editing wherever you left off. The way to do this depends on
128 the window system or shell. In most common shells, you can resume
129 Emacs after suspending it with the shell command @command{%emacs}.
130
131 @vindex cannot-suspend
132 On very old systems that don't support suspending programs,
133 @kbd{C-z} starts an inferior shell that communicates directly with the
134 terminal, and Emacs waits until you exit the subshell. (The way to
135 exit the subshell is usually @kbd{C-d} or @command{exit}.) On these
136 systems, you can only get back to the shell from which Emacs was run
137 (to log out, for example) when you kill Emacs. Suspending can also
138 fail if you run Emacs under a shell that doesn't support suspending
139 jobs, even if the system itself does support it. In this case, you
140 can set the variable @code{cannot-suspend} to a non-@code{nil} value
141 to force @kbd{C-z} to start an inferior shell.
142
143 Text-only terminals usually listen for certain special characters
144 whose meaning is to kill or suspend the program you are running.
145 @b{This terminal feature is turned off while you are in Emacs.} The
146 meanings of @kbd{C-z} and @kbd{C-x C-c} as keys in Emacs were inspired
147 by the use of @kbd{C-z} and @kbd{C-c} on several operating systems as
148 the characters for stopping or killing a program, but that is their
149 only relationship with the operating system. You can customize these
150 keys to run any commands of your choice (@pxref{Keymaps}).
151
152 @ifnottex
153 @lowersections
154 @end ifnottex
155
156 @ignore
157 arch-tag: df798d8b-f253-4113-b585-f528f078a944
158 @end ignore