Previous: Reading a Password, Up: Minibuffers


20.9 Minibuffer Miscellany

This section describes some basic functions and variables related to minibuffers.

— Command: exit-minibuffer

This command exits the active minibuffer. It is normally bound to keys in minibuffer local keymaps.

— Command: self-insert-and-exit

This command exits the active minibuffer after inserting the last character typed on the keyboard (found in last-command-char; see Command Loop Info).

— Command: previous-history-element n

This command replaces the minibuffer contents with the value of the nth previous (older) history element.

— Command: next-history-element n

This command replaces the minibuffer contents with the value of the nth more recent history element.

— Command: previous-matching-history-element pattern n

This command replaces the minibuffer contents with the value of the nth previous (older) history element that matches pattern (a regular expression).

— Command: next-matching-history-element pattern n

This command replaces the minibuffer contents with the value of the nth next (newer) history element that matches pattern (a regular expression).

— Function: minibuffer-prompt

This function returns the prompt string of the currently active minibuffer. If no minibuffer is active, it returns nil.

— Function: 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.

— Function: 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.

— Function: minibuffer-contents-no-properties

This is like minibuffer-contents, except that it does not copy text properties, just the characters themselves. See Text Properties.

— Function: 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.

— Function: minubuffer-prompt-width

This function returns the current display-width of the minibuffer prompt, if a minibuffer is current. Otherwise, it returns zero.

— Variable: minibuffer-setup-hook

This is a normal hook that is run whenever the minibuffer is entered. See Hooks.

— Variable: minibuffer-exit-hook

This is a normal hook that is run whenever the minibuffer is exited. See Hooks.

— Variable: minibuffer-help-form

The current value of this variable is used to rebind help-form locally inside the minibuffer (see Help Functions).

— Function: active-minibuffer-window

This function returns the currently active minibuffer window, or nil if none is currently active.

— Function: minibuffer-window &optional frame

This function returns the minibuffer window used for frame frame. If frame is nil, that stands for the current frame. Note that the minibuffer window used by a frame need not be part of that frame—a frame that has no minibuffer of its own necessarily uses some other frame's minibuffer window.

— Function: window-minibuffer-p window

This function returns non-nil if window is a minibuffer window.

It is not correct to determine whether a given window is a minibuffer by comparing it with the result of (minibuffer-window), because there can be more than one minibuffer window if there is more than one frame.

— Function: minibuffer-window-active-p window

This function returns non-nil if window, assumed to be a minibuffer window, is currently active.

— Variable: minibuffer-scroll-window

If the value of this variable is non-nil, it should be a window object. When the function scroll-other-window is called in the minibuffer, it scrolls this window.

Finally, some functions and variables deal with recursive minibuffers (see Recursive Editing):

— Function: minibuffer-depth

This function returns the current depth of activations of the minibuffer, a nonnegative integer. If no minibuffers are active, it returns zero.

— User Option: enable-recursive-minibuffers

If this variable is non-nil, you can invoke commands (such as 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.

If this variable is nil, you cannot invoke minibuffer commands when the minibuffer window is active, not even if you switch to another window to do it.

If a command name has a property enable-recursive-minibuffers that is non-nil, then the command can use the minibuffer to read arguments even if it is invoked from the minibuffer. The minibuffer command next-matching-history-element (normally M-s in the minibuffer) uses this feature.