aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Teirlinck2004-02-04 03:08:59 +0000
committerLuc Teirlinck2004-02-04 03:08:59 +0000
commit4b574f3d8ec5dc9a58a89d970e09715041d9f4a0 (patch)
tree0f4d579037fd9c442d6236ee3b41cd580d526ab5
parent13c5d120fc89e35407b0092bef93c809a0b715fd (diff)
downloademacs-4b574f3d8ec5dc9a58a89d970e09715041d9f4a0.tar.gz
emacs-4b574f3d8ec5dc9a58a89d970e09715041d9f4a0.zip
(Text from Minibuffer): Various corrections and clarifications.
(Object from Minibuffer): Correct Lisp description of read-minibuffer. (Minibuffer History): Clarify description of cons values for HISTORY arguments. (Basic Completion): Various corrections and clarifications. Add completion-regexp-list. (Minibuffer Completion): Correct and clarify description of completing-read. (Completion Commands): Mention partial-completion-mode. Various other minor changes. (High-Level Completion): Various corrections and clarifications. (Reading File Names): Ditto. (Minibuffer Misc): Ditto.
-rw-r--r--lispref/ChangeLog18
-rw-r--r--lispref/minibuf.texi337
2 files changed, 247 insertions, 108 deletions
diff --git a/lispref/ChangeLog b/lispref/ChangeLog
index 20dd4f13d03..7ec7f992ea0 100644
--- a/lispref/ChangeLog
+++ b/lispref/ChangeLog
@@ -1,3 +1,21 @@
12004-02-03 Luc Teirlinck <teirllm@auburn.edu>
2
3 * minibuf.texi (Text from Minibuffer): Various corrections and
4 clarifications.
5 (Object from Minibuffer): Correct Lisp description of
6 read-minibuffer.
7 (Minibuffer History): Clarify description of cons values for
8 HISTORY arguments.
9 (Basic Completion): Various corrections and clarifications. Add
10 completion-regexp-list.
11 (Minibuffer Completion): Correct and clarify description of
12 completing-read.
13 (Completion Commands): Mention partial-completion-mode. Various
14 other minor changes.
15 (High-Level Completion): Various corrections and clarifications.
16 (Reading File Names): Ditto.
17 (Minibuffer Misc): Ditto.
18
12004-01-26 Luc Teirlinck <teirllm@auburn.edu> 192004-01-26 Luc Teirlinck <teirllm@auburn.edu>
2 20
3 * strings.texi (Text Comparison): assoc-string also matches 21 * strings.texi (Text Comparison): assoc-string also matches
diff --git a/lispref/minibuf.texi b/lispref/minibuf.texi
index 473859ccd6c..e0e2e4a80b1 100644
--- a/lispref/minibuf.texi
+++ b/lispref/minibuf.texi
@@ -135,13 +135,17 @@ reads the text and returns the resulting Lisp object, unevaluated.
135(@xref{Input Functions}, for information about reading.) 135(@xref{Input Functions}, for information about reading.)
136 136
137The argument @var{default} specifies a default value to make available 137The argument @var{default} specifies a default value to make available
138through the history commands. It should be a string, or @code{nil}. If 138through the history commands. It should be a string, or @code{nil}.
139@var{read} is non-@code{nil}, then @var{default} is also used as the 139If non-@code{nil}, the user can access it using
140input to @code{read}, if the user enters empty input. However, in the 140@code{next-history-element}, usually bound in the minibuffer to
141usual case (where @var{read} is @code{nil}), @code{read-from-minibuffer} 141@kbd{M-n}. If @var{read} is non-@code{nil}, then @var{default} is
142does not return @var{default} when the user enters empty input; it 142also used as the input to @code{read}, if the user enters empty input.
143returns an empty string, @code{""}. In this respect, it is different 143(If @var{read} is non-@code{nil} and @var{default} is @code{nil}, empty
144from all the other minibuffer input functions in this chapter. 144input results in an @code{end-of-file} error.) However, in the usual
145case (where @var{read} is @code{nil}), @code{read-from-minibuffer}
146ignores @var{default} when the user enters empty input and returns an
147empty string, @code{""}. In this respect, it is different from all
148the other minibuffer input functions in this chapter.
145 149
146If @var{keymap} is non-@code{nil}, that keymap is the local keymap to 150If @var{keymap} is non-@code{nil}, that keymap is the local keymap to
147use in the minibuffer. If @var{keymap} is omitted or @code{nil}, the 151use in the minibuffer. If @var{keymap} is omitted or @code{nil}, the
@@ -171,8 +175,9 @@ its initial contents.
171 175
172Alternatively, @var{initial-contents} can be a cons cell of the form 176Alternatively, @var{initial-contents} can be a cons cell of the form
173@code{(@var{string} . @var{position})}. This means to insert 177@code{(@var{string} . @var{position})}. This means to insert
174@var{string} in the minibuffer but put point @var{position} characters 178@var{string} in the minibuffer but put point at @emph{one-indexed}
175from the beginning, rather than at the end. 179@var{position} in the minibuffer, rather than at the end. Any integer
180value less or equal to one puts point at the beginning of the string.
176 181
177@strong{Usage note:} The @var{initial-contents} argument and the 182@strong{Usage note:} The @var{initial-contents} argument and the
178@var{default} argument are two alternative features for more or less the 183@var{default} argument are two alternative features for more or less the
@@ -180,21 +185,21 @@ same job. It does not make sense to use both features in a single call
180to @code{read-from-minibuffer}. In general, we recommend using 185to @code{read-from-minibuffer}. In general, we recommend using
181@var{default}, since this permits the user to insert the default value 186@var{default}, since this permits the user to insert the default value
182when it is wanted, but does not burden the user with deleting it from 187when it is wanted, but does not burden the user with deleting it from
183the minibuffer on other occasions. 188the minibuffer on other occasions. For an exception to this rule,
189see @ref{Minibuffer History}.
184@end defun 190@end defun
185 191
186@defun read-string prompt &optional initial history default inherit-input-method 192@defun read-string prompt &optional initial history default inherit-input-method
187This function reads a string from the minibuffer and returns it. The 193This function reads a string from the minibuffer and returns it. The
188arguments @var{prompt} and @var{initial} are used as in 194arguments @var{prompt}, @var{initial}, @var{history} and
189@code{read-from-minibuffer}. The keymap used is 195@var{inherit-input-method} are used as in @code{read-from-minibuffer}.
190@code{minibuffer-local-map}. 196The keymap used is @code{minibuffer-local-map}.
191 197
192The optional argument @var{history}, if non-@code{nil}, specifies a 198The optional argument @var{default} is used as in
193history list and optionally the initial position in the list. The 199@code{read-from-minibuffer}, except that, if non-@code{nil}, it also
194optional argument @var{default} specifies a default value to return if 200specifies a default value to return if the user enters null input. As
195the user enters null input; it should be a string. The optional 201in @code{read-from-minibuffer} it should be a string, or @code{nil},
196argument @var{inherit-input-method} specifies whether to inherit the 202which is equivalent to an empty string.
197current buffer's input method.
198 203
199This function is a simplified interface to the 204This function is a simplified interface to the
200@code{read-from-minibuffer} function: 205@code{read-from-minibuffer} function:
@@ -206,7 +211,7 @@ This function is a simplified interface to the
206(let ((value 211(let ((value
207 (read-from-minibuffer @var{prompt} @var{initial} nil nil 212 (read-from-minibuffer @var{prompt} @var{initial} nil nil
208 @var{history} @var{default} @var{inherit}))) 213 @var{history} @var{default} @var{inherit})))
209 (if (equal value "") 214 (if (and (equal value "") @var{default})
210 @var{default} 215 @var{default}
211 value)) 216 value))
212@end group 217@end group
@@ -216,13 +221,15 @@ This function is a simplified interface to the
216@defvar minibuffer-allow-text-properties 221@defvar minibuffer-allow-text-properties
217If this variable is @code{nil}, then @code{read-from-minibuffer} strips 222If this variable is @code{nil}, then @code{read-from-minibuffer} strips
218all text properties from the minibuffer input before returning it. 223all text properties from the minibuffer input before returning it.
219Since all minibuffer input uses @code{read-from-minibuffer}, this 224This variable also affects @code{read-string}. However,
220variable applies to all minibuffer input. 225@code{read-no-blanks-input} (see below), as well as
221 226@code{read-minibuffer} and related functions (@pxref{Object from
222Note that the completion functions discard text properties unconditionally, 227Minibuffer,, Reading Lisp Objects With the Minibuffer}), and all
223regardless of the value of this variable. 228functions that do minibuffer input with completion, discard text
229properties unconditionally, regardless of the value of this variable.
224@end defvar 230@end defvar
225 231
232@anchor{Definition of minibuffer-local-map}
226@defvar minibuffer-local-map 233@defvar minibuffer-local-map
227This is the default local keymap for reading from the minibuffer. By 234This is the default local keymap for reading from the minibuffer. By
228default, it makes the following bindings: 235default, it makes the following bindings:
@@ -243,10 +250,10 @@ default, it makes the following bindings:
243@item @kbd{M-p} 250@item @kbd{M-p}
244@code{previous-history-element} 251@code{previous-history-element}
245 252
246@item @kbd{M-r} 253@item @kbd{M-s}
247@code{next-matching-history-element} 254@code{next-matching-history-element}
248 255
249@item @kbd{M-s} 256@item @kbd{M-r}
250@code{previous-matching-history-element} 257@code{previous-matching-history-element}
251@end table 258@end table
252@end defvar 259@end defvar
@@ -265,11 +272,15 @@ keymap as the @var{keymap} argument for that function. Since the keymap
265@code{minibuffer-local-ns-map} does not rebind @kbd{C-q}, it @emph{is} 272@code{minibuffer-local-ns-map} does not rebind @kbd{C-q}, it @emph{is}
266possible to put a space into the string, by quoting it. 273possible to put a space into the string, by quoting it.
267 274
275This function discards text properties, regardless of the value of
276@code{minibuffer-allow-text-properties}.
277
268@smallexample 278@smallexample
269@group 279@group
270(read-no-blanks-input @var{prompt} @var{initial}) 280(read-no-blanks-input @var{prompt} @var{initial})
271@equiv{} 281@equiv{}
272(read-from-minibuffer @var{prompt} @var{initial} minibuffer-local-ns-map) 282(let (minibuffer-allow-text-properties)
283 (read-from-minibuffer @var{prompt} @var{initial} minibuffer-local-ns-map))
273@end group 284@end group
274@end smallexample 285@end smallexample
275@end defun 286@end defun
@@ -312,7 +323,8 @@ This is a simplified interface to the
312@group 323@group
313(read-minibuffer @var{prompt} @var{initial}) 324(read-minibuffer @var{prompt} @var{initial})
314@equiv{} 325@equiv{}
315(read-from-minibuffer @var{prompt} @var{initial} nil t) 326(let (minibuffer-allow-text-properties)
327 (read-from-minibuffer @var{prompt} @var{initial} nil t))
316@end group 328@end group
317@end smallexample 329@end smallexample
318 330
@@ -421,11 +433,16 @@ Use @var{variable} (a symbol) as the history list.
421 433
422@item (@var{variable} . @var{startpos}) 434@item (@var{variable} . @var{startpos})
423Use @var{variable} (a symbol) as the history list, and assume that the 435Use @var{variable} (a symbol) as the history list, and assume that the
424initial history position is @var{startpos} (an integer, counting from 436initial history position is @var{startpos} (a nonnegative integer).
425zero which specifies the most recent element of the history). 437
426 438Specifying 0 for @var{startpos} is equivalent to just specifying the
427If you specify @var{startpos}, then you should also specify that element 439symbol @var{variable}. @code{previous-history-element} will display
428of the history as the initial minibuffer contents, for consistency. 440the most recent element of the history list in the minibuffer. If you
441specify a positive @var{startpos}, the minibuffer history functions
442behave as if @code{(elt @var{variable} (1- @var{STARTPOS}))} were the
443history element currently shown in the minibuffer. For consistency,
444you should also specify that element of the history as the initial
445minibuffer contents.
429@end table 446@end table
430 447
431 If you don't specify @var{hist}, then the default history list 448 If you don't specify @var{hist}, then the default history list
@@ -539,8 +556,9 @@ the higher-level completion features that do use the minibuffer.
539@defun try-completion string collection &optional predicate 556@defun try-completion string collection &optional predicate
540This function returns the longest common substring of all possible 557This function returns the longest common substring of all possible
541completions of @var{string} in @var{collection}. The value of 558completions of @var{string} in @var{collection}. The value of
542@var{collection} must be a list of strings, an alist, an obarray, or a 559@var{collection} must be a list of strings, an alist, an obarray, a
543function that implements a virtual set of strings (see below). 560hash table, or a function that implements a virtual set of strings
561(see below).
544 562
545Completion compares @var{string} against each of the permissible 563Completion compares @var{string} against each of the permissible
546completions specified by @var{collection}; if the beginning of the 564completions specified by @var{collection}; if the beginning of the
@@ -552,7 +570,12 @@ longest initial sequence common to all the permissible completions that
552match. 570match.
553 571
554If @var{collection} is an alist (@pxref{Association Lists}), the 572If @var{collection} is an alist (@pxref{Association Lists}), the
555@sc{car}s of the alist elements form the set of permissible completions. 573permissible completions are the elements of the alist that are either
574strings or conses whose @sc{car} is a string. Other elements of the
575alist are ignored. (Remember that in Emacs Lisp, the elements of
576alists do not @emph{have} to be conses.) As all elements of the alist
577can be strings, this case actually includes lists of strings, even
578though we usually do not think of such lists as alists.
556 579
557@cindex obarray in completion 580@cindex obarray in completion
558If @var{collection} is an obarray (@pxref{Creating Symbols}), the names 581If @var{collection} is an obarray (@pxref{Creating Symbols}), the names
@@ -564,6 +587,9 @@ Note that the only valid way to make a new obarray is to create it
564empty and then add symbols to it one by one using @code{intern}. 587empty and then add symbols to it one by one using @code{intern}.
565Also, you cannot intern a given symbol in more than one obarray. 588Also, you cannot intern a given symbol in more than one obarray.
566 589
590If @var{collection} is a hash table, then the keys that are strings
591are the possible completions. Other keys are ignored.
592
567You can also use a symbol that is a function as @var{collection}. Then 593You can also use a symbol that is a function as @var{collection}. Then
568the function is solely responsible for performing completion; 594the function is solely responsible for performing completion;
569@code{try-completion} returns whatever this function returns. The 595@code{try-completion} returns whatever this function returns. The
@@ -573,11 +599,20 @@ function can be used in @code{all-completions} and do the appropriate
573thing in either case.) @xref{Programmed Completion}. 599thing in either case.) @xref{Programmed Completion}.
574 600
575If the argument @var{predicate} is non-@code{nil}, then it must be a 601If the argument @var{predicate} is non-@code{nil}, then it must be a
576function of one argument. It is used to test each possible match, and 602function of one argument, unless @var{collection} is a hash table, in
577the match is accepted only if @var{predicate} returns non-@code{nil}. 603which case it should be a function of two arguments. It is used to
578The argument given to @var{predicate} is either a string from the 604test each possible match, and the match is accepted only if
579list, a cons cell from the alist (the @sc{car} of which is a string) 605@var{predicate} returns non-@code{nil}. The argument given to
580or a symbol (@emph{not} a symbol name) from the obarray. 606@var{predicate} is either a string or a cons cell (the @sc{car} of
607which is a string) from the alist, or a symbol (@emph{not} a symbol
608name) from the obarray. If @var{collection} is a hash table,
609@var{predicate} is called with two arguments, the string key and the
610associated value.
611
612In addition, to be acceptable, a completion must also match all the
613regular expressions in @code{completion-regexp-list}. (Unless
614@var{collection} is a function, in which case that function has to
615handle @code{completion-regexp-list} itself.)
581 616
582In the first of the following examples, the string @samp{foo} is 617In the first of the following examples, the string @samp{foo} is
583matched by three of the alist @sc{car}s. All of the matches begin with 618matched by three of the alist @sc{car}s. All of the matches begin with
@@ -633,10 +668,13 @@ too short). Both of those begin with the string @samp{foobar}.
633 668
634@defun all-completions string collection &optional predicate nospace 669@defun all-completions string collection &optional predicate nospace
635This function returns a list of all possible completions of 670This function returns a list of all possible completions of
636@var{string}. The arguments to this function (aside from @var{nospace}) 671@var{string}. The arguments to this function (aside from
637are the same as those of @code{try-completion}. If @var{nospace} is 672@var{nospace}) are the same as those of @code{try-completion}. Also,
638non-@code{nil}, completions that start with a space are ignored unless 673this function uses @code{completion-regexp-list} in the same way that
639@var{string} also starts with a space. 674@code{try-completion} does. The optional argument @var{nospace} only
675matters if @var{string} is the empty string. In that case, if
676@var{nospace} is non-@code{nil}, completions that start with a space
677are ignored.
640 678
641If @var{collection} is a function, it is called with three arguments: 679If @var{collection} is a function, it is called with three arguments:
642@var{string}, @var{predicate} and @code{t}; then @code{all-completions} 680@var{string}, @var{predicate} and @code{t}; then @code{all-completions}
@@ -662,13 +700,24 @@ example for @code{try-completion}:
662@end smallexample 700@end smallexample
663@end defun 701@end defun
664 702
703@anchor{Definition of test-completion}
665@defun test-completion string collection &optional predicate 704@defun test-completion string collection &optional predicate
666This function returns non-@code{nil} if @var{string} is a valid 705This function returns non-@code{nil} if @var{string} is a valid
667completion possibility specified by @var{collection} and 706completion possibility specified by @var{collection} and
668@var{predicate}. The other arguments are the same as in 707@var{predicate}. The arguments are the same as in
669@code{try-completion}. For instance, if @var{collection} is a list, 708@code{try-completion}. For instance, if @var{collection} is a list of
670this is true if @var{string} appears in the list and @var{predicate} 709strings, this is true if @var{string} appears in the list and
671is satisfied. 710@var{predicate} is satisfied.
711
712@code{test-completion} uses @code{completion-regexp-list} in the same
713way that @code{try-completion} does.
714
715If @var{predicate} is non-@code{nil} and if @var{collection} contains
716several strings that are equal to each other, as determined by
717@code{compare-strings} according to @code{completion-ignore-case},
718then @var{predicate} should accept either all or none of them.
719Otherwise, the return value of @code{test-completion} is essentially
720unpredictable.
672 721
673If @var{collection} is a function, it is called with three arguments, 722If @var{collection} is a function, it is called with three arguments,
674the values @var{string}, @var{predicate} and @code{lambda}; whatever 723the values @var{string}, @var{predicate} and @code{lambda}; whatever
@@ -680,6 +729,13 @@ If the value of this variable is non-@code{nil}, Emacs does not
680consider case significant in completion. 729consider case significant in completion.
681@end defvar 730@end defvar
682 731
732@defvar completion-regexp-list
733This is a list of regular expressions. The completion functions only
734consider a completion acceptable if it matches all regular expressions
735in this list, with @code{case-fold-search} (@pxref{Searching and Case})
736bound to the value of @code{completion-ignore-case}.
737@end defvar
738
683@defmac lazy-completion-table var fun &rest args 739@defmac lazy-completion-table var fun &rest args
684This macro provides a way to initialize the variable @var{var} as a 740This macro provides a way to initialize the variable @var{var} as a
685collection for completion in a lazy way, not computing its actual 741collection for completion in a lazy way, not computing its actual
@@ -711,8 +767,12 @@ providing completion. It activates the minibuffer with prompt
711@var{prompt}, which must be a string. 767@var{prompt}, which must be a string.
712 768
713The actual completion is done by passing @var{collection} and 769The actual completion is done by passing @var{collection} and
714@var{predicate} to the function @code{try-completion}. This happens in 770@var{predicate} to the function @code{try-completion}. This happens
715certain commands bound in the local keymaps used for completion. 771in certain commands bound in the local keymaps used for completion.
772Some of these commands also call @code{test-completion}. Thus, if
773@var{predicate} is non-@code{nil}, it should be compatible with
774@var{collection} and @code{completion-ignore-case}. @xref{Definition
775of test-completion}.
716 776
717If @var{require-match} is @code{nil}, the exit commands work regardless 777If @var{require-match} is @code{nil}, the exit commands work regardless
718of the input in the minibuffer. If @var{require-match} is @code{t}, the 778of the input in the minibuffer. If @var{require-match} is @code{t}, the
@@ -723,19 +783,13 @@ input already in the buffer matches an element of @var{collection}.
723 783
724However, empty input is always permitted, regardless of the value of 784However, empty input is always permitted, regardless of the value of
725@var{require-match}; in that case, @code{completing-read} returns 785@var{require-match}; in that case, @code{completing-read} returns
726@var{default}. The value of @var{default} (if non-@code{nil}) is also 786@var{default}, or @code{""}, if @var{default} is @code{nil}. The
727available to the user through the history commands. 787value of @var{default} (if non-@code{nil}) is also available to the
728 788user through the history commands.
729The user can exit with null input by typing @key{RET} with an empty 789
730minibuffer. Then @code{completing-read} returns @code{""}. This is how 790The function @code{completing-read} uses
731the user requests whatever default the command uses for the value being 791@code{minibuffer-local-completion-map} as the keymap if
732read. The user can return using @key{RET} in this way regardless of the 792@var{require-match} is @code{nil}, and uses
733value of @var{require-match}, and regardless of whether the empty string
734is included in @var{collection}.
735
736The function @code{completing-read} works by calling
737@code{read-minibuffer}. It uses @code{minibuffer-local-completion-map}
738as the keymap if @var{require-match} is @code{nil}, and uses
739@code{minibuffer-local-must-match-map} if @var{require-match} is 793@code{minibuffer-local-must-match-map} if @var{require-match} is
740non-@code{nil}. @xref{Completion Commands}. 794non-@code{nil}. @xref{Completion Commands}.
741 795
@@ -744,15 +798,21 @@ saving the input and for minibuffer history commands. It defaults to
744@code{minibuffer-history}. @xref{Minibuffer History}. 798@code{minibuffer-history}. @xref{Minibuffer History}.
745 799
746If @var{initial} is non-@code{nil}, @code{completing-read} inserts it 800If @var{initial} is non-@code{nil}, @code{completing-read} inserts it
747into the minibuffer as part of the input. Then it allows the user to 801into the minibuffer as part of the input, with point at the end. Then
748edit the input, providing several commands to attempt completion. 802it allows the user to edit the input, providing several commands to
749In most cases, we recommend using @var{default}, and not @var{initial}. 803attempt completion. @var{initial} can also be a cons cell of the form
804@code{(@var{string} . @var{position})}. In that case, point is put at
805@emph{zero-indexed} position @var{position} in @var{string}. Note
806that this is different from @code{read-from-minibuffer} and related
807functions, which use a one-indexed position. In most cases, we
808recommend using @var{default}, and not @var{initial}.
750 809
751@strong{We discourage use of a non-@code{nil} value for 810@strong{We discourage use of a non-@code{nil} value for
752@var{initial}}, because it is an intrusive interface. The history 811@var{initial}}, because it is an intrusive interface. The history
753list feature (which did not exist when we introduced @var{initial}) 812list feature (which did not exist when we introduced @var{initial})
754offers a far more convenient and general way for the user to get the 813offers a far more convenient and general way for the user to get the
755default and edit it, and it is always available. 814default and edit it, and it is always available. For an exception to
815this rule, see @ref{Minibuffer History}.
756 816
757If the argument @var{inherit-input-method} is non-@code{nil}, then the 817If the argument @var{inherit-input-method} is non-@code{nil}, then the
758minibuffer inherits the current input method (@pxref{Input 818minibuffer inherits the current input method (@pxref{Input
@@ -799,8 +859,11 @@ see @ref{Completion Commands}.
799@node Completion Commands 859@node Completion Commands
800@subsection Minibuffer Commands that Do Completion 860@subsection Minibuffer Commands that Do Completion
801 861
802 This section describes the keymaps, commands and user options used in 862 This section describes the keymaps, commands and user options used
803the minibuffer to do completion. 863in the minibuffer to do completion. The description refers to the
864situation when @code{partial-completion-mode} is disabled (as it is by
865default). When enabled, this minor mode uses its own alternatives to
866some of the commands described below.
804 867
805@defvar minibuffer-local-completion-map 868@defvar minibuffer-local-completion-map
806@code{completing-read} uses this value as the local keymap when an 869@code{completing-read} uses this value as the local keymap when an
@@ -820,7 +883,7 @@ keymap makes the following bindings:
820 883
821@noindent 884@noindent
822with other characters bound as in @code{minibuffer-local-map} 885with other characters bound as in @code{minibuffer-local-map}
823(@pxref{Text from Minibuffer}). 886(@pxref{Definition of minibuffer-local-map}).
824@end defvar 887@end defvar
825 888
826@defvar minibuffer-local-must-match-map 889@defvar minibuffer-local-must-match-map
@@ -852,8 +915,8 @@ with other characters bound as in @code{minibuffer-local-map}.
852@end defvar 915@end defvar
853 916
854@defvar minibuffer-completion-table 917@defvar minibuffer-completion-table
855The value of this variable is the alist or obarray used for completion 918The value of this variable is the collection used for completion in
856in the minibuffer. This is the global variable that contains what 919the minibuffer. This is the global variable that contains what
857@code{completing-read} passes to @code{try-completion}. It is used by 920@code{completing-read} passes to @code{try-completion}. It is used by
858minibuffer completion commands such as @code{minibuffer-complete-word}. 921minibuffer completion commands such as @code{minibuffer-complete-word}.
859@end defvar 922@end defvar
@@ -907,8 +970,10 @@ This function displays @var{completions} to the stream in
907information about streams.) The argument @var{completions} is normally 970information about streams.) The argument @var{completions} is normally
908a list of completions just returned by @code{all-completions}, but it 971a list of completions just returned by @code{all-completions}, but it
909does not have to be. Each element may be a symbol or a string, either 972does not have to be. Each element may be a symbol or a string, either
910of which is simply printed, or a list of two strings, which is printed 973of which is simply printed. It can also be a list of two strings,
911as if the strings were concatenated. 974which is printed as if the strings were concatenated. The first of
975the two strings is the actual completion, the second string serves as
976annotation.
912 977
913This function is called by @code{minibuffer-completion-help}. The 978This function is called by @code{minibuffer-completion-help}. The
914most common way to use it is together with 979most common way to use it is together with
@@ -948,9 +1013,10 @@ is not inserted in the minibuffer as initial input.
948If @var{existing} is non-@code{nil}, then the name specified must be 1013If @var{existing} is non-@code{nil}, then the name specified must be
949that of an existing buffer. The usual commands to exit the minibuffer 1014that of an existing buffer. The usual commands to exit the minibuffer
950do not exit if the text is not valid, and @key{RET} does completion to 1015do not exit if the text is not valid, and @key{RET} does completion to
951attempt to find a valid name. (However, @var{default} is not checked 1016attempt to find a valid name. If @var{existing} is neither @code{nil}
952for validity; it is returned, whatever it is, if the user exits with the 1017nor @code{t}, confirmation is required after completion. (However,
953minibuffer empty.) 1018@var{default} is not checked for validity; it is returned, whatever it
1019is, if the user exits with the minibuffer empty.)
954 1020
955In the following example, the user enters @samp{minibuffer.t}, and 1021In the following example, the user enters @samp{minibuffer.t}, and
956then types @key{RET}. The argument @var{existing} is @code{t}, and the 1022then types @key{RET}. The argument @var{existing} is @code{t}, and the
@@ -996,7 +1062,8 @@ The argument @var{default} specifies what to return if the user enters
996null input. It can be a symbol or a string; if it is a string, 1062null input. It can be a symbol or a string; if it is a string,
997@code{read-command} interns it before returning it. If @var{default} is 1063@code{read-command} interns it before returning it. If @var{default} is
998@code{nil}, that means no default has been specified; then if the user 1064@code{nil}, that means no default has been specified; then if the user
999enters null input, the return value is @code{nil}. 1065enters null input, the return value is @code{(intern "")}, that is, a
1066symbol whose name is an empty string.
1000 1067
1001@example 1068@example
1002(read-command "Command name? ") 1069(read-command "Command name? ")
@@ -1041,7 +1108,7 @@ The argument @var{default} specifies what to return if the user enters
1041null input. It can be a symbol or a string; if it is a string, 1108null input. It can be a symbol or a string; if it is a string,
1042@code{read-variable} interns it before returning it. If @var{default} 1109@code{read-variable} interns it before returning it. If @var{default}
1043is @code{nil}, that means no default has been specified; then if the 1110is @code{nil}, that means no default has been specified; then if the
1044user enters null input, the return value is @code{nil}. 1111user enters null input, the return value is @code{(intern "")}.
1045 1112
1046@example 1113@example
1047@group 1114@group
@@ -1090,10 +1157,7 @@ of the default directory.
1090 1157
1091@defun read-file-name prompt &optional directory default existing initial predicate 1158@defun read-file-name prompt &optional directory default existing initial predicate
1092This function reads a file name in the minibuffer, prompting with 1159This function reads a file name in the minibuffer, prompting with
1093@var{prompt} and providing completion. If @var{default} is 1160@var{prompt} and providing completion.
1094non-@code{nil}, then the function returns @var{default} if the user just
1095types @key{RET}. @var{default} is not checked for validity; it is
1096returned, whatever it is, if the user exits with the minibuffer empty.
1097 1161
1098If @var{existing} is non-@code{nil}, then the user must specify the name 1162If @var{existing} is non-@code{nil}, then the user must specify the name
1099of an existing file; @key{RET} performs completion to make the name 1163of an existing file; @key{RET} performs completion to make the name
@@ -1104,10 +1168,10 @@ value of @var{existing} is neither @code{nil} nor @code{t}, then
1104acceptable. 1168acceptable.
1105 1169
1106The argument @var{directory} specifies the directory to use for 1170The argument @var{directory} specifies the directory to use for
1107completion of relative file names. If @code{insert-default-directory} 1171completion of relative file names. It should be an absolute directory
1108is non-@code{nil}, @var{directory} is also inserted in the minibuffer as 1172name. If @code{insert-default-directory} is non-@code{nil},
1109initial input. It defaults to the current buffer's value of 1173@var{directory} is also inserted in the minibuffer as initial input.
1110@code{default-directory}. 1174It defaults to the current buffer's value of @code{default-directory}.
1111 1175
1112@c Emacs 19 feature 1176@c Emacs 19 feature
1113If you specify @var{initial}, that is an initial file name to insert 1177If you specify @var{initial}, that is an initial file name to insert
@@ -1118,11 +1182,45 @@ case, point goes at the beginning of @var{initial}. The default for
1118note:} we recommend using @var{default} rather than @var{initial} in 1182note:} we recommend using @var{default} rather than @var{initial} in
1119most cases. 1183most cases.
1120 1184
1185If @var{default} is non-@code{nil}, then the function returns
1186@var{default} if the user exits the minibuffer with the same non-empty
1187contents that @code{read-file-name} inserted initially. The initial
1188minibuffer contents are always non-empty if
1189@code{insert-default-directory} is non-@code{nil}, as it is by
1190default. @var{default} is not checked for validity, regardless of the
1191value of @var{existing}. However, if @var{existing} is
1192non-@code{nil}, the initial minibuffer contents should be a valid file
1193(or directory) name. Otherwise @code{read-file-name} attempts
1194completion if the user exits without any editing, and does not return
1195@var{default}. @var{default} is also available through the history
1196commands.
1197
1198If @var{default} is @code{nil}, @code{read-file-name} tries to find a
1199substitute default to use in its place, which it treats in exactly the
1200same way as if it had been specified explicitly. If @var{default} is
1201@code{nil}, but @var{initial} is non-@code{nil}, then the default is
1202the absolute file name obtained from @var{directory} and
1203@var{initial}. If both @var{default} and @var{initial} are @code{nil}
1204and the buffer is visiting a file, @code{read-file-name} uses the
1205absolute file name of that file as default. If the buffer is not
1206visiting a file, then there is no default. In that case, if the user
1207types @key{RET} without any editing, @code{read-file-name} simply
1208returns the pre-inserted contents of the minibuffer.
1209
1210If the user types @key{RET} in an empty minibuffer, this function
1211returns an empty string, regardless of the value of @var{existing}.
1212This is, for instance, how the user can make the current buffer visit
1213no file using @code{M-x set-visited-file-name}.
1214
1121If @var{predicate} is non-@code{nil}, it specifies a function of one 1215If @var{predicate} is non-@code{nil}, it specifies a function of one
1122argument that decides which file names are acceptable completion 1216argument that decides which file names are acceptable completion
1123possibilities. A file name is an acceptable value if @var{predicate} 1217possibilities. A file name is an acceptable value if @var{predicate}
1124returns non-@code{nil} for it. 1218returns non-@code{nil} for it.
1125 1219
1220@code{read-file-name} does not automatically expand file names. You
1221must call @code{expand-file-name} yourself if an absolute file name is
1222required.
1223
1126Here is an example: 1224Here is an example:
1127 1225
1128@example 1226@example
@@ -1160,17 +1258,35 @@ as the string @code{"/gp/gnu/elisp/manual.texi"}.
1160@defun read-directory-name prompt &optional directory default existing initial 1258@defun read-directory-name prompt &optional directory default existing initial
1161This function is like @code{read-file-name} but allows only directory 1259This function is like @code{read-file-name} but allows only directory
1162names as completion possibilities. 1260names as completion possibilities.
1261
1262If @var{default} is @code{nil} and @var{initial} is non-@code{nil},
1263@code{read-directory-name} constructs a substitute default by
1264combining @var{directory} (or the current buffer's default directory
1265if @var{directory} is @code{nil}) and @var{initial}. If both
1266@var{default} and @var{initial} are @code{nil}, this function uses the
1267current buffer's default directory as substitute default, ignoring
1268@var{directory}.
1163@end defun 1269@end defun
1164 1270
1165@defopt insert-default-directory 1271@defopt insert-default-directory
1166This variable is used by @code{read-file-name}. Its value controls 1272This variable is used by @code{read-file-name}, and thus, indirectly,
1167whether @code{read-file-name} starts by placing the name of the default 1273by most commands reading file names. (This includes all commands that
1168directory in the minibuffer, plus the initial file name if any. If the 1274use the code letters @samp{f} or @samp{F} in their interactive form.
1169value of this variable is @code{nil}, then @code{read-file-name} does 1275@xref{Interactive Codes,, Code Characters for interactive}.) Its
1170not place any initial input in the minibuffer (unless you specify 1276value controls whether @code{read-file-name} starts by placing the
1171initial input with the @var{initial} argument). In that case, the 1277name of the default directory in the minibuffer, plus the initial file
1172default directory is still used for completion of relative file names, 1278name if any. If the value of this variable is @code{nil}, then
1173but is not displayed. 1279@code{read-file-name} does not place any initial input in the
1280minibuffer (unless you specify initial input with the @var{initial}
1281argument). In that case, the default directory is still used for
1282completion of relative file names, but is not displayed.
1283
1284If this variable is @code{nil} and the initial minibuffer contents are
1285empty, the user may have to explicitly fetch the next history element
1286to access a default value. If the variable is non-@code{nil}, the
1287initial minibuffer contents are always non-empty and the user can
1288always request a default value by immediately typing @key{RET} in an
1289unedited minibuffer. (See above.)
1174 1290
1175For example: 1291For example:
1176 1292
@@ -1627,9 +1743,10 @@ The current value of this variable is used to rebind @code{help-form}
1627locally inside the minibuffer (@pxref{Help Functions}). 1743locally inside the minibuffer (@pxref{Help Functions}).
1628@end defvar 1744@end defvar
1629 1745
1630@defun minibufferp &optional buffer 1746@defun minibufferp &optional buffer-or-name
1631This function returns non-@code{nil} if @var{buffer} is a minibuffer. 1747This function returns non-@code{nil} if @var{buffer-or-name} is a
1632If @var{buffer} is omitted, it tests the current buffer. 1748minibuffer. If @var{buffer-or-name} is omitted, it tests the current
1749buffer.
1633@end defun 1750@end defun
1634 1751
1635@defun active-minibuffer-window 1752@defun active-minibuffer-window
@@ -1654,8 +1771,10 @@ choosing the minibuffer window according to the current frame.
1654@end defun 1771@end defun
1655 1772
1656@c Emacs 19 feature 1773@c Emacs 19 feature
1657@defun window-minibuffer-p window 1774@defun window-minibuffer-p &optional window
1658This function returns non-@code{nil} if @var{window} is a minibuffer window. 1775This function returns non-@code{nil} if @var{window} is a minibuffer
1776window.
1777@var{window} defaults to the selected window.
1659@end defun 1778@end defun
1660 1779
1661It is not correct to determine whether a given window is a minibuffer by 1780It is not correct to determine whether a given window is a minibuffer by
@@ -1704,14 +1823,16 @@ another window to do it.
1704@c Emacs 19 feature 1823@c Emacs 19 feature
1705If a command name has a property @code{enable-recursive-minibuffers} 1824If a command name has a property @code{enable-recursive-minibuffers}
1706that is non-@code{nil}, then the command can use the minibuffer to read 1825that is non-@code{nil}, then the command can use the minibuffer to read
1707arguments even if it is invoked from the minibuffer. The minibuffer 1826arguments even if it is invoked from the minibuffer. A command can
1708command @code{next-matching-history-element} (normally @kbd{M-s} in the 1827also achieve this by binding @code{enable-recursive-minibuffers}
1709minibuffer) uses this feature. 1828to @code{t} in the interactive declaration (@pxref{Using Interactive}).
1829The minibuffer command @code{next-matching-history-element} (normally
1830@kbd{M-s} in the minibuffer) does the latter.
1710 1831
1711@defun minibuffer-message string &optional timeout 1832@defun minibuffer-message string
1712This function displays @var{string} temporarily at the end of the 1833This function displays @var{string} temporarily at the end of the
1713minibuffer text, for @var{timeout} seconds. (The default is 2 1834minibuffer text, for two seconds, or until the next input event
1714seconds.) 1835arrives, whichever comes first.
1715@end defun 1836@end defun
1716 1837
1717@ignore 1838@ignore