Small doc updates re initial-buffer-choice
[bpt/emacs.git] / doc / emacs / entering.texi
CommitLineData
6bf7aab6 1@c This is part of the Emacs manual.
ba318903 2@c Copyright (C) 1985-1987, 1993-1995, 2001-2014 Free Software
ab422c4d 3@c Foundation, Inc.
6bf7aab6 4@c See file emacs.texi for copying conditions.
321ca37f 5@iftex
6bf7aab6 6@chapter Entering and Exiting Emacs
321ca37f
CY
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
abb9615e 15@node Entering Emacs
321ca37f 16@section Entering Emacs
6bf7aab6 17@cindex entering Emacs
177c0ea7 18@cindex starting Emacs
6bf7aab6 19
708bf232 20 The usual way to invoke Emacs is with the shell command
321ca37f 21@command{emacs}. From a terminal window running in the X Window
de0bde62
CY
22System, you can run Emacs in the background with @command{emacs &};
23this way, Emacs won't tie up the terminal window, so you can use it to
24run other shell commands.
321ca37f
CY
25
26@cindex startup screen
27 When Emacs starts up, the initial frame displays a special buffer
de0bde62
CY
28named @samp{*GNU Emacs*}. This @dfn{startup screen} contains
29information about Emacs and @dfn{links} to common tasks that are
30useful for beginning users. For instance, activating the @samp{Emacs
6edf847b
CY
31Tutorial} link opens the Emacs tutorial; this does the same thing as
32the command @kbd{C-h t} (@code{help-with-tutorial}). To activate a
33link, either move point onto it and type @kbd{@key{RET}}, or click on
34it with @kbd{mouse-1} (the left mouse button).
321ca37f
CY
35
36 Using a command line argument, you can tell Emacs to visit one or
de0bde62
CY
37more files as soon as it starts up. For example, @command{emacs
38foo.txt} starts Emacs with a buffer displaying the contents of the
39file @samp{foo.txt}. This feature exists mainly for compatibility
40with other editors, which are designed to be launched from the shell
41for short editing sessions. If you call Emacs this way, the initial
42frame is split into two windows---one showing the specified file, and
43the other showing the startup screen. @xref{Windows}.
44
45 Generally, it is unnecessary and wasteful to start Emacs afresh each
46time you want to edit a file. The recommended way to use Emacs is to
47start it just once, just after you log in, and do all your editing in
48the same Emacs session. @xref{Files}, for information on visiting
49more than one file. If you use Emacs this way, the Emacs session
50accumulates valuable context, such as the kill ring, registers, undo
51history, and mark ring data, which together make editing more
52convenient. These features are described later in the manual.
6bf7aab6 53
c9a769c8
RS
54 To edit a file from another program while Emacs is running, you can
55use the @command{emacsclient} helper program to open a file in the
de0bde62 56existing Emacs session. @xref{Emacs Server}.
9f1cc7eb 57
321ca37f 58 Emacs accepts other command line arguments that tell it to load
de0bde62
CY
59certain Lisp files, where to put the initial frame, and so forth.
60@xref{Emacs Invocation}.
6cca5de0 61
6edf847b 62@vindex inhibit-startup-screen
be77bd45
CY
63 If the variable @code{inhibit-startup-screen} is non-@code{nil},
64Emacs does not display the startup screen. In that case, if one or
65more files were specified on the command line, Emacs simply displays
1c64e6ed 66those files; otherwise, it displays a buffer named @file{*scratch*},
be77bd45
CY
67which can be used to evaluate Emacs Lisp expressions interactively.
68@xref{Lisp Interaction}. You can set the variable
69@code{inhibit-startup-screen} using the Customize facility
61b9fed1 70(@pxref{Easy Customization}), or by editing your initialization file
de0bde62
CY
71(@pxref{Init File}).@footnote{Setting @code{inhibit-startup-screen} in
72@file{site-start.el} doesn't work, because the startup screen is set
73up before reading @file{site-start.el}. @xref{Init File}, for
74information about @file{site-start.el}.}
6edf847b 75
be77bd45 76 You can also force Emacs to display a file or directory at startup
91dedc43 77by setting the variable @code{initial-buffer-choice} to a string
dfff9284 78naming that file or directory. The value of
6d069b1b
GM
79@code{initial-buffer-choice} may also be a function (of no arguments)
80that should return a buffer which is then displayed.
81@ignore
82@c I do not think this should be mentioned. AFAICS it is just a dodge
83@c around inhibit-startup-screen not being settable on a site-wide basis.
84@code{initial-buffer-choice} may also be @code{t} in which case the
85@file{*scratch*} buffer will be shown.
86@end ignore
87If @code{initial-buffer-choice} is non-@code{nil}, then if you specify
88any files on the command line, Emacs still visits them, but does not
89display them initially.
be77bd45 90
abb9615e 91@node Exiting
6bf7aab6
DL
92@section Exiting Emacs
93@cindex exiting
94@cindex killing Emacs
6bf7aab6
DL
95@cindex leaving Emacs
96@cindex quitting Emacs
97
6bf7aab6 98@table @kbd
321ca37f 99@item C-x C-c
a115d013 100Kill Emacs (@code{save-buffers-kill-terminal}).
6bf7aab6 101@item C-z
8ba46c89
CY
102On a text terminal, suspend Emacs; on a graphical display,
103``minimize'' the selected frame (@code{suspend-emacs}).
6bf7aab6
DL
104@end table
105
6bf7aab6 106@kindex C-x C-c
a115d013 107@findex save-buffers-kill-terminal
321ca37f 108 @dfn{Killing} Emacs means terminating the Emacs program. To do
a115d013 109this, type @kbd{C-x C-c} (@code{save-buffers-kill-terminal}). A
de0bde62
CY
110two-character key sequence is used to make it harder to type by
111accident. If there are any modified file-visiting buffers when you
112type @kbd{C-x C-c}, Emacs first offers to save these buffers. If you
113do not save them all, it asks for confirmation again, since the
114unsaved changes will be lost. Emacs also asks for confirmation if any
115subprocesses are still running, since killing Emacs will also kill the
116subprocesses (@pxref{Shell}).
321ca37f 117
a115d013
CY
118 @kbd{C-x C-c} behaves specially if you are using Emacs as a server.
119If you type it from a ``client frame'', it closes the client
120connection. @xref{Emacs Server}.
121
321ca37f
CY
122 Emacs can, optionally, record certain session information when you
123kill it, such as the files you were visiting at the time. This
124information is then available the next time you start Emacs.
125@xref{Saving Emacs Sessions}.
6bf7aab6 126
e020c833
EZ
127@vindex confirm-kill-emacs
128 If the value of the variable @code{confirm-kill-emacs} is
129non-@code{nil}, @kbd{C-x C-c} assumes that its value is a predicate
321ca37f
CY
130function, and calls that function. If the result of the function call
131is non-@code{nil}, the session is killed, otherwise Emacs continues to
132run. One convenient function to use as the value of
133@code{confirm-kill-emacs} is the function @code{yes-or-no-p}. The
134default value of @code{confirm-kill-emacs} is @code{nil}.
135
a115d013
CY
136@findex kill-emacs
137 To kill Emacs without being prompted about saving, type @kbd{M-x
138kill-emacs}.
139
321ca37f 140@kindex C-z
8ba46c89 141@findex suspend-frame
de0bde62
CY
142@cindex minimizing
143@cindex iconifying
144@cindex suspending
8ba46c89 145 @kbd{C-z} runs the command @code{suspend-frame}. On a graphical
de0bde62
CY
146display, this command @dfn{minimizes} (or @dfn{iconifies}) the
147selected Emacs frame, hiding it in a way that lets you bring it back
148later (exactly how this hiding occurs depends on the window system).
149On a text terminal, the @kbd{C-z} command @dfn{suspends} Emacs,
150stopping the program temporarily and returning control to the parent
151process (usually a shell); in most shells, you can resume Emacs after
152suspending it with the shell command @command{%emacs}.
321ca37f 153
0be641c0
CY
154 Text terminals usually listen for certain special characters whose
155meaning is to kill or suspend the program you are running. @b{This
156terminal feature is turned off while you are in Emacs.} The meanings
157of @kbd{C-z} and @kbd{C-x C-c} as keys in Emacs were inspired by the
158use of @kbd{C-z} and @kbd{C-c} on several operating systems as the
159characters for stopping or killing a program, but that is their only
160relationship with the operating system. You can customize these keys
161to run any commands of your choice (@pxref{Keymaps}).
ab5796a9 162
6cca5de0
LT
163@ifnottex
164@lowersections
165@end ifnottex