(Ffile_attributes): Don't return negative file sizes for
[bpt/emacs.git] / lispref / minibuf.texi
index 10dc146..1159602 100644 (file)
@@ -1,6 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. 
+@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001
+@c   Free Software Foundation, Inc. 
 @c See the file elisp.texi for copying conditions.
 @setfilename ../info/minibuf
 @node Minibuffers, Command Loop, Read and Print, Top
@@ -13,8 +14,8 @@
 arguments more complicated than the single numeric prefix argument.
 These arguments include file names, buffer names, and command names (as
 in @kbd{M-x}).  The minibuffer is displayed on the bottom line of the
-screen, in the same place as the echo area, but only while it is in
-use for reading an argument.
+frame, in the same place as the echo area, but only while it is in use
+for reading an argument.
 
 @menu
 * Intro to Minibuffers::      Basic information about minibuffers.
@@ -25,6 +26,7 @@ use for reading an argument.
 * Completion::                How to invoke and customize completion.
 * Yes-or-No Queries::         Asking a question with a simple answer.
 * Multiple Queries::         Asking a series of similar questions.
+* Reading a Password::       Reading a password from the terminal.
 * Minibuffer Misc::           Various customization hooks and variables.
 @end menu
 
@@ -35,18 +37,31 @@ use for reading an argument.
 @emph{within} a buffer, such as editing commands, work normally in a
 minibuffer.  However, many operations for managing buffers do not apply
 to minibuffers.  The name of a minibuffer always has the form @w{@samp{
-*Minibuf-@var{number}}}, and it cannot be changed.  Minibuffers are
+*Minibuf-@var{number}*}}, and it cannot be changed.  Minibuffers are
 displayed only in special windows used only for minibuffers; these
