summaryrefslogtreecommitdiff
path: root/devdocs/elisp/initial-input.html
blob: 6d5272010ae3b8b1dc492980f102c4978b67da82 (plain)
1
2
3
4
5
6
7
 <h3 class="section">Initial Input</h3> <p>Several of the functions for minibuffer input have an argument called <var>initial</var>. This is a mostly-deprecated feature for specifying that the minibuffer should start out with certain text, instead of empty as usual. </p> <p>If <var>initial</var> is a string, the minibuffer starts out containing the text of the string, with point at the end, when the user starts to edit the text. If the user simply types <tt class="key">RET</tt> to exit the minibuffer, it will use the initial input string to determine the value to return. </p> <p><strong>We discourage use of a non-<code>nil</code> value for <var>initial</var></strong>, because initial input is an intrusive interface. History lists and default values provide a much more convenient method to offer useful default inputs to the user. </p> <p>There is just one situation where you should specify a string for an <var>initial</var> argument. This is when you specify a cons cell for the <var>history</var> argument. See <a href="minibuffer-history">Minibuffer History</a>. </p> <p><var>initial</var> can also be a cons cell of the form <code>(<var>string</var>
. <var>position</var>)</code>. This means to insert <var>string</var> in the minibuffer but put point at <var>position</var> within the string’s text. </p> <p>As a historical accident, <var>position</var> was implemented inconsistently in different functions. In <code>completing-read</code>, <var>position</var>’s value is interpreted as origin-zero; that is, a value of 0 means the beginning of the string, 1 means after the first character, etc. In <code>read-minibuffer</code>, and the other non-completion minibuffer input functions that support this argument, 1 means the beginning of the string, 2 means after the first character, etc. </p> <p>Use of a cons cell as the value for <var>initial</var> arguments is deprecated. </p><div class="_attribution">
  <p class="_attribution-p">
    Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
    <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Initial-Input.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Initial-Input.html</a>
  </p>
</div>