Buildchain fixes and updates from Sebastian
[sxemacs] / info / sxemacs / entering.texi
1 @c This is part of the SXEmacs manual.
2 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995 Free Software Foundation, Inc.
3 @c Copyright (C) 2005 Steve Youngs
4 @c See file sxemacs.texi for copying conditions.
5 @node Entering Emacs, Exiting, Pull-down Menus, Top
6 @chapter Entering and Exiting Emacs
7 @cindex entering SXEmacs
8 @cindex starting SXEmacs
9
10   The usual way to invoke SXEmacs is to type @kbd{sxemacs @key{RET}} at
11 the shell.  SXEmacs clears the screen and then displays an initial
12 advisory message and copyright notice.  You can begin typing SXEmacs
13 commands immediately afterward.
14
15   Some operating systems insist on discarding all type-ahead when SXEmacs
16 starts up; they give SXEmacs no way to prevent this.  Therefore, it is
17 advisable to wait until SXEmacs clears the screen before typing your first
18 editing command.
19
20   If you run SXEmacs from a shell window under the X Window System, run it
21 in the background with @samp{sxemacs&}.  This way, SXEmacs does not tie up
22 the shell window, so you can use that to run other shell commands while
23 SXEmacs operates its own X windows.  You can begin typing SXEmacs commands
24 as soon as you direct your keyboard input to the SXEmacs frame.
25
26 @vindex initial-major-mode
27   Before Emacs reads the first command, you have not had a chance to
28 give a command to specify a file to edit.  Since Emacs must always have
29 a current buffer for editing, it presents a buffer, by default, a buffer
30 named @samp{*scratch*}.  The buffer is in Lisp Interaction mode; you can
31 use it to type Lisp expressions and evaluate them, or you can ignore
32 that capability and simply doodle.  (You can specify a different major
33 mode for this buffer by setting the variable @code{initial-major-mode}
34 in your init file.  @xref{Init File}.)
35
36   It is possible to specify files to be visited, Lisp files to be
37 loaded, and functions to be called, by giving Emacs arguments in the
38 shell command line.  @xref{Command Switches}.  But we don't recommend
39 doing this.  The feature exists mainly for compatibility with other
40 editors.
41
42   Many other editors are designed to be started afresh each time you
43 want to edit.  You edit one file and then exit the editor.  The next
44 time you want to edit either another file or the same one, you must run
45 the editor again.  With these editors, it makes sense to use a
46 command-line argument to say which file to edit.
47
48   But starting a new Emacs each time you want to edit a different file
49 does not make sense.  For one thing, this would be annoyingly slow.  For
50 another, this would fail to take advantage of Emacs's ability to visit
51 more than one file in a single editing session.  And it would lose the
52 other accumulated context, such as registers, undo history, and the mark
53 ring.
54
55   The recommended way to use SXEmacs is to start it only once, just
56 after you log in, and do all your editing in the same Emacs session.
57 Each time you want to edit a different file, you visit it with the
58 existing Emacs, which eventually comes to have many files in it ready
59 for editing.  Usually you do not kill the Emacs until you are about to
60 log out.  @xref{Files}, for more information on visiting more than one
61 file.
62
63 @node Exiting, Command Switches, Entering Emacs, Top
64 @section Exiting Emacs
65 @cindex exiting
66 @cindex killing Emacs
67 @cindex suspending
68 @cindex leaving Emacs
69 @cindex quitting Emacs
70 @cindex shrinking SXEmacs frame
71
72   There are two commands for exiting Emacs because there are two kinds
73 of exiting: @dfn{suspending} Emacs and @dfn{killing} Emacs.
74
75   @dfn{Suspending} means stopping Emacs temporarily and returning
76 control to its parent process (usually a shell), allowing you to resume
77 editing later in the same Emacs job, with the same buffers, same kill
78 ring, same undo history, and so on.  This is the usual way to exit.
79
80   @dfn{Killing} Emacs means destroying the Emacs job.  You can run Emacs
81 again later, but you will get a fresh Emacs; there is no way to resume
82 the same editing session after it has been killed.
83
84 @table @kbd
85 @item C-z
86 Suspend Emacs or iconify a frame
87 (@code{suspend-emacs-or-iconify-frame}).  If used under the X window
88 system, shrink the X window containing the Emacs frame to an icon (see
89 below).
90 @item C-x C-c
91 Kill Emacs (@code{save-buffers-kill-emacs}).
92 @end table
93
94 If you use SXEmacs under the X window system, @kbd{C-z} shrinks
95 the X window containing the Emacs frame to an icon.  The Emacs process
96 is stopped temporarily, and control is returned to the window manager.
97 If more than one frame is associated with the Emacs process, only the
98 frame from which you used @kbd{C-z} is iconified.
99
100 To activate the "suspended" Emacs, use the appropriate window manager
101 mouse gestures.  Usually left-clicking on the icon reactivates and
102 reopens the X window containing the Emacs frame, but the window manager
103 you use determines what exactly happens.  To actually kill the Emacs
104 process, use @kbd{C-x C-c} or the @b{Exit SXEmacs} item on the @b{File}
105 menu.
106
107 @kindex C-z
108 @findex suspend-emacs
109   To suspend Emacs, type @kbd{C-z} (@code{suspend-emacs}).  This takes
110 you back to the shell from which you invoked Emacs.  You can resume
111 Emacs with the shell command @samp{%sxemacs} in most common shells.
112
113   On systems that do not support suspending programs, @kbd{C-z} starts
114 an inferior shell that communicates directly with the terminal.
115 Emacs waits until you exit the subshell.  (The way to do that is
116 probably with @kbd{C-d} or @samp{exit}, but it depends on which shell
117 you use.)  The only way on these systems to get back to the shell from
118 which Emacs was run (to log out, for example) is to kill Emacs.
119
120   Suspending also fails if you run Emacs under a shell that doesn't
121 support suspending programs, even if the system itself does support it.
122 In such a case, you can set the variable @code{cannot-suspend} to a
123 non-@code{nil} value to force @kbd{C-z} to start an inferior shell.
124 (One might also describe Emacs's parent shell as ``inferior'' for
125 failing to support job control properly, but that is a matter of taste.)
126
127   When Emacs communicates directly with an X server and creates its own
128 dedicated X windows, @kbd{C-z} has a different meaning.  Suspending an
129 applications that uses its own X windows is not meaningful or useful.
130 Instead, @kbd{C-z} runs the command @code{iconify-or-deiconify-frame},
131 which temporarily closes up the selected Emacs frame.
132 The way to get back to a shell window is with the window manager.
133
134 @kindex C-x C-c
135 @findex save-buffers-kill-emacs
136   To kill Emacs, type @kbd{C-x C-c} (@code{save-buffers-kill-emacs}).  A
137 two-character key is used for this to make it harder to type.  Selecting
138 the @b{Exit SXEmacs} option of the @b{File} menu is an alternate way of
139 issuing the command.
140
141 Unless a numeric argument is used, this command first offers to save any
142 modified file-visiting buffers.  If you do not save all buffers, you are
143 asked for reconfirmation with @kbd{yes} before killing Emacs, since any
144 changes not saved will be lost forever.  If any subprocesses are still
145 running, @kbd{C-x C-c} asks you to confirm killing them, since killing
146 Emacs will kill the subprocesses immediately.
147
148   There is no way to restart an Emacs session once you have killed it.
149 You can, however, arrange for Emacs to record certain session
150 information, such as which files are visited, when you kill it, so that
151 the next time you restart Emacs it will try to visit the same files and
152 so on.
153 @c @xref{Saving Emacs Sessions}.
154
155   The operating system usually listens for certain special characters
156 whose meaning is to kill or suspend the program you are running.
157 @b{This operating system feature is turned off while you are in Emacs.}
158 The meanings of @kbd{C-z} and @kbd{C-x C-c} as keys in Emacs were
159 inspired by the use of @kbd{C-z} and @kbd{C-c} on several operating
160 systems as the characters for stopping or killing a program, but that is
161 their only relationship with the operating system.  You can customize
162 these keys to run any commands of your choice (@pxref{Keymaps}).