-windows always appear at the bottom of a frame.  (Sometime frames have
+windows always appear at the bottom of a frame.  (Sometimes frames have
 no minibuffer window, and sometimes a special kind of frame contains
 nothing but a minibuffer window; see @ref{Minibuffers and Frames}.)
 
-  The minibuffer's window is normally a single line.  You can resize it
-temporarily with the window sizing commands; it reverts to its normal
-size when the minibuffer is exited.  You can resize it permanently by
-using the window sizing commands in the frame's other window, when the
-minibuffer is not active.  If the frame contains just a minibuffer, you
-can change the minibuffer's size by changing the frame's size.
+  The text in the minibuffer always starts with the @dfn{prompt string},
+the text that was specified by the program that is using the minibuffer
+to tell the user what sort of input to type.  This text is marked
+read-only so you won't accidentally delete or change it.  It is also
+marked as a field (@pxref{Fields}), so that certain motion functions,
+including @code{beginning-of-line}, @code{forward-word},
+@code{forward-sentence}, and @code{forward-paragraph}, stop at the
+boundary between the prompt and the actual text.  (In older Emacs
+versions, the prompt was displayed using a special mechanism and was not
+part of the buffer contents.)
+
+  The minibuffer's window is normally a single line; it grows
+automatically if necessary if the contents require more space.  You can
+explicitly resize it temporarily with the window sizing commands; it
+reverts to its normal size when the minibuffer is exited.  You can
+resize it permanently by using the window sizing commands in the frame's
+other window, when the minibuffer is not active.  If the frame contains
+just a minibuffer, you can change the minibuffer's size by changing the
+frame's size.
 
   If a command uses a minibuffer while there is an active minibuffer,
 this is called a @dfn{recursive minibuffer}.  The first minibuffer is
@@ -61,7 +76,7 @@ name on command symbols (@pxref{Minibuffer Misc}).
 
   Like other buffers, a minibuffer may use any of several local keymaps
 (@pxref{Keymaps}); these contain various exit commands and in some cases
-completion commands.  @xref{Completion}.
+completion commands (@pxref{Completion}).
 
 @itemize @bullet
 @item
@@ -79,6 +94,10 @@ just like @key{RET}.  This is used mainly for Mocklisp compatibility.
 for cautious completion.
 @end itemize
 
+  When Emacs is running in batch mode, any request to read from the
+minibuffer actually reads a line from the standard input descriptor that
+was supplied when Emacs was started.
+
 @node Text from Minibuffer
 @section Reading Text Strings with the Minibuffer
 
@@ -87,26 +106,37 @@ also be used to read a Lisp object in textual form.  The most basic
 primitive for minibuffer input is @code{read-from-minibuffer}; it can do
 either one.
 
-@defun read-from-minibuffer prompt-string &optional initial-contents keymap read hist
+  In most cases, you should not call minibuffer input functions in the
+middle of a Lisp function.  Instead, do all minibuffer input as part of
+reading the arguments for a command, in the @code{interactive}
+specification.  @xref{Defining Commands}.
+
+@defun read-from-minibuffer prompt-string &optional initial-contents keymap read hist default inherit-input-method
 This function is the most general way to get input through the
 minibuffer.  By default, it accepts arbitrary text and returns it as a
 string; however, if @var{read} is non-@code{nil}, then it uses
 @code{read} to convert the text into a Lisp object (@pxref{Input
 Functions}).
 
-The first thing this function does is to activate a minibuffer and 
+The first thing this function does is to activate a minibuffer and
 display it with @var{prompt-string} as the prompt.  This value must be a
-string.
+string.  Then the user can edit text in the minibuffer.
 
-Then, if @var{initial-contents} is a string, @code{read-from-minibuffer}
-inserts it into the minibuffer, leaving point at the end.  The
-minibuffer appears with this text as its contents.
-
-@c Emacs 19 feature
-The value of @var{initial-contents} may also be a cons cell of the form
-@code{(@var{string} . @var{position})}.  This means to insert
-@var{string} in the minibuffer but put point @var{position} characters
-from the beginning, rather than at the end.
+When the user types a command to exit the minibuffer,
+@code{read-from-minibuffer} constructs the return value from the text in
+the minibuffer.  Normally it returns a string containing that text.
+However, if @var{read} is non-@code{nil}, @code{read-from-minibuffer}
+reads the text and returns the resulting Lisp object, unevaluated.
+(@xref{Input Functions}, for information about reading.)
+
+The argument @var{default} specifies a default value to make available
+through the history commands.  It should be a string, or @code{nil}.  If
+@var{read} is non-@code{nil}, then @var{default} is also used as the
+input to @code{read}, if the user enters empty input.  However, in the
+usual case (where @var{read} is @code{nil}), @code{read-from-minibuffer}
+does not return @var{default} when the user enters empty input; it
+returns an empty string, @code{""}.  In this respect, it is different
+from all the other minibuffer input functions in this chapter.
 
 If @var{keymap} is non-@code{nil}, that keymap is the local keymap to
 use in the minibuffer.  If @var{keymap} is omitted or @code{nil}, the
@@ -118,39 +148,82 @@ The argument @var{hist} specifies which history list variable to use
 for saving the input and for history commands used in the minibuffer.
 It defaults to @code{minibuffer-history}.  @xref{Minibuffer History}.
 
-When the user types a command to exit the minibuffer,
-@code{read-from-minibuffer} uses the text in the minibuffer to produce
-its return value.  Normally it simply makes a string containing that
-text.  However, if @var{read} is non-@code{nil},
-@code{read-from-minibuffer} reads the text and returns the resulting
-Lisp object, unevaluated.  (@xref{Input Functions}, for information
-about reading.)
+If the variable @code{minibuffer-allow-text-properties} is
+non-@code{nil}, then the string which is returned includes whatever text
+properties were present in the minibuffer.  Otherwise all the text
+properties are stripped when the value is returned.
+
+If the argument @var{inherit-input-method} is non-@code{nil}, then the
+minibuffer inherits the current input method (@pxref{Input Methods}) and
+the setting of @code{enable-multibyte-characters} (@pxref{Text
+Representations}) from whichever buffer was current before entering the
+minibuffer.
+
+If @var{initial-contents} is a string, @code{read-from-minibuffer}
+inserts it into the minibuffer, leaving point at the end, before the
+user starts to edit the text.  The minibuffer appears with this text as
+its initial contents.
+
+Alternatively, @var{initial-contents} can be a cons cell of the form
+@code{(@var{string} . @var{position})}.  This means to insert
+@var{string} in the minibuffer but put point @var{position} characters
+from the beginning, rather than at the end.
+
+@strong{Usage note:} The @var{initial-contents} argument and the
+@var{default} argument are two alternative features for more or less the
+same job.  It does not make sense to use both features in a single call
+to @code{read-from-minibuffer}.  In general, we recommend using
+@var{default}, since this permits the user to insert the default value
+when it is wanted, but does not burden the user with deleting it from
+the minibuffer on other occasions.
 @end defun
 
-@defun read-string prompt &optional initial
+@defun read-string prompt &optional initial history default inherit-input-method
 This function reads a string from the minibuffer and returns it.  The
 arguments @var{prompt} and @var{initial} are used as in
 @code{read-from-minibuffer}.  The keymap used is
 @code{minibuffer-local-map}.
 
-This is a simplified interface to the
+The optional argument @var{history}, if non-nil, specifies a history
+list and optionally the initial position in the list.  The optional
+argument @var{default} specifies a default value to return if the user
+enters null input; it should be a string.  The optional argument
+@var{inherit-input-method} specifies whether to inherit the current
+buffer's input method.
+
+This function is a simplified interface to the
 @code{read-from-minibuffer} function:
 
 @smallexample
 @group
-(read-string @var{prompt} @var{initial})
+(read-string @var{prompt} @var{initial} @var{history} @var{default} @var{inherit})
 @equiv{}
-(read-from-minibuffer @var{prompt} @var{initial} nil nil nil)
+(let ((value
+       (read-from-minibuffer @var{prompt} @var{initial} nil nil
+                             @var{history} @var{default} @var{inherit})))
+  (if (equal value "")
+      @var{default}
+    value))
 @end group
 @end smallexample
 @end defun
 
+@defvar minibuffer-allow-text-properties
+If this variable is @code{nil}, then @code{read-from-minibuffer} strips
+all text properties from the minibuffer input before returning it.
+Since all minibuffer input uses @code{read-from-minibuffer}, this
+variable applies to all minibuffer input.
+
+Note that the completion functions discard text properties unconditionally,
+regardless of the value of this variable.
+@end defvar
+
 @defvar minibuffer-local-map
 This is the default local keymap for reading from the minibuffer.  By
 default, it makes the following bindings:
 
 @table @asis
-@item @key{LFD}
+@item @kbd{C-j}
 @code{exit-minibuffer}
 
 @item @key{RET}
@@ -175,11 +248,11 @@ default, it makes the following bindings:
 
 @c In version 18, initial is required
 @c Emacs 19 feature
-@defun read-no-blanks-input prompt &optional initial
+@defun read-no-blanks-input prompt &optional initial inherit-input-method
 This function reads a string from the minibuffer, but does not allow
 whitespace characters as part of the input: instead, those characters
-terminate the input.  The arguments @var{prompt} and @var{initial} are
-used as in @code{read-from-minibuffer}.
+terminate the input.  The arguments @var{prompt}, @var{initial}, and
+@var{inherit-input-method} are used as in @code{read-from-minibuffer}.
 
 This is a simplified interface to the @code{read-from-minibuffer}
 function, and passes the value of the @code{minibuffer-local-ns-map}
@@ -199,12 +272,9 @@ possible to put a space into the string, by quoting it.
 @defvar minibuffer-local-ns-map
 This built-in variable is the keymap used as the minibuffer local keymap
 in the function @code{read-no-blanks-input}.  By default, it makes the
-following bindings:
+following bindings, in addition to those of @code{minibuffer-local-map}:
 
 @table @asis
-@item @key{LFD}
-@code{exit-minibuffer}
-
 @item @key{SPC}
 @cindex @key{SPC} in minibuffer
 @code{exit-minibuffer}
@@ -213,27 +283,9 @@ following bindings:
 @cindex @key{TAB} in minibuffer
 @code{exit-minibuffer}
 
-@item @key{RET}
-@code{exit-minibuffer}
-
-@item @kbd{C-g}
-@code{abort-recursive-edit}
-
 @item @kbd{?}
 @cindex @kbd{?} in minibuffer
 @code{self-insert-and-exit}
-
-@item @kbd{M-n}
-@code{next-history-element}
-
-@item @kbd{M-p}
-@code{previous-history-element}
-
-@item @kbd{M-r}
-@code{next-matching-history-element}
-
-@item @kbd{M-s}
-@code{previous-matching-history-element}
 @end table
 @end defvar
 
@@ -244,7 +296,7 @@ following bindings:
 minibuffer.
 
 @defun read-minibuffer prompt &optional initial
-This function reads a Lisp object in the minibuffer and returns it,
+This function reads a Lisp object using the minibuffer, and returns it
 without evaluating it.  The arguments @var{prompt} and @var{initial} are
 used as in @code{read-from-minibuffer}.
 
@@ -283,9 +335,9 @@ default, or can edit the input.
 @end defun
 
 @defun eval-minibuffer prompt &optional initial
-This function reads a Lisp expression in the minibuffer, evaluates it,
-then returns the result.  The arguments @var{prompt} and @var{initial}
-are used as in @code{read-from-minibuffer}.
+This function reads a Lisp expression using the minibuffer, evaluates
+it, then returns the result.  The arguments @var{prompt} and
+@var{initial} are used as in @code{read-from-minibuffer}.
 
 This function simply evaluates the result of a call to
 @code{read-minibuffer}:
@@ -310,7 +362,7 @@ appear in the initial text.  @xref{Output Functions}.
 
 The first thing @code{edit-and-eval-command} does is to activate the
 minibuffer with @var{prompt} as the prompt.  Then it inserts the printed
-representation of @var{form} in the minibuffer, and lets the user edit.
+representation of @var{form} in the minibuffer, and lets the user edit it.
 When the user exits the minibuffer, the edited text is read with
 @code{read} and then evaluated.  The resulting value becomes the value
 of @code{edit-and-eval-command}.
@@ -344,16 +396,16 @@ expression, thus moving point forward one word.
 @cindex minibuffer history
 @cindex history list
 
-A @dfn{minibuffer history list} records previous minibuffer inputs so
+  A @dfn{minibuffer history list} records previous minibuffer inputs so
 the user can reuse them conveniently.  A history list is actually a
 symbol, not a list; it is a variable whose value is a list of strings
 (previous inputs), most recent first.
 
-There are many separate history lists, used for different kinds of
+  There are many separate history lists, used for different kinds of
 inputs.  It's the Lisp programmer's job to specify the right history
 list for each use of the minibuffer.
 
-The basic minibuffer input functions @code{read-from-minibuffer} and
+  The basic minibuffer input functions @code{read-from-minibuffer} and
 @code{completing-read} both accept an optional argument named @var{hist}
 which is how you specify the history list.  Here are the possible
 values:
@@ -371,18 +423,20 @@ If you specify @var{startpos}, then you should also specify that element
 of the history as the initial minibuffer contents, for consistency.
 @end table
 
-If you don't specify @var{hist}, then the default history list
+  If you don't specify @var{hist}, then the default history list
 @code{minibuffer-history} is used.  For other standard history lists,
 see below.  You can also create your own history list variable; just
 initialize it to @code{nil} before the first use.
 
-Both @code{read-from-minibuffer} and @code{completing-read} add new
+  Both @code{read-from-minibuffer} and @code{completing-read} add new
 elements to the history list automatically, and provide commands to
 allow the user to reuse items on the list.  The only thing your program
 needs to do to use a history list is to initialize it and to pass its
 name to the input functions when you wish.  But it is safe to modify the
 list by hand when the minibuffer input functions are not using it.
 
+  Here are some of the standard minibuffer history list variables:
+
 @defvar minibuffer-history
 The default history list for minibuffer history input.
 @end defvar
@@ -393,7 +447,11 @@ arguments to other commands).
 @end defvar
 
 @defvar file-name-history
