diff options
| author | Richard M. Stallman | 2004-06-05 17:39:46 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2004-06-05 17:39:46 +0000 |
| commit | 79467ffe3e64fe46149e578124c62c38f6eaaf8a (patch) | |
| tree | c232a027c69aa5356f1104a09c5e5414a28bad1d | |
| parent | 1fb101f339ebef5c2d5f5ffdadb281d673703354 (diff) | |
| download | emacs-79467ffe3e64fe46149e578124c62c38f6eaaf8a.tar.gz emacs-79467ffe3e64fe46149e578124c62c38f6eaaf8a.zip | |
(Minibuffer Completion): For INITIAL arg,
refer the user to the Initial Input node.
(Text from Minibuffer): Likewise.
(Initial Input): New node. Document this feature
and say it is mostly deprecated.
| -rw-r--r-- | lispref/minibuf.texi | 90 |
1 files changed, 52 insertions, 38 deletions
diff --git a/lispref/minibuf.texi b/lispref/minibuf.texi index 0c56f9d4622..a2695eab6b9 100644 --- a/lispref/minibuf.texi +++ b/lispref/minibuf.texi | |||
| @@ -23,6 +23,7 @@ for reading an argument. | |||
| 23 | * Object from Minibuffer:: How to read a Lisp object or expression. | 23 | * Object from Minibuffer:: How to read a Lisp object or expression. |
| 24 | * Minibuffer History:: Recording previous minibuffer inputs | 24 | * Minibuffer History:: Recording previous minibuffer inputs |
| 25 | so the user can reuse them. | 25 | so the user can reuse them. |
| 26 | * Initial Input:: Specifying initial contents for the minibuffer. | ||
| 26 | * Completion:: How to invoke and customize completion. | 27 | * Completion:: How to invoke and customize completion. |
| 27 | * Yes-or-No Queries:: Asking a question with a simple answer. | 28 | * Yes-or-No Queries:: Asking a question with a simple answer. |
| 28 | * Multiple Queries:: Asking a series of similar questions. | 29 | * Multiple Queries:: Asking a series of similar questions. |
| @@ -168,25 +169,9 @@ the setting of @code{enable-multibyte-characters} (@pxref{Text | |||
| 168 | Representations}) from whichever buffer was current before entering the | 169 | Representations}) from whichever buffer was current before entering the |
| 169 | minibuffer. | 170 | minibuffer. |
| 170 | 171 | ||
| 171 | If @var{initial-contents} is a string, @code{read-from-minibuffer} | 172 | Use of @var{initial-contents} is mostly deprecated; we recommend using |
| 172 | inserts it into the minibuffer, leaving point at the end, before the | 173 | a non-@code{nil} value only in conjunction with specifying a cons cell |
| 173 | user starts to edit the text. The minibuffer appears with this text as | 174 | for @var{hist}. @xref{Initial Input}. |
| 174 | its initial contents. | ||
| 175 | |||
| 176 | Alternatively, @var{initial-contents} can be a cons cell of the form | ||
| 177 | @code{(@var{string} . @var{position})}. This means to insert | ||
| 178 | @var{string} in the minibuffer but put point at @emph{one-indexed} | ||
| 179 | @var{position} in the minibuffer, rather than at the end. Any integer | ||
| 180 | value less or equal to one puts point at the beginning of the string. | ||
| 181 | |||
| 182 | @strong{Usage note:} The @var{initial-contents} argument and the | ||
| 183 | @var{default} argument are two alternative features for more or less the | ||
| 184 | same job. It does not make sense to use both features in a single call | ||
| 185 | to @code{read-from-minibuffer}. In general, we recommend using | ||
| 186 | @var{default}, since this permits the user to insert the default value | ||
| 187 | when it is wanted, but does not burden the user with deleting it from | ||
| 188 | the minibuffer on other occasions. For an exception to this rule, | ||
| 189 | see @ref{Minibuffer History}. | ||
| 190 | @end defun | 175 | @end defun |
| 191 | 176 | ||
| 192 | @defun read-string prompt &optional initial history default inherit-input-method | 177 | @defun read-string prompt &optional initial history default inherit-input-method |
| @@ -440,9 +425,11 @@ symbol @var{variable}. @code{previous-history-element} will display | |||
| 440 | the most recent element of the history list in the minibuffer. If you | 425 | the most recent element of the history list in the minibuffer. If you |
| 441 | specify a positive @var{startpos}, the minibuffer history functions | 426 | specify a positive @var{startpos}, the minibuffer history functions |
| 442 | behave as if @code{(elt @var{variable} (1- @var{STARTPOS}))} were the | 427 | behave as if @code{(elt @var{variable} (1- @var{STARTPOS}))} were the |
| 443 | history element currently shown in the minibuffer. For consistency, | 428 | history element currently shown in the minibuffer. |
| 444 | you should also specify that element of the history as the initial | 429 | |
| 445 | minibuffer contents. | 430 | For consistency, you should also specify that element of the history |
| 431 | as the initial minibuffer contents, using the @var{initial} argument | ||
| 432 | to the minibuffer input function (@pxref{Initial Input}). | ||
| 446 | @end table | 433 | @end table |
| 447 | 434 | ||
| 448 | If you don't specify @var{hist}, then the default history list | 435 | If you don't specify @var{hist}, then the default history list |
| @@ -506,6 +493,45 @@ A history list for arguments that are shell commands. | |||
| 506 | A history list for arguments that are Lisp expressions to evaluate. | 493 | A history list for arguments that are Lisp expressions to evaluate. |
| 507 | @end defvar | 494 | @end defvar |
| 508 | 495 | ||
| 496 | @node Initial Input | ||
| 497 | @section Initial Input | ||
| 498 | |||
| 499 | Several of the functions for minibuffer input have an argument called | ||
| 500 | @var{initial} or @var{initial-contents}. This is a mostly-deprecated | ||
| 501 | feature for specifiying that the minibuffer should start out with | ||
| 502 | certain text, instead of empty as usual. | ||
| 503 | |||
| 504 | If @var{initial} is a string, the minibuffer starts out containing the | ||
| 505 | text of the string, with point at the end, when the user starts to | ||
| 506 | edit the text. If the user simply types @key{RET} to exit the | ||
| 507 | minibuffer, it will use the initial input string to determine the | ||
| 508 | value to return. | ||
| 509 | |||
| 510 | @strong{We discourage use of a non-@code{nil} value for | ||
| 511 | @var{initial}}, because initial input is an intrusive interface. | ||
| 512 | History lists and default values provide a much more convenient method | ||
| 513 | to offer useful default inputs to the user. | ||
| 514 | |||
| 515 | There is just one situation where you should specify a string for an | ||
| 516 | @var{initial} argument. This is when you specify a cons cell for the | ||
| 517 | @var{hist} or @var{history} argument. @xref{Minibuffer History}. | ||
| 518 | |||
| 519 | @var{initial} can also be a cons cell of the form @code{(@var{string} | ||
| 520 | . @var{position})}. This means to insert @var{string} in the | ||
| 521 | minibuffer but put point at @var{position} within the string's text. | ||
| 522 | |||
| 523 | As a historical accident, @var{position} was implemented | ||
| 524 | inconsistently in different functions. In @code{completing-read}, | ||
| 525 | @var{position}'s value is interpreted as origin-zero; that is, a value | ||
| 526 | of 0 means the beginning of the string, 1 means after the first | ||
| 527 | character, etc. In @code{read-minibuffer}, and the other | ||
| 528 | non-completion minibuffer input functions that support this argument, | ||
| 529 | 1 means the beginning of the string 2 means after the first character, | ||
| 530 | etc. | ||
| 531 | |||
| 532 | Use of a cons cell as the value for @var{initial} arguments is | ||
| 533 | deprecated in user code. | ||
| 534 | |||
| 509 | @node Completion | 535 | @node Completion |
| 510 | @section Completion | 536 | @section Completion |
| 511 | @cindex completion | 537 | @cindex completion |
| @@ -797,22 +823,10 @@ The argument @var{hist} specifies which history list variable to use for | |||
| 797 | saving the input and for minibuffer history commands. It defaults to | 823 | saving the input and for minibuffer history commands. It defaults to |
| 798 | @code{minibuffer-history}. @xref{Minibuffer History}. | 824 | @code{minibuffer-history}. @xref{Minibuffer History}. |
| 799 | 825 | ||
| 800 | If @var{initial} is non-@code{nil}, @code{completing-read} inserts it | 826 | The argument @var{initial} is mostly deprecated; we recommend using a |
| 801 | into the minibuffer as part of the input, with point at the end. Then | 827 | non-@code{nil} value only in conjunction with specifying a cons cell |
| 802 | it allows the user to edit the input, providing several commands to | 828 | for @var{hist}. @xref{Initial Input}. For default input, use |
| 803 | attempt completion. @var{initial} can also be a cons cell of the form | 829 | @var{default} instead. |
| 804 | @code{(@var{string} . @var{position})}. In that case, point is put at | ||
| 805 | @emph{zero-indexed} position @var{position} in @var{string}. Note | ||
| 806 | that this is different from @code{read-from-minibuffer} and related | ||
| 807 | functions, which use a one-indexed position. In most cases, we | ||
| 808 | recommend using @var{default}, and not @var{initial}. | ||
| 809 | |||
| 810 | @strong{We discourage use of a non-@code{nil} value for | ||
| 811 | @var{initial}}, because it is an intrusive interface. The history | ||
| 812 | list feature (which did not exist when we introduced @var{initial}) | ||
| 813 | offers a far more convenient and general way for the user to get the | ||
| 814 | default and edit it, and it is always available. For an exception to | ||
| 815 | this rule, see @ref{Minibuffer History}. | ||
| 816 | 830 | ||
| 817 | If the argument @var{inherit-input-method} is non-@code{nil}, then the | 831 | If the argument @var{inherit-input-method} is non-@code{nil}, then the |
| 818 | minibuffer inherits the current input method (@pxref{Input | 832 | minibuffer inherits the current input method (@pxref{Input |