Next: Object from Minibuffer, Previous: Intro to Minibuffers, Up: Minibuffers
Most often, the minibuffer is used to read text as a string. It can
also be used to read a Lisp object in textual form. The most basic
primitive for minibuffer input is read-from-minibuffer; it can do
either one. There are also specialized commands for reading
commands, variables, file names, etc. (see Completion).
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 interactive
specification. See Defining Commands.
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 read is non-
nil, then it usesreadto convert the text into a Lisp object (see Input Functions).The first thing this function does is to activate a minibuffer and display it with prompt-string as the prompt. This value must be a string. Then the user can edit text in the minibuffer.
When the user types a command to exit the minibuffer,
read-from-minibufferconstructs the return value from the text in the minibuffer. Normally it returns a string containing that text. However, if read is non-nil,read-from-minibufferreads the text and returns the resulting Lisp object, unevaluated. (See Input Functions, for information about reading.)The argument default specifies a default value to make available through the history commands. It should be a string, or
nil. If non-nil, the user can access it usingnext-history-element, usually bound in the minibuffer to M-n. If read is non-nil, then default is also used as the input toread, if the user enters empty input. (If read is non-niland default isnil, empty input results in anend-of-fileerror.) However, in the usual case (where read isnil),read-from-minibufferignores default when the user enters empty input and returns an empty string,"". In this respect, it is different from all the other minibuffer input functions in this chapter.If keymap is non-
nil, that keymap is the local keymap to use in the minibuffer. If keymap is omitted ornil, the value ofminibuffer-local-mapis used as the keymap. Specifying a keymap is the most important way to customize the minibuffer for various applications such as completion.The argument hist specifies which history list variable to use for saving the input and for history commands used in the minibuffer. It defaults to
minibuffer-history. See Minibuffer History.If the variable
minibuffer-allow-text-propertiesis non-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 inherit-input-method is non-
nil, then the minibuffer inherits the current input method (see Input Methods) and the setting ofenable-multibyte-characters(see Text Representations) from whichever buffer was current before entering the minibuffer.Use of initial-contents is mostly deprecated; we recommend using a non-
nilvalue only in conjunction with specifying a cons cell for hist. See Initial Input.
This function reads a string from the minibuffer and returns it. The arguments prompt, initial, history and inherit-input-method are used as in
read-from-minibuffer. The keymap used isminibuffer-local-map.The optional argument default is used as in
read-from-minibuffer, except that, if non-nil, it also specifies a default value to return if the user enters null input. As inread-from-minibufferit should be a string, ornil, which is equivalent to an empty string.This function is a simplified interface to the
read-from-minibufferfunction:(read-string prompt initial history default inherit) == (let ((value (read-from-minibuffer prompt initial nil nil history default inherit))) (if (and (equal value "") default) default value))
If this variable is
nil, thenread-from-minibufferstrips all text properties from the minibuffer input before returning it. This variable also affectsread-string. However,read-no-blanks-input(see below), as well asread-minibufferand related functions (see Reading Lisp Objects With the Minibuffer), and all functions that do minibuffer input with completion, discard text properties unconditionally, regardless of the value of this variable.
This is the default local keymap for reading from the minibuffer. By default, it makes the following bindings:
- C-j
exit-minibuffer- <RET>
exit-minibuffer- C-g
abort-recursive-edit- M-n
- <DOWN>
next-history-element- M-p
- <UP>
previous-history-element- M-s
next-matching-history-element- M-r
previous-matching-history-element
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 prompt, initial, and inherit-input-method are used as in
read-from-minibuffer.This is a simplified interface to the
read-from-minibufferfunction, and passes the value of theminibuffer-local-ns-mapkeymap as the keymap argument for that function. Since the keymapminibuffer-local-ns-mapdoes not rebind C-q, it is possible to put a space into the string, by quoting it.This function discards text properties, regardless of the value of
minibuffer-allow-text-properties.(read-no-blanks-input prompt initial) == (let (minibuffer-allow-text-properties) (read-from-minibuffer prompt initial minibuffer-local-ns-map))