manpagez: man pages & more
info emacs
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

41.4 Shell Prompts

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 comint-use-prompt-regexp is non-nil, then Comint mode uses a regular expression to recognize prompts. In Shell mode, shell-prompt-pattern specifies the regular expression.

The value of comint-use-prompt-regexp also affects many motion and paragraph commands. If the value is non-nil, the general Emacs motion commands behave as they normally do in buffers without special text properties. However, if the value is nil, the default, then Comint mode divides the buffer into two types of “fields” (ranges of consecutive characters having the same 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, C-a puts point at the beginning of the input if comint-use-prompt-regexp is 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 comint-use-prompt-regexp is 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 shell-prompt-pattern, regardless of comint-use-prompt-regexp.

© 2000-2017
Individual documents may contain additional copyright information.