-A history list for file name arguments.
+A history list for file-name arguments.
+@end defvar
+
+@defvar buffer-name-history
+A history list for buffer-name arguments.
 @end defvar
 
 @defvar regexp-history
@@ -556,16 +614,15 @@ too short).  Both of those begin with the string @samp{foobar}.
 
 @defun all-completions string collection &optional predicate nospace
 This function returns a list of all possible completions of
-@var{string}.  The parameters to this function are the same as to
-@code{try-completion}.
+@var{string}.  The arguments to this function (aside from @var{nospace})
+are the same as those of @code{try-completion}.  If @var{nospace} is
+non-@code{nil}, completions that start with a space are ignored unless
+@var{string} also starts with a space.
 
 If @var{collection} is a function, it is called with three arguments:
 @var{string}, @var{predicate} and @code{t}; then @code{all-completions}
 returns whatever the function returns.  @xref{Programmed Completion}.
 
-If @var{nospace} is non-@code{nil}, completions that start with a space
-are ignored unless @var{string} also starts with a space.
-
 Here is an example, using the function @code{test} shown in the
 example for @code{try-completion}:
 
@@ -597,30 +654,33 @@ non-@code{nil}, Emacs does not consider case significant in completion.
   This section describes the basic interface for reading from the
 minibuffer with completion.
 
