@cindex shell commands
Emacs has commands for passing single command lines to inferior shell
-processes; it can also run a shell interactively with input and output to
-an Emacs buffer named @samp{*shell*}.
+processes; it can also run a shell interactively with input and output
+to an Emacs buffer named @samp{*shell*} or run s shell inside a terminal
+emulator window.
+
+There is a shell implemented entirely in Emacs, documented in a separate
+manual. @xref{, ,Eshell , eshell, Eshell: The Emacs Shell}.
@table @kbd
@item M-! @var{cmd} @key{RET}
Run a subshell with input and output through an Emacs buffer.
You can then give commands interactively.
Full terminal emulation is available.
+@item M-x eshell
+@findex eshell
+Start the Emacs shell.
@end table
@menu
@item @key{RET}
@kindex RET @r{(Shell mode)}
@findex comint-send-input
+@vindex comint-use-prompt-regexp-instead-of-fields
+@cindex prompt, shell
At end of buffer send line as input; otherwise, copy current line to end
of buffer and send it (@code{comint-send-input}). When a line is
-copied, any text at the beginning of the line that matches the variable
-@code{shell-prompt-pattern} is left out; this variable's value should be
-a regexp string that matches the prompts that your shell uses.
+copied, any prompt is left out (where the prompt is the part of the line
+that was not input by the user; see also
+@code{comint-use-prompt-regexp-instead-of-fields}).
@item @key{TAB}
@kindex TAB @r{(Shell mode)}
@item C-c C-o
@kindex C-c C-o @r{(Shell mode)}
-@findex comint-kill-output
-Kill the last batch of output from a shell command
-(@code{comint-kill-output}). This is useful if a shell command spews
-out lots of output that just gets in the way.
+@findex comint-delete-output
+Delete the last batch of output from a shell command
+(@code{comint-delete-output}). This is useful if a shell command spews
+out lots of output that just gets in the way. This command used to be
+called @code{comint-kill-output}.
+
+@item C-c C-s
+@kindex C-c C-s @r{(Shell mode)}
+@findex comint-write-output
+Write the last batch of output from a shell command to a file
+(@code{comint-write-output}). With a prefix argument, the file is
+appended to instead. Any prompt at the end of the output is not
+written.
@item C-c C-r
@itemx C-M-l
Shell mode is a derivative of Comint mode, a general-purpose mode for
communicating with interactive subprocesses. Most of the features of
Shell mode actually come from Comint mode, as you can see from the
-command names listed above. The special features of Shell mode in
-particular include the choice of regular expression for detecting
-prompts, the directory tracking feature, and a few user commands.
+command names listed above. The special features of Shell mode include
+the directory tracking feature, and a few user commands.
Other Emacs features that use variants of Comint mode include GUD
(@pxref{Debuggers}) and @kbd{M-x run-lisp} (@pxref{External Lisp}).
@vindex shell-prompt-pattern
@vindex comint-prompt-regexp
+@vindex comint-use-prompt-regexp-instead-of-fields
+@cindex prompt, shell
History references take effect only following a shell prompt. The
+prompt is defined to be any text not input by the user, unless the
+variable @code{comint-use-prompt-regexp-instead-of-fields} is
+non-@code{nil} (the default value is @code{nil}). When
+@code{comint-use-prompt-regexp-instead-of-fields} is non-@code{nil}, the
variable @code{shell-prompt-pattern} specifies how to recognize a shell
-prompt. Comint modes in general use the variable
-@code{comint-prompt-regexp} to specify how to find a prompt; Shell mode
-uses @code{shell-prompt-pattern} to set up the local value of
-@code{comint-prompt-regexp}.
+prompt, and comint modes in general use the variable
+@code{comint-prompt-regexp} (shell mode uses @code{shell-prompt-pattern}
+to set up the local value of @code{comint-prompt-regexp}).
@vindex comint-input-autoexpand
Shell mode can optionally expand history references in the buffer when
this sense; its value should be a regular expression that matches file
names that are temporary.
+@vindex server-kill-new-buffers
+ If the variable @code{server-kill-new-buffers} is set to non-nil,
+buffers which still have a client are killed when you are done with
+them, unless they were already present before Emacs Server visited
+them. This overrides the effect of the @code{server-temp-file-regexp}
+variable. By default, @code{server-kill-new-buffers} has a non-nil
+value; set it to nil if you want the old behavior governed by
+@code{server-temp-file-regexp}.
+
If you run @code{emacsclient} with the option @samp{--no-wait}, it
returns immediately without waiting for you to ``finish'' the buffer in
-Emacs.
+Emacs. Note that it this case, buffers for temporary files will not be
+killed automatically with the default value of
+@code{server-kill-new-buffers}, since those buffers will not have a
+client.
If you have forgotten to start Emacs, then the option
@samp{--alternate-editor=@var{command}} may be useful. It specifies a
@cindex Hexl mode
@cindex mode, Hexl
@cindex editing binary files
+@cindex hex editing
There is a special major mode for editing binary files: Hexl mode. To
use it, use @kbd{M-x hexl-find-file} instead of @kbd{C-x C-f} to visit
the file. This command converts the file's contents to hexadecimal and
invoked @code{hexl-mode}.
@end table
+@noindent
+Other Hexl commands let you insert strings (sequences) of binary bytes,
+move by short's or int's, etc.; type @kbd{C-h a hexl- RET} for details.
+
+
@node Saving Emacs Sessions, Recursive Edit, Editing Binary Files, Top
@section Saving Emacs Sessions
@cindex saving sessions
There is a simpler mechanism provided by Saveplace library which records
your position in each file when you kill its buffer (or kill Emacs), and
jumps to the same position when you visit the file again (even in
-another Emacs session). Use @key{M-x toggle-save-place} to turn on
+another Emacs session). Use @kbd{M-x toggle-save-place} to turn on
place-saving in a given file. Customize the option @code{save-place} to
turn it on for all files in each session.
operate on the active region, bound to @kbd{C-insert}, @kbd{S-delete}
and @kbd{S-insert} respectively.
+@cindex s-region package
The @code{s-region} package provides similar, but less complete,
facilities.