A minibuffer is a complicated monster, and usually we get by copying snippets from existing code to write our minibuffer read calls. It should however be possible to document the workings of the beast in a systematic way, and dispell the mystery, so here we go.
The workhorse of minibuffer interaction is a coroutine called minibuffer.read. That it is a coroutine should not be intimidating to the novice — you need not necessarily understand how coroutines work in order to use them in the most common ways — only that the yield keyword is used to call them.
There are a dozen or more procedures in Conkeror with names that start with "minibuffer.read", for example minibuffer.read_file, and minibuffer.read_yes_or_no. However, most of these are simply wrappers around minibuffer.read itself, so that is the place to begin.
Minibuffer.read's behavior is controlled by keyword options. Because of the number of these options, keywords have a clear advantage over positional parameters because it results in a shortened call form, and each argument is labeled by its keyword, which makes the form easier to read than it would be otherwise. A note about keyword usage: anywhere you would give a value of boolean true for a keyword, you can simply give the keyword name with no value.
1.1. keyword options
- The prompt string.
- The initial input text.
- When given and true, the initial input will be selected.
Gives the keymap to use for the minibuffer interaction. Defaults to minibuffer_keymap. Typically if you wanted to add key bindings to a particular minibuffer prompt, you would make a keymap that inherits from minibuffer_keymap, and pass that keymap as the value for $keymap to minibuffer.read.
- When given, a string key name, under which the minibuffer history for this call to read will be accessed and saved.
- When given, should be a function of two arguments. The first is the input string, and the second is a reference to the minibuffer. Normal exit from the minibuffer will not be permitted unless the validator function returns a true value.
So glad you asked. See below.
- When true, normal exit from the minibuffer will only be allowed when an item found in the completions is chosen.
- When present, it must be a string found in the completions. This entry will be selected in the completions list when the input is empty. This option is only used in conjunction with $match_required.
boolean or string. string values are labels that will be resolved to booleans by traversing minibuffer_auto_complete_preferences and minibuffer_auto_complete_default, which see.
- When true, the completions display will pop open as soon as there are completions to display for the input. For example, you type "f" and there is a completion "foo", the completions display would pop open without you hitting tab.
- When true, auto-completion is performed immediately when the minibuffer input is opened. Valid only when $auto_complete is also given.
- Normally, empty input (such as after deleting all text, or if $auto_complete_initial is given, immediately when the prompt is opened) results in a completions display of all available completions. When this option is given, empty input results in no completions. Valid only when $auto_complete is also given.
Delay (in milliseconds) after the most recent key-stroke before auto-completing. Defaults to value of the user variable default_minibuffer_auto_complete_delay. There is rarely any need to give this keyword.
When given, space will be made in the completions display for an icon on each row. The icons are gotten from the get_icon method of the completer.
- When true, space can be used as a completion key in addition to tab. Useful for minibuffer interactions where space never appears as a character in the allowed input. Often useful in combination with prefix_completer.
Constructs a completer that completes based on prefix. The completion data and the procedures to interpret the items for display in the UI are given by the following keywords.
Gives either an array of items to select among, or a function for obtaining such an array, which we will come back to in a moment. The simplest case is an array of strings. You can also have an array of other types of objects, and then provide $get_string and optionally $get_description and/or $get_value.
- This can also be given as a function, and it's a little bit subtle how it works, so here goes: it should be a function of one argument. The object passed to the function is itself a function, which should be called for each completion item. You could think of it as "add item".
- A procedure that takes a completion item as its argument and returns the string representation that will actually be completed upon. The default for this keyword is an identity procedure (a procedure that returns its argument unchanged).
- A procedure that takes a completion item as its argument and returns a string description, normally displayed in the column to the right of the completions. Generally used to provide extra information about the item. The default is a procedure that always returns the empty string.
- When given, this is a procedure that takes a completion item as its argument and returns the string url of an icon to display in the completions pane for this item. Used only in combination with the minibuffer.read keyword $enable_icons.
- When given, this is a procedure that transforms the final chosen item from the completions to another value to return to the caller of minibuffer.read. Used only in combination with the minibuffer.read keyword $match_required.
An all_word_completer allows you to match completions by typing any number of substrings, separated by spaces. The input is allowed to match either the item itself (rather its string representation) or its description.
Takes the same keyword arguments as prefix_completer.
2. readers derived from minibuffer.read
3. other readers