-@defun completing-read prompt collection &optional predicate require-match initial hist
+@defun completing-read prompt collection &optional predicate require-match initial hist default inherit-input-method
 This function reads a string in the minibuffer, assisting the user by
 providing completion.  It activates the minibuffer with prompt
-@var{prompt}, which must be a string.  If @var{initial} is
-non-@code{nil}, @code{completing-read} inserts it into the minibuffer as
-part of the input.  Then it allows the user to edit the input, providing
-several commands to attempt completion.
+@var{prompt}, which must be a string.
 
 The actual completion is done by passing @var{collection} and
 @var{predicate} to the function @code{try-completion}.  This happens in
 certain commands bound in the local keymaps used for completion.
 
-If @var{require-match} is @code{t}, the usual minibuffer exit commands
-won't exit unless the input completes to an element of @var{collection}.
-If @var{require-match} is neither @code{nil} nor @code{t}, then the exit
-commands won't exit unless the input typed is itself an element of
-@var{collection}.  If @var{require-match} is @code{nil}, the exit
-commands work regardless of the input in the minibuffer.
+If @var{require-match} is @code{nil}, the exit commands work regardless
+of the input in the minibuffer.  If @var{require-match} is @code{t}, the
+usual minibuffer exit commands won't exit unless the input completes to
+an element of @var{collection}.  If @var{require-match} is neither
+@code{nil} nor @code{t}, then the exit commands won't exit unless the
+input already in the buffer matches an element of @var{collection}.
+
+However, empty input is always permitted, regardless of the value of
+@var{require-match}; in that case, @code{completing-read} returns
+@var{default}.  The value of @var{default} (if non-@code{nil}) is also
+available to the user through the history commands.
 
 The user can exit with null input by typing @key{RET} with an empty
