2007-09-06 04:25:08 +00:00
|
|
|
@c -*-texinfo-*-
|
|
|
|
@c This is part of the GNU Emacs Lisp Reference Manual.
|
2015-01-01 14:26:41 -08:00
|
|
|
@c Copyright (C) 1990-1995, 1998-1999, 2001-2015 Free Software
|
2013-01-01 09:11:05 +00:00
|
|
|
@c Foundation, Inc.
|
2007-09-06 04:25:08 +00:00
|
|
|
@c See the file elisp.texi for copying conditions.
|
2012-05-26 18:34:14 -07:00
|
|
|
@node Minibuffers
|
2007-09-06 04:25:08 +00:00
|
|
|
@chapter Minibuffers
|
|
|
|
@cindex arguments, reading
|
|
|
|
@cindex complex arguments
|
|
|
|
@cindex minibuffer
|
|
|
|
|
|
|
|
A @dfn{minibuffer} is a special buffer that Emacs commands use to
|
|
|
|
read arguments more complicated than the single numeric prefix
|
|
|
|
argument. These arguments include file names, buffer names, and
|
|
|
|
command names (as in @kbd{M-x}). The minibuffer is displayed on the
|
|
|
|
bottom line of the frame, in the same place as the echo area
|
|
|
|
(@pxref{The Echo Area}), but only while it is in use for reading an
|
|
|
|
argument.
|
|
|
|
|
|
|
|
@menu
|
|
|
|
* Intro to Minibuffers:: Basic information about minibuffers.
|
|
|
|
* Text from Minibuffer:: How to read a straight text string.
|
|
|
|
* Object from Minibuffer:: How to read a Lisp object or expression.
|
Untabify doc/lispref/*.texi.
* abbrevs.texi, commands.texi, compile.texi, debugging.texi:
* display.texi, edebug.texi, elisp.texi, eval.texi, files.texi:
* frames.texi, functions.texi, internals.texi, keymaps.texi:
* loading.texi, minibuf.texi, numbers.texi, os.texi, processes.texi:
* searching.texi, sequences.texi, strings.texi, syntax.texi:
* text.texi, tips.texi, vol1.texi, vol2.texi, windows.texi:
Untabify Texinfo files.
2010-06-22 20:36:56 -07:00
|
|
|
* Minibuffer History:: Recording previous minibuffer inputs
|
|
|
|
so the user can reuse them.
|
2007-09-06 04:25:08 +00:00
|
|
|
* Initial Input:: Specifying initial contents for the minibuffer.
|
|
|
|
* Completion:: How to invoke and customize completion.
|
|
|
|
* Yes-or-No Queries:: Asking a question with a simple answer.
|
Untabify doc/lispref/*.texi.
* abbrevs.texi, commands.texi, compile.texi, debugging.texi:
* display.texi, edebug.texi, elisp.texi, eval.texi, files.texi:
* frames.texi, functions.texi, internals.texi, keymaps.texi:
* loading.texi, minibuf.texi, numbers.texi, os.texi, processes.texi:
* searching.texi, sequences.texi, strings.texi, syntax.texi:
* text.texi, tips.texi, vol1.texi, vol2.texi, windows.texi:
Untabify Texinfo files.
2010-06-22 20:36:56 -07:00
|
|
|
* Multiple Queries:: Asking a series of similar questions.
|
|
|
|
* Reading a Password:: Reading a password from the terminal.
|
2007-09-06 04:25:08 +00:00
|
|
|
* Minibuffer Commands:: Commands used as key bindings in minibuffers.
|
|
|
|
* Minibuffer Windows:: Operating on the special minibuffer windows.
|
2012-04-18 23:04:05 -07:00
|
|
|
* Minibuffer Contents:: How such commands access the minibuffer text.
|
2007-09-06 04:25:08 +00:00
|
|
|
* Recursive Mini:: Whether recursive entry to minibuffer is allowed.
|
|
|
|
* Minibuffer Misc:: Various customization hooks and variables.
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
@node Intro to Minibuffers
|
|
|
|
@section Introduction to Minibuffers
|
|
|
|
|
|
|
|
In most ways, a minibuffer is a normal Emacs buffer. Most operations
|
|
|
|
@emph{within} a buffer, such as editing commands, work normally in a
|
|
|
|
minibuffer. However, many operations for managing buffers do not apply
|
|
|
|
to minibuffers. The name of a minibuffer always has the form @w{@samp{
|
|
|
|
*Minibuf-@var{number}*}}, and it cannot be changed. Minibuffers are
|
|
|
|
displayed only in special windows used only for minibuffers; these
|
|
|
|
windows always appear at the bottom of a frame. (Sometimes frames have
|
|
|
|
no minibuffer window, and sometimes a special kind of frame contains
|
|
|
|
nothing but a minibuffer window; see @ref{Minibuffers and Frames}.)
|
|
|
|
|
|
|
|
The text in the minibuffer always starts with the @dfn{prompt string},
|
|
|
|
the text that was specified by the program that is using the minibuffer
|
|
|
|
to tell the user what sort of input to type. This text is marked
|
|
|
|
read-only so you won't accidentally delete or change it. It is also
|
|
|
|
marked as a field (@pxref{Fields}), so that certain motion functions,
|
|
|
|
including @code{beginning-of-line}, @code{forward-word},
|
|
|
|
@code{forward-sentence}, and @code{forward-paragraph}, stop at the
|
2009-03-23 03:07:51 +00:00
|
|
|
boundary between the prompt and the actual text.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2012-04-20 20:14:11 -04:00
|
|
|
@c See http://debbugs.gnu.org/11276
|
2007-09-06 04:25:08 +00:00
|
|
|
The minibuffer's window is normally a single line; it grows
|
2012-04-20 20:14:11 -04:00
|
|
|
automatically if the contents require more space. Whilst it is
|
|
|
|
active, you can explicitly resize it temporarily with the window
|
|
|
|
sizing commands; it reverts to its normal size when the minibuffer is
|
|
|
|
exited. When the minibuffer is not active, you can resize it
|
2009-03-23 03:07:51 +00:00
|
|
|
permanently by using the window sizing commands in the frame's other
|
2012-04-20 20:14:11 -04:00
|
|
|
window, or dragging the mode line with the mouse. (Due to details of
|
|
|
|
the current implementation, for this to work @code{resize-mini-windows}
|
|
|
|
must be @code{nil}.) If the frame contains just a minibuffer, you can
|
|
|
|
change the minibuffer's size by changing the frame's size.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
Use of the minibuffer reads input events, and that alters the values
|
|
|
|
of variables such as @code{this-command} and @code{last-command}
|
|
|
|
(@pxref{Command Loop Info}). Your program should bind them around the
|
|
|
|
code that uses the minibuffer, if you do not want that to change them.
|
|
|
|
|
2009-03-23 03:07:51 +00:00
|
|
|
Under some circumstances, a command can use a minibuffer even if
|
2012-04-18 22:00:23 -04:00
|
|
|
there is an active minibuffer; such a minibuffer is called a
|
2009-03-23 03:07:51 +00:00
|
|
|
@dfn{recursive minibuffer}. The first minibuffer is named
|
2012-04-18 22:00:23 -04:00
|
|
|
@w{@samp{ *Minibuf-1*}}. Recursive minibuffers are named by
|
2009-03-23 03:07:51 +00:00
|
|
|
incrementing the number at the end of the name. (The names begin with
|
|
|
|
a space so that they won't show up in normal buffer lists.) Of
|
|
|
|
several recursive minibuffers, the innermost (or most recently
|
2015-09-15 08:46:48 -07:00
|
|
|
entered) is the active minibuffer. We usually call this @emph{the}
|
2009-03-23 03:07:51 +00:00
|
|
|
minibuffer. You can permit or forbid recursive minibuffers by setting
|
|
|
|
the variable @code{enable-recursive-minibuffers}, or by putting
|
2009-03-23 10:10:39 +00:00
|
|
|
properties of that name on command symbols (@xref{Recursive Mini}.)
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
Like other buffers, a minibuffer uses a local keymap
|
|
|
|
(@pxref{Keymaps}) to specify special key bindings. The function that
|
|
|
|
invokes the minibuffer also sets up its local map according to the job
|
|
|
|
to be done. @xref{Text from Minibuffer}, for the non-completion
|
|
|
|
minibuffer local maps. @xref{Completion Commands}, for the minibuffer
|
|
|
|
local maps for completion.
|
|
|
|
|
2012-04-18 22:00:23 -04:00
|
|
|
@cindex inactive minibuffer
|
2012-04-18 19:44:48 -07:00
|
|
|
When a minibuffer is inactive, its major mode is
|
2012-04-18 22:00:23 -04:00
|
|
|
@code{minibuffer-inactive-mode}, with keymap
|
|
|
|
@code{minibuffer-inactive-mode-map}. This is only really useful if
|
|
|
|
the minibuffer is in a separate frame. @xref{Minibuffers and Frames}.
|
|
|
|
|
2007-09-06 04:25:08 +00:00
|
|
|
When Emacs is running in batch mode, any request to read from the
|
|
|
|
minibuffer actually reads a line from the standard input descriptor that
|
2014-06-26 15:00:42 -04:00
|
|
|
was supplied when Emacs was started. This supports only basic input:
|
2015-03-17 16:55:02 -07:00
|
|
|
none of the special minibuffer features (history, completion, etc.)@:
|
2014-07-11 11:09:54 +02:00
|
|
|
are available in batch mode.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@node Text from Minibuffer
|
|
|
|
@section Reading Text Strings with the Minibuffer
|
Improve indexing on the chapter/section/subsection levels.
doc/lispref/windows.texi (Recombining Windows): Index subject of sections.
doc/lispref/variables.texi (Variables with Restricted Values)
(Generalized Variables): Index subject of sections.
doc/lispref/text.texi (Buffer Contents, Examining Properties)
(Changing Properties, Property Search, Substitution): Index
subject of sections.
doc/lispref/syntax.texi (Motion and Syntax, Parsing Expressions)
(Motion via Parsing, Position Parse, Control Parsing): Index
subject of sections.
doc/lispref/strings.texi (Predicates for Strings, Creating Strings)
(Modifying Strings, Text Comparison): Index subject of sections.
doc/lispref/searching.texi (Syntax of Regexps, Regexp Special)
(Regexp Functions, Regexp Functions): Index subject of sections.
doc/lispref/processes.texi (Subprocess Creation, Process Information): Index
subject of sections.
doc/lispref/positions.texi (Screen Lines): Index subject of sections.
doc/lispref/nonascii.texi (Scanning Charsets, Specifying Coding Systems):
Index subject of sections.
doc/lispref/minibuf.texi (Text from Minibuffer, Object from Minibuffer)
(Multiple Queries, Minibuffer Contents): Index subject of
sections.
doc/lispref/markers.texi (Predicates on Markers, Creating Markers)
(Information from Markers, Moving Markers): Index subject of
sections.
doc/lispref/macros.texi (Defining Macros, Problems with Macros): Index
subject of sections.
doc/lispref/loading.texi (Loading Non-ASCII, Where Defined): Index subject
of sections.
doc/lispref/lists.texi (List-related Predicates, List Variables, Setcar)
(Setcdr, Plist Access): Index subject of sections.
doc/lispref/keymaps.texi (Controlling Active Maps, Scanning Keymaps)
(Modifying Menus): Index subject of sections.
doc/lispref/help.texi (Accessing Documentation, Help Functions): Index
subject of sections.
doc/lispref/hash.texi (Hash Access): Index subject of sections.
doc/lispref/functions.texi (Core Advising Primitives)
(Advising Named Functions, Porting old advices): Index subject of
sections.
doc/lispref/frames.texi (Creating Frames, Initial Parameters)
(Position Parameters, Buffer Parameters, Minibuffers and Frames)
(Pop-Up Menus, Drag and Drop): Index subject of sections.
doc/lispref/files.texi (Visiting Functions, Kinds of Files)
(Unique File Names): Index subject of sections.
doc/lispref/display.texi (Refresh Screen, Echo Area Customization)
(Warning Variables, Warning Options, Delayed Warnings)
(Temporary Displays, Managing Overlays, Overlay Properties)
(Finding Overlays, Size of Displayed Text, Defining Faces)
(Attribute Functions, Displaying Faces, Face Remapping)
(Basic Faces, Font Lookup, Fontsets, Replacing Specs)
(Defining Images, Showing Images): Index subject of sections.
doc/lispref/debugging.texi (Debugging, Explicit Debug)
(Invoking the Debugger, Excess Open, Excess Close): Index subject
of sections.
doc/lispref/customize.texi (Defining New Types, Applying Customizations)
(Custom Themes): Index subject of sections.
doc/lispref/control.texi (Sequencing, Combining Conditions)
(Processing of Errors, Cleanups): Index subject of sections.
doc/lispref/compile.texi (Eval During Compile): Index subject of sections.
doc/lispref/commands.texi (Using Interactive, Distinguish Interactive)
(Command Loop Info, Classifying Events, Event Mod)
(Invoking the Input Method): Index subject of sections.
doc/lispref/buffers.texi (Buffer List, Buffer Gap): Index subject of sections.
doc/lispref/backups.texi (Making Backups, Numbered Backups, Backup Names)
(Reverting): Index subject of sections.
doc/lispref/abbrevs.texi (Abbrev Tables, Defining Abbrevs, Abbrev Files)
(Abbrev Expansion, Standard Abbrev Tables, Abbrev Properties)
(Abbrev Table Properties): Index subject of sections.
doc/lispref/os.texi (Time of Day, Time Conversion, Time Parsing)
(Time Calculations, Idle Timers): Index subject of sections.
2014-12-23 20:42:30 +02:00
|
|
|
@cindex minibuffer input, reading text strings
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2009-03-23 03:07:51 +00:00
|
|
|
The most basic primitive for minibuffer input is
|
|
|
|
@code{read-from-minibuffer}, which can be used to read either a string
|
|
|
|
or a Lisp object in textual form. The function @code{read-regexp} is
|
|
|
|
used for reading regular expressions (@pxref{Regular Expressions}),
|
|
|
|
which are a special kind of string. There are also specialized
|
|
|
|
functions for reading commands, variables, file names, etc.@:
|
|
|
|
(@pxref{Completion}).
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
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 @code{interactive}
|
|
|
|
specification. @xref{Defining Commands}.
|
|
|
|
|
2012-04-18 22:00:23 -04:00
|
|
|
@defun read-from-minibuffer prompt &optional initial keymap read history default inherit-input-method
|
2009-03-23 03:07:51 +00:00
|
|
|
This function is the most general way to get input from the
|
2007-09-06 04:25:08 +00:00
|
|
|
minibuffer. By default, it accepts arbitrary text and returns it as a
|
|
|
|
string; however, if @var{read} is non-@code{nil}, then it uses
|
|
|
|
@code{read} to convert the text into a Lisp object (@pxref{Input
|
|
|
|
Functions}).
|
|
|
|
|
|
|
|
The first thing this function does is to activate a minibuffer and
|
2012-04-18 22:00:23 -04:00
|
|
|
display it with @var{prompt} (which must be a string) as the
|
|
|
|
prompt. Then the user can edit text in the minibuffer.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
When the user types a command to exit the minibuffer,
|
|
|
|
@code{read-from-minibuffer} constructs the return value from the text in
|
|
|
|
the minibuffer. Normally it returns a string containing that text.
|
|
|
|
However, if @var{read} is non-@code{nil}, @code{read-from-minibuffer}
|
|
|
|
reads the text and returns the resulting Lisp object, unevaluated.
|
|
|
|
(@xref{Input Functions}, for information about reading.)
|
|
|
|
|
2007-10-26 09:48:56 +00:00
|
|
|
The argument @var{default} specifies default values to make available
|
|
|
|
through the history commands. It should be a string, a list of
|
|
|
|
strings, or @code{nil}. The string or strings become the minibuffer's
|
Restore some of the quoting in the manuals
* doc/lispref/windows.texi (Coordinates and Windows)
(Coordinates and Windows):
* doc/lispref/variables.texi (Lexical Binding)
(File Local Variables):
* doc/lispref/text.texi (Format Properties):
* doc/lispref/symbols.texi (Symbol Components):
* doc/lispref/strings.texi (Creating Strings):
* doc/lispref/sequences.texi (Sequence Functions):
* doc/lispref/searching.texi (Regexp Special, Regexp Search)
(Search and Replace):
* doc/lispref/processes.texi (Bindat Spec):
* doc/lispref/os.texi (Idle Timers):
* doc/lispref/objects.texi (Basic Char Syntax):
* doc/lispref/numbers.texi (Float Basics, Random Numbers):
* doc/lispref/nonascii.texi (Character Properties):
* doc/lispref/modes.texi (Major Mode Conventions, Mode Hooks)
(Mode Line Variables):
* doc/lispref/minibuf.texi (Text from Minibuffer):
* doc/lispref/loading.texi (Autoload):
* doc/lispref/keymaps.texi (Controlling Active Maps):
* doc/lispref/frames.texi (Frame Layout, Size and Position)
(Size Parameters, Implied Frame Resizing):
* doc/lispref/files.texi (Changing Files, Magic File Names):
* doc/lispref/eval.texi (Self-Evaluating Forms):
* doc/lispref/display.texi (Progress, Abstract Display)
(Abstract Display Example, Bidirectional Display):
* doc/lispref/commands.texi (Event Mod):
* doc/emacs/windows.texi (Displaying Buffers):
* doc/emacs/trouble.texi (Bug Criteria, Checklist):
* doc/emacs/text.texi (Enriched Text):
* doc/emacs/programs.texi (MixedCase Words):
* doc/emacs/picture-xtra.texi (Insert in Picture)
(Tabs in Picture):
* doc/emacs/misc.texi (Emacs Server, Printing):
* doc/emacs/mini.texi (Minibuffer History):
* doc/emacs/maintaining.texi (Old Revisions, VC Change Log)
(Pulling / Pushing):
* doc/emacs/killing.texi (Yanking, Cut and Paste, Clipboard):
* doc/emacs/help.texi (Help, Help Echo):
* doc/emacs/glossary.texi (Glossary):
* doc/emacs/frames.texi (Mouse Commands, Creating Frames)
(Frame Commands):
* doc/emacs/files.texi (Reverting, Saving, Directories):
* doc/emacs/entering.texi (Exiting):
* doc/emacs/emacs.texi (Top):
* doc/emacs/cmdargs.texi (Window Size X, Icons X):
* doc/emacs/anti.texi (Antinews): Restore quoting of text where
appropriate or replace quoting with @dfn.
* doc/misc/ediff.texi (Window and Frame Configuration):
* doc/lispref/processes.texi (Network Feature Testing):
* doc/lispref/display.texi (Display Margins): Quote the phrase
after "a.k.a." where appropriate.
2015-09-16 12:56:45 +03:00
|
|
|
``future history'', available to the user with @kbd{M-n}.
|
2007-10-26 09:48:56 +00:00
|
|
|
|
2008-05-02 01:03:38 +00:00
|
|
|
If @var{read} is non-@code{nil}, then @var{default} is also used
|
|
|
|
as the input to @code{read}, if the user enters empty input.
|
|
|
|
If @var{default} is a list of strings, the first string is used as the input.
|
|
|
|
If @var{default} is @code{nil}, empty input results in an @code{end-of-file} error.
|
|
|
|
However, in the usual case (where @var{read} is @code{nil}),
|
|
|
|
@code{read-from-minibuffer} ignores @var{default} when the user enters
|
|
|
|
empty input and returns an empty string, @code{""}. In this respect,
|
|
|
|
it differs from all the other minibuffer input functions in this chapter.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
If @var{keymap} is non-@code{nil}, that keymap is the local keymap to
|
|
|
|
use in the minibuffer. If @var{keymap} is omitted or @code{nil}, the
|
|
|
|
value of @code{minibuffer-local-map} is used as the keymap. Specifying
|
|
|
|
a keymap is the most important way to customize the minibuffer for
|
|
|
|
various applications such as completion.
|
|
|
|
|
2012-04-18 22:00:23 -04:00
|
|
|
The argument @var{history} specifies a history list variable to use
|
2007-09-06 04:25:08 +00:00
|
|
|
for saving the input and for history commands used in the minibuffer.
|
2012-04-18 22:00:23 -04:00
|
|
|
It defaults to @code{minibuffer-history}. You can optionally specify
|
|
|
|
a starting position in the history list as well. @xref{Minibuffer History}.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
If the variable @code{minibuffer-allow-text-properties} is
|
2012-04-18 22:00:23 -04:00
|
|
|
non-@code{nil}, then the string that is returned includes whatever text
|
2007-09-06 04:25:08 +00:00
|
|
|
properties were present in the minibuffer. Otherwise all the text
|
|
|
|
properties are stripped when the value is returned.
|
|
|
|
|
|
|
|
If the argument @var{inherit-input-method} is non-@code{nil}, then the
|
|
|
|
minibuffer inherits the current input method (@pxref{Input Methods}) and
|
|
|
|
the setting of @code{enable-multibyte-characters} (@pxref{Text
|
|
|
|
Representations}) from whichever buffer was current before entering the
|
|
|
|
minibuffer.
|
|
|
|
|
2012-04-18 22:00:23 -04:00
|
|
|
Use of @var{initial} is mostly deprecated; we recommend using
|
2007-09-06 04:25:08 +00:00
|
|
|
a non-@code{nil} value only in conjunction with specifying a cons cell
|
2012-04-18 22:00:23 -04:00
|
|
|
for @var{history}. @xref{Initial Input}.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun read-string prompt &optional initial history default inherit-input-method
|
|
|
|
This function reads a string from the minibuffer and returns it. The
|
|
|
|
arguments @var{prompt}, @var{initial}, @var{history} and
|
|
|
|
@var{inherit-input-method} are used as in @code{read-from-minibuffer}.
|
|
|
|
The keymap used is @code{minibuffer-local-map}.
|
|
|
|
|
|
|
|
The optional argument @var{default} is used as in
|
|
|
|
@code{read-from-minibuffer}, except that, if non-@code{nil}, it also
|
|
|
|
specifies a default value to return if the user enters null input. As
|
2007-10-26 09:48:56 +00:00
|
|
|
in @code{read-from-minibuffer} it should be a string, a list of
|
2012-04-18 22:00:23 -04:00
|
|
|
strings, or @code{nil}, which is equivalent to an empty string. When
|
2007-10-26 09:48:56 +00:00
|
|
|
@var{default} is a string, that string is the default value. When it
|
|
|
|
is a list of strings, the first string is the default value. (All
|
Restore some of the quoting in the manuals
* doc/lispref/windows.texi (Coordinates and Windows)
(Coordinates and Windows):
* doc/lispref/variables.texi (Lexical Binding)
(File Local Variables):
* doc/lispref/text.texi (Format Properties):
* doc/lispref/symbols.texi (Symbol Components):
* doc/lispref/strings.texi (Creating Strings):
* doc/lispref/sequences.texi (Sequence Functions):
* doc/lispref/searching.texi (Regexp Special, Regexp Search)
(Search and Replace):
* doc/lispref/processes.texi (Bindat Spec):
* doc/lispref/os.texi (Idle Timers):
* doc/lispref/objects.texi (Basic Char Syntax):
* doc/lispref/numbers.texi (Float Basics, Random Numbers):
* doc/lispref/nonascii.texi (Character Properties):
* doc/lispref/modes.texi (Major Mode Conventions, Mode Hooks)
(Mode Line Variables):
* doc/lispref/minibuf.texi (Text from Minibuffer):
* doc/lispref/loading.texi (Autoload):
* doc/lispref/keymaps.texi (Controlling Active Maps):
* doc/lispref/frames.texi (Frame Layout, Size and Position)
(Size Parameters, Implied Frame Resizing):
* doc/lispref/files.texi (Changing Files, Magic File Names):
* doc/lispref/eval.texi (Self-Evaluating Forms):
* doc/lispref/display.texi (Progress, Abstract Display)
(Abstract Display Example, Bidirectional Display):
* doc/lispref/commands.texi (Event Mod):
* doc/emacs/windows.texi (Displaying Buffers):
* doc/emacs/trouble.texi (Bug Criteria, Checklist):
* doc/emacs/text.texi (Enriched Text):
* doc/emacs/programs.texi (MixedCase Words):
* doc/emacs/picture-xtra.texi (Insert in Picture)
(Tabs in Picture):
* doc/emacs/misc.texi (Emacs Server, Printing):
* doc/emacs/mini.texi (Minibuffer History):
* doc/emacs/maintaining.texi (Old Revisions, VC Change Log)
(Pulling / Pushing):
* doc/emacs/killing.texi (Yanking, Cut and Paste, Clipboard):
* doc/emacs/help.texi (Help, Help Echo):
* doc/emacs/glossary.texi (Glossary):
* doc/emacs/frames.texi (Mouse Commands, Creating Frames)
(Frame Commands):
* doc/emacs/files.texi (Reverting, Saving, Directories):
* doc/emacs/entering.texi (Exiting):
* doc/emacs/emacs.texi (Top):
* doc/emacs/cmdargs.texi (Window Size X, Icons X):
* doc/emacs/anti.texi (Antinews): Restore quoting of text where
appropriate or replace quoting with @dfn.
* doc/misc/ediff.texi (Window and Frame Configuration):
* doc/lispref/processes.texi (Network Feature Testing):
* doc/lispref/display.texi (Display Margins): Quote the phrase
after "a.k.a." where appropriate.
2015-09-16 12:56:45 +03:00
|
|
|
these strings are available to the user in the ``future minibuffer
|
|
|
|
history''.)
|
2007-10-26 09:48:56 +00:00
|
|
|
|
|
|
|
This function works by calling the
|
2007-09-06 04:25:08 +00:00
|
|
|
@code{read-from-minibuffer} function:
|
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
(read-string @var{prompt} @var{initial} @var{history} @var{default} @var{inherit})
|
|
|
|
@equiv{}
|
|
|
|
(let ((value
|
|
|
|
(read-from-minibuffer @var{prompt} @var{initial} nil nil
|
|
|
|
@var{history} @var{default} @var{inherit})))
|
|
|
|
(if (and (equal value "") @var{default})
|
2007-10-22 00:30:11 +00:00
|
|
|
(if (consp @var{default}) (car @var{default}) @var{default})
|
2007-09-06 04:25:08 +00:00
|
|
|
value))
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
@end defun
|
|
|
|
|
2014-02-16 18:12:50 -08:00
|
|
|
@defun read-regexp prompt &optional defaults history
|
2008-10-18 13:14:59 +00:00
|
|
|
This function reads a regular expression as a string from the
|
2014-02-16 18:12:50 -08:00
|
|
|
minibuffer and returns it. If the minibuffer prompt string
|
|
|
|
@var{prompt} does not end in @samp{:} (followed by optional
|
|
|
|
whitespace), the function adds @samp{: } to the end, preceded by the
|
|
|
|
default return value (see below), if that is non-empty.
|
2008-10-18 13:14:59 +00:00
|
|
|
|
2014-02-16 18:12:50 -08:00
|
|
|
The optional argument @var{defaults} controls the default value to
|
|
|
|
return if the user enters null input, and should be one of: a string;
|
|
|
|
@code{nil}, which is equivalent to an empty string; a list of strings;
|
|
|
|
or a symbol.
|
2008-10-18 19:31:15 +00:00
|
|
|
|
2014-02-16 18:12:50 -08:00
|
|
|
If @var{defaults} is a symbol, @code{read-regexp} consults the value
|
|
|
|
of the variable @code{read-regexp-defaults-function} (see below), and
|
|
|
|
if that is non-@code{nil} uses it in preference to @var{defaults}.
|
|
|
|
The value in this case should be either:
|
|
|
|
|
|
|
|
@itemize @minus
|
|
|
|
@item
|
|
|
|
@code{regexp-history-last}, which means to use the first element of
|
|
|
|
the appropriate minibuffer history list (see below).
|
|
|
|
|
|
|
|
@item
|
|
|
|
A function of no arguments, whose return value (which should be
|
|
|
|
@code{nil}, a string, or a list of strings) becomes the value of
|
|
|
|
@var{defaults}.
|
|
|
|
@end itemize
|
2012-10-24 22:38:49 +08:00
|
|
|
|
2014-02-16 18:12:50 -08:00
|
|
|
@code{read-regexp} now ensures that the result of processing
|
|
|
|
@var{defaults} is a list (i.e., if the value is @code{nil} or a
|
|
|
|
string, it converts it to a list of one element). To this list,
|
|
|
|
@code{read-regexp} then appends a few potentially useful candidates for
|
|
|
|
input. These are:
|
2008-10-18 13:14:59 +00:00
|
|
|
|
|
|
|
@itemize @minus
|
|
|
|
@item
|
2008-10-19 22:07:30 +00:00
|
|
|
The word or symbol at point.
|
2008-10-18 13:14:59 +00:00
|
|
|
@item
|
|
|
|
The last regexp used in an incremental search.
|
|
|
|
@item
|
|
|
|
The last string used in an incremental search.
|
|
|
|
@item
|
|
|
|
The last string or pattern used in query-replace commands.
|
|
|
|
@end itemize
|
|
|
|
|
2014-02-16 18:12:50 -08:00
|
|
|
The function now has a list of regular expressions that it passes to
|
|
|
|
@code{read-from-minibuffer} to obtain the user's input. The first
|
|
|
|
element of the list is the default result in case of empty input. All
|
Restore some of the quoting in the manuals
* doc/lispref/windows.texi (Coordinates and Windows)
(Coordinates and Windows):
* doc/lispref/variables.texi (Lexical Binding)
(File Local Variables):
* doc/lispref/text.texi (Format Properties):
* doc/lispref/symbols.texi (Symbol Components):
* doc/lispref/strings.texi (Creating Strings):
* doc/lispref/sequences.texi (Sequence Functions):
* doc/lispref/searching.texi (Regexp Special, Regexp Search)
(Search and Replace):
* doc/lispref/processes.texi (Bindat Spec):
* doc/lispref/os.texi (Idle Timers):
* doc/lispref/objects.texi (Basic Char Syntax):
* doc/lispref/numbers.texi (Float Basics, Random Numbers):
* doc/lispref/nonascii.texi (Character Properties):
* doc/lispref/modes.texi (Major Mode Conventions, Mode Hooks)
(Mode Line Variables):
* doc/lispref/minibuf.texi (Text from Minibuffer):
* doc/lispref/loading.texi (Autoload):
* doc/lispref/keymaps.texi (Controlling Active Maps):
* doc/lispref/frames.texi (Frame Layout, Size and Position)
(Size Parameters, Implied Frame Resizing):
* doc/lispref/files.texi (Changing Files, Magic File Names):
* doc/lispref/eval.texi (Self-Evaluating Forms):
* doc/lispref/display.texi (Progress, Abstract Display)
(Abstract Display Example, Bidirectional Display):
* doc/lispref/commands.texi (Event Mod):
* doc/emacs/windows.texi (Displaying Buffers):
* doc/emacs/trouble.texi (Bug Criteria, Checklist):
* doc/emacs/text.texi (Enriched Text):
* doc/emacs/programs.texi (MixedCase Words):
* doc/emacs/picture-xtra.texi (Insert in Picture)
(Tabs in Picture):
* doc/emacs/misc.texi (Emacs Server, Printing):
* doc/emacs/mini.texi (Minibuffer History):
* doc/emacs/maintaining.texi (Old Revisions, VC Change Log)
(Pulling / Pushing):
* doc/emacs/killing.texi (Yanking, Cut and Paste, Clipboard):
* doc/emacs/help.texi (Help, Help Echo):
* doc/emacs/glossary.texi (Glossary):
* doc/emacs/frames.texi (Mouse Commands, Creating Frames)
(Frame Commands):
* doc/emacs/files.texi (Reverting, Saving, Directories):
* doc/emacs/entering.texi (Exiting):
* doc/emacs/emacs.texi (Top):
* doc/emacs/cmdargs.texi (Window Size X, Icons X):
* doc/emacs/anti.texi (Antinews): Restore quoting of text where
appropriate or replace quoting with @dfn.
* doc/misc/ediff.texi (Window and Frame Configuration):
* doc/lispref/processes.texi (Network Feature Testing):
* doc/lispref/display.texi (Display Margins): Quote the phrase
after "a.k.a." where appropriate.
2015-09-16 12:56:45 +03:00
|
|
|
elements of the list are available to the user as the ``future
|
|
|
|
minibuffer history'' list (@pxref{Minibuffer History, future list,,
|
2014-02-16 18:12:50 -08:00
|
|
|
emacs, The GNU Emacs Manual}).
|
|
|
|
|
|
|
|
The optional argument @var{history}, if non-@code{nil}, is a symbol
|
|
|
|
specifying a minibuffer history list to use (@pxref{Minibuffer
|
|
|
|
History}). If it is omitted or @code{nil}, the history list defaults
|
|
|
|
to @code{regexp-history}.
|
2008-10-18 13:14:59 +00:00
|
|
|
@end defun
|
|
|
|
|
2014-02-16 18:12:50 -08:00
|
|
|
@defvar read-regexp-defaults-function
|
|
|
|
The function @code{read-regexp} may use the value of this variable to
|
|
|
|
determine its list of default regular expressions. If non-@code{nil},
|
|
|
|
the value of this variable should be either:
|
|
|
|
|
|
|
|
@itemize @minus
|
|
|
|
@item
|
|
|
|
The symbol @code{regexp-history-last}.
|
|
|
|
|
|
|
|
@item
|
|
|
|
A function of no arguments that returns either @code{nil}, a string,
|
|
|
|
or a list of strings.
|
|
|
|
@end itemize
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
See @code{read-regexp} above for details of how these values are used.
|
|
|
|
@end defvar
|
|
|
|
|
2007-09-06 04:25:08 +00:00
|
|
|
@defvar minibuffer-allow-text-properties
|
2012-04-18 22:00:23 -04:00
|
|
|
If this variable is @code{nil}, then @code{read-from-minibuffer}
|
|
|
|
and @code{read-string} strip all text properties from the minibuffer
|
|
|
|
input before returning it. However,
|
2007-09-06 04:25:08 +00:00
|
|
|
@code{read-no-blanks-input} (see below), as well as
|
|
|
|
@code{read-minibuffer} and related functions (@pxref{Object from
|
|
|
|
Minibuffer,, 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.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar minibuffer-local-map
|
|
|
|
This
|
|
|
|
@anchor{Definition of minibuffer-local-map}
|
|
|
|
@c avoid page break at anchor; work around Texinfo deficiency
|
|
|
|
is the default local keymap for reading from the minibuffer. By
|
|
|
|
default, it makes the following bindings:
|
|
|
|
|
|
|
|
@table @asis
|
|
|
|
@item @kbd{C-j}
|
|
|
|
@code{exit-minibuffer}
|
|
|
|
|
|
|
|
@item @key{RET}
|
|
|
|
@code{exit-minibuffer}
|
|
|
|
|
|
|
|
@item @kbd{C-g}
|
|
|
|
@code{abort-recursive-edit}
|
|
|
|
|
|
|
|
@item @kbd{M-n}
|
|
|
|
@itemx @key{DOWN}
|
|
|
|
@code{next-history-element}
|
|
|
|
|
|
|
|
@item @kbd{M-p}
|
|
|
|
@itemx @key{UP}
|
|
|
|
@code{previous-history-element}
|
|
|
|
|
|
|
|
@item @kbd{M-s}
|
|
|
|
@code{next-matching-history-element}
|
|
|
|
|
|
|
|
@item @kbd{M-r}
|
|
|
|
@code{previous-matching-history-element}
|
2012-04-18 22:00:23 -04:00
|
|
|
|
|
|
|
@ignore
|
|
|
|
@c Does not seem worth/appropriate mentioning.
|
|
|
|
@item @kbd{C-@key{TAB}}
|
|
|
|
@code{file-cache-minibuffer-complete}
|
|
|
|
@end ignore
|
2007-09-06 04:25:08 +00:00
|
|
|
@end table
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@c In version 18, initial is required
|
|
|
|
@c Emacs 19 feature
|
|
|
|
@defun read-no-blanks-input prompt &optional initial inherit-input-method
|
|
|
|
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 @var{prompt}, @var{initial}, and
|
|
|
|
@var{inherit-input-method} are used as in @code{read-from-minibuffer}.
|
|
|
|
|
|
|
|
This is a simplified interface to the @code{read-from-minibuffer}
|
|
|
|
function, and passes the value of the @code{minibuffer-local-ns-map}
|
|
|
|
keymap as the @var{keymap} argument for that function. Since the keymap
|
|
|
|
@code{minibuffer-local-ns-map} does not rebind @kbd{C-q}, it @emph{is}
|
|
|
|
possible to put a space into the string, by quoting it.
|
|
|
|
|
|
|
|
This function discards text properties, regardless of the value of
|
|
|
|
@code{minibuffer-allow-text-properties}.
|
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
(read-no-blanks-input @var{prompt} @var{initial})
|
|
|
|
@equiv{}
|
|
|
|
(let (minibuffer-allow-text-properties)
|
|
|
|
(read-from-minibuffer @var{prompt} @var{initial} minibuffer-local-ns-map))
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
@end defun
|
|
|
|
|
2012-04-18 22:00:23 -04:00
|
|
|
@c Slightly unfortunate name, suggesting it might be related to the
|
|
|
|
@c Nextstep port...
|
2007-09-06 04:25:08 +00:00
|
|
|
@defvar minibuffer-local-ns-map
|
|
|
|
This built-in variable is the keymap used as the minibuffer local keymap
|
|
|
|
in the function @code{read-no-blanks-input}. By default, it makes the
|
|
|
|
following bindings, in addition to those of @code{minibuffer-local-map}:
|
|
|
|
|
|
|
|
@table @asis
|
|
|
|
@item @key{SPC}
|
|
|
|
@cindex @key{SPC} in minibuffer
|
|
|
|
@code{exit-minibuffer}
|
|
|
|
|
|
|
|
@item @key{TAB}
|
|
|
|
@cindex @key{TAB} in minibuffer
|
|
|
|
@code{exit-minibuffer}
|
|
|
|
|
|
|
|
@item @kbd{?}
|
|
|
|
@cindex @kbd{?} in minibuffer
|
|
|
|
@code{self-insert-and-exit}
|
|
|
|
@end table
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@node Object from Minibuffer
|
|
|
|
@section Reading Lisp Objects with the Minibuffer
|
Improve indexing on the chapter/section/subsection levels.
doc/lispref/windows.texi (Recombining Windows): Index subject of sections.
doc/lispref/variables.texi (Variables with Restricted Values)
(Generalized Variables): Index subject of sections.
doc/lispref/text.texi (Buffer Contents, Examining Properties)
(Changing Properties, Property Search, Substitution): Index
subject of sections.
doc/lispref/syntax.texi (Motion and Syntax, Parsing Expressions)
(Motion via Parsing, Position Parse, Control Parsing): Index
subject of sections.
doc/lispref/strings.texi (Predicates for Strings, Creating Strings)
(Modifying Strings, Text Comparison): Index subject of sections.
doc/lispref/searching.texi (Syntax of Regexps, Regexp Special)
(Regexp Functions, Regexp Functions): Index subject of sections.
doc/lispref/processes.texi (Subprocess Creation, Process Information): Index
subject of sections.
doc/lispref/positions.texi (Screen Lines): Index subject of sections.
doc/lispref/nonascii.texi (Scanning Charsets, Specifying Coding Systems):
Index subject of sections.
doc/lispref/minibuf.texi (Text from Minibuffer, Object from Minibuffer)
(Multiple Queries, Minibuffer Contents): Index subject of
sections.
doc/lispref/markers.texi (Predicates on Markers, Creating Markers)
(Information from Markers, Moving Markers): Index subject of
sections.
doc/lispref/macros.texi (Defining Macros, Problems with Macros): Index
subject of sections.
doc/lispref/loading.texi (Loading Non-ASCII, Where Defined): Index subject
of sections.
doc/lispref/lists.texi (List-related Predicates, List Variables, Setcar)
(Setcdr, Plist Access): Index subject of sections.
doc/lispref/keymaps.texi (Controlling Active Maps, Scanning Keymaps)
(Modifying Menus): Index subject of sections.
doc/lispref/help.texi (Accessing Documentation, Help Functions): Index
subject of sections.
doc/lispref/hash.texi (Hash Access): Index subject of sections.
doc/lispref/functions.texi (Core Advising Primitives)
(Advising Named Functions, Porting old advices): Index subject of
sections.
doc/lispref/frames.texi (Creating Frames, Initial Parameters)
(Position Parameters, Buffer Parameters, Minibuffers and Frames)
(Pop-Up Menus, Drag and Drop): Index subject of sections.
doc/lispref/files.texi (Visiting Functions, Kinds of Files)
(Unique File Names): Index subject of sections.
doc/lispref/display.texi (Refresh Screen, Echo Area Customization)
(Warning Variables, Warning Options, Delayed Warnings)
(Temporary Displays, Managing Overlays, Overlay Properties)
(Finding Overlays, Size of Displayed Text, Defining Faces)
(Attribute Functions, Displaying Faces, Face Remapping)
(Basic Faces, Font Lookup, Fontsets, Replacing Specs)
(Defining Images, Showing Images): Index subject of sections.
doc/lispref/debugging.texi (Debugging, Explicit Debug)
(Invoking the Debugger, Excess Open, Excess Close): Index subject
of sections.
doc/lispref/customize.texi (Defining New Types, Applying Customizations)
(Custom Themes): Index subject of sections.
doc/lispref/control.texi (Sequencing, Combining Conditions)
(Processing of Errors, Cleanups): Index subject of sections.
doc/lispref/compile.texi (Eval During Compile): Index subject of sections.
doc/lispref/commands.texi (Using Interactive, Distinguish Interactive)
(Command Loop Info, Classifying Events, Event Mod)
(Invoking the Input Method): Index subject of sections.
doc/lispref/buffers.texi (Buffer List, Buffer Gap): Index subject of sections.
doc/lispref/backups.texi (Making Backups, Numbered Backups, Backup Names)
(Reverting): Index subject of sections.
doc/lispref/abbrevs.texi (Abbrev Tables, Defining Abbrevs, Abbrev Files)
(Abbrev Expansion, Standard Abbrev Tables, Abbrev Properties)
(Abbrev Table Properties): Index subject of sections.
doc/lispref/os.texi (Time of Day, Time Conversion, Time Parsing)
(Time Calculations, Idle Timers): Index subject of sections.
2014-12-23 20:42:30 +02:00
|
|
|
@cindex minibuffer input, reading lisp objects
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
This section describes functions for reading Lisp objects with the
|
|
|
|
minibuffer.
|
|
|
|
|
|
|
|
@defun read-minibuffer prompt &optional initial
|
|
|
|
This function reads a Lisp object using the minibuffer, and returns it
|
|
|
|
without evaluating it. The arguments @var{prompt} and @var{initial} are
|
|
|
|
used as in @code{read-from-minibuffer}.
|
|
|
|
|
|
|
|
This is a simplified interface to the
|
|
|
|
@code{read-from-minibuffer} function:
|
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
(read-minibuffer @var{prompt} @var{initial})
|
|
|
|
@equiv{}
|
|
|
|
(let (minibuffer-allow-text-properties)
|
|
|
|
(read-from-minibuffer @var{prompt} @var{initial} nil t))
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
|
|
|
|
Here is an example in which we supply the string @code{"(testing)"} as
|
|
|
|
initial input:
|
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
(read-minibuffer
|
|
|
|
"Enter an expression: " (format "%s" '(testing)))
|
|
|
|
|
|
|
|
;; @r{Here is how the minibuffer is displayed:}
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
Enter an expression: (testing)@point{}
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
The user can type @key{RET} immediately to use the initial input as a
|
|
|
|
default, or can edit the input.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun eval-minibuffer prompt &optional initial
|
|
|
|
This function reads a Lisp expression using the minibuffer, evaluates
|
|
|
|
it, then returns the result. The arguments @var{prompt} and
|
|
|
|
@var{initial} are used as in @code{read-from-minibuffer}.
|
|
|
|
|
|
|
|
This function simply evaluates the result of a call to
|
|
|
|
@code{read-minibuffer}:
|
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
(eval-minibuffer @var{prompt} @var{initial})
|
|
|
|
@equiv{}
|
|
|
|
(eval (read-minibuffer @var{prompt} @var{initial}))
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun edit-and-eval-command prompt form
|
2012-04-18 23:04:05 -07:00
|
|
|
This function reads a Lisp expression in the minibuffer, evaluates it,
|
|
|
|
then returns the result. The difference between this command and
|
2007-09-06 04:25:08 +00:00
|
|
|
@code{eval-minibuffer} is that here the initial @var{form} is not
|
|
|
|
optional and it is treated as a Lisp object to be converted to printed
|
|
|
|
representation rather than as a string of text. It is printed with
|
|
|
|
@code{prin1}, so if it is a string, double-quote characters (@samp{"})
|
|
|
|
appear in the initial text. @xref{Output Functions}.
|
|
|
|
|
|
|
|
In the following example, we offer the user an expression with initial
|
2012-04-18 23:04:05 -07:00
|
|
|
text that is already a valid form:
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
(edit-and-eval-command "Please edit: " '(forward-word 1))
|
|
|
|
|
|
|
|
;; @r{After evaluation of the preceding expression,}
|
|
|
|
;; @r{the following appears in the minibuffer:}
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
Please edit: (forward-word 1)@point{}
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
Typing @key{RET} right away would exit the minibuffer and evaluate the
|
|
|
|
expression, thus moving point forward one word.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@node Minibuffer History
|
|
|
|
@section Minibuffer History
|
|
|
|
@cindex minibuffer history
|
|
|
|
@cindex history list
|
|
|
|
|
2011-02-27 17:10:48 -05:00
|
|
|
A @dfn{minibuffer history list} records previous minibuffer inputs
|
|
|
|
so the user can reuse them conveniently. It is a variable whose value
|
|
|
|
is a list of strings (previous inputs), most recent first.
|
|
|
|
|
|
|
|
There are many separate minibuffer history lists, used for different
|
|
|
|
kinds of inputs. It's the Lisp programmer's job to specify the right
|
|
|
|
history list for each use of the minibuffer.
|
|
|
|
|
2012-04-18 22:00:23 -04:00
|
|
|
You specify a minibuffer history list with the optional @var{history}
|
2011-02-27 17:10:48 -05:00
|
|
|
argument to @code{read-from-minibuffer} or @code{completing-read}.
|
|
|
|
Here are the possible values for it:
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@table @asis
|
|
|
|
@item @var{variable}
|
|
|
|
Use @var{variable} (a symbol) as the history list.
|
|
|
|
|
|
|
|
@item (@var{variable} . @var{startpos})
|
|
|
|
Use @var{variable} (a symbol) as the history list, and assume that the
|
|
|
|
initial history position is @var{startpos} (a nonnegative integer).
|
|
|
|
|
|
|
|
Specifying 0 for @var{startpos} is equivalent to just specifying the
|
|
|
|
symbol @var{variable}. @code{previous-history-element} will display
|
|
|
|
the most recent element of the history list in the minibuffer. If you
|
|
|
|
specify a positive @var{startpos}, the minibuffer history functions
|
2012-04-18 22:00:23 -04:00
|
|
|
behave as if @code{(elt @var{variable} (1- @var{startpos}))} were the
|
2007-09-06 04:25:08 +00:00
|
|
|
history element currently shown in the minibuffer.
|
|
|
|
|
|
|
|
For consistency, you should also specify that element of the history
|
|
|
|
as the initial minibuffer contents, using the @var{initial} argument
|
|
|
|
to the minibuffer input function (@pxref{Initial Input}).
|
|
|
|
@end table
|
|
|
|
|
2012-04-18 22:00:23 -04:00
|
|
|
If you don't specify @var{history}, then the default history list
|
2007-09-06 04:25:08 +00:00
|
|
|
@code{minibuffer-history} is used. For other standard history lists,
|
|
|
|
see below. You can also create your own history list variable; just
|
|
|
|
initialize it to @code{nil} before the first use.
|
|
|
|
|
|
|
|
Both @code{read-from-minibuffer} and @code{completing-read} add new
|
|
|
|
elements to the history list automatically, and provide commands to
|
|
|
|
allow the user to reuse items on the list. The only thing your program
|
|
|
|
needs to do to use a history list is to initialize it and to pass its
|
|
|
|
name to the input functions when you wish. But it is safe to modify the
|
|
|
|
list by hand when the minibuffer input functions are not using it.
|
|
|
|
|
|
|
|
Emacs functions that add a new element to a history list can also
|
|
|
|
delete old elements if the list gets too long. The variable
|
|
|
|
@code{history-length} specifies the maximum length for most history
|
|
|
|
lists. To specify a different maximum length for a particular history
|
|
|
|
list, put the length in the @code{history-length} property of the
|
|
|
|
history list symbol. The variable @code{history-delete-duplicates}
|
|
|
|
specifies whether to delete duplicates in history.
|
|
|
|
|
|
|
|
@defun add-to-history history-var newelt &optional maxelt keep-all
|
|
|
|
This function adds a new element @var{newelt}, if it isn't the empty
|
|
|
|
string, to the history list stored in the variable @var{history-var},
|
|
|
|
and returns the updated history list. It limits the list length to
|
|
|
|
the value of @var{maxelt} (if non-@code{nil}) or @code{history-length}
|
|
|
|
(described below). The possible values of @var{maxelt} have the same
|
|
|
|
meaning as the values of @code{history-length}.
|
|
|
|
|
|
|
|
Normally, @code{add-to-history} removes duplicate members from the
|
|
|
|
history list if @code{history-delete-duplicates} is non-@code{nil}.
|
|
|
|
However, if @var{keep-all} is non-@code{nil}, that says not to remove
|
|
|
|
duplicates, and to add @var{newelt} to the list even if it is empty.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defvar history-add-new-input
|
|
|
|
If the value of this variable is @code{nil}, standard functions that
|
|
|
|
read from the minibuffer don't add new elements to the history list.
|
|
|
|
This lets Lisp programs explicitly manage input history by using
|
2012-05-04 19:49:19 -07:00
|
|
|
@code{add-to-history}. The default value is @code{t}.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defvar
|
|
|
|
|
2009-05-21 15:31:31 +00:00
|
|
|
@defopt history-length
|
2007-09-06 04:25:08 +00:00
|
|
|
The value of this variable specifies the maximum length for all
|
|
|
|
history lists that don't specify their own maximum lengths. If the
|
2010-05-03 18:01:23 -04:00
|
|
|
value is @code{t}, that means there is no maximum (don't delete old
|
2012-04-18 23:04:05 -07:00
|
|
|
elements). If a history list variable's symbol has a non-@code{nil}
|
|
|
|
@code{history-length} property, it overrides this variable for that
|
2007-09-06 04:25:08 +00:00
|
|
|
particular history list.
|
2009-05-21 15:31:31 +00:00
|
|
|
@end defopt
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2009-05-21 15:31:31 +00:00
|
|
|
@defopt history-delete-duplicates
|
2007-09-06 04:25:08 +00:00
|
|
|
If the value of this variable is @code{t}, that means when adding a
|
|
|
|
new history element, all previous identical elements are deleted.
|
2009-05-21 15:31:31 +00:00
|
|
|
@end defopt
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
Here are some of the standard minibuffer history list variables:
|
|
|
|
|
|
|
|
@defvar minibuffer-history
|
|
|
|
The default history list for minibuffer history input.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar query-replace-history
|
|
|
|
A history list for arguments to @code{query-replace} (and similar
|
|
|
|
arguments to other commands).
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar file-name-history
|
|
|
|
A history list for file-name arguments.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar buffer-name-history
|
|
|
|
A history list for buffer-name arguments.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar regexp-history
|
|
|
|
A history list for regular expression arguments.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar extended-command-history
|
|
|
|
A history list for arguments that are names of extended commands.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar shell-command-history
|
|
|
|
A history list for arguments that are shell commands.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar read-expression-history
|
|
|
|
A history list for arguments that are Lisp expressions to evaluate.
|
|
|
|
@end defvar
|
|
|
|
|
2012-04-18 23:04:05 -07:00
|
|
|
@defvar face-name-history
|
|
|
|
A history list for arguments that are faces.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@c Less common: coding-system-history, input-method-history,
|
|
|
|
@c command-history, grep-history, grep-find-history,
|
|
|
|
@c read-envvar-name-history, setenv-history, yes-or-no-p-history.
|
|
|
|
|
2007-09-06 04:25:08 +00:00
|
|
|
@node Initial Input
|
|
|
|
@section Initial Input
|
|
|
|
|
|
|
|
Several of the functions for minibuffer input have an argument called
|
2012-04-18 22:00:23 -04:00
|
|
|
@var{initial}. This is a mostly-deprecated
|
2007-09-06 04:25:08 +00:00
|
|
|
feature for specifying that the minibuffer should start out with
|
|
|
|
certain text, instead of empty as usual.
|
|
|
|
|
|
|
|
If @var{initial} 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 @key{RET} to exit the
|
|
|
|
minibuffer, it will use the initial input string to determine the
|
|
|
|
value to return.
|
|
|
|
|
|
|
|
@strong{We discourage use of a non-@code{nil} value for
|
|
|
|
@var{initial}}, 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.
|
|
|
|
|
|
|
|
There is just one situation where you should specify a string for an
|
|
|
|
@var{initial} argument. This is when you specify a cons cell for the
|
2012-04-18 22:00:23 -04:00
|
|
|
@var{history} argument. @xref{Minibuffer History}.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@var{initial} can also be a cons cell of the form @code{(@var{string}
|
|
|
|
. @var{position})}. This means to insert @var{string} in the
|
|
|
|
minibuffer but put point at @var{position} within the string's text.
|
|
|
|
|
|
|
|
As a historical accident, @var{position} was implemented
|
|
|
|
inconsistently in different functions. In @code{completing-read},
|
|
|
|
@var{position}'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}, and the other
|
|
|
|
non-completion minibuffer input functions that support this argument,
|
2012-04-18 23:04:05 -07:00
|
|
|
1 means the beginning of the string, 2 means after the first character,
|
2007-09-06 04:25:08 +00:00
|
|
|
etc.
|
|
|
|
|
2012-04-18 23:04:05 -07:00
|
|
|
Use of a cons cell as the value for @var{initial} arguments is deprecated.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@node Completion
|
|
|
|
@section Completion
|
|
|
|
@cindex completion
|
|
|
|
|
|
|
|
@dfn{Completion} is a feature that fills in the rest of a name
|
|
|
|
starting from an abbreviation for it. Completion works by comparing the
|
|
|
|
user's input against a list of valid names and determining how much of
|
|
|
|
the name is determined uniquely by what the user has typed. For
|
|
|
|
example, when you type @kbd{C-x b} (@code{switch-to-buffer}) and then
|
2012-04-19 21:37:14 -04:00
|
|
|
@c "This is the sort of English up with which I will not put."
|
2007-09-06 04:25:08 +00:00
|
|
|
type the first few letters of the name of the buffer to which you wish
|
|
|
|
to switch, and then type @key{TAB} (@code{minibuffer-complete}), Emacs
|
|
|
|
extends the name as far as it can.
|
|
|
|
|
|
|
|
Standard Emacs commands offer completion for names of symbols, files,
|
|
|
|
buffers, and processes; with the functions in this section, you can
|
|
|
|
implement completion for other kinds of names.
|
|
|
|
|
|
|
|
The @code{try-completion} function is the basic primitive for
|
|
|
|
completion: it returns the longest determined completion of a given
|
|
|
|
initial string, with a given set of strings to match against.
|
|
|
|
|
|
|
|
The function @code{completing-read} provides a higher-level interface
|
|
|
|
for completion. A call to @code{completing-read} specifies how to
|
|
|
|
determine the list of valid names. The function then activates the
|
|
|
|
minibuffer with a local keymap that binds a few keys to commands useful
|
|
|
|
for completion. Other functions provide convenient simple interfaces
|
|
|
|
for reading certain kinds of names with completion.
|
|
|
|
|
|
|
|
@menu
|
|
|
|
* Basic Completion:: Low-level functions for completing strings.
|
|
|
|
* Minibuffer Completion:: Invoking the minibuffer with completion.
|
|
|
|
* Completion Commands:: Minibuffer commands that do completion.
|
|
|
|
* High-Level Completion:: Convenient special cases of completion
|
2012-04-19 21:37:14 -04:00
|
|
|
(reading buffer names, variable names, etc.).
|
2008-10-19 16:12:19 +00:00
|
|
|
* Reading File Names:: Using completion to read file names and
|
|
|
|
shell commands.
|
2012-04-04 17:19:32 +08:00
|
|
|
* Completion Variables:: Variables controlling completion behavior.
|
|
|
|
* Programmed Completion:: Writing your own completion function.
|
2012-02-15 21:45:02 +08:00
|
|
|
* Completion in Buffers:: Completing text in ordinary buffers.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end menu
|
|
|
|
|
|
|
|
@node Basic Completion
|
|
|
|
@subsection Basic Completion Functions
|
|
|
|
|
2010-04-25 17:21:51 -04:00
|
|
|
The following completion functions have nothing in themselves to do
|
|
|
|
with minibuffers. We describe them here to keep them near the
|
|
|
|
higher-level completion features that do use the minibuffer.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@defun try-completion string collection &optional predicate
|
|
|
|
This function returns the longest common substring of all possible
|
2012-02-15 21:45:02 +08:00
|
|
|
completions of @var{string} in @var{collection}.
|
|
|
|
|
|
|
|
@cindex completion table
|
2012-10-05 15:48:25 +08:00
|
|
|
@var{collection} is called the @dfn{completion table}. Its value must
|
|
|
|
be a list of strings or cons cells, an obarray, a hash table, or a
|
|
|
|
completion function.
|
|
|
|
|
|
|
|
@code{try-completion} compares @var{string} against each of the
|
|
|
|
permissible completions specified by the completion table. If no
|
|
|
|
permissible completions match, it returns @code{nil}. If there is
|
|
|
|
just one matching completion, and the match is exact, it returns
|
2010-04-25 17:21:51 -04:00
|
|
|
@code{t}. Otherwise, it returns the longest initial sequence common
|
|
|
|
to all possible matching completions.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2015-03-14 19:46:01 +02:00
|
|
|
If @var{collection} is a list, the permissible completions are
|
2012-10-05 15:48:25 +08:00
|
|
|
specified by the elements of the list, each of which should be either
|
|
|
|
a string, or a cons cell whose @sc{car} is either a string or a symbol
|
|
|
|
(a symbol is converted to a string using @code{symbol-name}). If the
|
|
|
|
list contains elements of any other type, those are ignored.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@cindex obarray in completion
|
|
|
|
If @var{collection} is an obarray (@pxref{Creating Symbols}), the names
|
2012-04-19 21:37:14 -04:00
|
|
|
of all symbols in the obarray form the set of permissible completions.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
If @var{collection} is a hash table, then the keys that are strings
|
|
|
|
are the possible completions. Other keys are ignored.
|
|
|
|
|
2012-02-15 21:45:02 +08:00
|
|
|
You can also use a function as @var{collection}. Then the function is
|
|
|
|
solely responsible for performing completion; @code{try-completion}
|
|
|
|
returns whatever this function returns. The function is called with
|
|
|
|
three arguments: @var{string}, @var{predicate} and @code{nil} (the
|
2012-05-04 19:49:19 -07:00
|
|
|
third argument is so that the same function can be used
|
2012-02-15 21:45:02 +08:00
|
|
|
in @code{all-completions} and do the appropriate thing in either
|
|
|
|
case). @xref{Programmed Completion}.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
If the argument @var{predicate} is non-@code{nil}, then it must be a
|
|
|
|
function of one argument, unless @var{collection} is a hash table, in
|
|
|
|
which case it should be a function of two arguments. It is used to
|
|
|
|
test each possible match, and the match is accepted only if
|
|
|
|
@var{predicate} returns non-@code{nil}. The argument given to
|
|
|
|
@var{predicate} is either a string or a cons cell (the @sc{car} of
|
|
|
|
which is a string) from the alist, or a symbol (@emph{not} a symbol
|
|
|
|
name) from the obarray. If @var{collection} is a hash table,
|
|
|
|
@var{predicate} is called with two arguments, the string key and the
|
|
|
|
associated value.
|
|
|
|
|
|
|
|
In addition, to be acceptable, a completion must also match all the
|
|
|
|
regular expressions in @code{completion-regexp-list}. (Unless
|
|
|
|
@var{collection} is a function, in which case that function has to
|
|
|
|
handle @code{completion-regexp-list} itself.)
|
|
|
|
|
|
|
|
In the first of the following examples, the string @samp{foo} is
|
|
|
|
matched by three of the alist @sc{car}s. All of the matches begin with
|
|
|
|
the characters @samp{fooba}, so that is the result. In the second
|
2012-05-04 19:49:19 -07:00
|
|
|
example, there is only one possible match, and it is exact, so the
|
|
|
|
return value is @code{t}.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
(try-completion
|
|
|
|
"foo"
|
|
|
|
'(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4)))
|
|
|
|
@result{} "fooba"
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
(try-completion "foo" '(("barfoo" 2) ("foo" 3)))
|
|
|
|
@result{} t
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
|
|
|
|
In the following example, numerous symbols begin with the characters
|
|
|
|
@samp{forw}, and all of them begin with the word @samp{forward}. In
|
|
|
|
most of the symbols, this is followed with a @samp{-}, but not in all,
|
|
|
|
so no more than @samp{forward} can be completed.
|
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
(try-completion "forw" obarray)
|
|
|
|
@result{} "forward"
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
|
|
|
|
Finally, in the following example, only two of the three possible
|
|
|
|
matches pass the predicate @code{test} (the string @samp{foobaz} is
|
|
|
|
too short). Both of those begin with the string @samp{foobar}.
|
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
(defun test (s)
|
|
|
|
(> (length (car s)) 6))
|
|
|
|
@result{} test
|
|
|
|
@end group
|
|
|
|
@group
|
|
|
|
(try-completion
|
|
|
|
"foo"
|
|
|
|
'(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
|
|
|
|
'test)
|
|
|
|
@result{} "foobar"
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
@end defun
|
|
|
|
|
2012-04-19 21:37:14 -04:00
|
|
|
@c Removed obsolete argument nospace.
|
|
|
|
@defun all-completions string collection &optional predicate
|
2007-09-06 04:25:08 +00:00
|
|
|
This function returns a list of all possible completions of
|
2012-04-19 21:37:14 -04:00
|
|
|
@var{string}. The arguments to this function
|
|
|
|
@c (aside from @var{nospace})
|
2012-12-05 14:27:56 -08:00
|
|
|
are the same as those of @code{try-completion}, and it
|
2012-04-19 21:37:14 -04:00
|
|
|
uses @code{completion-regexp-list} in the same way that
|
2009-12-25 20:04:07 +00:00
|
|
|
@code{try-completion} does.
|
|
|
|
|
2012-04-19 21:37:14 -04:00
|
|
|
@ignore
|
2009-12-25 20:04:07 +00:00
|
|
|
The optional argument @var{nospace} is obsolete. If it is
|
|
|
|
non-@code{nil}, completions that start with a space are ignored unless
|
|
|
|
@var{string} starts with a space.
|
2012-04-19 21:37:14 -04:00
|
|
|
@end ignore
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
If @var{collection} is a function, it is called with three arguments:
|
|
|
|
@var{string}, @var{predicate} and @code{t}; then @code{all-completions}
|
|
|
|
returns whatever the function returns. @xref{Programmed Completion}.
|
|
|
|
|
|
|
|
Here is an example, using the function @code{test} shown in the
|
|
|
|
example for @code{try-completion}:
|
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
(defun test (s)
|
|
|
|
(> (length (car s)) 6))
|
|
|
|
@result{} test
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
(all-completions
|
|
|
|
"foo"
|
|
|
|
'(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
|
|
|
|
'test)
|
|
|
|
@result{} ("foobar1" "foobar2")
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun test-completion string collection &optional predicate
|
|
|
|
@anchor{Definition of test-completion}
|
|
|
|
This function returns non-@code{nil} if @var{string} is a valid
|
2012-04-04 17:19:32 +08:00
|
|
|
completion alternative specified by @var{collection} and
|
2007-09-06 04:25:08 +00:00
|
|
|
@var{predicate}. The arguments are the same as in
|
|
|
|
@code{try-completion}. For instance, if @var{collection} is a list of
|
|
|
|
strings, this is true if @var{string} appears in the list and
|
|
|
|
@var{predicate} is satisfied.
|
|
|
|
|
|
|
|
This function uses @code{completion-regexp-list} in the same
|
|
|
|
way that @code{try-completion} does.
|
|
|
|
|
|
|
|
If @var{predicate} is non-@code{nil} and if @var{collection} contains
|
|
|
|
several strings that are equal to each other, as determined by
|
|
|
|
@code{compare-strings} according to @code{completion-ignore-case},
|
|
|
|
then @var{predicate} should accept either all or none of them.
|
|
|
|
Otherwise, the return value of @code{test-completion} is essentially
|
|
|
|
unpredictable.
|
|
|
|
|
|
|
|
If @var{collection} is a function, it is called with three arguments,
|
|
|
|
the values @var{string}, @var{predicate} and @code{lambda}; whatever
|
|
|
|
it returns, @code{test-completion} returns in turn.
|
2010-05-31 00:50:31 +02:00
|
|
|
@end defun
|
2010-05-30 17:18:35 -04:00
|
|
|
|
|
|
|
@defun completion-boundaries string collection predicate suffix
|
|
|
|
This function returns the boundaries of the field on which @var{collection}
|
|
|
|
will operate, assuming that @var{string} holds the text before point
|
|
|
|
and @var{suffix} holds the text after point.
|
|
|
|
|
|
|
|
Normally completion operates on the whole string, so for all normal
|
|
|
|
collections, this will always return @code{(0 . (length
|
|
|
|
@var{suffix}))}. But more complex completion such as completion on
|
|
|
|
files is done one field at a time. For example, completion of
|
|
|
|
@code{"/usr/sh"} will include @code{"/usr/share/"} but not
|
|
|
|
@code{"/usr/share/doc"} even if @code{"/usr/share/doc"} exists.
|
|
|
|
Also @code{all-completions} on @code{"/usr/sh"} will not include
|
|
|
|
@code{"/usr/share/"} but only @code{"share/"}. So if @var{string} is
|
|
|
|
@code{"/usr/sh"} and @var{suffix} is @code{"e/doc"},
|
|
|
|
@code{completion-boundaries} will return @code{(5 . 1)} which tells us
|
|
|
|
that the @var{collection} will only return completion information that
|
|
|
|
pertains to the area after @code{"/usr/"} and before @code{"/doc"}.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defun
|
|
|
|
|
2010-04-25 17:21:51 -04:00
|
|
|
If you store a completion alist in a variable, you should mark the
|
2015-09-15 08:46:48 -07:00
|
|
|
variable as risky by giving it a non-@code{nil}
|
2010-04-25 17:21:51 -04:00
|
|
|
@code{risky-local-variable} property. @xref{File Local Variables}.
|
|
|
|
|
2007-09-06 04:25:08 +00:00
|
|
|
@defvar completion-ignore-case
|
2011-05-29 13:18:46 -04:00
|
|
|
If the value of this variable is non-@code{nil}, case is not
|
|
|
|
considered significant in completion. Within @code{read-file-name},
|
|
|
|
this variable is overridden by
|
|
|
|
@code{read-file-name-completion-ignore-case} (@pxref{Reading File
|
|
|
|
Names}); within @code{read-buffer}, it is overridden by
|
|
|
|
@code{read-buffer-completion-ignore-case} (@pxref{High-Level
|
|
|
|
Completion}).
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar completion-regexp-list
|
|
|
|
This is a list of regular expressions. The completion functions only
|
|
|
|
consider a completion acceptable if it matches all regular expressions
|
|
|
|
in this list, with @code{case-fold-search} (@pxref{Searching and Case})
|
|
|
|
bound to the value of @code{completion-ignore-case}.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defmac lazy-completion-table var fun
|
|
|
|
This macro provides a way to initialize the variable @var{var} as a
|
|
|
|
collection for completion in a lazy way, not computing its actual
|
|
|
|
contents until they are first needed. You use this macro to produce a
|
|
|
|
value that you store in @var{var}. The actual computation of the
|
|
|
|
proper value is done the first time you do completion using @var{var}.
|
|
|
|
It is done by calling @var{fun} with no arguments. The
|
|
|
|
value @var{fun} returns becomes the permanent value of @var{var}.
|
|
|
|
|
2012-04-19 21:37:14 -04:00
|
|
|
Here is an example:
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@smallexample
|
|
|
|
(defvar foo (lazy-completion-table foo make-my-alist))
|
|
|
|
@end smallexample
|
|
|
|
@end defmac
|
|
|
|
|
2012-11-17 14:45:24 -08:00
|
|
|
@c FIXME? completion-table-with-context?
|
|
|
|
@findex completion-table-case-fold
|
|
|
|
@findex completion-table-in-turn
|
2014-02-06 03:22:38 +02:00
|
|
|
@findex completion-table-merge
|
2012-11-17 14:45:24 -08:00
|
|
|
@findex completion-table-subvert
|
2012-11-17 15:29:29 -08:00
|
|
|
@findex completion-table-with-quoting
|
2012-11-17 14:45:24 -08:00
|
|
|
@findex completion-table-with-predicate
|
|
|
|
@findex completion-table-with-terminator
|
2012-11-17 15:24:36 -08:00
|
|
|
@cindex completion table, modifying
|
|
|
|
@cindex completion tables, combining
|
2012-11-17 14:45:24 -08:00
|
|
|
There are several functions that take an existing completion table and
|
|
|
|
return a modified version. @code{completion-table-case-fold} returns
|
2014-02-06 03:22:38 +02:00
|
|
|
a case-insensitive table. @code{completion-table-in-turn} and
|
|
|
|
@code{completion-table-merge} combine multiple input tables in
|
|
|
|
different ways. @code{completion-table-subvert} alters a table to use
|
|
|
|
a different initial prefix. @code{completion-table-with-quoting}
|
2012-11-17 15:29:29 -08:00
|
|
|
returns a table suitable for operating on quoted text.
|
2012-11-17 14:45:24 -08:00
|
|
|
@code{completion-table-with-predicate} filters a table with a
|
2012-11-17 15:29:29 -08:00
|
|
|
predicate function. @code{completion-table-with-terminator} adds a
|
|
|
|
terminating string.
|
2012-11-17 14:45:24 -08:00
|
|
|
|
|
|
|
|
2007-09-06 04:25:08 +00:00
|
|
|
@node Minibuffer Completion
|
|
|
|
@subsection Completion and the Minibuffer
|
|
|
|
@cindex minibuffer completion
|
|
|
|
@cindex reading from minibuffer with completion
|
|
|
|
|
|
|
|
This section describes the basic interface for reading from the
|
|
|
|
minibuffer with completion.
|
|
|
|
|
2012-04-18 22:00:23 -04:00
|
|
|
@defun completing-read prompt collection &optional predicate require-match initial history default inherit-input-method
|
2007-09-06 04:25:08 +00:00
|
|
|
This function reads a string in the minibuffer, assisting the user by
|
|
|
|
providing completion. It activates the minibuffer with prompt
|
|
|
|
@var{prompt}, which must be a string.
|
|
|
|
|
2012-02-15 21:45:02 +08:00
|
|
|
The actual completion is done by passing the completion table
|
|
|
|
@var{collection} and the completion predicate @var{predicate} to the
|
|
|
|
function @code{try-completion} (@pxref{Basic Completion}). This
|
|
|
|
happens in certain commands bound in the local keymaps used for
|
|
|
|
completion. Some of these commands also call @code{test-completion}.
|
|
|
|
Thus, if @var{predicate} is non-@code{nil}, it should be compatible
|
|
|
|
with @var{collection} and @code{completion-ignore-case}.
|
|
|
|
@xref{Definition of test-completion}.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2009-03-17 04:54:14 +00:00
|
|
|
The value of the optional argument @var{require-match} determines how
|
|
|
|
the user may exit the minibuffer:
|
|
|
|
|
|
|
|
@itemize @bullet
|
|
|
|
@item
|
|
|
|
If @code{nil}, the usual minibuffer exit commands work regardless of
|
|
|
|
the input in the minibuffer.
|
|
|
|
|
|
|
|
@item
|
|
|
|
If @code{t}, the usual minibuffer exit commands won't exit unless the
|
|
|
|
input completes to an element of @var{collection}.
|
|
|
|
|
|
|
|
@item
|
|
|
|
If @code{confirm}, the user can exit with any input, but is asked for
|
|
|
|
confirmation if the input is not an element of @var{collection}.
|
|
|
|
|
|
|
|
@item
|
|
|
|
If @code{confirm-after-completion}, the user can exit with any input,
|
|
|
|
but is asked for confirmation if the preceding command was a
|
|
|
|
completion command (i.e., one of the commands in
|
|
|
|
@code{minibuffer-confirm-exit-commands}) and the resulting input is
|
|
|
|
not an element of @var{collection}. @xref{Completion Commands}.
|
|
|
|
|
|
|
|
@item
|
|
|
|
Any other value of @var{require-match} behaves like @code{t}, except
|
|
|
|
that the exit commands won't exit if it performs completion.
|
|
|
|
@end itemize
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
However, empty input is always permitted, regardless of the value of
|
2007-10-26 09:48:56 +00:00
|
|
|
@var{require-match}; in that case, @code{completing-read} returns the
|
|
|
|
first element of @var{default}, if it is a list; @code{""}, if
|
2007-10-28 14:47:58 +00:00
|
|
|
@var{default} is @code{nil}; or @var{default}. The string or strings
|
|
|
|
in @var{default} are also available to the user through the history
|
2007-10-26 09:48:56 +00:00
|
|
|
commands.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
The function @code{completing-read} uses
|
|
|
|
@code{minibuffer-local-completion-map} as the keymap if
|
|
|
|
@var{require-match} is @code{nil}, and uses
|
|
|
|
@code{minibuffer-local-must-match-map} if @var{require-match} is
|
|
|
|
non-@code{nil}. @xref{Completion Commands}.
|
|
|
|
|
2012-04-18 22:00:23 -04:00
|
|
|
The argument @var{history} specifies which history list variable to use for
|
2007-09-06 04:25:08 +00:00
|
|
|
saving the input and for minibuffer history commands. It defaults to
|
|
|
|
@code{minibuffer-history}. @xref{Minibuffer History}.
|
|
|
|
|
|
|
|
The argument @var{initial} is mostly deprecated; we recommend using a
|
|
|
|
non-@code{nil} value only in conjunction with specifying a cons cell
|
2012-04-18 22:00:23 -04:00
|
|
|
for @var{history}. @xref{Initial Input}. For default input, use
|
2007-09-06 04:25:08 +00:00
|
|
|
@var{default} instead.
|
|
|
|
|
|
|
|
If the argument @var{inherit-input-method} is non-@code{nil}, then the
|
|
|
|
minibuffer inherits the current input method (@pxref{Input
|
|
|
|
Methods}) and the setting of @code{enable-multibyte-characters}
|
|
|
|
(@pxref{Text Representations}) from whichever buffer was current before
|
|
|
|
entering the minibuffer.
|
|
|
|
|
2012-04-19 21:37:14 -04:00
|
|
|
If the variable @code{completion-ignore-case} is
|
2007-09-06 04:25:08 +00:00
|
|
|
non-@code{nil}, completion ignores case when comparing the input
|
|
|
|
against the possible matches. @xref{Basic Completion}. In this mode
|
|
|
|
of operation, @var{predicate} must also ignore case, or you will get
|
|
|
|
surprising results.
|
|
|
|
|
|
|
|
Here's an example of using @code{completing-read}:
|
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
(completing-read
|
|
|
|
"Complete a foo: "
|
|
|
|
'(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
|
|
|
|
nil t "fo")
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
;; @r{After evaluation of the preceding expression,}
|
|
|
|
;; @r{the following appears in the minibuffer:}
|
|
|
|
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
Complete a foo: fo@point{}
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
If the user then types @kbd{@key{DEL} @key{DEL} b @key{RET}},
|
|
|
|
@code{completing-read} returns @code{barfoo}.
|
|
|
|
|
|
|
|
The @code{completing-read} function binds variables to pass
|
|
|
|
information to the commands that actually do completion.
|
|
|
|
They are described in the following section.
|
|
|
|
@end defun
|
|
|
|
|
2012-04-04 18:32:35 +08:00
|
|
|
@defvar completing-read-function
|
|
|
|
The value of this variable must be a function, which is called by
|
|
|
|
@code{completing-read} to actually do its work. It should accept the
|
|
|
|
same arguments as @code{completing-read}. This can be bound to a
|
|
|
|
different function to completely override the normal behavior of
|
|
|
|
@code{completing-read}.
|
|
|
|
@end defvar
|
|
|
|
|
2007-09-06 04:25:08 +00:00
|
|
|
@node Completion Commands
|
|
|
|
@subsection Minibuffer Commands that Do Completion
|
|
|
|
|
|
|
|
This section describes the keymaps, commands and user options used
|
2009-03-17 04:54:14 +00:00
|
|
|
in the minibuffer to do completion.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@defvar minibuffer-completion-table
|
2012-02-15 21:45:02 +08:00
|
|
|
The value of this variable is the completion table used for completion
|
|
|
|
in the minibuffer. This is the global variable that contains what
|
2007-09-06 04:25:08 +00:00
|
|
|
@code{completing-read} passes to @code{try-completion}. It is used by
|
2012-02-15 21:45:02 +08:00
|
|
|
minibuffer completion commands such as
|
|
|
|
@code{minibuffer-complete-word}.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar minibuffer-completion-predicate
|
|
|
|
This variable's value is the predicate that @code{completing-read}
|
|
|
|
passes to @code{try-completion}. The variable is also used by the other
|
|
|
|
minibuffer completion functions.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar minibuffer-completion-confirm
|
2009-03-17 04:54:14 +00:00
|
|
|
This variable determines whether Emacs asks for confirmation before
|
|
|
|
exiting the minibuffer; @code{completing-read} binds this variable,
|
|
|
|
and the function @code{minibuffer-complete-and-exit} checks the value
|
|
|
|
before exiting. If the value is @code{nil}, confirmation is not
|
|
|
|
required. If the value is @code{confirm}, the user may exit with an
|
|
|
|
input that is not a valid completion alternative, but Emacs asks for
|
|
|
|
confirmation. If the value is @code{confirm-after-completion}, the
|
|
|
|
user may exit with an input that is not a valid completion
|
|
|
|
alternative, but Emacs asks for confirmation if the user submitted the
|
|
|
|
input right after any of the completion commands in
|
|
|
|
@code{minibuffer-confirm-exit-commands}.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar minibuffer-confirm-exit-commands
|
|
|
|
This variable holds a list of commands that cause Emacs to ask for
|
|
|
|
confirmation before exiting the minibuffer, if the @var{require-match}
|
|
|
|
argument to @code{completing-read} is @code{confirm-after-completion}.
|
|
|
|
The confirmation is requested if the user attempts to exit the
|
|
|
|
minibuffer immediately after calling any command in this list.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@deffn Command minibuffer-complete-word
|
|
|
|
This function completes the minibuffer contents by at most a single
|
|
|
|
word. Even if the minibuffer contents have only one completion,
|
|
|
|
@code{minibuffer-complete-word} does not add any characters beyond the
|
|
|
|
first character that is not a word constituent. @xref{Syntax Tables}.
|
|
|
|
@end deffn
|
|
|
|
|
|
|
|
@deffn Command minibuffer-complete
|
|
|
|
This function completes the minibuffer contents as far as possible.
|
|
|
|
@end deffn
|
|
|
|
|
|
|
|
@deffn Command minibuffer-complete-and-exit
|
|
|
|
This function completes the minibuffer contents, and exits if
|
|
|
|
confirmation is not required, i.e., if
|
|
|
|
@code{minibuffer-completion-confirm} is @code{nil}. If confirmation
|
|
|
|
@emph{is} required, it is given by repeating this command
|
|
|
|
immediately---the command is programmed to work without confirmation
|
|
|
|
when run twice in succession.
|
|
|
|
@end deffn
|
|
|
|
|
|
|
|
@deffn Command minibuffer-completion-help
|
|
|
|
This function creates a list of the possible completions of the
|
|
|
|
current minibuffer contents. It works by calling @code{all-completions}
|
|
|
|
using the value of the variable @code{minibuffer-completion-table} as
|
|
|
|
the @var{collection} argument, and the value of
|
|
|
|
@code{minibuffer-completion-predicate} as the @var{predicate} argument.
|
|
|
|
The list of completions is displayed as text in a buffer named
|
2012-04-10 00:11:23 -07:00
|
|
|
@file{*Completions*}.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end deffn
|
|
|
|
|
2014-02-17 13:04:17 -05:00
|
|
|
@defun display-completion-list completions
|
2007-09-06 04:25:08 +00:00
|
|
|
This function displays @var{completions} to the stream in
|
|
|
|
@code{standard-output}, usually a buffer. (@xref{Read and Print}, for more
|
|
|
|
information about streams.) The argument @var{completions} is normally
|
|
|
|
a list of completions just returned by @code{all-completions}, but it
|
|
|
|
does not have to be. Each element may be a symbol or a string, either
|
|
|
|
of which is simply printed. It can also be a list of two strings,
|
|
|
|
which is printed as if the strings were concatenated. The first of
|
|
|
|
the two strings is the actual completion, the second string serves as
|
|
|
|
annotation.
|
|
|
|
|
2012-04-19 21:37:14 -04:00
|
|
|
This function is called by @code{minibuffer-completion-help}. A
|
|
|
|
common way to use it is together with
|
2007-09-06 04:25:08 +00:00
|
|
|
@code{with-output-to-temp-buffer}, like this:
|
|
|
|
|
|
|
|
@example
|
|
|
|
(with-output-to-temp-buffer "*Completions*"
|
|
|
|
(display-completion-list
|
2014-02-17 13:04:17 -05:00
|
|
|
(all-completions (buffer-string) my-alist)))
|
2007-09-06 04:25:08 +00:00
|
|
|
@end example
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defopt completion-auto-help
|
|
|
|
If this variable is non-@code{nil}, the completion commands
|
|
|
|
automatically display a list of possible completions whenever nothing
|
|
|
|
can be completed because the next character is not uniquely determined.
|
|
|
|
@end defopt
|
|
|
|
|
|
|
|
@defvar minibuffer-local-completion-map
|
|
|
|
@code{completing-read} uses this value as the local keymap when an
|
|
|
|
exact match of one of the completions is not required. By default, this
|
|
|
|
keymap makes the following bindings:
|
|
|
|
|
|
|
|
@table @asis
|
|
|
|
@item @kbd{?}
|
|
|
|
@code{minibuffer-completion-help}
|
|
|
|
|
|
|
|
@item @key{SPC}
|
|
|
|
@code{minibuffer-complete-word}
|
|
|
|
|
|
|
|
@item @key{TAB}
|
|
|
|
@code{minibuffer-complete}
|
|
|
|
@end table
|
|
|
|
|
|
|
|
@noindent
|
2012-04-19 21:37:14 -04:00
|
|
|
and uses @code{minibuffer-local-map} as its parent keymap
|
2007-09-06 04:25:08 +00:00
|
|
|
(@pxref{Definition of minibuffer-local-map}).
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar minibuffer-local-must-match-map
|
|
|
|
@code{completing-read} uses this value as the local keymap when an
|
|
|
|
exact match of one of the completions is required. Therefore, no keys
|
|
|
|
are bound to @code{exit-minibuffer}, the command that exits the
|
|
|
|
minibuffer unconditionally. By default, this keymap makes the following
|
|
|
|
bindings:
|
|
|
|
|
|
|
|
@table @asis
|
|
|
|
@item @kbd{C-j}
|
|
|
|
@code{minibuffer-complete-and-exit}
|
|
|
|
|
|
|
|
@item @key{RET}
|
|
|
|
@code{minibuffer-complete-and-exit}
|
|
|
|
@end table
|
|
|
|
|
|
|
|
@noindent
|
2012-04-19 21:37:14 -04:00
|
|
|
and uses @code{minibuffer-local-completion-map} as its parent keymap.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar minibuffer-local-filename-completion-map
|
2012-04-19 21:37:14 -04:00
|
|
|
This is a sparse keymap that simply unbinds @key{SPC}; because
|
|
|
|
filenames can contain spaces. The function @code{read-file-name}
|
|
|
|
combines this keymap with either @code{minibuffer-local-completion-map}
|
|
|
|
or @code{minibuffer-local-must-match-map}.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defvar
|
|
|
|
|
|
|
|
|
|
|
|
@node High-Level Completion
|
2008-10-19 16:12:19 +00:00
|
|
|
@subsection High-Level Completion Functions
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2012-04-19 21:37:14 -04:00
|
|
|
This section describes the higher-level convenience functions for
|
2007-09-06 04:25:08 +00:00
|
|
|
reading certain sorts of names with completion.
|
|
|
|
|
|
|
|
In most cases, you should not call these functions in the middle of a
|
|
|
|
Lisp function. When possible, do all minibuffer input as part of
|
|
|
|
reading the arguments for a command, in the @code{interactive}
|
|
|
|
specification. @xref{Defining Commands}.
|
|
|
|
|
2009-03-17 04:54:14 +00:00
|
|
|
@defun read-buffer prompt &optional default require-match
|
2007-09-06 04:25:08 +00:00
|
|
|
This function reads the name of a buffer and returns it as a string.
|
|
|
|
The argument @var{default} is the default name to use, the value to
|
|
|
|
return if the user exits with an empty minibuffer. If non-@code{nil},
|
2007-10-22 00:30:11 +00:00
|
|
|
it should be a string, a list of strings, or a buffer. If it is
|
|
|
|
a list, the default value is the first element of this list. It is
|
|
|
|
mentioned in the prompt, but is not inserted in the minibuffer as
|
|
|
|
initial input.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
The argument @var{prompt} should be a string ending with a colon and a
|
|
|
|
space. If @var{default} is non-@code{nil}, the function inserts it in
|
|
|
|
@var{prompt} before the colon to follow the convention for reading from
|
|
|
|
the minibuffer with a default value (@pxref{Programming Tips}).
|
|
|
|
|
2009-03-17 04:54:14 +00:00
|
|
|
The optional argument @var{require-match} has the same meaning as in
|
|
|
|
@code{completing-read}. @xref{Minibuffer Completion}.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
In the following example, the user enters @samp{minibuffer.t}, and
|
2009-03-17 04:54:14 +00:00
|
|
|
then types @key{RET}. The argument @var{require-match} is @code{t},
|
|
|
|
and the only buffer name starting with the given input is
|
2007-09-06 04:25:08 +00:00
|
|
|
@samp{minibuffer.texi}, so that name is the value.
|
|
|
|
|
|
|
|
@example
|
|
|
|
(read-buffer "Buffer name: " "foo" t)
|
|
|
|
@group
|
|
|
|
;; @r{After evaluation of the preceding expression,}
|
|
|
|
;; @r{the following prompt appears,}
|
|
|
|
;; @r{with an empty minibuffer:}
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
Buffer name (default foo): @point{}
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
;; @r{The user types @kbd{minibuffer.t @key{RET}}.}
|
|
|
|
@result{} "minibuffer.texi"
|
|
|
|
@end group
|
|
|
|
@end example
|
|
|
|
@end defun
|
|
|
|
|
2009-05-21 15:31:31 +00:00
|
|
|
@defopt read-buffer-function
|
2012-10-27 13:03:52 +08:00
|
|
|
This variable, if non-@code{nil}, specifies a function for reading
|
|
|
|
buffer names. @code{read-buffer} calls this function instead of doing
|
|
|
|
its usual work, with the same arguments passed to @code{read-buffer}.
|
2009-05-21 15:31:31 +00:00
|
|
|
@end defopt
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2009-05-21 15:31:31 +00:00
|
|
|
@defopt read-buffer-completion-ignore-case
|
2009-03-17 04:54:14 +00:00
|
|
|
If this variable is non-@code{nil}, @code{read-buffer} ignores case
|
|
|
|
when performing completion.
|
2009-05-21 15:31:31 +00:00
|
|
|
@end defopt
|
2009-03-17 04:54:14 +00:00
|
|
|
|
2007-09-06 04:25:08 +00:00
|
|
|
@defun read-command prompt &optional default
|
|
|
|
This function reads the name of a command and returns it as a Lisp
|
|
|
|
symbol. The argument @var{prompt} is used as in
|
|
|
|
@code{read-from-minibuffer}. Recall that a command is anything for
|
|
|
|
which @code{commandp} returns @code{t}, and a command name is a symbol
|
|
|
|
for which @code{commandp} returns @code{t}. @xref{Interactive Call}.
|
|
|
|
|
|
|
|
The argument @var{default} specifies what to return if the user enters
|
2007-10-22 00:30:11 +00:00
|
|
|
null input. It can be a symbol, a string or a list of strings. If it
|
|
|
|
is a string, @code{read-command} interns it before returning it.
|
2012-04-19 21:37:14 -04:00
|
|
|
If it is a list, @code{read-command} interns the first element of this list.
|
2007-10-22 00:30:11 +00:00
|
|
|
If @var{default} is @code{nil}, that means no default has been
|
|
|
|
specified; then if the user enters null input, the return value is
|
|
|
|
@code{(intern "")}, that is, a symbol whose name is an empty string.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@example
|
|
|
|
(read-command "Command name? ")
|
|
|
|
|
|
|
|
@group
|
|
|
|
;; @r{After evaluation of the preceding expression,}
|
|
|
|
;; @r{the following prompt appears with an empty minibuffer:}
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
Command name?
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
@end group
|
|
|
|
@end example
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
If the user types @kbd{forward-c @key{RET}}, then this function returns
|
|
|
|
@code{forward-char}.
|
|
|
|
|
|
|
|
The @code{read-command} function is a simplified interface to
|
|
|
|
@code{completing-read}. It uses the variable @code{obarray} so as to
|
|
|
|
complete in the set of extant Lisp symbols, and it uses the
|
|
|
|
@code{commandp} predicate so as to accept only command names:
|
|
|
|
|
|
|
|
@cindex @code{commandp} example
|
|
|
|
@example
|
|
|
|
@group
|
|
|
|
(read-command @var{prompt})
|
|
|
|
@equiv{}
|
|
|
|
(intern (completing-read @var{prompt} obarray
|
|
|
|
'commandp t nil))
|
|
|
|
@end group
|
|
|
|
@end example
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun read-variable prompt &optional default
|
|
|
|
@anchor{Definition of read-variable}
|
2012-04-20 16:48:50 +08:00
|
|
|
This function reads the name of a customizable variable and returns it
|
|
|
|
as a symbol. Its arguments have the same form as those of
|
|
|
|
@code{read-command}. It behaves just like @code{read-command}, except
|
|
|
|
that it uses the predicate @code{custom-variable-p} instead of
|
|
|
|
@code{commandp}.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defun
|
|
|
|
|
2008-10-21 11:23:57 +00:00
|
|
|
@deffn Command read-color &optional prompt convert allow-empty display
|
|
|
|
This function reads a string that is a color specification, either the
|
|
|
|
color's name or an RGB hex value such as @code{#RRRGGGBBB}. It
|
2012-02-03 20:23:09 -05:00
|
|
|
prompts with @var{prompt} (default: @code{"Color (name or #RGB triplet):"})
|
2008-10-21 11:23:57 +00:00
|
|
|
and provides completion for color names, but not for hex RGB values.
|
|
|
|
In addition to names of standard colors, completion candidates include
|
|
|
|
the foreground and background colors at point.
|
|
|
|
|
|
|
|
Valid RGB values are described in @ref{Color Names}.
|
|
|
|
|
2012-02-03 20:23:09 -05:00
|
|
|
The function's return value is the string typed by the user in the
|
2008-10-21 11:23:57 +00:00
|
|
|
minibuffer. However, when called interactively or if the optional
|
2012-02-03 20:23:09 -05:00
|
|
|
argument @var{convert} is non-@code{nil}, it converts any input color
|
|
|
|
name into the corresponding RGB value string and instead returns that.
|
|
|
|
This function requires a valid color specification to be input.
|
2012-04-19 21:37:14 -04:00
|
|
|
Empty color names are allowed when @var{allow-empty} is
|
2008-10-21 11:23:57 +00:00
|
|
|
non-@code{nil} and the user enters null input.
|
|
|
|
|
2009-06-07 20:45:49 +00:00
|
|
|
Interactively, or when @var{display} is non-@code{nil}, the return
|
2008-10-21 11:23:57 +00:00
|
|
|
value is also displayed in the echo area.
|
|
|
|
@end deffn
|
|
|
|
|
2007-09-06 04:25:08 +00:00
|
|
|
See also the functions @code{read-coding-system} and
|
|
|
|
@code{read-non-nil-coding-system}, in @ref{User-Chosen Coding Systems},
|
|
|
|
and @code{read-input-method-name}, in @ref{Input Methods}.
|
|
|
|
|
|
|
|
@node Reading File Names
|
|
|
|
@subsection Reading File Names
|
|
|
|
@cindex read file names
|
|
|
|
@cindex prompt for file name
|
|
|
|
|
2009-06-07 20:45:49 +00:00
|
|
|
The high-level completion functions @code{read-file-name},
|
|
|
|
@code{read-directory-name}, and @code{read-shell-command} are designed
|
2012-04-19 21:37:14 -04:00
|
|
|
to read file names, directory names, and shell commands, respectively.
|
2009-06-07 20:45:49 +00:00
|
|
|
They provide special features, including automatic insertion of the
|
|
|
|
default directory.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2009-03-17 04:54:14 +00:00
|
|
|
@defun read-file-name prompt &optional directory default require-match initial predicate
|
2009-11-02 02:30:04 +00:00
|
|
|
This function reads a file name, prompting with @var{prompt} and
|
|
|
|
providing completion.
|
|
|
|
|
|
|
|
As an exception, this function reads a file name using a graphical
|
2012-04-19 21:37:14 -04:00
|
|
|
file dialog instead of the minibuffer, if all of the following are
|
|
|
|
true:
|
|
|
|
|
|
|
|
@enumerate
|
|
|
|
@item
|
|
|
|
It is invoked via a mouse command.
|
|
|
|
|
|
|
|
@item
|
|
|
|
The selected frame is on a graphical display supporting such dialogs.
|
|
|
|
|
|
|
|
@item
|
|
|
|
The variable @code{use-dialog-box} is non-@code{nil}.
|
|
|
|
@xref{Dialog Boxes,, Dialog Boxes, emacs, The GNU Emacs Manual}.
|
|
|
|
|
|
|
|
@item
|
|
|
|
The @var{directory} argument, described below, does not specify a
|
|
|
|
remote file. @xref{Remote Files,, Remote Files, emacs, The GNU Emacs Manual}.
|
|
|
|
@end enumerate
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
The exact behavior when using a graphical file dialog is
|
|
|
|
platform-dependent. Here, we simply document the behavior when using
|
|
|
|
the minibuffer.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2011-05-28 15:58:43 -04:00
|
|
|
@code{read-file-name} does not automatically expand the returned file
|
|
|
|
name. You must call @code{expand-file-name} yourself if an absolute
|
|
|
|
file name is required.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2011-05-28 15:58:43 -04:00
|
|
|
The optional argument @var{require-match} has the same meaning as in
|
2012-04-04 18:32:35 +08:00
|
|
|
@code{completing-read}. @xref{Minibuffer Completion}.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
The argument @var{directory} specifies the directory to use for
|
2011-05-28 15:58:43 -04:00
|
|
|
completing relative file names. It should be an absolute directory
|
2012-04-19 21:37:14 -04:00
|
|
|
name. If the variable @code{insert-default-directory} is non-@code{nil},
|
2007-09-06 04:25:08 +00:00
|
|
|
@var{directory} is also inserted in the minibuffer as initial input.
|
|
|
|
It defaults to the current buffer's value of @code{default-directory}.
|
|
|
|
|
|
|
|
If you specify @var{initial}, that is an initial file name to insert
|
|
|
|
in the buffer (after @var{directory}, if that is inserted). In this
|
|
|
|
case, point goes at the beginning of @var{initial}. The default for
|
|
|
|
@var{initial} is @code{nil}---don't insert any file name. To see what
|
2012-04-19 21:37:14 -04:00
|
|
|
@var{initial} does, try the command @kbd{C-x C-v} in a buffer visiting
|
|
|
|
a file. @strong{Please note:} we recommend using @var{default} rather
|
|
|
|
than @var{initial} in most cases.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
If @var{default} is non-@code{nil}, then the function returns
|
|
|
|
@var{default} if the user exits the minibuffer with the same non-empty
|
|
|
|
contents that @code{read-file-name} inserted initially. The initial
|
|
|
|
minibuffer contents are always non-empty if
|
|
|
|
@code{insert-default-directory} is non-@code{nil}, as it is by
|
|
|
|
default. @var{default} is not checked for validity, regardless of the
|
2009-03-17 04:54:14 +00:00
|
|
|
value of @var{require-match}. However, if @var{require-match} is
|
2007-09-06 04:25:08 +00:00
|
|
|
non-@code{nil}, the initial minibuffer contents should be a valid file
|
|
|
|
(or directory) name. Otherwise @code{read-file-name} attempts
|
|
|
|
completion if the user exits without any editing, and does not return
|
|
|
|
@var{default}. @var{default} is also available through the history
|
|
|
|
commands.
|
|
|
|
|
|
|
|
If @var{default} is @code{nil}, @code{read-file-name} tries to find a
|
|
|
|
substitute default to use in its place, which it treats in exactly the
|
|
|
|
same way as if it had been specified explicitly. If @var{default} is
|
|
|
|
@code{nil}, but @var{initial} is non-@code{nil}, then the default is
|
|
|
|
the absolute file name obtained from @var{directory} and
|
|
|
|
@var{initial}. If both @var{default} and @var{initial} are @code{nil}
|
|
|
|
and the buffer is visiting a file, @code{read-file-name} uses the
|
|
|
|
absolute file name of that file as default. If the buffer is not
|
|
|
|
visiting a file, then there is no default. In that case, if the user
|
|
|
|
types @key{RET} without any editing, @code{read-file-name} simply
|
|
|
|
returns the pre-inserted contents of the minibuffer.
|
|
|
|
|
|
|
|
If the user types @key{RET} in an empty minibuffer, this function
|
2009-03-17 04:54:14 +00:00
|
|
|
returns an empty string, regardless of the value of
|
|
|
|
@var{require-match}. This is, for instance, how the user can make the
|
2012-05-15 11:38:50 +02:00
|
|
|
current buffer visit no file using @kbd{M-x set-visited-file-name}.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
If @var{predicate} is non-@code{nil}, it specifies a function of one
|
|
|
|
argument that decides which file names are acceptable completion
|
2012-04-04 17:19:32 +08:00
|
|
|
alternatives. A file name is an acceptable value if @var{predicate}
|
2007-09-06 04:25:08 +00:00
|
|
|
returns non-@code{nil} for it.
|
|
|
|
|
2011-05-28 15:58:43 -04:00
|
|
|
Here is an example of using @code{read-file-name}:
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@example
|
|
|
|
@group
|
|
|
|
(read-file-name "The file is ")
|
|
|
|
|
|
|
|
;; @r{After evaluation of the preceding expression,}
|
|
|
|
;; @r{the following appears in the minibuffer:}
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
The file is /gp/gnu/elisp/@point{}
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
@end group
|
|
|
|
@end example
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
Typing @kbd{manual @key{TAB}} results in the following:
|
|
|
|
|
|
|
|
@example
|
|
|
|
@group
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
The file is /gp/gnu/elisp/manual.texi@point{}
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
@end group
|
|
|
|
@end example
|
|
|
|
|
|
|
|
@c Wordy to avoid overfull hbox in smallbook mode.
|
|
|
|
@noindent
|
|
|
|
If the user types @key{RET}, @code{read-file-name} returns the file name
|
|
|
|
as the string @code{"/gp/gnu/elisp/manual.texi"}.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defvar read-file-name-function
|
|
|
|
If non-@code{nil}, this should be a function that accepts the same
|
|
|
|
arguments as @code{read-file-name}. When @code{read-file-name} is
|
|
|
|
called, it calls this function with the supplied arguments instead of
|
|
|
|
doing its usual work.
|
|
|
|
@end defvar
|
|
|
|
|
2009-05-21 15:31:31 +00:00
|
|
|
@defopt read-file-name-completion-ignore-case
|
2007-09-06 04:25:08 +00:00
|
|
|
If this variable is non-@code{nil}, @code{read-file-name} ignores case
|
|
|
|
when performing completion.
|
2009-05-21 15:31:31 +00:00
|
|
|
@end defopt
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2009-03-17 04:54:14 +00:00
|
|
|
@defun read-directory-name prompt &optional directory default require-match initial
|
2007-09-06 04:25:08 +00:00
|
|
|
This function is like @code{read-file-name} but allows only directory
|
2012-04-04 17:19:32 +08:00
|
|
|
names as completion alternatives.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
If @var{default} is @code{nil} and @var{initial} is non-@code{nil},
|
|
|
|
@code{read-directory-name} constructs a substitute default by
|
|
|
|
combining @var{directory} (or the current buffer's default directory
|
|
|
|
if @var{directory} is @code{nil}) and @var{initial}. If both
|
|
|
|
@var{default} and @var{initial} are @code{nil}, this function uses
|
|
|
|
@var{directory} as substitute default, or the current buffer's default
|
|
|
|
directory if @var{directory} is @code{nil}.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defopt insert-default-directory
|
|
|
|
This variable is used by @code{read-file-name}, and thus, indirectly,
|
|
|
|
by most commands reading file names. (This includes all commands that
|
|
|
|
use the code letters @samp{f} or @samp{F} in their interactive form.
|
|
|
|
@xref{Interactive Codes,, Code Characters for interactive}.) Its
|
|
|
|
value controls whether @code{read-file-name} starts by placing the
|
|
|
|
name of the default directory in the minibuffer, plus the initial file
|
2012-04-19 21:37:14 -04:00
|
|
|
name, if any. If the value of this variable is @code{nil}, then
|
2007-09-06 04:25:08 +00:00
|
|
|
@code{read-file-name} does not place any initial input in the
|
|
|
|
minibuffer (unless you specify initial input with the @var{initial}
|
|
|
|
argument). In that case, the default directory is still used for
|
|
|
|
completion of relative file names, but is not displayed.
|
|
|
|
|
|
|
|
If this variable is @code{nil} and the initial minibuffer contents are
|
|
|
|
empty, the user may have to explicitly fetch the next history element
|
|
|
|
to access a default value. If the variable is non-@code{nil}, the
|
|
|
|
initial minibuffer contents are always non-empty and the user can
|
|
|
|
always request a default value by immediately typing @key{RET} in an
|
|
|
|
unedited minibuffer. (See above.)
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
@example
|
|
|
|
@group
|
|
|
|
;; @r{Here the minibuffer starts out with the default directory.}
|
|
|
|
(let ((insert-default-directory t))
|
|
|
|
(read-file-name "The file is "))
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
The file is ~lewis/manual/@point{}
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
;; @r{Here the minibuffer is empty and only the prompt}
|
|
|
|
;; @r{appears on its line.}
|
|
|
|
(let ((insert-default-directory nil))
|
|
|
|
(read-file-name "The file is "))
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
The file is @point{}
|
|
|
|
---------- Buffer: Minibuffer ----------
|
|
|
|
@end group
|
|
|
|
@end example
|
|
|
|
@end defopt
|
|
|
|
|
2012-04-18 22:00:23 -04:00
|
|
|
@defun read-shell-command prompt &optional initial history &rest args
|
2008-10-19 16:12:19 +00:00
|
|
|
This function reads a shell command from the minibuffer, prompting
|
|
|
|
with @var{prompt} and providing intelligent completion. It completes
|
|
|
|
the first word of the command using candidates that are appropriate
|
2008-10-20 10:41:50 +00:00
|
|
|
for command names, and the rest of the command words as file names.
|
|
|
|
|
|
|
|
This function uses @code{minibuffer-local-shell-command-map} as the
|
2012-04-18 22:00:23 -04:00
|
|
|
keymap for minibuffer input. The @var{history} argument specifies the
|
2008-10-20 10:41:50 +00:00
|
|
|
history list to use; if is omitted or @code{nil}, it defaults to
|
2008-10-19 16:12:19 +00:00
|
|
|
@code{shell-command-history} (@pxref{Minibuffer History,
|
2012-04-18 22:00:23 -04:00
|
|
|
shell-command-history}). The optional argument @var{initial}
|
2008-10-20 10:41:50 +00:00
|
|
|
specifies the initial content of the minibuffer (@pxref{Initial
|
|
|
|
Input}). The rest of @var{args}, if present, are used as the
|
|
|
|
@var{default} and @var{inherit-input-method} arguments in
|
|
|
|
@code{read-from-minibuffer} (@pxref{Text from Minibuffer}).
|
2008-10-19 16:12:19 +00:00
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defvar minibuffer-local-shell-command-map
|
|
|
|
This keymap is used by @code{read-shell-command} for completing
|
2012-04-19 21:37:14 -04:00
|
|
|
command and file names that are part of a shell command. It uses
|
|
|
|
@code{minibuffer-local-map} as its parent keymap, and binds @key{TAB}
|
|
|
|
to @code{completion-at-point}.
|
2008-10-19 16:12:19 +00:00
|
|
|
@end defvar
|
|
|
|
|
2012-04-04 17:19:32 +08:00
|
|
|
@node Completion Variables
|
|
|
|
@subsection Completion Variables
|
2009-03-18 04:01:05 +00:00
|
|
|
|
2012-04-19 21:37:14 -04:00
|
|
|
Here are some variables that can be used to alter the default
|
2012-04-04 17:19:32 +08:00
|
|
|
completion behavior.
|
2009-03-18 04:01:05 +00:00
|
|
|
|
2012-04-04 17:19:32 +08:00
|
|
|
@cindex completion styles
|
2009-03-18 04:01:05 +00:00
|
|
|
@defopt completion-styles
|
2012-04-06 14:39:35 +08:00
|
|
|
The value of this variable is a list of completion style (symbols) to
|
|
|
|
use for performing completion. A @dfn{completion style} is a set of
|
2012-04-19 21:37:14 -04:00
|
|
|
rules for generating completions. Each symbol occurring this list
|
2012-04-06 14:39:35 +08:00
|
|
|
must have a corresponding entry in @code{completion-styles-alist}.
|
2009-03-18 04:01:05 +00:00
|
|
|
@end defopt
|
|
|
|
|
|
|
|
@defvar completion-styles-alist
|
|
|
|
This variable stores a list of available completion styles. Each
|
2012-04-04 17:19:32 +08:00
|
|
|
element in the list has the form
|
|
|
|
|
|
|
|
@example
|
2012-04-06 14:39:35 +08:00
|
|
|
(@var{style} @var{try-completion} @var{all-completions} @var{doc})
|
2012-04-04 17:19:32 +08:00
|
|
|
@end example
|
|
|
|
|
|
|
|
@noindent
|
2012-04-06 14:39:35 +08:00
|
|
|
Here, @var{style} is the name of the completion style (a symbol),
|
|
|
|
which may be used in the @code{completion-styles} variable to refer to
|
|
|
|
this style; @var{try-completion} is the function that does the
|
|
|
|
completion; @var{all-completions} is the function that lists the
|
|
|
|
completions; and @var{doc} is a string describing the completion
|
|
|
|
style.
|
2012-04-04 17:19:32 +08:00
|
|
|
|
|
|
|
The @var{try-completion} and @var{all-completions} functions should
|
|
|
|
each accept four arguments: @var{string}, @var{collection},
|
|
|
|
@var{predicate}, and @var{point}. The @var{string}, @var{collection},
|
|
|
|
and @var{predicate} arguments have the same meanings as in
|
|
|
|
@code{try-completion} (@pxref{Basic Completion}), and the @var{point}
|
|
|
|
argument is the position of point within @var{string}. Each function
|
|
|
|
should return a non-@code{nil} value if it performed its job, and
|
2012-12-05 14:27:56 -08:00
|
|
|
@code{nil} if it did not (e.g., if there is no way to complete
|
2012-04-04 17:19:32 +08:00
|
|
|
@var{string} according to the completion style).
|
|
|
|
|
|
|
|
When the user calls a completion command like
|
2009-03-18 04:01:05 +00:00
|
|
|
@code{minibuffer-complete} (@pxref{Completion Commands}), Emacs looks
|
|
|
|
for the first style listed in @code{completion-styles} and calls its
|
|
|
|
@var{try-completion} function. If this function returns @code{nil},
|
2012-04-04 17:19:32 +08:00
|
|
|
Emacs moves to the next listed completion style and calls its
|
|
|
|
@var{try-completion} function, and so on until one of the
|
|
|
|
@var{try-completion} functions successfully performs completion and
|
|
|
|
returns a non-@code{nil} value. A similar procedure is used for
|
|
|
|
listing completions, via the @var{all-completions} functions.
|
|
|
|
|
|
|
|
@xref{Completion Styles,,, emacs, The GNU Emacs Manual}, for a
|
|
|
|
description of the available completion styles.
|
2009-03-18 04:01:05 +00:00
|
|
|
@end defvar
|
|
|
|
|
2012-04-06 14:39:35 +08:00
|
|
|
@defopt completion-category-overrides
|
|
|
|
This variable specifies special completion styles and other completion
|
|
|
|
behaviors to use when completing certain types of text. Its value
|
2012-04-19 21:37:14 -04:00
|
|
|
should be an alist with elements of the form @code{(@var{category}
|
|
|
|
. @var{alist})}. @var{category} is a symbol describing what is being
|
|
|
|
completed; currently, the @code{buffer}, @code{file}, and
|
|
|
|
@code{unicode-name} categories are defined, but others can be defined
|
|
|
|
via specialized completion functions (@pxref{Programmed Completion}).
|
|
|
|
@var{alist} is an association list describing how completion should
|
|
|
|
behave for the corresponding category. The following alist keys are
|
|
|
|
supported:
|
2012-04-06 14:39:35 +08:00
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item styles
|
|
|
|
The value should be a list of completion styles (symbols).
|
|
|
|
|
|
|
|
@item cycle
|
|
|
|
The value should be a value for @code{completion-cycle-threshold}
|
|
|
|
(@pxref{Completion Options,,, emacs, The GNU Emacs Manual}) for this
|
|
|
|
category.
|
|
|
|
@end table
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
Additional alist entries may be defined in the future.
|
|
|
|
@end defopt
|
|
|
|
|
2012-04-04 17:19:32 +08:00
|
|
|
@defvar completion-extra-properties
|
|
|
|
This variable is used to specify extra properties of the current
|
|
|
|
completion command. It is intended to be let-bound by specialized
|
|
|
|
completion commands. Its value should be a list of property and value
|
|
|
|
pairs. The following properties are supported:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item :annotation-function
|
|
|
|
The value should be a function to add annotations in the completions
|
|
|
|
buffer. This function must accept one argument, a completion, and
|
|
|
|
should either return @code{nil} or a string to be displayed next to
|
|
|
|
the completion.
|
|
|
|
|
|
|
|
@item :exit-function
|
|
|
|
The value should be a function to run after performing completion.
|
|
|
|
The function should accept two arguments, @var{string} and
|
|
|
|
@var{status}, where @var{string} is the text to which the field was
|
2012-04-19 21:37:14 -04:00
|
|
|
completed, and @var{status} indicates what kind of operation happened:
|
2012-04-04 17:19:32 +08:00
|
|
|
@code{finished} if text is now complete, @code{sole} if the text
|
|
|
|
cannot be further completed but completion is not finished, or
|
|
|
|
@code{exact} if the text is a valid completion but may be further
|
|
|
|
completed.
|
|
|
|
@end table
|
|
|
|
@end defvar
|
2009-03-18 04:01:05 +00:00
|
|
|
|
2007-09-06 04:25:08 +00:00
|
|
|
@node Programmed Completion
|
|
|
|
@subsection Programmed Completion
|
|
|
|
@cindex programmed completion
|
|
|
|
|
2011-03-21 11:30:01 -04:00
|
|
|
Sometimes it is not possible or convenient to create an alist or
|
|
|
|
an obarray containing all the intended possible completions ahead
|
|
|
|
of time. In such a case, you can supply your own function to compute
|
|
|
|
the completion of a given string. This is called @dfn{programmed
|
|
|
|
completion}. Emacs uses programmed completion when completing file
|
|
|
|
names (@pxref{File Name Completion}), among many other cases.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2010-05-30 17:18:35 -04:00
|
|
|
To use this feature, pass a function as the @var{collection}
|
|
|
|
argument to @code{completing-read}. The function
|
2007-09-06 04:25:08 +00:00
|
|
|
@code{completing-read} arranges to pass your completion function along
|
2010-05-30 17:18:35 -04:00
|
|
|
to @code{try-completion}, @code{all-completions}, and other basic
|
|
|
|
completion functions, which will then let your function do all
|
|
|
|
the work.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
The completion function should accept three arguments:
|
|
|
|
|
|
|
|
@itemize @bullet
|
|
|
|
@item
|
|
|
|
The string to be completed.
|
|
|
|
|
|
|
|
@item
|
2012-04-04 17:19:32 +08:00
|
|
|
A predicate function with which to filter possible matches, or
|
|
|
|
@code{nil} if none. The function should call the predicate for each
|
|
|
|
possible match, and ignore the match if the predicate returns
|
|
|
|
@code{nil}.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@item
|
2012-04-04 17:19:32 +08:00
|
|
|
A flag specifying the type of completion operation to perform. This
|
2014-04-08 03:33:48 -07:00
|
|
|
flag may be one of the following values.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2012-04-04 17:19:32 +08:00
|
|
|
@table @code
|
|
|
|
@item nil
|
|
|
|
This specifies a @code{try-completion} operation. The function should
|
|
|
|
return @code{t} if the specified string is a unique and exact match;
|
|
|
|
if there is more than one match, it should return the common substring
|
|
|
|
of all matches (if the string is an exact match for one completion
|
|
|
|
alternative but also matches other longer alternatives, the return
|
|
|
|
value is the string); if there are no matches, it should return
|
|
|
|
@code{nil}.
|
|
|
|
|
|
|
|
@item t
|
|
|
|
This specifies an @code{all-completions} operation. The function
|
2007-09-06 04:25:08 +00:00
|
|
|
should return a list of all possible completions of the specified
|
|
|
|
string.
|
|
|
|
|
2012-04-04 17:19:32 +08:00
|
|
|
@item lambda
|
|
|
|
This specifies a @code{test-completion} operation. The function
|
|
|
|
should return @code{t} if the specified string is an exact match for
|
|
|
|
some completion alternative; @code{nil} otherwise.
|
2010-05-30 17:18:35 -04:00
|
|
|
|
2012-04-04 17:19:32 +08:00
|
|
|
@item (boundaries . @var{suffix})
|
|
|
|
This specifies a @code{completion-boundaries} operation. The function
|
2012-04-18 22:00:23 -04:00
|
|
|
should return @code{(boundaries @var{start} . @var{end})}, where
|
|
|
|
@var{start} is the position of the beginning boundary in the specified
|
|
|
|
string, and @var{end} is the position of the end boundary in
|
|
|
|
@var{suffix}.
|
2012-04-06 14:39:35 +08:00
|
|
|
|
|
|
|
@item metadata
|
|
|
|
This specifies a request for information about the state of the
|
2012-11-17 15:45:52 +08:00
|
|
|
current completion. The return value should have the form
|
|
|
|
@code{(metadata . @var{alist})}, where @var{alist} is an alist whose
|
|
|
|
elements are described below.
|
2012-04-04 17:19:32 +08:00
|
|
|
@end table
|
2012-04-06 14:39:35 +08:00
|
|
|
|
|
|
|
@noindent
|
|
|
|
If the flag has any other value, the completion function should return
|
|
|
|
@code{nil}.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end itemize
|
|
|
|
|
2012-04-06 14:39:35 +08:00
|
|
|
The following is a list of metadata entries that a completion function
|
|
|
|
may return in response to a @code{metadata} flag argument:
|
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item category
|
|
|
|
The value should be a symbol describing what kind of text the
|
|
|
|
completion function is trying to complete. If the symbol matches one
|
|
|
|
of the keys in @code{completion-category-overrides}, the usual
|
|
|
|
completion behavior is overridden. @xref{Completion Variables}.
|
|
|
|
|
|
|
|
@item annotation-function
|
|
|
|
The value should be a function for @dfn{annotating} completions. The
|
|
|
|
function should take one argument, @var{string}, which is a possible
|
|
|
|
completion. It should return a string, which is displayed after the
|
2012-04-10 00:11:23 -07:00
|
|
|
completion @var{string} in the @file{*Completions*} buffer.
|
2012-04-06 14:39:35 +08:00
|
|
|
|
|
|
|
@item display-sort-function
|
|
|
|
The value should be a function for sorting completions. The function
|
|
|
|
should take one argument, a list of completion strings, and return a
|
|
|
|
sorted list of completion strings. It is allowed to alter the input
|
|
|
|
list destructively.
|
|
|
|
|
|
|
|
@item cycle-sort-function
|
|
|
|
The value should be a function for sorting completions, when
|
|
|
|
@code{completion-cycle-threshold} is non-@code{nil} and the user is
|
|
|
|
cycling through completion alternatives. @xref{Completion Options,,,
|
|
|
|
emacs, The GNU Emacs Manual}. Its argument list and return value are
|
|
|
|
the same as for @code{display-sort-function}.
|
|
|
|
@end table
|
|
|
|
|
2008-04-19 03:23:15 +00:00
|
|
|
@defun completion-table-dynamic function
|
|
|
|
This function is a convenient way to write a function that can act as
|
2012-04-19 21:37:14 -04:00
|
|
|
a programmed completion function. The argument @var{function} should be
|
2007-09-06 04:25:08 +00:00
|
|
|
a function that takes one argument, a string, and returns an alist of
|
|
|
|
possible completions of it. You can think of
|
2008-04-19 03:23:15 +00:00
|
|
|
@code{completion-table-dynamic} as a transducer between that interface
|
2007-09-06 04:25:08 +00:00
|
|
|
and the interface for programmed completion functions.
|
2008-04-19 03:23:15 +00:00
|
|
|
@end defun
|
2007-09-06 04:25:08 +00:00
|
|
|
|
2014-02-27 00:01:22 -08:00
|
|
|
@defun completion-table-with-cache function &optional ignore-case
|
|
|
|
This is a wrapper for @code{completion-table-dynamic} that saves the
|
|
|
|
last argument-result pair. This means that multiple lookups with the
|
|
|
|
same argument only need to call @var{function} once. This can be useful
|
|
|
|
when a slow operation is involved, such as calling an external process.
|
|
|
|
@end defun
|
|
|
|
|
2012-02-15 21:45:02 +08:00
|
|
|
@node Completion in Buffers
|
|
|
|
@subsection Completion in Ordinary Buffers
|
|
|
|
@cindex inline completion
|
|
|
|
|
|
|
|
@findex completion-at-point
|
|
|
|
Although completion is usually done in the minibuffer, the
|
|
|
|
completion facility can also be used on the text in ordinary Emacs
|
|
|
|
buffers. In many major modes, in-buffer completion is performed by
|
|
|
|
the @kbd{C-M-i} or @kbd{M-@key{TAB}} command, bound to
|
|
|
|
@code{completion-at-point}. @xref{Symbol Completion,,, emacs, The GNU
|
|
|
|
Emacs Manual}. This command uses the abnormal hook variable
|
|
|
|
@code{completion-at-point-functions}:
|
|
|
|
|
|
|
|
@defvar completion-at-point-functions
|
|
|
|
The value of this abnormal hook should be a list of functions, which
|
|
|
|
are used to compute a completion table for completing the text at
|
|
|
|
point. It can be used by major modes to provide mode-specific
|
|
|
|
completion tables (@pxref{Major Mode Conventions}).
|
|
|
|
|
|
|
|
When the command @code{completion-at-point} runs, it calls the
|
|
|
|
functions in the list one by one, without any argument. Each function
|
|
|
|
should return @code{nil} if it is unable to produce a completion table
|
|
|
|
for the text at point. Otherwise it should return a list of the form
|
|
|
|
|
|
|
|
@example
|
|
|
|
(@var{start} @var{end} @var{collection} . @var{props})
|
|
|
|
@end example
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
@var{start} and @var{end} delimit the text to complete (which should
|
|
|
|
enclose point). @var{collection} is a completion table for completing
|
|
|
|
that text, in a form suitable for passing as the second argument to
|
|
|
|
@code{try-completion} (@pxref{Basic Completion}); completion
|
|
|
|
alternatives will be generated from this completion table in the usual
|
|
|
|
way, via the completion styles defined in @code{completion-styles}
|
2012-04-04 17:19:32 +08:00
|
|
|
(@pxref{Completion Variables}). @var{props} is a property list for
|
2012-04-04 18:32:35 +08:00
|
|
|
additional information; any of the properties in
|
|
|
|
@code{completion-extra-properties} are recognized (@pxref{Completion
|
|
|
|
Variables}), as well as the following additional ones:
|
2012-02-15 21:45:02 +08:00
|
|
|
|
|
|
|
@table @code
|
|
|
|
@item :predicate
|
|
|
|
The value should be a predicate that completion candidates need to
|
|
|
|
satisfy.
|
|
|
|
|
|
|
|
@item :exclusive
|
|
|
|
If the value is @code{no}, then if the completion table fails to match
|
2012-04-19 21:37:14 -04:00
|
|
|
the text at point, @code{completion-at-point} moves on to the
|
2012-02-15 21:45:02 +08:00
|
|
|
next function in @code{completion-at-point-functions} instead of
|
|
|
|
reporting a completion failure.
|
|
|
|
@end table
|
|
|
|
|
2014-03-30 19:25:02 -07:00
|
|
|
Supplying a function for @var{collection} is strongly recommended if
|
|
|
|
generating the list of completions is an expensive operation. Emacs
|
|
|
|
may internally call functions in @code{completion-at-point-functions}
|
|
|
|
many times, but care about the value of @var{collection} for only some
|
|
|
|
of these calls. By supplying a function for @var{collection}, Emacs
|
|
|
|
can defer generating completions until necessary. You can use
|
|
|
|
@var{completion-table-dynamic} to create a wrapper function:
|
|
|
|
|
|
|
|
@smallexample
|
|
|
|
;; Avoid this pattern.
|
|
|
|
(let ((beg ...) (end ...) (my-completions (my-make-completions)))
|
|
|
|
(list beg end my-completions))
|
|
|
|
|
|
|
|
;; Use this instead.
|
|
|
|
(let ((beg ...) (end ...))
|
|
|
|
(list beg
|
|
|
|
end
|
|
|
|
(completion-table-dynamic
|
|
|
|
(lambda (_)
|
|
|
|
(my-make-completions)))))
|
|
|
|
@end smallexample
|
|
|
|
|
2012-02-15 21:45:02 +08:00
|
|
|
A function in @code{completion-at-point-functions} may also return a
|
2014-03-30 19:25:02 -07:00
|
|
|
function instead of a list as described above. In that case, that
|
|
|
|
returned function is called, with no argument, and it is entirely
|
|
|
|
responsible for performing the completion. We discourage this usage;
|
|
|
|
it is intended to help convert old code to using
|
|
|
|
@code{completion-at-point}.
|
2012-02-15 21:45:02 +08:00
|
|
|
|
|
|
|
The first function in @code{completion-at-point-functions} to return a
|
|
|
|
non-@code{nil} value is used by @code{completion-at-point}. The
|
|
|
|
remaining functions are not called. The exception to this is when
|
2012-04-19 21:37:14 -04:00
|
|
|
there is an @code{:exclusive} specification, as described above.
|
2012-02-15 21:45:02 +08:00
|
|
|
@end defvar
|
|
|
|
|
|
|
|
The following function provides a convenient way to perform
|
|
|
|
completion on an arbitrary stretch of text in an Emacs buffer:
|
|
|
|
|
|
|
|
@defun completion-in-region start end collection &optional predicate
|
|
|
|
This function completes the text in the current buffer between the
|
|
|
|
positions @var{start} and @var{end}, using @var{collection}. The
|
|
|
|
argument @var{collection} has the same meaning as in
|
|
|
|
@code{try-completion} (@pxref{Basic Completion}).
|
|
|
|
|
|
|
|
This function inserts the completion text directly into the current
|
|
|
|
buffer. Unlike @code{completing-read} (@pxref{Minibuffer
|
|
|
|
Completion}), it does not activate the minibuffer.
|
|
|
|
|
|
|
|
For this function to work, point must be somewhere between @var{start}
|
|
|
|
and @var{end}.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
|
2007-09-06 04:25:08 +00:00
|
|
|
@node Yes-or-No Queries
|
|
|
|
@section Yes-or-No Queries
|
|
|
|
@cindex asking the user questions
|
|
|
|
@cindex querying the user
|
|
|
|
@cindex yes-or-no questions
|
|
|
|
|
|
|
|
This section describes functions used to ask the user a yes-or-no
|
|
|
|
question. The function @code{y-or-n-p} can be answered with a single
|
|
|
|
character; it is useful for questions where an inadvertent wrong answer
|
|
|
|
will not have serious consequences. @code{yes-or-no-p} is suitable for
|
|
|
|
more momentous questions, since it requires three or four characters to
|
|
|
|
answer.
|
|
|
|
|
|
|
|
If either of these functions is called in a command that was invoked
|
|
|
|
using the mouse---more precisely, if @code{last-nonmenu-event}
|
|
|
|
(@pxref{Command Loop Info}) is either @code{nil} or a list---then it
|
|
|
|
uses a dialog box or pop-up menu to ask the question. Otherwise, it
|
2012-04-18 23:04:05 -07:00
|
|
|
uses keyboard input. You can force use either of the mouse or of keyboard
|
2007-09-06 04:25:08 +00:00
|
|
|
input by binding @code{last-nonmenu-event} to a suitable value around
|
|
|
|
the call.
|
|
|
|
|
|
|
|
Strictly speaking, @code{yes-or-no-p} uses the minibuffer and
|
|
|
|
@code{y-or-n-p} does not; but it seems best to describe them together.
|
|
|
|
|
|
|
|
@defun y-or-n-p prompt
|
|
|
|
This function asks the user a question, expecting input in the echo
|
|
|
|
area. It returns @code{t} if the user types @kbd{y}, @code{nil} if the
|
|
|
|
user types @kbd{n}. This function also accepts @key{SPC} to mean yes
|
2015-09-15 08:46:48 -07:00
|
|
|
and @key{DEL} to mean no. It accepts @kbd{C-]} to quit, like
|
2007-09-06 04:25:08 +00:00
|
|
|
@kbd{C-g}, because the question might look like a minibuffer and for
|
|
|
|
that reason the user might try to use @kbd{C-]} to get out. The answer
|
|
|
|
is a single character, with no @key{RET} needed to terminate it. Upper
|
|
|
|
and lower case are equivalent.
|
|
|
|
|
|
|
|
``Asking the question'' means printing @var{prompt} in the echo area,
|
|
|
|
followed by the string @w{@samp{(y or n) }}. If the input is not one of
|
|
|
|
the expected answers (@kbd{y}, @kbd{n}, @kbd{@key{SPC}},
|
|
|
|
@kbd{@key{DEL}}, or something that quits), the function responds
|
|
|
|
@samp{Please answer y or n.}, and repeats the request.
|
|
|
|
|
|
|
|
This function does not actually use the minibuffer, since it does not
|
|
|
|
allow editing of the answer. It actually uses the echo area (@pxref{The
|
|
|
|
Echo Area}), which uses the same screen space as the minibuffer. The
|
|
|
|
cursor moves to the echo area while the question is being asked.
|
|
|
|
|
|
|
|
The answers and their meanings, even @samp{y} and @samp{n}, are not
|
2012-09-09 14:43:47 +08:00
|
|
|
hardwired, and are specified by the keymap @code{query-replace-map}
|
|
|
|
(@pxref{Search and Replace}). In particular, if the user enters the
|
|
|
|
special responses @code{recenter}, @code{scroll-up},
|
|
|
|
@code{scroll-down}, @code{scroll-other-window}, or
|
|
|
|
@code{scroll-other-window-down} (respectively bound to @kbd{C-l},
|
|
|
|
@kbd{C-v}, @kbd{M-v}, @kbd{C-M-v} and @kbd{C-M-S-v} in
|
|
|
|
@code{query-replace-map}), this function performs the specified window
|
|
|
|
recentering or scrolling operation, and poses the question again.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@noindent
|
|
|
|
We show successive lines of echo area messages, but only one actually
|
|
|
|
appears on the screen at a time.
|
|
|
|
@end defun
|
|
|
|
|
2012-04-18 22:00:23 -04:00
|
|
|
@defun y-or-n-p-with-timeout prompt seconds default
|
2007-09-06 04:25:08 +00:00
|
|
|
Like @code{y-or-n-p}, except that if the user fails to answer within
|
|
|
|
@var{seconds} seconds, this function stops waiting and returns
|
2012-04-18 22:00:23 -04:00
|
|
|
@var{default}. It works by setting up a timer; see @ref{Timers}.
|
Style fixes for floating-point doc.
* commands.texi, customize.texi, display.texi, elisp.texi, files.texi:
* frames.texi, hash.texi, internals.texi, keymaps.texi, lists.texi:
* minibuf.texi, nonascii.texi, numbers.texi, objects.texi, os.texi:
* processes.texi, streams.texi, strings.texi, text.texi:
* variables.texi, windows.texi:
Hyphenate "floating-point" iff it precedes a noun.
Reword to avoid nouns and hyphenation when that's easy.
Prefer "integer" to "integer number" and "is floating point"
to "is a floating point number".
Prefer "@minus{}" to "-" when it's a minus.
2014-03-17 18:19:03 -07:00
|
|
|
The argument @var{seconds} should be a number.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun yes-or-no-p prompt
|
|
|
|
This function asks the user a question, expecting input in the
|
|
|
|
minibuffer. It returns @code{t} if the user enters @samp{yes},
|
|
|
|
@code{nil} if the user types @samp{no}. The user must type @key{RET} to
|
|
|
|
finalize the response. Upper and lower case are equivalent.
|
|
|
|
|
|
|
|
@code{yes-or-no-p} starts by displaying @var{prompt} in the echo area,
|
|
|
|
followed by @w{@samp{(yes or no) }}. The user must type one of the
|
|
|
|
expected responses; otherwise, the function responds @samp{Please answer
|
|
|
|
yes or no.}, waits about two seconds and repeats the request.
|
|
|
|
|
|
|
|
@code{yes-or-no-p} requires more work from the user than
|
|
|
|
@code{y-or-n-p} and is appropriate for more crucial decisions.
|
|
|
|
|
|
|
|
Here is an example:
|
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
(yes-or-no-p "Do you really want to remove everything? ")
|
|
|
|
|
|
|
|
;; @r{After evaluation of the preceding expression,}
|
|
|
|
;; @r{the following prompt appears,}
|
|
|
|
;; @r{with an empty minibuffer:}
|
|
|
|
@end group
|
|
|
|
|
|
|
|
@group
|
|
|
|
---------- Buffer: minibuffer ----------
|
|
|
|
Do you really want to remove everything? (yes or no)
|
|
|
|
---------- Buffer: minibuffer ----------
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
If the user first types @kbd{y @key{RET}}, which is invalid because this
|
|
|
|
function demands the entire word @samp{yes}, it responds by displaying
|
|
|
|
these prompts, with a brief pause between them:
|
|
|
|
|
|
|
|
@smallexample
|
|
|
|
@group
|
|
|
|
---------- Buffer: minibuffer ----------
|
|
|
|
Please answer yes or no.
|
|
|
|
Do you really want to remove everything? (yes or no)
|
|
|
|
---------- Buffer: minibuffer ----------
|
|
|
|
@end group
|
|
|
|
@end smallexample
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@node Multiple Queries
|
|
|
|
@section Asking Multiple Y-or-N Questions
|
Improve indexing on the chapter/section/subsection levels.
doc/lispref/windows.texi (Recombining Windows): Index subject of sections.
doc/lispref/variables.texi (Variables with Restricted Values)
(Generalized Variables): Index subject of sections.
doc/lispref/text.texi (Buffer Contents, Examining Properties)
(Changing Properties, Property Search, Substitution): Index
subject of sections.
doc/lispref/syntax.texi (Motion and Syntax, Parsing Expressions)
(Motion via Parsing, Position Parse, Control Parsing): Index
subject of sections.
doc/lispref/strings.texi (Predicates for Strings, Creating Strings)
(Modifying Strings, Text Comparison): Index subject of sections.
doc/lispref/searching.texi (Syntax of Regexps, Regexp Special)
(Regexp Functions, Regexp Functions): Index subject of sections.
doc/lispref/processes.texi (Subprocess Creation, Process Information): Index
subject of sections.
doc/lispref/positions.texi (Screen Lines): Index subject of sections.
doc/lispref/nonascii.texi (Scanning Charsets, Specifying Coding Systems):
Index subject of sections.
doc/lispref/minibuf.texi (Text from Minibuffer, Object from Minibuffer)
(Multiple Queries, Minibuffer Contents): Index subject of
sections.
doc/lispref/markers.texi (Predicates on Markers, Creating Markers)
(Information from Markers, Moving Markers): Index subject of
sections.
doc/lispref/macros.texi (Defining Macros, Problems with Macros): Index
subject of sections.
doc/lispref/loading.texi (Loading Non-ASCII, Where Defined): Index subject
of sections.
doc/lispref/lists.texi (List-related Predicates, List Variables, Setcar)
(Setcdr, Plist Access): Index subject of sections.
doc/lispref/keymaps.texi (Controlling Active Maps, Scanning Keymaps)
(Modifying Menus): Index subject of sections.
doc/lispref/help.texi (Accessing Documentation, Help Functions): Index
subject of sections.
doc/lispref/hash.texi (Hash Access): Index subject of sections.
doc/lispref/functions.texi (Core Advising Primitives)
(Advising Named Functions, Porting old advices): Index subject of
sections.
doc/lispref/frames.texi (Creating Frames, Initial Parameters)
(Position Parameters, Buffer Parameters, Minibuffers and Frames)
(Pop-Up Menus, Drag and Drop): Index subject of sections.
doc/lispref/files.texi (Visiting Functions, Kinds of Files)
(Unique File Names): Index subject of sections.
doc/lispref/display.texi (Refresh Screen, Echo Area Customization)
(Warning Variables, Warning Options, Delayed Warnings)
(Temporary Displays, Managing Overlays, Overlay Properties)
(Finding Overlays, Size of Displayed Text, Defining Faces)
(Attribute Functions, Displaying Faces, Face Remapping)
(Basic Faces, Font Lookup, Fontsets, Replacing Specs)
(Defining Images, Showing Images): Index subject of sections.
doc/lispref/debugging.texi (Debugging, Explicit Debug)
(Invoking the Debugger, Excess Open, Excess Close): Index subject
of sections.
doc/lispref/customize.texi (Defining New Types, Applying Customizations)
(Custom Themes): Index subject of sections.
doc/lispref/control.texi (Sequencing, Combining Conditions)
(Processing of Errors, Cleanups): Index subject of sections.
doc/lispref/compile.texi (Eval During Compile): Index subject of sections.
doc/lispref/commands.texi (Using Interactive, Distinguish Interactive)
(Command Loop Info, Classifying Events, Event Mod)
(Invoking the Input Method): Index subject of sections.
doc/lispref/buffers.texi (Buffer List, Buffer Gap): Index subject of sections.
doc/lispref/backups.texi (Making Backups, Numbered Backups, Backup Names)
(Reverting): Index subject of sections.
doc/lispref/abbrevs.texi (Abbrev Tables, Defining Abbrevs, Abbrev Files)
(Abbrev Expansion, Standard Abbrev Tables, Abbrev Properties)
(Abbrev Table Properties): Index subject of sections.
doc/lispref/os.texi (Time of Day, Time Conversion, Time Parsing)
(Time Calculations, Idle Timers): Index subject of sections.
2014-12-23 20:42:30 +02:00
|
|
|
@cindex multiple yes-or-no questions
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
When you have a series of similar questions to ask, such as ``Do you
|
2015-09-15 08:46:48 -07:00
|
|
|
want to save this buffer?'' for each buffer in turn, you should use
|
2007-09-06 04:25:08 +00:00
|
|
|
@code{map-y-or-n-p} to ask the collection of questions, rather than
|
|
|
|
asking each question individually. This gives the user certain
|
|
|
|
convenient facilities such as the ability to answer the whole series at
|
|
|
|
once.
|
|
|
|
|
|
|
|
@defun map-y-or-n-p prompter actor list &optional help action-alist no-cursor-in-echo-area
|
|
|
|
This function asks the user a series of questions, reading a
|
|
|
|
single-character answer in the echo area for each one.
|
|
|
|
|
|
|
|
The value of @var{list} specifies the objects to ask questions about.
|
|
|
|
It should be either a list of objects or a generator function. If it is
|
|
|
|
a function, it should expect no arguments, and should return either the
|
2012-04-18 23:04:05 -07:00
|
|
|
next object to ask about, or @code{nil}, meaning to stop asking questions.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
The argument @var{prompter} specifies how to ask each question. If
|
|
|
|
@var{prompter} is a string, the question text is computed like this:
|
|
|
|
|
|
|
|
@example
|
|
|
|
(format @var{prompter} @var{object})
|
|
|
|
@end example
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
where @var{object} is the next object to ask about (as obtained from
|
|
|
|
@var{list}).
|
|
|
|
|
|
|
|
If not a string, @var{prompter} should be a function of one argument
|
|
|
|
(the next object to ask about) and should return the question text. If
|
|
|
|
the value is a string, that is the question to ask the user. The
|
2012-04-18 23:04:05 -07:00
|
|
|
function can also return @code{t}, meaning do act on this object (and
|
|
|
|
don't ask the user), or @code{nil}, meaning ignore this object (and don't
|
2007-09-06 04:25:08 +00:00
|
|
|
ask the user).
|
|
|
|
|
|
|
|
The argument @var{actor} says how to act on the answers that the user
|
|
|
|
gives. It should be a function of one argument, and it is called with
|
|
|
|
each object that the user says yes for. Its argument is always an
|
|
|
|
object obtained from @var{list}.
|
|
|
|
|
|
|
|
If the argument @var{help} is given, it should be a list of this form:
|
|
|
|
|
|
|
|
@example
|
|
|
|
(@var{singular} @var{plural} @var{action})
|
|
|
|
@end example
|
|
|
|
|
|
|
|
@noindent
|
|
|
|
where @var{singular} is a string containing a singular noun that
|
|
|
|
describes the objects conceptually being acted on, @var{plural} is the
|
|
|
|
corresponding plural noun, and @var{action} is a transitive verb
|
|
|
|
describing what @var{actor} does.
|
|
|
|
|
|
|
|
If you don't specify @var{help}, the default is @code{("object"
|
|
|
|
"objects" "act on")}.
|
|
|
|
|
|
|
|
Each time a question is asked, the user may enter @kbd{y}, @kbd{Y}, or
|
|
|
|
@key{SPC} to act on that object; @kbd{n}, @kbd{N}, or @key{DEL} to skip
|
|
|
|
that object; @kbd{!} to act on all following objects; @key{ESC} or
|
|
|
|
@kbd{q} to exit (skip all following objects); @kbd{.} (period) to act on
|
|
|
|
the current object and then exit; or @kbd{C-h} to get help. These are
|
|
|
|
the same answers that @code{query-replace} accepts. The keymap
|
|
|
|
@code{query-replace-map} defines their meaning for @code{map-y-or-n-p}
|
|
|
|
as well as for @code{query-replace}; see @ref{Search and Replace}.
|
|
|
|
|
|
|
|
You can use @var{action-alist} to specify additional possible answers
|
|
|
|
and what they mean. It is an alist of elements of the form
|
|
|
|
@code{(@var{char} @var{function} @var{help})}, each of which defines one
|
|
|
|
additional answer. In this element, @var{char} is a character (the
|
|
|
|
answer); @var{function} is a function of one argument (an object from
|
|
|
|
@var{list}); @var{help} is a string.
|
|
|
|
|
|
|
|
When the user responds with @var{char}, @code{map-y-or-n-p} calls
|
|
|
|
@var{function}. If it returns non-@code{nil}, the object is considered
|
2015-09-15 08:46:48 -07:00
|
|
|
acted upon, and @code{map-y-or-n-p} advances to the next object in
|
2007-09-06 04:25:08 +00:00
|
|
|
@var{list}. If it returns @code{nil}, the prompt is repeated for the
|
|
|
|
same object.
|
|
|
|
|
|
|
|
Normally, @code{map-y-or-n-p} binds @code{cursor-in-echo-area} while
|
|
|
|
prompting. But if @var{no-cursor-in-echo-area} is non-@code{nil}, it
|
|
|
|
does not do that.
|
|
|
|
|
|
|
|
If @code{map-y-or-n-p} is called in a command that was invoked using the
|
|
|
|
mouse---more precisely, if @code{last-nonmenu-event} (@pxref{Command
|
|
|
|
Loop Info}) is either @code{nil} or a list---then it uses a dialog box
|
|
|
|
or pop-up menu to ask the question. In this case, it does not use
|
2012-04-18 23:04:05 -07:00
|
|
|
keyboard input or the echo area. You can force use either of the mouse or
|
2007-09-06 04:25:08 +00:00
|
|
|
of keyboard input by binding @code{last-nonmenu-event} to a suitable
|
|
|
|
value around the call.
|
|
|
|
|
|
|
|
The return value of @code{map-y-or-n-p} is the number of objects acted on.
|
|
|
|
@end defun
|
2012-04-18 23:04:05 -07:00
|
|
|
@c FIXME An example of this would be more useful than all the
|
|
|
|
@c preceding examples of simple things.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@node Reading a Password
|
|
|
|
@section Reading a Password
|
|
|
|
@cindex passwords, reading
|
|
|
|
|
|
|
|
To read a password to pass to another program, you can use the
|
|
|
|
function @code{read-passwd}.
|
|
|
|
|
|
|
|
@defun read-passwd prompt &optional confirm default
|
|
|
|
This function reads a password, prompting with @var{prompt}. It does
|
2014-07-11 11:09:54 +02:00
|
|
|
not echo the password as the user types it; instead, it echoes
|
|
|
|
@samp{.} for each character in the password. If you want to apply
|
|
|
|
another character to hide the password, let-bind the variable
|
|
|
|
@code{read-hide-char} with that character.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
The optional argument @var{confirm}, if non-@code{nil}, says to read the
|
|
|
|
password twice and insist it must be the same both times. If it isn't
|
|
|
|
the same, the user has to type it over and over until the last two
|
|
|
|
times match.
|
|
|
|
|
|
|
|
The optional argument @var{default} specifies the default password to
|
|
|
|
return if the user enters empty input. If @var{default} is @code{nil},
|
|
|
|
then @code{read-passwd} returns the null string in that case.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@node Minibuffer Commands
|
|
|
|
@section Minibuffer Commands
|
|
|
|
|
|
|
|
This section describes some commands meant for use in the
|
|
|
|
minibuffer.
|
|
|
|
|
|
|
|
@deffn Command exit-minibuffer
|
|
|
|
This command exits the active minibuffer. It is normally bound to
|
|
|
|
keys in minibuffer local keymaps.
|
|
|
|
@end deffn
|
|
|
|
|
|
|
|
@deffn Command self-insert-and-exit
|
|
|
|
This command exits the active minibuffer after inserting the last
|
2009-01-09 05:22:05 +00:00
|
|
|
character typed on the keyboard (found in @code{last-command-event};
|
2007-09-06 04:25:08 +00:00
|
|
|
@pxref{Command Loop Info}).
|
|
|
|
@end deffn
|
|
|
|
|
|
|
|
@deffn Command previous-history-element n
|
|
|
|
This command replaces the minibuffer contents with the value of the
|
|
|
|
@var{n}th previous (older) history element.
|
|
|
|
@end deffn
|
|
|
|
|
|
|
|
@deffn Command next-history-element n
|
|
|
|
This command replaces the minibuffer contents with the value of the
|
|
|
|
@var{n}th more recent history element.
|
|
|
|
@end deffn
|
|
|
|
|
|
|
|
@deffn Command previous-matching-history-element pattern n
|
|
|
|
This command replaces the minibuffer contents with the value of the
|
|
|
|
@var{n}th previous (older) history element that matches @var{pattern} (a
|
|
|
|
regular expression).
|
|
|
|
@end deffn
|
|
|
|
|
|
|
|
@deffn Command next-matching-history-element pattern n
|
|
|
|
This command replaces the minibuffer contents with the value of the
|
|
|
|
@var{n}th next (newer) history element that matches @var{pattern} (a
|
|
|
|
regular expression).
|
|
|
|
@end deffn
|
|
|
|
|
2012-04-18 23:04:05 -07:00
|
|
|
@deffn Command previous-complete-history-element n
|
|
|
|
This command replaces the minibuffer contents with the value of the
|
|
|
|
@var{n}th previous (older) history element that completes the current
|
|
|
|
contents of the minibuffer before the point.
|
|
|
|
@end deffn
|
|
|
|
|
|
|
|
@deffn Command next-complete-history-element n
|
|
|
|
This command replaces the minibuffer contents with the value of the
|
|
|
|
@var{n}th next (newer) history element that completes the current
|
|
|
|
contents of the minibuffer before the point.
|
|
|
|
@end deffn
|
|
|
|
|
|
|
|
|
2007-09-06 04:25:08 +00:00
|
|
|
@node Minibuffer Windows
|
|
|
|
@section Minibuffer Windows
|
|
|
|
@cindex minibuffer windows
|
|
|
|
|
2014-12-25 14:13:26 +01:00
|
|
|
These functions access and select minibuffer windows, test whether they
|
|
|
|
are active and control how they get resized.
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
@defun active-minibuffer-window
|
|
|
|
This function returns the currently active minibuffer window, or
|
2012-04-18 23:04:05 -07:00
|
|
|
@code{nil} if there is none.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun minibuffer-window &optional frame
|
|
|
|
@anchor{Definition of minibuffer-window}
|
|
|
|
This function returns the minibuffer window used for frame @var{frame}.
|
|
|
|
If @var{frame} is @code{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.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun set-minibuffer-window window
|
|
|
|
This function specifies @var{window} as the minibuffer window to use.
|
|
|
|
This affects where the minibuffer is displayed if you put text in it
|
|
|
|
without invoking the usual minibuffer commands. It has no effect on
|
|
|
|
the usual minibuffer input functions because they all start by
|
|
|
|
choosing the minibuffer window according to the current frame.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@c Emacs 19 feature
|
|
|
|
@defun window-minibuffer-p &optional window
|
|
|
|
This function returns non-@code{nil} if @var{window} is a minibuffer
|
|
|
|
window.
|
|
|
|
@var{window} defaults to the selected window.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
It is not correct to determine whether a given window is a minibuffer by
|
|
|
|
comparing it with the result of @code{(minibuffer-window)}, because
|
|
|
|
there can be more than one minibuffer window if there is more than one
|
|
|
|
frame.
|
|
|
|
|
|
|
|
@defun minibuffer-window-active-p window
|
2012-04-18 23:04:05 -07:00
|
|
|
This function returns non-@code{nil} if @var{window} is the currently
|
|
|
|
active minibuffer window.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defun
|
|
|
|
|
2014-12-25 14:13:26 +01:00
|
|
|
The following two options control whether minibuffer windows are resized
|
|
|
|
automatically and how large they can get in the process.
|
|
|
|
|
|
|
|
@defopt resize-mini-windows
|
|
|
|
This option specifies whether minibuffer windows are resized
|
|
|
|
automatically. The default value is @code{grow-only}, which means that
|
|
|
|
a minibuffer window by default expands automatically to accommodate the
|
|
|
|
text it displays and shrinks back to one line as soon as the minibuffer
|
|
|
|
gets empty. If the value is @code{t}, Emacs will always try to fit the
|
|
|
|
height of a minibuffer window to the text it displays (with a minimum of
|
|
|
|
one line). If the value is @code{nil}, a minibuffer window never
|
|
|
|
changes size automatically. In that case the window resizing commands
|
|
|
|
(@pxref{Resizing Windows}) can be used to adjust its height.
|
|
|
|
@end defopt
|
|
|
|
|
|
|
|
@defopt max-mini-window-height
|
|
|
|
This option provides a maximum height for resizing minibuffer windows
|
|
|
|
automatically. A floating-point number specifies a fraction of the
|
|
|
|
frame's height; an integer specifies the maximum number of lines. The
|
|
|
|
default value is 0.25.
|
|
|
|
@end defopt
|
|
|
|
|
|
|
|
|
2007-09-06 04:25:08 +00:00
|
|
|
@node Minibuffer Contents
|
|
|
|
@section Minibuffer Contents
|
Improve indexing on the chapter/section/subsection levels.
doc/lispref/windows.texi (Recombining Windows): Index subject of sections.
doc/lispref/variables.texi (Variables with Restricted Values)
(Generalized Variables): Index subject of sections.
doc/lispref/text.texi (Buffer Contents, Examining Properties)
(Changing Properties, Property Search, Substitution): Index
subject of sections.
doc/lispref/syntax.texi (Motion and Syntax, Parsing Expressions)
(Motion via Parsing, Position Parse, Control Parsing): Index
subject of sections.
doc/lispref/strings.texi (Predicates for Strings, Creating Strings)
(Modifying Strings, Text Comparison): Index subject of sections.
doc/lispref/searching.texi (Syntax of Regexps, Regexp Special)
(Regexp Functions, Regexp Functions): Index subject of sections.
doc/lispref/processes.texi (Subprocess Creation, Process Information): Index
subject of sections.
doc/lispref/positions.texi (Screen Lines): Index subject of sections.
doc/lispref/nonascii.texi (Scanning Charsets, Specifying Coding Systems):
Index subject of sections.
doc/lispref/minibuf.texi (Text from Minibuffer, Object from Minibuffer)
(Multiple Queries, Minibuffer Contents): Index subject of
sections.
doc/lispref/markers.texi (Predicates on Markers, Creating Markers)
(Information from Markers, Moving Markers): Index subject of
sections.
doc/lispref/macros.texi (Defining Macros, Problems with Macros): Index
subject of sections.
doc/lispref/loading.texi (Loading Non-ASCII, Where Defined): Index subject
of sections.
doc/lispref/lists.texi (List-related Predicates, List Variables, Setcar)
(Setcdr, Plist Access): Index subject of sections.
doc/lispref/keymaps.texi (Controlling Active Maps, Scanning Keymaps)
(Modifying Menus): Index subject of sections.
doc/lispref/help.texi (Accessing Documentation, Help Functions): Index
subject of sections.
doc/lispref/hash.texi (Hash Access): Index subject of sections.
doc/lispref/functions.texi (Core Advising Primitives)
(Advising Named Functions, Porting old advices): Index subject of
sections.
doc/lispref/frames.texi (Creating Frames, Initial Parameters)
(Position Parameters, Buffer Parameters, Minibuffers and Frames)
(Pop-Up Menus, Drag and Drop): Index subject of sections.
doc/lispref/files.texi (Visiting Functions, Kinds of Files)
(Unique File Names): Index subject of sections.
doc/lispref/display.texi (Refresh Screen, Echo Area Customization)
(Warning Variables, Warning Options, Delayed Warnings)
(Temporary Displays, Managing Overlays, Overlay Properties)
(Finding Overlays, Size of Displayed Text, Defining Faces)
(Attribute Functions, Displaying Faces, Face Remapping)
(Basic Faces, Font Lookup, Fontsets, Replacing Specs)
(Defining Images, Showing Images): Index subject of sections.
doc/lispref/debugging.texi (Debugging, Explicit Debug)
(Invoking the Debugger, Excess Open, Excess Close): Index subject
of sections.
doc/lispref/customize.texi (Defining New Types, Applying Customizations)
(Custom Themes): Index subject of sections.
doc/lispref/control.texi (Sequencing, Combining Conditions)
(Processing of Errors, Cleanups): Index subject of sections.
doc/lispref/compile.texi (Eval During Compile): Index subject of sections.
doc/lispref/commands.texi (Using Interactive, Distinguish Interactive)
(Command Loop Info, Classifying Events, Event Mod)
(Invoking the Input Method): Index subject of sections.
doc/lispref/buffers.texi (Buffer List, Buffer Gap): Index subject of sections.
doc/lispref/backups.texi (Making Backups, Numbered Backups, Backup Names)
(Reverting): Index subject of sections.
doc/lispref/abbrevs.texi (Abbrev Tables, Defining Abbrevs, Abbrev Files)
(Abbrev Expansion, Standard Abbrev Tables, Abbrev Properties)
(Abbrev Table Properties): Index subject of sections.
doc/lispref/os.texi (Time of Day, Time Conversion, Time Parsing)
(Time Calculations, Idle Timers): Index subject of sections.
2014-12-23 20:42:30 +02:00
|
|
|
@cindex access minibuffer contents
|
|
|
|
@cindex minibuffer contents, accessing
|
2007-09-06 04:25:08 +00:00
|
|
|
|
|
|
|
These functions access the minibuffer prompt and contents.
|
|
|
|
|
|
|
|
@defun minibuffer-prompt
|
|
|
|
This function returns the prompt string of the currently active
|
|
|
|
minibuffer. If no minibuffer is active, it returns @code{nil}.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun minibuffer-prompt-end
|
|
|
|
This function returns the current
|
|
|
|
position of the end of the minibuffer prompt, if a minibuffer is
|
|
|
|
current. Otherwise, it returns the minimum valid buffer position.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun minibuffer-prompt-width
|
|
|
|
This function returns the current display-width of the minibuffer
|
|
|
|
prompt, if a minibuffer is current. Otherwise, it returns zero.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun minibuffer-contents
|
|
|
|
This function 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.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun minibuffer-contents-no-properties
|
|
|
|
This is like @code{minibuffer-contents}, except that it does not copy text
|
|
|
|
properties, just the characters themselves. @xref{Text Properties}.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defun delete-minibuffer-contents
|
|
|
|
This function erases the editable contents of the minibuffer (that is,
|
|
|
|
everything except the prompt), if a minibuffer is current. Otherwise,
|
|
|
|
it erases the entire current buffer.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@node Recursive Mini
|
|
|
|
@section Recursive Minibuffers
|
|
|
|
@cindex recursive minibuffers
|
|
|
|
|
|
|
|
These functions and variables deal with recursive minibuffers
|
|
|
|
(@pxref{Recursive Editing}):
|
|
|
|
|
|
|
|
@defun minibuffer-depth
|
|
|
|
This function returns the current depth of activations of the
|
|
|
|
minibuffer, a nonnegative integer. If no minibuffers are active, it
|
|
|
|
returns zero.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defopt enable-recursive-minibuffers
|
|
|
|
If this variable is non-@code{nil}, you can invoke commands (such as
|
|
|
|
@code{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 @code{nil}, you cannot invoke minibuffer
|
|
|
|
commands when the minibuffer window is active, not even if you switch to
|
|
|
|
another window to do it.
|
|
|
|
@end defopt
|
|
|
|
|
|
|
|
@c Emacs 19 feature
|
|
|
|
If a command name has a property @code{enable-recursive-minibuffers}
|
|
|
|
that is non-@code{nil}, then the command can use the minibuffer to read
|
|
|
|
arguments even if it is invoked from the minibuffer. A command can
|
|
|
|
also achieve this by binding @code{enable-recursive-minibuffers}
|
|
|
|
to @code{t} in the interactive declaration (@pxref{Using Interactive}).
|
|
|
|
The minibuffer command @code{next-matching-history-element} (normally
|
|
|
|
@kbd{M-s} in the minibuffer) does the latter.
|
|
|
|
|
|
|
|
@node Minibuffer Misc
|
|
|
|
@section Minibuffer Miscellany
|
|
|
|
|
|
|
|
@defun minibufferp &optional buffer-or-name
|
|
|
|
This function returns non-@code{nil} if @var{buffer-or-name} is a
|
|
|
|
minibuffer. If @var{buffer-or-name} is omitted, it tests the current
|
|
|
|
buffer.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defvar minibuffer-setup-hook
|
|
|
|
This is a normal hook that is run whenever the minibuffer is entered.
|
|
|
|
@xref{Hooks}.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar minibuffer-exit-hook
|
|
|
|
This is a normal hook that is run whenever the minibuffer is exited.
|
|
|
|
@xref{Hooks}.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar minibuffer-help-form
|
|
|
|
@anchor{Definition of minibuffer-help-form}
|
|
|
|
The current value of this variable is used to rebind @code{help-form}
|
|
|
|
locally inside the minibuffer (@pxref{Help Functions}).
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defvar minibuffer-scroll-window
|
|
|
|
@anchor{Definition of minibuffer-scroll-window}
|
|
|
|
If the value of this variable is non-@code{nil}, it should be a window
|
|
|
|
object. When the function @code{scroll-other-window} is called in the
|
|
|
|
minibuffer, it scrolls this window.
|
|
|
|
@end defvar
|
|
|
|
|
|
|
|
@defun minibuffer-selected-window
|
2012-04-18 23:04:05 -07:00
|
|
|
This function returns the window that was selected when the
|
2007-09-06 04:25:08 +00:00
|
|
|
minibuffer was entered. If selected window is not a minibuffer
|
|
|
|
window, it returns @code{nil}.
|
|
|
|
@end defun
|
|
|
|
|
|
|
|
@defopt max-mini-window-height
|
|
|
|
This variable specifies the maximum height for resizing minibuffer
|
|
|
|
windows. If a float, it specifies a fraction of the height of the
|
|
|
|
frame. If an integer, it specifies a number of lines.
|
|
|
|
@end defopt
|
|
|
|
|
2012-04-18 23:04:05 -07:00
|
|
|
@vindex minibuffer-message-timeout
|
2009-05-20 02:56:33 +00:00
|
|
|
@defun minibuffer-message string &rest args
|
2007-09-06 04:25:08 +00:00
|
|
|
This function displays @var{string} temporarily at the end of the
|
2012-04-18 23:04:05 -07:00
|
|
|
minibuffer text, for a few seconds, or until the next input event
|
|
|
|
arrives, whichever comes first. The variable
|
|
|
|
@code{minibuffer-message-timeout} specifies the number of seconds to
|
|
|
|
wait in the absence of input. It defaults to 2. If @var{args} is
|
|
|
|
non-@code{nil}, the actual message is obtained by passing @var{string}
|
More-conservative ‘format’ quote restyling
Instead of restyling curved quotes for every call to ‘format’,
create a new function ‘format-message’ that does the restyling,
and using the new function instead of ‘format’ only in contexts
where this seems appropriate.
Problem reported by Dmitry Gutov and Andreas Schwab in:
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00826.html
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00827.html
* doc/lispref/commands.texi (Using Interactive):
* doc/lispref/control.texi (Signaling Errors, Signaling Errors):
* doc/lispref/display.texi (Displaying Messages, Progress):
* doc/lispref/elisp.texi:
* doc/lispref/help.texi (Keys in Documentation):
* doc/lispref/minibuf.texi (Minibuffer Misc):
* doc/lispref/strings.texi (Formatting Strings):
* etc/NEWS:
Document the changes.
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/apropos.el (apropos-library):
* lisp/calc/calc-ext.el (calc-record-message)
(calc-user-function-list):
* lisp/calc/calc-help.el (calc-describe-key, calc-full-help):
* lisp/calc/calc-lang.el (math-read-big-balance):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--add-diary-entry):
* lisp/cedet/mode-local.el (mode-local-print-binding)
(mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-completion-message):
* lisp/cedet/semantic/edit.el (semantic-parse-changes-failed):
* lisp/cedet/semantic/wisent/comp.el (wisent-log):
* lisp/cedet/srecode/insert.el (srecode-insert-show-error-report):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dframe.el (dframe-message):
* lisp/dired-aux.el (dired-query):
* lisp/emacs-lisp/byte-opt.el (byte-compile-log-lap-1):
* lisp/emacs-lisp/bytecomp.el (byte-compile-log)
(byte-compile-log-file, byte-compile-warn, byte-compile-form):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use)
(cconv-analyze-form):
* lisp/emacs-lisp/check-declare.el (check-declare-warn):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet):
* lisp/emacs-lisp/edebug.el (edebug-format):
* lisp/emacs-lisp/eieio-core.el (eieio-oref):
* lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message)
(eldoc-message):
* lisp/emacs-lisp/elint.el (elint-file, elint-log):
* lisp/emacs-lisp/find-func.el (find-function-library):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring):
* lisp/emacs-lisp/package.el (package-compute-transaction)
(package-install-button-action, package-delete-button-action)
(package-menu--list-to-prompt):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emacs-lisp/warnings.el (lwarn, warn):
* lisp/emulation/viper-cmd.el:
(viper-toggle-parse-sexp-ignore-comments)
(viper-kill-buffer, viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/facemenu.el (facemenu-add-new-face):
* lisp/faces.el (face-documentation, read-face-name)
(face-read-string, read-face-font, describe-face):
* lisp/files.el (find-alternate-file, hack-local-variables)
(hack-one-local-variable--obsolete, write-file)
(basic-save-buffer, delete-directory):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--obsolete)
(help-fns--interactive-only, describe-function-1)
(describe-variable):
* lisp/help.el (describe-mode):
* lisp/info-xref.el (info-xref-output):
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
* lisp/international/kkc.el (kkc-error):
* lisp/international/mule-cmds.el:
(select-safe-coding-system-interactively)
(select-safe-coding-system, describe-input-method):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/international/quail.el (quail-error):
* lisp/minibuffer.el (minibuffer-message):
* lisp/mpc.el (mpc--debug):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-message):
* lisp/net/gnutls.el (gnutls-message-maybe):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/nsm.el (nsm-query-user):
* lisp/net/rlogin.el (rlogin):
* lisp/net/soap-client.el (soap-warning):
* lisp/net/tramp.el (tramp-debug-message):
* lisp/nxml/nxml-outln.el (nxml-report-outline-error):
* lisp/nxml/nxml-parse.el (nxml-parse-error):
* lisp/nxml/rng-cmpct.el (rng-c-error):
* lisp/nxml/rng-match.el (rng-compile-error):
* lisp/nxml/rng-uri.el (rng-uri-error):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/org/org-ctags.el:
(org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/proced.el (proced-log):
* lisp/progmodes/ebnf2ps.el (ebnf-log):
* lisp/progmodes/flymake.el (flymake-log):
* lisp/progmodes/vhdl-mode.el (vhdl-warning-when-idle):
* lisp/replace.el (occur-1):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, define-alternatives):
* lisp/startup.el (command-line):
* lisp/subr.el (error, user-error, add-to-list):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* src/callint.c (Fcall_interactively):
* src/editfns.c (Fmessage, Fmessage_box):
Restyle the quotes of format strings intended for use as a
diagnostic, when restyling seems appropriate.
* lisp/subr.el (format-message): New function.
* src/doc.c (Finternal__text_restyle): New function.
(syms_of_doc): Define it.
2015-08-23 22:38:02 -07:00
|
|
|
and @var{args} through @code{format-message}. @xref{Formatting Strings}.
|
2007-09-06 04:25:08 +00:00
|
|
|
@end defun
|
2012-04-18 23:04:05 -07:00
|
|
|
|
|
|
|
@deffn Command minibuffer-inactive-mode
|
|
|
|
This is the major mode used in inactive minibuffers. It uses
|
|
|
|
keymap @code{minibuffer-inactive-mode-map}. This can be useful
|
|
|
|
if the minibuffer is in a separate frame. @xref{Minibuffers and Frames}.
|
|
|
|
@end deffn
|