Commit 88c5c7c8 authored by Chong Yidong's avatar Chong Yidong

More updates to misc.texi.

* doc/emacs/misc.texi (Single Shell): Don't document Lisp usage of
shell-command.  Tidy up discussion of synchronicity.  Add index
entries for async-shell-command.
(Interactive Shell): Note that M-x shell uses shell-file-name.
Note change in behavior in Emacs 24.
(Shell Mode): Shell mode now uses completion-at-point.
(Shell Prompts): Emphasize that comint-use-prompt-regexp isn't the
default method for recognizing prompts nowadays.
(Shell Ring): Add xref to Minibuffer History.
(Directory Tracking): Explain Dirtrack mode in more detail.
(Term Mode): Fix index entries.
(Paging in Term): Merge into Term Mode.
(Serial Terminal, Emacs Server, emacsclient Options): Copyedits.
(Printing): Fix xref.  State default of lpr-switches.
(PostScript): Remove obsolete sentence.  Omit description of
non-interactive behaviors.
(Hyperlinking): Improve description.
(Browse-URL): Using compose-mail for mailto URLs is the default.
Document browse-url-mailto-function.
(Goto Address mode): Add index entries.  Add xref to Browse-URL.
(FFAP): FFAP is not a minor mode.
(Amusements): M-x lm was renamed to M-x landmark.  Document
nato-region.
parent 787cdb34
......@@ -156,7 +156,7 @@ macos.texi
maintaining.texi cyd
mark.texi cyd
mini.texi
misc.texi
misc.texi cyd
modes.texi cyd
msdog.texi
msdog-xtra.texi
......
2012-01-03 Chong Yidong <cyd@gnu.org>
* misc.texi (Single Shell): Don't document Lisp usage of
shell-command. Tidy up discussion of synchronicity. Add index
entries for async-shell-command.
(Interactive Shell): Note that M-x shell uses shell-file-name.
Note change in behavior in Emacs 24.
(Shell Mode): Shell mode now uses completion-at-point.
(Shell Prompts): Emphasize that comint-use-prompt-regexp isn't the
default method for recognizing prompts nowadays.
(Shell Ring): Add xref to Minibuffer History.
(Directory Tracking): Explain Dirtrack mode in more detail.
(Term Mode): Fix index entries.
(Paging in Term): Merge into Term Mode.
(Serial Terminal, Emacs Server, emacsclient Options): Copyedits.
(Printing): Fix xref. State default of lpr-switches.
(PostScript): Remove obsolete sentence. Omit description of
non-interactive behaviors.
(Hyperlinking): Improve description.
(Browse-URL): Using compose-mail for mailto URLs is the default.
Document browse-url-mailto-function.
(Goto Address mode): Add index entries. Add xref to Browse-URL.
(FFAP): FFAP is not a minor mode.
(Amusements): M-x lm was renamed to M-x landmark. Document
nato-region.
2012-01-01 Chong Yidong <cyd@gnu.org>
* misc.texi (Gnus, Buffers of Gnus): Copyedits.
......
......@@ -988,7 +988,6 @@ Running Shell Commands from Emacs
* Shell Options:: Options for customizing Shell mode.
* Terminal emulator:: An Emacs window as a terminal emulator.
* Term Mode:: Special Emacs commands used in Term mode.
* Paging in Term:: Paging in the terminal emulator.
* Remote Host:: Connecting to another computer.
* Serial Terminal:: Connecting to a serial port.
......
......@@ -447,27 +447,32 @@ emulator window.
@table @kbd
@item M-! @var{cmd} @key{RET}
Run the shell command line @var{cmd} and display the output
Run the shell command @var{cmd} and display the output
(@code{shell-command}).
@item M-| @var{cmd} @key{RET}
Run the shell command line @var{cmd} with region contents as input;
Run the shell command @var{cmd} with region contents as input;
optionally replace the region with the output
(@code{shell-command-on-region}).
@item M-& @var{cmd} @key{RET}
Run the shell command line @var{cmd} asynchronously, and display the
output (@code{async-shell-command}).
Run the shell command @var{cmd} asynchronously, and display the output
(@code{async-shell-command}).
@item M-x shell
Run a subshell with input and output through an Emacs buffer.
You can then give commands interactively.
Run a subshell with input and output through an Emacs buffer. You can
then give commands interactively.
@item M-x term
Run a subshell with input and output through an Emacs buffer.
You can then give commands interactively.
Full terminal emulation is available.
Run a subshell with input and output through an Emacs buffer. You can
then give commands interactively. Full terminal emulation is
available.
@end table
@kbd{M-x eshell} invokes a shell implemented entirely in Emacs. It
is documented in a separate manual. @xref{Top,Eshell,Eshell, eshell,
Eshell: The Emacs Shell}.
is documented in its own manual.
@ifnottex
@xref{Top,Eshell,Eshell, eshell, Eshell: The Emacs Shell}.
@end ifnottex
@iftex
See the Eshell Info manual, which is distributed with Emacs.
@end iftex
@menu
* Single Shell:: How to run one shell command and return.
......@@ -479,7 +484,6 @@ Eshell: The Emacs Shell}.
* Options: Shell Options. Options for customizing Shell mode.
* Terminal emulator:: An Emacs window as a terminal emulator.
* Term Mode:: Special Emacs commands used in Term mode.
* Paging in Term:: Paging in the terminal emulator.
* Remote Host:: Connecting to another computer.
* Serial Terminal:: Connecting to a serial port.
@end menu
......@@ -490,53 +494,62 @@ Eshell: The Emacs Shell}.
@kindex M-!
@findex shell-command
@kbd{M-!} (@code{shell-command}) reads a line of text using the
minibuffer and executes it as a shell command in a subshell made just
minibuffer and executes it as a shell command, in a subshell made just
for that command. Standard input for the command comes from the null
device. If the shell command produces any output, the output appears
either in the echo area (if it is short), or in an Emacs buffer named
@samp{*Shell Command Output*}, which is displayed in another window
but not selected (if the output is long).
For instance, one way to decompress a file @file{foo.gz} from Emacs
is to type @kbd{M-! gunzip foo.gz @key{RET}}. That shell command
normally creates the file @file{foo} and produces no terminal output.
A numeric argument, as in @kbd{M-1 M-!}, says to insert terminal
output into the current buffer instead of a separate buffer. It puts
point before the output, and sets the mark after the output. For
instance, @kbd{M-1 M-! gunzip < foo.gz @key{RET}} would insert the
uncompressed equivalent of @file{foo.gz} into the current buffer.
If the shell command line ends in @samp{&}, it runs asynchronously.
For a synchronous shell command, @code{shell-command} returns the
command's exit status (0 means success), when it is called from a Lisp
program. You do not get any status information for an asynchronous
command, since it hasn't finished yet when @code{shell-command} returns.
You can also type @kbd{M-&} (@code{async-shell-command}) to execute
a shell command asynchronously. This behaves exactly like calling
@code{shell-command} with @samp{&}, except that you do not need to add
the @samp{&} to the shell command line.
@samp{*Shell Command Output*}, displayed in another window (if the
output is long).
For instance, one way to decompress a file named @file{foo.gz} is to
type @kbd{M-! gunzip foo.gz @key{RET}}. That shell command normally
creates the file @file{foo} and produces no terminal output.
A numeric argument to @code{shell-command}, e.g.@: @kbd{M-1 M-!},
causes it to insert terminal output into the current buffer instead of
a separate buffer. It puts point before the output, and sets the mark
after the output. For instance, @kbd{M-1 M-! gunzip < foo.gz
@key{RET}} would insert the uncompressed form of the file
@file{foo.gz} into the current buffer.
Provided the specified shell command does not end with @samp{&}, it
runs @dfn{synchronously}, and you must wait for it to exit before
continuing to use Emacs. To stop waiting, type @kbd{C-g} to quit;
this sends a @code{SIGINT} signal to terminate the shell command (this
is the same signal that @kbd{C-c} normally generates in the shell).
Emacs then waits until the command actually terminates. If the shell
command doesn't stop (because it ignores the @code{SIGINT} signal),
type @kbd{C-g} again; this sends the command a @code{SIGKILL} signal,
which is impossible to ignore.
@kindex M-&
@findex async-shell-command
A shell command that ends in @samp{&} is executed
@dfn{asynchronously}, and you can continue to use Emacs as it runs.
You can also type @kbd{M-&} (@code{async-shell-command}) to execute a
shell command asynchronously; this is exactly like calling @kbd{M-!}
with a trailing @samp{&}, except that you do not need the @samp{&}.
The output buffer for asynchronous shell commands is named
@samp{*Async Shell Command*}. Emacs inserts the output into this
buffer as it comes in, whether or not the buffer is visible in a
window.
@kindex M-|
@findex shell-command-on-region
@kbd{M-|} (@code{shell-command-on-region}) is like @kbd{M-!} but
@kbd{M-|} (@code{shell-command-on-region}) is like @kbd{M-!}, but
passes the contents of the region as the standard input to the shell
command, instead of no input. With a numeric argument, meaning insert
the output in the current buffer, it deletes the old region and the
output replaces it as the contents of the region. It returns the
command's exit status, like @kbd{M-!}.
One use for @kbd{M-|} is to run @code{gpg} to see what keys are in
the buffer. For instance, if the buffer contains a GPG key, type
@kbd{C-x h M-| gpg @key{RET}} to feed the entire buffer contents to
the @code{gpg} program. That program will ignore everything except
the encoded keys, and will output a list of the keys the buffer
contains.
command, instead of no input. With a numeric argument, it deletes the
old region and replaces it with the output from the shell command.
For example, you can use @kbd{M-|} with the @command{gpg} program to
see what keys are in the buffer. If the buffer contains a GnuPG key,
type @kbd{C-x h M-| gpg @key{RET}} to feed the entire buffer contents
to @command{gpg}. This will output the list of keys to the
@samp{*Shell Command Output*} buffer.
@vindex shell-file-name
Both @kbd{M-!} and @kbd{M-|} use @code{shell-file-name} to specify
the shell to use. This variable is initialized based on your
The above commands use the shell specified by the variable
@code{shell-file-name}. Its default value is determined by the
@env{SHELL} environment variable when Emacs is started. If the file
name is relative, Emacs searches the directories in the list
@code{exec-path}; this list is initialized based on the environment
......@@ -544,81 +557,65 @@ variable @env{PATH} when Emacs is started. Your init file can
override either or both of these default initializations (@pxref{Init
File}).
Both @kbd{M-!} and @kbd{M-|} wait for the shell command to complete,
unless you end the command with @samp{&} to make it asynchronous. To
stop waiting, type @kbd{C-g} to quit; that terminates the shell
command with the signal @code{SIGINT}---the same signal that @kbd{C-c}
normally generates in the shell. Emacs then waits until the command
actually terminates. If the shell command doesn't stop (because it
ignores the @code{SIGINT} signal), type @kbd{C-g} again; this sends
the command a @code{SIGKILL} signal which is impossible to ignore.
Asynchronous commands ending in @samp{&} feed their output into
the buffer @samp{*Async Shell Command*}. Output arrives in that
buffer regardless of whether it is visible in a window.
To specify a coding system for @kbd{M-!} or @kbd{M-|}, use the command
@kbd{C-x @key{RET} c} immediately beforehand. @xref{Communication Coding}.
@vindex shell-command-default-error-buffer
Error output from these commands is normally intermixed with the
regular output. But if the variable
@code{shell-command-default-error-buffer} has a string as value, and
it's the name of a buffer, @kbd{M-!} and @kbd{M-|} insert error output
before point in that buffer.
By default, error output is intermixed with the regular output in
the output buffer. But if you change the value of the variable
@code{shell-command-default-error-buffer} to a string, error output is
inserted into a buffer of that name.
@node Interactive Shell
@subsection Interactive Inferior Shell
@subsection Interactive Subshell
@findex shell
To run a subshell interactively, use @kbd{M-x shell}. This creates
(or reuses) a buffer named @samp{*shell*} and runs a subshell with
input coming from and output going to that buffer. That is to say,
any ``terminal output'' from the subshell goes into the buffer,
advancing point, and any ``terminal input'' for the subshell comes
from text in the buffer. To give input to the subshell, go to the end
of the buffer and type the input, terminated by @key{RET}.
Emacs does not wait for the subshell to do anything. You can switch
windows or buffers and edit them while the shell is waiting, or while it is
running a command. Output from the subshell waits until Emacs has time to
process it; this happens whenever Emacs is waiting for keyboard input or
for time to elapse.
To run a subshell interactively, type @kbd{M-x shell}. This creates
(or reuses) a buffer named @samp{*shell*}, and runs a shell subprocess
with input coming from and output going to that buffer. That is to
say, any terminal output from the subshell goes into the buffer,
advancing point, and any terminal input for the subshell comes from
text in the buffer. To give input to the subshell, go to the end of
the buffer and type the input, terminated by @key{RET}.
While the subshell is waiting or running a command, you can switch
windows or buffers and perform other editing in Emacs. Emacs inserts
the output from the subshell into the Shell buffer whenever it has
time to process it (e.g.@: while waiting for keyboard input).
@cindex @code{comint-highlight-input} face
@cindex @code{comint-highlight-prompt} face
Input lines, once you submit them, are displayed using the face
@code{comint-highlight-input}, and prompts are displayed using the
face @code{comint-highlight-prompt}. This makes it easier to see
previous input lines in the buffer. @xref{Faces}.
To make multiple subshells, you can invoke @kbd{M-x shell} with a
prefix argument (e.g. @kbd{C-u M-x shell}), which will read a buffer
name and create (or reuse) a subshell in that buffer. You can also
rename the @samp{*shell*} buffer using @kbd{M-x rename-uniquely}, then
create a new @samp{*shell*} buffer using plain @kbd{M-x shell}.
In the Shell buffer, prompts are displayed with the face
@code{comint-highlight-prompt}, and submitted input lines are
displayed with the face @code{comint-highlight-input}. This makes it
easier to distinguish input lines from the shell output.
@xref{Faces}.
To make multiple subshells, invoke @kbd{M-x shell} with a prefix
argument (e.g. @kbd{C-u M-x shell}). Then the command will read a
buffer name, and create (or reuse) a subshell in that buffer. You can
also rename the @samp{*shell*} buffer using @kbd{M-x rename-uniquely},
then create a new @samp{*shell*} buffer using plain @kbd{M-x shell}.
Subshells in different buffers run independently and in parallel.
@vindex explicit-shell-file-name
@cindex environment variables for subshells
@cindex @env{ESHELL} environment variable
@cindex @env{SHELL} environment variable
The file name used to load the subshell is the value of the variable
@code{explicit-shell-file-name}, if that is non-@code{nil}.
Otherwise, the environment variable @env{ESHELL} is used, or the
environment variable @env{SHELL} if there is no @env{ESHELL}. If the
file name specified is relative, the directories in the list
@code{exec-path} are searched; this list is initialized based on the
environment variable @env{PATH} when Emacs is started. Your init file
can override either or both of these default initializations.
(@pxref{Init File}).
To specify the shell file name used by @kbd{M-x shell}, customize
the variable @code{explicit-shell-file-name}. If this is @code{nil}
(the default), Emacs uses the environment variable @env{ESHELL} if it
exists. Otherwise, it usually uses the variable
@code{shell-file-name} (@pxref{Single Shell}); but if the default
directory is remote (@pxref{Remote Files}), it prompts you for the
shell file name.
Emacs sends the new shell the contents of the file
@file{~/.emacs_@var{shellname}} as input, if it exists, where
@var{shellname} is the name of the file that the shell was loaded
from. For example, if you use bash, the file sent to it is
@file{~/.emacs_bash}. If this file is not found, Emacs tries to fallback
on @file{~/.emacs.d/init_@var{shellname}.sh}.
@file{~/.emacs_bash}. If this file is not found, Emacs tries with
@file{~/.emacs.d/init_@var{shellname}.sh}.
To specify a coding system for the shell, you can use the command
@kbd{C-x @key{RET} c} immediately before @kbd{M-x shell}. You can
......@@ -627,44 +624,46 @@ also change the coding system for a running subshell by typing
Coding}.
@cindex @env{INSIDE_EMACS} environment variable
Emacs sets the environment variable @env{INSIDE_EMACS} in the
subshell to a comma-separated list including the Emacs version.
Programs can check this variable to determine whether they are running
inside an Emacs subshell.
@cindex @env{EMACS} environment variable
Emacs also sets the @env{EMACS} environment variable (to @code{t}) if
it is not already defined. @strong{Warning:} This environment
variable is deprecated. Programs that check this variable should be
changed to check @env{INSIDE_EMACS} instead.
Emacs sets the environment variable @env{INSIDE_EMACS} in the
subshell to @samp{@var{version},comint}, where @var{version} is the
Emacs version (e.g.@: @samp{24.1}). Programs can check this variable
to determine whether they are running inside an Emacs subshell. (It
also sets the @env{EMACS} environment variable to @code{t}, if that
environment variable is not already defined. However, this
environment variable is deprecated; programs that use it should switch
to using @env{INSIDE_EMACS} instead.)
@node Shell Mode
@subsection Shell Mode
@cindex Shell mode
@cindex mode, Shell
Shell buffers use Shell mode, which defines several special keys
attached to the @kbd{C-c} prefix. They are chosen to resemble the usual
editing and job control characters present in shells that are not under
Emacs, except that you must type @kbd{C-c} first. Here is a complete list
of the special key bindings of Shell mode:
The major mode for Shell buffers is Shell mode. Many of its special
commands are bound to the @kbd{C-c} prefix, and resemble the usual
editing and job control characters present in ordinary shells, except
that you must type @kbd{C-c} first. Here is a list of Shell mode
commands:
@table @kbd
@item @key{RET}
@kindex RET @r{(Shell mode)}
@findex comint-send-input
At end of buffer send line as input; otherwise, copy current line to
end of buffer and send it (@code{comint-send-input}). Copying a line
in this way omits any prompt at the beginning of the line (text output
by programs preceding your input). @xref{Shell Prompts}, for how
Shell mode recognizes prompts.
Send the current line as input to the subshell
(@code{comint-send-input}). Any shell prompt at the beginning of the
line is omitted (@pxref{Shell Prompts}). If point is at the end of
buffer, this is like submitting the command line in an ordinary
interactive shell. However, you can also invoke @key{RET} elsewhere
in the shell buffer to submit the current line as input.
@item @key{TAB}
@kindex TAB @r{(Shell mode)}
@findex comint-dynamic-complete
Complete the command name or file name before point in the shell buffer
(@code{comint-dynamic-complete}). @key{TAB} also completes history
references (@pxref{History References}) and environment variable names.
@findex completion-at-point
Complete the command name or file name before point in the shell
buffer (@code{completion-at-point}). This uses the usual Emacs
completion rules (@pxref{Completion}), with the completion
alternatives being file names, environment variable names, the shell
command history, and history references (@pxref{History References}).
@vindex shell-completion-fignore
@vindex comint-completion-fignore
......@@ -678,17 +677,16 @@ instead.
@item M-?
@kindex M-? @r{(Shell mode)}
@findex comint-dynamic-list-filename@dots{}
Display temporarily a list of the possible completions of the file name
before point in the shell buffer
(@code{comint-dynamic-list-filename-completions}).
Display temporarily a list of the possible completions of the file
name before point (@code{comint-dynamic-list-filename-completions}).
@item C-d
@kindex C-d @r{(Shell mode)}
@findex comint-delchar-or-maybe-eof
Either delete a character or send @acronym{EOF}
(@code{comint-delchar-or-maybe-eof}). Typed at the end of the shell
buffer, @kbd{C-d} sends @acronym{EOF} to the subshell. Typed at any other
position in the buffer, @kbd{C-d} deletes a character as usual.
buffer, this sends @acronym{EOF} to the subshell. Typed at any other
position in the buffer, this deletes a character as usual.
@item C-c C-a
@kindex C-c C-a @r{(Shell mode)}
......@@ -784,8 +782,8 @@ Move backward across one shell command, but not beyond the current line
(@code{shell-backward-command}).
@item M-x dirs
Ask the shell what its current directory is, so that Emacs can agree
with the shell.
Ask the shell for its working directory, and update the Shell buffer's
default directory. @xref{Directory Tracking}.
@item M-x send-invisible @key{RET} @var{text} @key{RET}
@findex send-invisible
......@@ -854,41 +852,38 @@ specializations of Shell mode.
@node Shell Prompts
@subsection Shell Prompts
@vindex shell-prompt-pattern
@vindex comint-prompt-regexp
@vindex comint-use-prompt-regexp
@cindex prompt, shell
A prompt is text output by a program to show that it is ready to
accept new user input. Normally, Comint mode (and thus Shell mode)
considers the prompt to be any text output by a program at the
beginning of an input line. However, if the variable
@code{comint-use-prompt-regexp} is non-@code{nil}, then Comint mode
uses a regular expression to recognize prompts. In Shell mode,
@code{shell-prompt-pattern} specifies the regular expression.
The value of @code{comint-use-prompt-regexp} also affects many
motion and paragraph commands. If the value is non-@code{nil}, the
general Emacs motion commands behave as they normally do in buffers
without special text properties. However, if the value is @code{nil},
the default, then Comint mode divides the buffer into two types of
``fields'' (ranges of consecutive characters having the same
@code{field} text property): input and output. Prompts are part of
the output. Most Emacs motion commands do not cross field boundaries,
unless they move over multiple lines. For instance, when point is in
input on the same line as a prompt, @kbd{C-a} puts point at the
beginning of the input if @code{comint-use-prompt-regexp} is
@code{nil} and at the beginning of the line otherwise.
In Shell mode, only shell prompts start new paragraphs. Thus, a
paragraph consists of a prompt and the input and output that follow
it. However, if @code{comint-use-prompt-regexp} is @code{nil}, the
default, most paragraph commands do not cross field boundaries. This
means that prompts, ranges of input, and ranges of non-prompt output
behave mostly like separate paragraphs; with this setting, numeric
arguments to most paragraph commands yield essentially undefined
behavior. For the purpose of finding paragraph boundaries, Shell mode
uses @code{shell-prompt-pattern}, regardless of
@code{comint-use-prompt-regexp}.
automatically figures out part of the buffer is a prompt, based on the
output of the subprocess. (Specifically, it assumes that any received
output line which doesn't end with a newline is a prompt.)
Comint mode divides the buffer into two types of @dfn{fields}: input
fields (where user input is typed) and output fields (everywhere
else). Prompts are part of the output fields. Most Emacs motion
commands do not cross field boundaries, unless they move over multiple
lines. For instance, when point is in the input field on a shell
command line, @kbd{C-a} puts point at the beginning of the input
field, after the prompt. Internally, the fields are implemented using
the @code{field} text property (@pxref{Text Properties,,, elisp, the
Emacs Lisp Reference Manual}).
@vindex comint-use-prompt-regexp
@vindex shell-prompt-pattern
If you change the variable @code{comint-use-prompt-regexp} to a
non-@code{nil} value, then Comint mode recognize prompts using a
regular expression (@pxref{Regexps}). In Shell mode, the regular
expression is specified by the variable @code{shell-prompt-pattern}.
The default value of @code{comint-use-prompt-regexp} is @code{nil},
because this method for recognizing prompts is unreliable, but you may
want to set it to a non-@code{nil} value in unusual circumstances. In
that case, Emacs does not divide the Comint buffer into fields, so the
general motion commands behave as they normally do in buffers without
special text properties. However, you can use the paragraph motion
commands to conveniently navigate the buffer (@pxref{Paragraphs}); in
Shell mode, Emacs uses @code{shell-prompt-pattern} as paragraph
boundaries.
@node Shell History
@subsection Shell Command History
......@@ -945,11 +940,12 @@ Display the buffer's history of shell commands in another window
(@code{comint-dynamic-list-input-ring}).
@end table
Shell buffers provide a history of previously entered shell commands. To
reuse shell commands from the history, use the editing commands @kbd{M-p},
@kbd{M-n}, @kbd{M-r} and @kbd{M-s}. These work just like the minibuffer
history commands except that they operate on the text at the end of the
shell buffer, where you would normally insert text to send to the shell.
Shell buffers provide a history of previously entered shell
commands. To reuse shell commands from the history, use the editing
commands @kbd{M-p}, @kbd{M-n}, @kbd{M-r} and @kbd{M-s}. These work
just like the minibuffer history commands (@pxref{Minibuffer
History}), except that they operate within the Shell buffer rather
than the minibuffer.
@kbd{M-p} fetches an earlier shell command to the end of the shell
buffer. Successive use of @kbd{M-p} fetches successively earlier
......@@ -1076,39 +1072,40 @@ command @code{comint-magic-space}.
@vindex shell-popd-regexp
@vindex shell-cd-regexp
Shell mode keeps track of @samp{cd}, @samp{pushd} and @samp{popd}
commands given to the inferior shell, so it can keep the
@samp{*shell*} buffer's default directory the same as the shell's
working directory. It recognizes these commands syntactically, by
examining lines of input that are sent.
commands given to the subshell, in order to keep the Shell buffer's
default directory (@pxref{File Names}) the same as the shell's working
directory. It recognizes these commands by examining lines of input
that you send.
If you use aliases for these commands, you can tell Emacs to
recognize them also. For example, if the value of the variable
@code{shell-pushd-regexp} matches the beginning of a shell command
line, that line is regarded as a @code{pushd} command. Change this
variable when you add aliases for @samp{pushd}. Likewise,
@code{shell-popd-regexp} and @code{shell-cd-regexp} are used to
recognize commands with the meaning of @samp{popd} and @samp{cd}.
These commands are recognized only at the beginning of a shell command
line.
@ignore @c This seems to have been deleted long ago.
@vindex shell-set-directory-error-hook
If Emacs gets an error while trying to handle what it believes is a
@samp{cd}, @samp{pushd} or @samp{popd} command, it runs the hook
@code{shell-set-directory-error-hook} (@pxref{Hooks}).
@end ignore
recognize them also, by setting the variables
@code{shell-pushd-regexp}, @code{shell-popd-regexp}, and
@code{shell-cd-regexp} to the appropriate regular expressions
(@pxref{Regexps}). For example, if @code{shell-pushd-regexp} matches
the beginning of a shell command line, that line is regarded as a
@code{pushd} command. These commands are recognized only at the
beginning of a shell command line.
@findex dirs
If Emacs gets confused about changes in the current directory of the
subshell, use the command @kbd{M-x dirs} to ask the shell what its
current directory is. This command works for shells that support the
most common command syntax; it may not work for unusual shells.
If Emacs gets confused about changes in the working directory of the
subshell, type @kbd{M-x dirs}. This command asks the shell for its
working directory and updates the default directory accordingly. It
works for shells that support the most common command syntax, but may
not work for unusual shells.
@findex dirtrack-mode
You can also use @kbd{M-x dirtrack-mode} to enable (or disable) an
alternative method of tracking changes in the current directory. This
method relies on your shell prompt containing the full current working
directory at all times.
@cindex Dirtrack mode
@cindex mode, Dirtrack
@vindex dirtrack-list
You can also use Dirtrack mode, a buffer-local minor mode that
implements an alternative method of tracking the shell's working
directory. To use this method, your shell prompt must contain the
working directory at all times, and you must supply a regular
expression for recognizing which part of the prompt contains the
working directory; see the documentation of the variable
@code{dirtrack-list} for details. To use Dirtrack mode, type @kbd{M-x
dirtrack-mode} in the Shell buffer, or add @code{dirtrack-mode} to
@code{shell-mode-hook} (@pxref{Hooks}).
@node Shell Options
@subsection Shell Mode Options
......@@ -1185,10 +1182,10 @@ subshell with input coming from your keyboard, and output going to
that buffer.
The terminal emulator uses Term mode, which has two input modes. In
line mode, Term basically acts like Shell mode; see @ref{Shell Mode}.
line mode, Term basically acts like Shell mode (@pxref{Shell Mode}).
In char mode, each character is sent directly to the inferior
subshell, as ``terminal input.'' Any ``echoing'' of your input is the
In char mode, each character is sent directly to the subshell, as
``terminal input.'' Any ``echoing'' of your input is the
responsibility of the subshell. The sole exception is the terminal
escape character, which by default is @kbd{C-c} (@pxref{Term Mode}).
Any ``terminal output'' from the subshell goes into the buffer,
......@@ -1204,8 +1201,8 @@ handles each one appropriately, changing the buffer so that the
appearance of the window matches what it would be on a real terminal.
You can actually run Emacs inside an Emacs Term window.
You can use Term mode to communicate with a device connected to a
serial port of your computer. @xref{Serial Terminal}.
You can also Term mode to communicate with a device connected to a
serial port. @xref{Serial Terminal}.
The file name used to load the subshell is determined the same way
as for Shell mode. To make multiple terminal emulators, rename the
......@@ -1223,22 +1220,24 @@ and later.
@cindex mode, Term
The terminal emulator uses Term mode, which has two input modes. In
line mode, Term basically acts like Shell mode; see @ref{Shell Mode}.
In char mode, each character is sent directly to the inferior
subshell, except for the Term escape character, normally @kbd{C-c}.
line mode, Term basically acts like Shell mode (@pxref{Shell Mode}).
In char mode, each character is sent directly to the subshell, except
for the Term escape character, normally @kbd{C-c}.
To switch between line and char mode, use these commands:
@table @kbd
@kindex C-c C-j @r{(Term mode)}
@findex term-char-mode
@findex term-line-mode
@item C-c C-j
Switch to line mode. Do nothing if already in line mode.
Switch to line mode (@code{term-line-mode}). Do nothing if already in
line mode.
@kindex C-c C-k @r{(Term mode)}
@findex term-line-mode
@findex term-char-mode
@item C-c C-k
Switch to char mode. Do nothing if already in char mode.
Switch to char mode (@code{term-char-mode}). Do nothing if already in
char mode.
@end table
The following commands are only available in char mode:
......@@ -1253,28 +1252,23 @@ example, @kbd{C-c o} invokes the global binding of @kbd{C-x o}, which
is normally @samp{other-window}.
@end table
@node Paging in Term
@subsection Page-At-A-Time Output
@cindex page-at-a-time
Term mode has a page-at-a-time feature. When enabled it makes
output pause at the end of each screenful.
@cindex paging in Term mode
Term mode has a page-at-a-time feature. When enabled, it makes
output pause at the end of each screenful:
@table @kbd
@kindex C-c C-q @r{(Term mode)}
@findex term-pager-toggle
@item C-c C-q
Toggle the page-at-a-time feature. This command works in both line
and char modes. When page-at-a-time is enabled, the mode-line
displays the word @samp{page}.
and char modes. When the feature is enabled, the mode-line displays