-minibuffer.  Then @code{completing-read} returns @code{nil}.  This is
-how the user requests whatever default the command uses for the value
-being read.  The user can return using @key{RET} in this way regardless
-of the value of @var{require-match}.
+minibuffer.  Then @code{completing-read} returns @code{""}.  This is how
+the user requests whatever default the command uses for the value being
+read.  The user can return using @key{RET} in this way regardless of the
+value of @var{require-match}, and regardless of whether the empty string
+is included in @var{collection}.
 
 The function @code{completing-read} works by calling
 @code{read-minibuffer}.  It uses @code{minibuffer-local-completion-map}
@@ -632,6 +692,23 @@ The argument @var{hist} specifies which history list variable to use for
 saving the input and for minibuffer history commands.  It defaults to
 @code{minibuffer-history}.  @xref{Minibuffer History}.
 
+If @var{initial} is non-@code{nil}, @code{completing-read} inserts it
+into the minibuffer as part of the input.  Then it allows the user to
+edit the input, providing several commands to attempt completion.
+In most cases, we recommend using @var{default}, and not @var{initial}.
+
+@strong{We discourage use of a non-@code{nil} value for
+@var{initial}}, because it is an intrusive interface.  The history
+list feature (which did not exist when we introduced @var{initial})
+offers a far more convenient and general way for the user to get the
+default and edit it, and it is always available.
+
+If the argument @var{inherit-input-method} is non-@code{nil}, then the
+minibuffer inherits the current input method (@pxref{Input
+Methods}) and the setting of @code{enable-multibyte-characters}
+(@pxref{Text Representations}) from whichever buffer was current before
+entering the minibuffer.
+
 Completion ignores case when comparing the input against the possible
 matches, if the built-in variable @code{completion-ignore-case} is
 non-@code{nil}.  @xref{Basic Completion}.
@@ -669,7 +746,7 @@ see @ref{Completion Commands}.
 @end defun
 
 @node Completion Commands
-@subsection Minibuffer Commands That Do Completion
+@subsection Minibuffer Commands that Do Completion
 
   This section describes the keymaps, commands and user options used in
 the minibuffer to do completion.
@@ -712,7 +789,7 @@ bindings:
 @item @key{TAB}
 @code{minibuffer-complete}
 
-@item @key{LFD}
+@item @kbd{C-j}
 @code{minibuffer-complete-and-exit}
 
 @item @key{RET}
@@ -750,7 +827,7 @@ This function completes the minibuffer contents as far as possible.
 @deffn Command minibuffer-complete-and-exit
 This function completes the minibuffer contents, and exits if
 confirmation is not required, i.e., if
-@code{minibuffer-completion-confirm} is non-@code{nil}.  If confirmation
+@code{minibuffer-completion-confirm} is @code{nil}.  If confirmation
 @emph{is} required, it is given by repeating this command
 immediately---the command is programmed to work without confirmation
 when run twice in succession.
