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