entering.texi 7.7 KB

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