@@ -805,6 +882,11 @@ can be completed because the next character is not uniquely determined.
   This section describes the higher-level convenient functions for
 reading certain sorts of names with completion.
 
+  In most cases, you should not call these functions in the middle of a
+Lisp function.  When possible, do all minibuffer input as part of
+reading the arguments for a command, in the @code{interactive}
+specification.  @xref{Defining Commands}.
+
 @defun read-buffer prompt &optional default existing
 This function reads the name of a buffer and returns it as a string.
 The argument @var{default} is the default name to use, the value to
@@ -845,13 +927,26 @@ Buffer name? (default foo) @point{}
 @end example
 @end defun
 
-@defun read-command prompt
+@defvar read-buffer-function
+This variable specifies how to read buffer names.  For example, if you
+set this variable to @code{iswitchb-read-buffer}, all Emacs commands
+that call @code{read-buffer} to read a buffer name will actually use the
+@code{iswitchb} package to read it.
+@end defvar
+
+@defun read-command prompt &optional default
 This function reads the name of a command and returns it as a Lisp
 symbol.  The argument @var{prompt} is used as in
 @code{read-from-minibuffer}.  Recall that a command is anything for
 which @code{commandp} returns @code{t}, and a command name is a symbol
 for which @code{commandp} returns @code{t}.  @xref{Interactive Call}.
 
+The argument @var{default} specifies what to return if the user enters
+null input.  It can be a symbol or a string; if it is a string,
+@code{read-command} interns it before returning it.  If @var{default} is
+@code{nil}, that means no default has been specified; then if the user
+enters null input, the return value is @code{nil}.
+
 @example
 (read-command "Command name? ")
 
@@ -871,9 +966,9 @@ Command name?
 If the user types @kbd{forward-c @key{RET}}, then this function returns
 @code{forward-char}.
 
-The @code{read-command} function is a simplified interface to the
-function @code{completing-read}.  It uses the variable @code{obarray} so
-as to complete in the set of extant Lisp symbols, and it uses the
+The @code{read-command} function is a simplified interface to
+@code{completing-read}.  It uses the variable @code{obarray} so as to
+complete in the set of extant Lisp symbols, and it uses the
 @code{commandp} predicate so as to accept only command names:
 
 @cindex @code{commandp} example
@@ -887,10 +982,16 @@ as to complete in the set of extant Lisp symbols, and it uses the
 @end example
 @end defun
 
-@defun read-variable prompt
+@defun read-variable prompt &optional default
 This function reads the name of a user variable and returns it as a
 symbol.
 
+The argument @var{default} specifies what to return if the user enters
+null input.  It can be a symbol or a string; if it is a string,
+@code{read-variable} interns it before returning it.  If @var{default}
+is @code{nil}, that means no default has been specified; then if the
+user enters null input, the return value is @code{nil}.
+
 @example
 @group
 (read-variable "Variable name? ")
@@ -926,6 +1027,9 @@ predicate @code{user-variable-p} instead of @code{commandp}:
 @end example
 @end defun
 
+  See also the functions @code{read-coding-system} and
+@code{read-non-nil-coding-system}, in @ref{User-Chosen Coding Systems}.
+
 @node Reading File Names
 @subsection Reading File Names
 
@@ -956,10 +1060,11 @@ initial input.  It defaults to the current buffer's value of
 
 @c Emacs 19 feature
 If you specify @var{initial}, that is an initial file name to insert in
-the buffer (after with @var{directory}, if that is inserted).  In this
+the buffer (after @var{directory}, if that is inserted).  In this
 case, point goes at the beginning of @var{initial}.  The default for
 @var{initial} is @code{nil}---don't insert any file name.  To see what
-@var{initial} does, try the command @kbd{C-x C-v}.
+@var{initial} does, try the command @kbd{C-x C-v}.  @strong{Note:} we
+recommend using @var{default} rather than @var{initial} in most cases.
 
 Here is an example: 
 
@@ -1000,7 +1105,8 @@ This variable is used by @code{read-file-name}.  Its value controls
 whether @code{read-file-name} starts by placing the name of the default
 directory in the minibuffer, plus the initial file name if any.  If the
 value of this variable is @code{nil}, then @code{read-file-name} does
-not place any initial input in the minibuffer.  In that case, the
+not place any initial input in the minibuffer (unless you specify
+initial input with the @var{initial} argument).  In that case, the
 default directory is still used for completion of relative file names,
 but is not displayed.
 
@@ -1070,8 +1176,12 @@ A flag specifying the type of operation.
 @item
 @code{nil} specifies @code{try-completion}.  The completion function
 should return the completion of the specified string, or @code{t} if the
-string is an exact match already, or @code{nil} if the string matches no
-possibility.
+string is a unique and exact match already, or @code{nil} if the string
+matches no possibility.
+
+If the string is an exact match for one possibility, but also matches
+other longer possibilities, the function should return the string, not
+@code{t}.
 
 @item
 @code{t} specifies @code{all-completions}.  The completion function
@@ -1085,7 +1195,7 @@ match for some possibility; @code{nil} otherwise.
 @end itemize
 
   It would be consistent and clean for completion functions to allow
-lambda expressions (lists tha are functions) as well as function
+lambda expressions (lists that are functions) as well as function
 symbols as @var{collection}, but this is impossible.  Lists as
 completion tables are already assigned another meaning---as alists.  It
 would be unreliable to fail to handle an alist normally because it is
@@ -1184,6 +1294,13 @@ We show successive lines of echo area messages, but only one actually
 appears on the screen at a time.
 @end defun
 
+@defun y-or-n-p-with-timeout prompt seconds default-value
+Like @code{y-or-n-p}, except that if the user fails to answer within
+@var{seconds} seconds, this function stops waiting and returns
+@var{default-value}.  It works by setting up a timer; see @ref{Timers}.
+The argument @var{seconds} may be an integer or a floating point number.
+@end defun
+
 @defun yes-or-no-p prompt
 This function asks the user a question, expecting input in the
 minibuffer.  It returns @code{t} if the user enters @samp{yes},
@@ -1241,9 +1358,9 @@ asking each question individually.  This gives the user certain
 convenient facilities such as the ability to answer the whole series at
 once.
 
-@defun map-y-or-n-p prompter actor list &optional help action-alist
-This function, new in Emacs 19, asks the user a series of questions,
-reading a single-character answer in the echo area for each one.
+@defun map-y-or-n-p prompter actor list &optional help action-alist no-cursor-in-echo-area
+This function asks the user a series of questions, reading a
+single-character answer in the echo area for each one.
 
 The value of @var{list} specifies the objects to ask questions about.
 It should be either a list of objects or a generator function.  If it is
@@ -1262,7 +1379,11 @@ where @var{object} is the next object to ask about (as obtained from
 @var{list}).
 
 If not a string, @var{prompter} should be a function of one argument
-(the next object to ask about) and should return the question text.
+(the next object to ask about) and should return the question text.  If
+the value is a string, that is the question to ask the user.  The
+function can also return @code{t} meaning do act on this object (and
+don't ask the user), or @code{nil} meaning ignore this object (and don't
+ask the user).
 
 The argument @var{actor} says how to act on the answers that the user
 gives.  It should be a function of one argument, and it is called with
@@ -1306,6 +1427,10 @@ When the user responds with @var{char}, @code{map-y-or-n-p} calls
 @var{list}.  If it returns @code{nil}, the prompt is repeated for the
 same object.
 
+Normally, @code{map-y-or-n-p} binds @code{cursor-in-echo-area} while
+prompting.  But if @var{no-cursor-in-echo-area} is non-@code{nil}, it
+does not do that.
+
 If @code{map-y-or-n-p} is called in a command that was invoked using the
 mouse---more precisely, if @code{last-nonmenu-event} (@pxref{Command
 Loop Info}) is either @code{nil} or a list---then it uses a dialog box
@@ -1317,8 +1442,29 @@ value around the call.
 The return value of @code{map-y-or-n-p} is the number of objects acted on.
 @end defun
 
+@node Reading a Password
+@section Reading a Password
+@cindex passwords, reading
+
+  To read a password to pass to another program, you can use the
+function @code{read-passwd}.
+
+@defun read-passwd prompt &optional confirm default
+This function reads a password, prompting with @var{prompt}.  It does
+not echo the password as the user types it; instead, it echoes @samp{.}
+for each character in the password.
+
+The optional argument @var{confirm}, if non-@code{nil}, says to read the
+password twice and insist it must be the same both times.  If it isn't
+the same, the user has to type it over and over until the last two
+times match.
+
+The optional argument @var{default} specifies the default password to
+return if the user enters empty input.  If @var{default} is @code{nil},
+then @code{read-passwd} returns the null string in that case.
+@end defun
+
 @node Minibuffer Misc
-@comment  node-name,  next,  previous,  up
 @section Minibuffer Miscellany
 
   This section describes some basic functions and variables related to
@@ -1345,18 +1491,56 @@ This command replaces the minibuffer contents with the value of the
 @var{n}th more recent history element.
 @end deffn
 
-@deffn Command previous-matching-history-element pattern
+@deffn Command previous-matching-history-element pattern n
 This command replaces the minibuffer contents with the value of the
-previous (older) history element that matches @var{pattern} (a regular
-expression).
+@var{n}th previous (older) history element that matches @var{pattern} (a
+regular expression).
 @end deffn
 
-@deffn Command next-matching-history-element pattern
-This command replaces the minibuffer contents with the value of the next
-(newer) history element that matches @var{pattern} (a regular
-expression).
+@deffn Command next-matching-history-element pattern n
+This command replaces the minibuffer contents with the value of the
+@var{n}th next (newer) history element that matches @var{pattern} (a
+regular expression).
 @end deffn
 
+@defun minibuffer-prompt
+This function returns the prompt string of the currently active
+minibuffer.  If no minibuffer is active, it returns @code{nil}.
+@end defun
+
+@defun minibuffer-prompt-end
+@tindex minibuffer-prompt-end
+This function, available starting in Emacs 21, returns the current
+position of the end of the minibuffer prompt, if a minibuffer is
+current.  Otherwise, it returns the minimum valid buffer position.
+@end defun
+
+@defun minibuffer-contents
+@tindex minibuffer-contents
+This function, available starting in Emacs 21, returns the editable
+contents of the minibuffer (that is, everything except the prompt) as
+a string, if a minibuffer is current.  Otherwise, it returns the
+entire contents of the current buffer.
+@end defun
+
+@defun minibuffer-contents-no-properties
+@tindex minibuffer-contents-no-properties
+This is like @code{minibuffer-contents}, except that it does not copy text
+properties, just the characters themselves.  @xref{Text Properties}.
+@end defun
+
+@defun delete-minibuffer-contents
+@tindex delete-minibuffer-contents
+This function, available starting in Emacs 21, erases the editable
+contents of the minibuffer (that is, everything except the prompt), if
+a minibuffer is current.  Otherwise, it erases the entire buffer.
+@end defun
+
+@defun minibuffer-prompt-width
+This function returns the current display-width of the minibuffer
+prompt, if a minibuffer is current.  Otherwise, it returns zero.
+@end defun
+
 @defvar minibuffer-setup-hook
 This is a normal hook that is run whenever the minibuffer is entered.
 @xref{Hooks}.
@@ -1415,32 +1599,21 @@ minibuffer, a nonnegative integer.  If no minibuffers are active, it
 returns zero.
 @end defun
 
-@defun minibuffer-prompt
-This function returns the prompt string of the currently active
-minibuffer.  If no minibuffer is active, it returns @code{nil}.
-@end defun
-
-@defun minibuffer-prompt-width
-This function returns the display width of the prompt string of the
-currently active minibuffer.  If no minibuffer is active, it returns 0.
-@end defun
-
 @defopt enable-recursive-minibuffers
 If this variable is non-@code{nil}, you can invoke commands (such as
-@code{find-file}) that use minibuffers even while in the minibuffer
-window.  Such invocation produces a recursive editing level for a new
+@code{find-file}) that use minibuffers even while the minibuffer window
+is active.  Such invocation produces a recursive editing level for a new
 minibuffer.  The outer-level minibuffer is invisible while you are
 editing the inner one.
 
-This variable only affects invoking the minibuffer while the
-minibuffer window is selected.   If you switch windows while in the 
-minibuffer, you can always invoke minibuffer commands while some other
-window is selected.
+If this variable is @code{nil}, you cannot invoke minibuffer
+commands when the minibuffer window is active, not even if you switch to
+another window to do it.
 @end defopt
 
 @c Emacs 19 feature
 If a command name has a property @code{enable-recursive-minibuffers}
 that is non-@code{nil}, then the command can use the minibuffer to read
 arguments even if it is invoked from the minibuffer.  The minibuffer
-command @code{next-matching-history-element} (normally bound to
-@kbd{M-s} in the minibuffer) uses this feature.
+command @code{next-matching-history-element} (normally @kbd{M-s} in the
+minibuffer) uses this feature.