1 /* Minibuffer input and completion.
2 Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #include "dispextern.h"
30 #define min(a, b) ((a) < (b) ? (a) : (b))
32 /* List of buffers for use as minibuffers.
33 The first element of the list is used for the outermost minibuffer invocation,
34 the next element is used for a recursive minibuffer invocation, etc.
35 The list is extended at the end as deeped minibuffer recursions are encountered. */
36 Lisp_Object Vminibuffer_list
;
38 struct minibuf_save_data
42 Lisp_Object help_form
;
43 Lisp_Object current_prefix_arg
;
44 Lisp_Object history_position
;
45 Lisp_Object history_variable
;
48 int minibuf_save_vector_size
;
49 struct minibuf_save_data
*minibuf_save_vector
;
51 /* Depth in minibuffer invocations. */
54 /* Nonzero means display completion help for invalid input */
57 /* Fread_minibuffer leaves the input, as a string, here */
58 Lisp_Object last_minibuf_string
;
60 /* Nonzero means let functions called when within a minibuffer
61 invoke recursive minibuffers (to read arguments, or whatever) */
62 int enable_recursive_minibuffers
;
64 /* help-form is bound to this while in the minibuffer. */
66 Lisp_Object Vminibuffer_help_form
;
68 /* Variable which is the history list to add minibuffer values to. */
70 Lisp_Object Vminibuffer_history_variable
;
72 /* Current position in the history list (adjusted by M-n and M-p). */
74 Lisp_Object Vminibuffer_history_position
;
76 Lisp_Object Qminibuffer_history
;
78 /* Normal hook for entry to minibuffer. */
80 Lisp_Object Qminibuffer_setup_hook
, Vminibuffer_setup_hook
;
82 /* Nonzero means completion ignores case. */
84 int completion_ignore_case
;
86 /* If last completion attempt reported "Complete but not unique"
87 then this is the string completed then; otherwise this is nil. */
89 static Lisp_Object last_exact_completion
;
91 Lisp_Object Quser_variable_p
;
94 /* Actual minibuffer invocation. */
96 void read_minibuf_unwind ();
97 Lisp_Object
get_minibuffer ();
98 Lisp_Object
read_minibuf ();
100 /* Read from the minibuffer using keymap MAP, initial contents INITIAL
101 (a string), putting point minus BACKUP_N chars from the end of INITIAL,
102 prompting with PROMPT (a string), using history list HISTVAR
103 with initial position HISTPOS. (BACKUP_N should be <= 0.)
105 Normally return the result as a string (the text that was read),
106 but if EXPFLAG is non-nil, read it and return the object read. */
109 read_minibuf (map
, initial
, prompt
, backup_n
, expflag
, histvar
, histpos
)
113 Lisp_Object backup_n
;
118 register Lisp_Object val
;
119 int count
= specpdl_ptr
- specpdl
;
120 Lisp_Object mini_frame
;
121 struct gcpro gcpro1
, gcpro2
;
123 if (XTYPE (prompt
) != Lisp_String
)
124 prompt
= build_string ("");
126 /* Emacs in -batch mode calls minibuffer: print the prompt. */
127 if (noninteractive
&& XTYPE (prompt
) == Lisp_String
)
128 printf ("%s", XSTRING (prompt
)->data
);
130 if (!enable_recursive_minibuffers
132 && (EQ (selected_window
, minibuf_window
)))
134 || selected_frame
!= XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window
)))
136 error ("Command attempted to use minibuffer while in minibuffer");
138 if (minibuf_level
== minibuf_save_vector_size
)
139 minibuf_save_vector
=
140 (struct minibuf_save_data
*)
141 xrealloc (minibuf_save_vector
,
142 (minibuf_save_vector_size
*= 2)
143 * sizeof (struct minibuf_save_data
));
144 minibuf_save_vector
[minibuf_level
].prompt
= minibuf_prompt
;
145 minibuf_save_vector
[minibuf_level
].prompt_width
= minibuf_prompt_width
;
146 minibuf_prompt_width
= 0;
147 /* >> Why is this done this way rather than binding these variables? */
148 minibuf_save_vector
[minibuf_level
].help_form
= Vhelp_form
;
149 minibuf_save_vector
[minibuf_level
].current_prefix_arg
= Vcurrent_prefix_arg
;
150 minibuf_save_vector
[minibuf_level
].history_position
= Vminibuffer_history_position
;
151 minibuf_save_vector
[minibuf_level
].history_variable
= Vminibuffer_history_variable
;
152 GCPRO2 (minibuf_save_vector
[minibuf_level
].help_form
,
153 minibuf_save_vector
[minibuf_level
].current_prefix_arg
);
155 record_unwind_protect (Fset_window_configuration
,
156 Fcurrent_window_configuration (Qnil
));
158 /* If the minibuffer window is on a different frame, save that
159 frame's configuration too. */
161 XSET (mini_frame
, Lisp_Frame
, WINDOW_FRAME (XWINDOW (minibuf_window
)));
162 if (XFRAME (mini_frame
) != selected_frame
)
163 record_unwind_protect (Fset_window_configuration
,
164 Fcurrent_window_configuration (mini_frame
));
167 val
= current_buffer
->directory
;
168 Fset_buffer (get_minibuffer (minibuf_level
));
170 /* The current buffer's default directory is usually the right thing
171 for our minibuffer here. However, if you're typing a command at
172 a minibuffer-only frame when minibuf_level is zero, then buf IS
173 the current_buffer, so reset_buffer leaves buf's default
174 directory unchanged. This is a bummer when you've just started
175 up Emacs and buf's default directory is Qnil. Here's a hack; can
176 you think of something better to do? Find another buffer with a
177 better directory, and use that one instead. */
178 if (XTYPE (val
) == Lisp_String
)
179 current_buffer
->directory
= val
;
182 Lisp_Object buf_list
;
184 for (buf_list
= Vbuffer_alist
;
186 buf_list
= XCONS (buf_list
)->cdr
)
188 Lisp_Object other_buf
= XCONS (XCONS (buf_list
)->car
)->cdr
;
190 if (XTYPE (XBUFFER (other_buf
)->directory
) == Lisp_String
)
192 current_buffer
->directory
= XBUFFER (other_buf
)->directory
;
199 Fredirect_frame_focus (Fselected_frame (), mini_frame
);
201 Fmake_local_variable (Qprint_escape_newlines
);
202 print_escape_newlines
= 1;
204 record_unwind_protect (read_minibuf_unwind
, Qnil
);
206 Vminibuf_scroll_window
= selected_window
;
207 Fset_window_buffer (minibuf_window
, Fcurrent_buffer ());
208 Fselect_window (minibuf_window
);
209 XFASTINT (XWINDOW (minibuf_window
)->hscroll
) = 0;
216 Finsert (1, &initial
);
217 if (!NILP (backup_n
) && XTYPE (backup_n
) == Lisp_Int
)
218 Fforward_char (backup_n
);
221 minibuf_prompt
= (char *) alloca (XSTRING (prompt
)->size
+ 1);
222 bcopy (XSTRING (prompt
)->data
, minibuf_prompt
, XSTRING (prompt
)->size
+ 1);
223 echo_area_glyphs
= 0;
225 Vhelp_form
= Vminibuffer_help_form
;
226 current_buffer
->keymap
= map
;
227 Vminibuffer_history_position
= histpos
;
228 Vminibuffer_history_variable
= histvar
;
230 /* Run our hook, but not if it is empty.
231 (run-hooks would do nothing if it is empty,
232 but it's important to save time here in the usual case. */
233 if (!NILP (Vminibuffer_setup_hook
) && !EQ (Vminibuffer_setup_hook
, Qunbound
))
234 call1 (Vrun_hooks
, Qminibuffer_setup_hook
);
236 /* ??? MCC did redraw_screen here if switching screens. */
239 /* If cursor is on the minibuffer line,
240 show the user we have exited by putting it in column 0. */
241 if ((FRAME_CURSOR_Y (selected_frame
)
242 >= XFASTINT (XWINDOW (minibuf_window
)->top
))
245 FRAME_CURSOR_X (selected_frame
) = 0;
246 update_frame (selected_frame
, 1, 1);
249 /* Make minibuffer contents into a string */
250 val
= make_buffer_string (1, Z
);
251 bcopy (GAP_END_ADDR
, XSTRING (val
)->data
+ GPT
- BEG
, Z
- GPT
);
253 /* Add the value to the appropriate history list. */
254 if (XTYPE (Vminibuffer_history_variable
) == Lisp_Symbol
255 && ! EQ (XSYMBOL (Vminibuffer_history_variable
)->value
, Qunbound
))
256 Fset (Vminibuffer_history_variable
,
257 Fcons (val
, Fsymbol_value (Vminibuffer_history_variable
)));
259 unbind_to (count
, Qnil
); /* The appropriate frame will get selected
260 in set-window-configuration. */
264 /* VAL is the string of minibuffer text. */
265 last_minibuf_string
= val
;
267 /* If Lisp form desired instead of string, parse it */
274 /* Return a buffer to be used as the minibuffer at depth `depth'.
275 depth = 0 is the lowest allowed argument, and that is the value
276 used for nonrecursive minibuffer invocations */
279 get_minibuffer (depth
)
282 Lisp_Object tail
, num
, buf
;
284 extern Lisp_Object
nconc2 ();
286 XFASTINT (num
) = depth
;
287 tail
= Fnthcdr (num
, Vminibuffer_list
);
290 tail
= Fcons (Qnil
, Qnil
);
291 Vminibuffer_list
= nconc2 (Vminibuffer_list
, tail
);
294 if (NILP (buf
) || NILP (XBUFFER (buf
)->name
))
296 sprintf (name
, " *Minibuf-%d*", depth
);
297 buf
= Fget_buffer_create (build_string (name
));
299 /* Although the buffer's name starts with a space, undo should be
301 Fbuffer_enable_undo (buf
);
303 XCONS (tail
)->car
= buf
;
306 reset_buffer (XBUFFER (buf
));
311 /* This function is called on exiting minibuffer, whether normally or not,
312 and it restores the current window, buffer, etc. */
315 read_minibuf_unwind (data
)
318 /* Erase the minibuffer we were using at this level. */
319 Fset_buffer (XWINDOW (minibuf_window
)->buffer
);
321 /* Prevent error in erase-buffer. */
322 current_buffer
->read_only
= Qnil
;
325 /* If this was a recursive minibuffer,
326 tie the minibuffer window back to the outer level minibuffer buffer */
328 /* Make sure minibuffer window is erased, not ignored */
329 windows_or_buffers_changed
++;
330 XFASTINT (XWINDOW (minibuf_window
)->last_modified
) = 0;
332 /* Restore prompt from outer minibuffer */
333 minibuf_prompt
= minibuf_save_vector
[minibuf_level
].prompt
;
334 minibuf_prompt_width
= minibuf_save_vector
[minibuf_level
].prompt_width
;
335 Vhelp_form
= minibuf_save_vector
[minibuf_level
].help_form
;
336 Vcurrent_prefix_arg
= minibuf_save_vector
[minibuf_level
].current_prefix_arg
;
337 Vminibuffer_history_position
338 = minibuf_save_vector
[minibuf_level
].history_position
;
339 Vminibuffer_history_variable
340 = minibuf_save_vector
[minibuf_level
].history_variable
;
344 /* This comment supplies the doc string for read-from-minibuffer,
345 for make-docfile to see. We cannot put this in the real DEFUN
346 due to limits in the Unix cpp.
348 DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 5, 0,
349 "Read a string from the minibuffer, prompting with string PROMPT.\n\
350 If optional second arg INITIAL-CONTENTS is non-nil, it is a string\n\
351 to be inserted into the minibuffer before reading input.\n\
352 If INITIAL-CONTENTS is (STRING . POSITION), the initial input\n\
353 is STRING, but point is placed POSITION characters into the string.\n\
354 Third arg KEYMAP is a keymap to use whilst reading;\n\
355 if omitted or nil, the default is `minibuffer-local-map'.\n\
356 If fourth arg READ is non-nil, then interpret the result as a lisp object\n\
357 and return that object:\n\
358 in other words, do `(car (read-from-string INPUT-STRING))'\n\
359 Fifth arg HIST, if non-nil, specifies a history list\n\
360 and optionally the initial position in the list.\n\
361 It can be a symbol, which is the history list variable to use,\n\
362 or it can be a cons cell (HISTVAR . HISTPOS).\n\
363 In that case, HISTVAR is the history list variable to use,\n\
364 and HISTPOS is the initial position (the position in the list\n\
365 which INITIAL-CONTENTS corresponds to).\n\
366 Positions are counted starting from 1 at the beginning of the list."
369 DEFUN ("read-from-minibuffer", Fread_from_minibuffer
, Sread_from_minibuffer
, 1, 5, 0,
370 0 /* See immediately above */)
371 (prompt
, initial_input
, keymap
, read
, hist
)
372 Lisp_Object prompt
, initial_input
, keymap
, read
, hist
;
375 Lisp_Object histvar
, histpos
, position
;
378 CHECK_STRING (prompt
, 0);
379 if (!NILP (initial_input
))
381 if (XTYPE (initial_input
) == Lisp_Cons
)
383 position
= Fcdr (initial_input
);
384 initial_input
= Fcar (initial_input
);
386 CHECK_STRING (initial_input
, 1);
387 if (!NILP (position
))
389 CHECK_NUMBER (position
, 0);
390 /* Convert to distance from end of input. */
391 pos
= XINT (position
) - 1 - XSTRING (initial_input
)->size
;
396 keymap
= Vminibuffer_local_map
;
398 keymap
= get_keymap (keymap
,2);
400 if (XTYPE (hist
) == Lisp_Symbol
)
407 histvar
= Fcar_safe (hist
);
408 histpos
= Fcdr_safe (hist
);
411 histvar
= Qminibuffer_history
;
413 XFASTINT (histpos
) = 0;
415 return read_minibuf (keymap
, initial_input
, prompt
,
416 make_number (pos
), !NILP (read
), histvar
, histpos
);
419 DEFUN ("read-minibuffer", Fread_minibuffer
, Sread_minibuffer
, 1, 2, 0,
420 "Return a Lisp object read using the minibuffer.\n\
421 Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS\n\
422 is a string to insert in the minibuffer before reading.")
423 (prompt
, initial_contents
)
424 Lisp_Object prompt
, initial_contents
;
426 CHECK_STRING (prompt
, 0);
427 if (!NILP (initial_contents
))
428 CHECK_STRING (initial_contents
, 1);
429 return read_minibuf (Vminibuffer_local_map
, initial_contents
,
430 prompt
, Qnil
, 1, Qminibuffer_history
, make_number (0));
433 DEFUN ("eval-minibuffer", Feval_minibuffer
, Seval_minibuffer
, 1, 2, 0,
434 "Return value of Lisp expression read using the minibuffer.\n\
435 Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS\n\
436 is a string to insert in the minibuffer before reading.")
437 (prompt
, initial_contents
)
438 Lisp_Object prompt
, initial_contents
;
440 return Feval (Fread_minibuffer (prompt
, initial_contents
));
443 /* Functions that use the minibuffer to read various things. */
445 DEFUN ("read-string", Fread_string
, Sread_string
, 1, 2, 0,
446 "Read a string from the minibuffer, prompting with string PROMPT.\n\
447 If non-nil second arg INITIAL-INPUT is a string to insert before reading.")
448 (prompt
, initial_input
)
449 Lisp_Object prompt
, initial_input
;
451 return Fread_from_minibuffer (prompt
, initial_input
, Qnil
, Qnil
, Qnil
);
454 DEFUN ("read-no-blanks-input", Fread_no_blanks_input
, Sread_no_blanks_input
, 2, 2, 0,
455 "Args PROMPT and INIT, strings. Read a string from the terminal, not allowing blanks.\n\
456 Prompt with PROMPT, and provide INIT as an initial value of the input string.")
458 Lisp_Object prompt
, init
;
460 CHECK_STRING (prompt
, 0);
462 CHECK_STRING (init
, 1);
464 return read_minibuf (Vminibuffer_local_ns_map
, init
, prompt
, Qnil
, 0,
465 Qminibuffer_history
, make_number (0));
468 DEFUN ("read-command", Fread_command
, Sread_command
, 1, 1, 0,
469 "One arg PROMPT, a string. Read the name of a command and return as a symbol.\n\
470 Prompts with PROMPT.")
474 return Fintern (Fcompleting_read (prompt
, Vobarray
, Qcommandp
, Qt
, Qnil
, Qnil
),
479 DEFUN ("read-function", Fread_function
, Sread_function
, 1, 1, 0,
480 "One arg PROMPT, a string. Read the name of a function and return as a symbol.\n\
481 Prompts with PROMPT.")
485 return Fintern (Fcompleting_read (prompt
, Vobarray
, Qfboundp
, Qt
, Qnil
, Qnil
),
490 DEFUN ("read-variable", Fread_variable
, Sread_variable
, 1, 1, 0,
491 "One arg PROMPT, a string. Read the name of a user variable and return\n\
492 it as a symbol. Prompts with PROMPT.\n\
493 A user variable is one whose documentation starts with a `*' character.")
497 return Fintern (Fcompleting_read (prompt
, Vobarray
,
498 Quser_variable_p
, Qt
, Qnil
, Qnil
),
502 DEFUN ("read-buffer", Fread_buffer
, Sread_buffer
, 1, 3, 0,
503 "One arg PROMPT, a string. Read the name of a buffer and return as a string.\n\
504 Prompts with PROMPT.\n\
505 Optional second arg is value to return if user enters an empty line.\n\
506 If optional third arg REQUIRE-MATCH is non-nil, only existing buffer names are allowed.")
507 (prompt
, def
, require_match
)
508 Lisp_Object prompt
, def
, require_match
;
514 if (XTYPE (def
) == Lisp_Buffer
)
515 def
= XBUFFER (def
)->name
;
518 args
[0] = build_string ("%s(default %s) ");
521 prompt
= Fformat (3, args
);
524 tem
= Fcompleting_read (prompt
, Vbuffer_alist
, Qnil
, require_match
, Qnil
, Qnil
);
526 if (XSTRING (tem
)->size
)
531 DEFUN ("try-completion", Ftry_completion
, Stry_completion
, 2, 3, 0,
532 "Return common substring of all completions of STRING in ALIST.\n\
533 Each car of each element of ALIST is tested to see if it begins with STRING.\n\
534 All that match are compared together; the longest initial sequence\n\
535 common to all matches is returned as a string.\n\
536 If there is no match at all, nil is returned.\n\
537 For an exact match, t is returned.\n\
539 ALIST can be an obarray instead of an alist.\n\
540 Then the print names of all symbols in the obarray are the possible matches.\n\
542 ALIST can also be a function to do the completion itself.\n\
543 It receives three arguments: the values STRING, PREDICATE and nil.\n\
544 Whatever it returns becomes the value of `try-completion'.\n\
546 If optional third argument PREDICATE is non-nil,\n\
547 it is used to test each possible match.\n\
548 The match is a candidate only if PREDICATE returns non-nil.\n\
549 The argument given to PREDICATE is the alist element or the symbol from the obarray.")
550 (string
, alist
, pred
)
551 Lisp_Object string
, alist
, pred
;
553 Lisp_Object bestmatch
, tail
, elt
, eltstring
;
555 int compare
, matchsize
;
556 int list
= CONSP (alist
) || NILP (alist
);
559 Lisp_Object bucket
, zero
, end
, tem
;
560 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
;
562 CHECK_STRING (string
, 0);
563 if (!list
&& XTYPE (alist
) != Lisp_Vector
)
564 return call3 (alist
, string
, pred
, Qnil
);
568 /* If ALIST is not a list, set TAIL just for gc pro. */
573 obsize
= XVECTOR (alist
)->size
;
574 bucket
= XVECTOR (alist
)->contents
[index
];
579 /* Get the next element of the alist or obarray. */
580 /* Exit the loop if the elements are all used up. */
581 /* elt gets the alist element or symbol.
582 eltstring gets the name to check as a completion. */
589 eltstring
= Fcar (elt
);
594 if (XFASTINT (bucket
) != 0)
597 eltstring
= Fsymbol_name (elt
);
598 if (XSYMBOL (bucket
)->next
)
599 XSETSYMBOL (bucket
, XSYMBOL (bucket
)->next
);
601 XFASTINT (bucket
) = 0;
603 else if (++index
>= obsize
)
607 bucket
= XVECTOR (alist
)->contents
[index
];
612 /* Is this element a possible completion? */
614 if (XTYPE (eltstring
) == Lisp_String
&&
615 XSTRING (string
)->size
<= XSTRING (eltstring
)->size
&&
616 0 > scmp (XSTRING (eltstring
)->data
, XSTRING (string
)->data
,
617 XSTRING (string
)->size
))
620 /* Ignore this element if there is a predicate
621 and the predicate doesn't like it. */
625 if (EQ (pred
, Qcommandp
))
626 tem
= Fcommandp (elt
);
629 GCPRO4 (tail
, string
, eltstring
, bestmatch
);
630 tem
= call1 (pred
, elt
);
633 if (NILP (tem
)) continue;
636 /* Update computation of how much all possible completions match */
639 if (NILP (bestmatch
))
640 bestmatch
= eltstring
, bestmatchsize
= XSTRING (eltstring
)->size
;
643 compare
= min (bestmatchsize
, XSTRING (eltstring
)->size
);
644 matchsize
= scmp (XSTRING (bestmatch
)->data
,
645 XSTRING (eltstring
)->data
,
649 if (completion_ignore_case
)
651 /* If this is an exact match except for case,
652 use it as the best match rather than one that is not an
653 exact match. This way, we get the case pattern
654 of the actual match. */
655 if ((matchsize
== XSTRING (eltstring
)->size
656 && matchsize
< XSTRING (bestmatch
)->size
)
658 /* If there is more than one exact match ignoring case,
659 and one of them is exact including case,
661 /* If there is no exact match ignoring case,
662 prefer a match that does not change the case
664 ((matchsize
== XSTRING (eltstring
)->size
)
666 (matchsize
== XSTRING (bestmatch
)->size
)
667 && !bcmp (XSTRING (eltstring
)->data
,
668 XSTRING (string
)->data
, XSTRING (string
)->size
)
669 && bcmp (XSTRING (bestmatch
)->data
,
670 XSTRING (string
)->data
, XSTRING (string
)->size
)))
671 bestmatch
= eltstring
;
673 bestmatchsize
= matchsize
;
678 if (NILP (bestmatch
))
679 return Qnil
; /* No completions found */
680 /* If we are ignoring case, and there is no exact match,
681 and no additional text was supplied,
682 don't change the case of what the user typed. */
683 if (completion_ignore_case
&& bestmatchsize
== XSTRING (string
)->size
684 && XSTRING (bestmatch
)->size
> bestmatchsize
)
687 /* Return t if the supplied string is an exact match (counting case);
688 it does not require any change to be made. */
689 if (matchcount
== 1 && bestmatchsize
== XSTRING (string
)->size
690 && !bcmp (XSTRING (bestmatch
)->data
, XSTRING (string
)->data
,
694 XFASTINT (zero
) = 0; /* Else extract the part in which */
695 XFASTINT (end
) = bestmatchsize
; /* all completions agree */
696 return Fsubstring (bestmatch
, zero
, end
);
699 /* Compare exactly LEN chars of strings at S1 and S2,
700 ignoring case if appropriate.
701 Return -1 if strings match,
702 else number of chars that match at the beginning. */
705 register char *s1
, *s2
;
708 register int l
= len
;
710 if (completion_ignore_case
)
712 while (l
&& DOWNCASE (*s1
++) == DOWNCASE (*s2
++))
717 while (l
&& *s1
++ == *s2
++)
725 DEFUN ("all-completions", Fall_completions
, Sall_completions
, 2, 3, 0,
726 "Search for partial matches to STRING in ALIST.\n\
727 Each car of each element of ALIST is tested to see if it begins with STRING.\n\
728 The value is a list of all the strings from ALIST that match.\n\
729 ALIST can be an obarray instead of an alist.\n\
730 Then the print names of all symbols in the obarray are the possible matches.\n\
732 ALIST can also be a function to do the completion itself.\n\
733 It receives three arguments: the values STRING, PREDICATE and t.\n\
734 Whatever it returns becomes the value of `all-completion'.\n\
736 If optional third argument PREDICATE is non-nil,\n\
737 it is used to test each possible match.\n\
738 The match is a candidate only if PREDICATE returns non-nil.\n\
739 The argument given to PREDICATE is the alist element or the symbol from the obarray.")
740 (string
, alist
, pred
)
741 Lisp_Object string
, alist
, pred
;
743 Lisp_Object tail
, elt
, eltstring
;
744 Lisp_Object allmatches
;
745 int list
= CONSP (alist
) || NILP (alist
);
747 Lisp_Object bucket
, tem
;
748 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
;
750 CHECK_STRING (string
, 0);
751 if (!list
&& XTYPE (alist
) != Lisp_Vector
)
753 return call3 (alist
, string
, pred
, Qt
);
757 /* If ALIST is not a list, set TAIL just for gc pro. */
762 obsize
= XVECTOR (alist
)->size
;
763 bucket
= XVECTOR (alist
)->contents
[index
];
768 /* Get the next element of the alist or obarray. */
769 /* Exit the loop if the elements are all used up. */
770 /* elt gets the alist element or symbol.
771 eltstring gets the name to check as a completion. */
778 eltstring
= Fcar (elt
);
783 if (XFASTINT (bucket
) != 0)
786 eltstring
= Fsymbol_name (elt
);
787 if (XSYMBOL (bucket
)->next
)
788 XSETSYMBOL (bucket
, XSYMBOL (bucket
)->next
);
790 XFASTINT (bucket
) = 0;
792 else if (++index
>= obsize
)
796 bucket
= XVECTOR (alist
)->contents
[index
];
801 /* Is this element a possible completion? */
803 if (XTYPE (eltstring
) == Lisp_String
&&
804 XSTRING (string
)->size
<= XSTRING (eltstring
)->size
&&
805 XSTRING (eltstring
)->data
[0] != ' ' &&
806 0 > scmp (XSTRING (eltstring
)->data
, XSTRING (string
)->data
,
807 XSTRING (string
)->size
))
810 /* Ignore this element if there is a predicate
811 and the predicate doesn't like it. */
815 if (EQ (pred
, Qcommandp
))
816 tem
= Fcommandp (elt
);
819 GCPRO4 (tail
, eltstring
, allmatches
, string
);
820 tem
= call1 (pred
, elt
);
823 if (NILP (tem
)) continue;
825 /* Ok => put it on the list. */
826 allmatches
= Fcons (eltstring
, allmatches
);
830 return Fnreverse (allmatches
);
833 Lisp_Object Vminibuffer_completion_table
, Qminibuffer_completion_table
;
834 Lisp_Object Vminibuffer_completion_predicate
, Qminibuffer_completion_predicate
;
835 Lisp_Object Vminibuffer_completion_confirm
, Qminibuffer_completion_confirm
;
837 /* This comment supplies the doc string for completing-read,
838 for make-docfile to see. We cannot put this in the real DEFUN
839 due to limits in the Unix cpp.
841 DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 6, 0,
842 "Read a string in the minibuffer, with completion.\n\
843 Args: PROMPT, TABLE, PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST.\n\
844 PROMPT is a string to prompt with; normally it ends in a colon and a space.\n\
845 TABLE is an alist whose elements' cars are strings, or an obarray.\n\
846 PREDICATE limits completion to a subset of TABLE.\n\
847 See `try-completion' for more details on completion, TABLE, and PREDICATE.\n\
848 If REQUIRE-MATCH is non-nil, the user is not allowed to exit unless\n\
849 the input is (or completes to) an element of TABLE.\n\
850 If it is also not t, Return does not exit if it does non-null completion.\n\
851 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.\n\
852 If it is (STRING . POSITION), the initial input\n\
853 is STRING, but point is placed POSITION characters into the string.\n\
854 HIST, if non-nil, specifies a history list\n\
855 and optionally the initial position in the list.\n\
856 It can be a symbol, which is the history list variable to use,\n\
857 or it can be a cons cell (HISTVAR . HISTPOS).\n\
858 In that case, HISTVAR is the history list variable to use,\n\
859 and HISTPOS is the initial position (the position in the list\n\
860 which INITIAL-CONTENTS corresponds to).\n\
861 Positions are counted starting from 1 at the beginning of the list.\n\
862 Completion ignores case if the ambient value of\n\
863 `completion-ignore-case' is non-nil."
865 DEFUN ("completing-read", Fcompleting_read
, Scompleting_read
, 2, 6, 0,
866 0 /* See immediately above */)
867 (prompt
, table
, pred
, require_match
, init
, hist
)
868 Lisp_Object prompt
, table
, pred
, require_match
, init
, hist
;
870 Lisp_Object val
, histvar
, histpos
, position
;
872 int count
= specpdl_ptr
- specpdl
;
873 specbind (Qminibuffer_completion_table
, table
);
874 specbind (Qminibuffer_completion_predicate
, pred
);
875 specbind (Qminibuffer_completion_confirm
,
876 EQ (require_match
, Qt
) ? Qnil
: Qt
);
877 last_exact_completion
= Qnil
;
882 if (XTYPE (init
) == Lisp_Cons
)
884 position
= Fcdr (init
);
887 CHECK_STRING (init
, 0);
888 if (!NILP (position
))
890 CHECK_NUMBER (position
, 0);
891 /* Convert to distance from end of input. */
892 pos
= XINT (position
) - XSTRING (init
)->size
;
896 if (XTYPE (hist
) == Lisp_Symbol
)
903 histvar
= Fcar_safe (hist
);
904 histpos
= Fcdr_safe (hist
);
907 histvar
= Qminibuffer_history
;
909 XFASTINT (histpos
) = 0;
911 val
= read_minibuf (NILP (require_match
)
912 ? Vminibuffer_local_completion_map
913 : Vminibuffer_local_must_match_map
,
914 init
, prompt
, make_number (pos
), 0,
916 return unbind_to (count
, val
);
919 /* Temporarily display the string M at the end of the current
920 minibuffer contents. This is used to display things like
921 "[No Match]" when the user requests a completion for a prefix
922 that has no possible completions, and other quick, unobtrusive
925 temp_echo_area_glyphs (m
)
929 Lisp_Object oinhibit
;
930 oinhibit
= Vinhibit_quit
;
932 /* Clear out any old echo-area message to make way for our new thing. */
939 Fsit_for (make_number (2), Qnil
, Qnil
);
940 del_range (point
, ZV
);
941 if (!NILP (Vquit_flag
))
944 unread_command_events
= Fcons (make_number (Ctl ('g')), Qnil
);
946 Vinhibit_quit
= oinhibit
;
949 Lisp_Object
Fminibuffer_completion_help ();
950 Lisp_Object
assoc_for_completion ();
953 * 0 no possible completion
954 * 1 was already an exact and unique completion
955 * 3 was already an exact completion
956 * 4 completed to an exact completion
957 * 5 some completion happened
958 * 6 no completion happened
963 Lisp_Object completion
, tem
;
967 completion
= Ftry_completion (Fbuffer_string (), Vminibuffer_completion_table
,
968 Vminibuffer_completion_predicate
);
969 last
= last_exact_completion
;
970 last_exact_completion
= Qnil
;
972 if (NILP (completion
))
975 temp_echo_area_glyphs (" [No match]");
979 if (EQ (completion
, Qt
)) /* exact and unique match */
983 tem
= Fstring_equal (completion
, Fbuffer_string());
984 if (completedp
= NILP (tem
))
986 Ferase_buffer (); /* Some completion happened */
987 Finsert (1, &completion
);
990 /* It did find a match. Do we match some possibility exactly now? */
991 if (CONSP (Vminibuffer_completion_table
)
992 || NILP (Vminibuffer_completion_table
))
993 tem
= assoc_for_completion (Fbuffer_string (),
994 Vminibuffer_completion_table
);
995 else if (XTYPE (Vminibuffer_completion_table
) == Lisp_Vector
)
997 /* the primitive used by Fintern_soft */
998 extern Lisp_Object
oblookup ();
1000 tem
= Fbuffer_string ();
1001 /* Bypass intern-soft as that loses for nil */
1002 tem
= oblookup (Vminibuffer_completion_table
,
1003 XSTRING (tem
)->data
, XSTRING (tem
)->size
);
1004 if (XTYPE (tem
) != Lisp_Symbol
)
1006 else if (!NILP (Vminibuffer_completion_predicate
))
1007 tem
= call1 (Vminibuffer_completion_predicate
, tem
);
1012 tem
= call3 (Vminibuffer_completion_table
,
1014 Vminibuffer_completion_predicate
,
1018 { /* not an exact match */
1022 Fminibuffer_completion_help ();
1024 temp_echo_area_glyphs (" [Next char not unique]");
1027 else if (completedp
)
1029 /* If the last exact completion and this one were the same,
1030 it means we've already given a "Complete but not unique"
1031 message and the user's hit TAB again, so now we give him help. */
1032 last_exact_completion
= completion
;
1035 tem
= Fbuffer_string ();
1036 if (!NILP (Fequal (tem
, last
)))
1037 Fminibuffer_completion_help ();
1042 /* Like assoc but assumes KEY is a string, and ignores case if appropriate. */
1045 assoc_for_completion (key
, list
)
1046 register Lisp_Object key
;
1049 register Lisp_Object tail
;
1051 if (completion_ignore_case
)
1052 key
= Fupcase (key
);
1054 for (tail
= list
; !NILP (tail
); tail
= Fcdr (tail
))
1056 register Lisp_Object elt
, tem
, thiscar
;
1058 if (!CONSP (elt
)) continue;
1059 thiscar
= Fcar (elt
);
1060 if (XTYPE (thiscar
) != Lisp_String
)
1062 if (completion_ignore_case
)
1063 thiscar
= Fupcase (thiscar
);
1064 tem
= Fequal (thiscar
, key
);
1065 if (!NILP (tem
)) return elt
;
1071 DEFUN ("minibuffer-complete", Fminibuffer_complete
, Sminibuffer_complete
, 0, 0, "",
1072 "Complete the minibuffer contents as far as possible.")
1075 register int i
= do_completion ();
1082 temp_echo_area_glyphs (" [Sole completion]");
1086 temp_echo_area_glyphs (" [Complete, but not unique]");
1093 DEFUN ("minibuffer-complete-and-exit", Fminibuffer_complete_and_exit
,
1094 Sminibuffer_complete_and_exit
, 0, 0, "",
1095 "Complete the minibuffer contents, and maybe exit.\n\
1096 Exit if the name is valid with no completion needed.\n\
1097 If name was completed to a valid match,\n\
1098 a repetition of this command will exit.")
1103 /* Allow user to specify null string */
1107 i
= do_completion ();
1115 if (!NILP (Vminibuffer_completion_confirm
))
1117 temp_echo_area_glyphs (" [Confirm]");
1127 Fthrow (Qexit
, Qnil
);
1131 DEFUN ("minibuffer-complete-word", Fminibuffer_complete_word
, Sminibuffer_complete_word
,
1133 "Complete the minibuffer contents at most a single word.\n\
1134 After one word is completed as much as possible, a space or hyphen\n\
1135 is added, provided that matches some possible completion.")
1138 Lisp_Object completion
, tem
;
1140 register unsigned char *completion_string
;
1141 /* We keep calling Fbuffer_string
1142 rather than arrange for GC to hold onto a pointer to
1143 one of the strings thus made. */
1145 completion
= Ftry_completion (Fbuffer_string (),
1146 Vminibuffer_completion_table
,
1147 Vminibuffer_completion_predicate
);
1148 if (NILP (completion
))
1151 temp_echo_area_glyphs (" [No match]");
1154 if (EQ (completion
, Qt
))
1157 #if 0 /* How the below code used to look, for reference */
1158 tem
= Fbuffer_string ();
1159 b
= XSTRING (tem
)->data
;
1160 i
= ZV
- 1 - XSTRING (completion
)->size
;
1161 p
= XSTRING (completion
)->data
;
1163 0 <= scmp (b
, p
, ZV
- 1))
1166 /* Set buffer to longest match of buffer tail and completion head. */
1167 while (0 <= scmp (b
+ i
, p
, ZV
- 1 - i
))
1169 del_range (1, i
+ 1);
1172 #else /* Rewritten code */
1174 register unsigned char *buffer_string
;
1175 int buffer_length
, completion_length
;
1177 tem
= Fbuffer_string ();
1178 buffer_string
= XSTRING (tem
)->data
;
1179 completion_string
= XSTRING (completion
)->data
;
1180 buffer_length
= XSTRING (tem
)->size
; /* ie ZV - BEGV */
1181 completion_length
= XSTRING (completion
)->size
;
1182 i
= buffer_length
- completion_length
;
1183 /* Mly: I don't understand what this is supposed to do AT ALL */
1185 0 <= scmp (buffer_string
, completion_string
, buffer_length
))
1187 /* Set buffer to longest match of buffer tail and completion head. */
1191 while (0 <= scmp (buffer_string
++, completion_string
, buffer_length
--))
1193 del_range (1, i
+ 1);
1197 #endif /* Rewritten code */
1200 /* If completion finds next char not unique,
1201 consider adding a space or a hyphen */
1202 if (i
== XSTRING (completion
)->size
)
1204 tem
= Ftry_completion (concat2 (Fbuffer_string (), build_string (" ")),
1205 Vminibuffer_completion_table
,
1206 Vminibuffer_completion_predicate
);
1207 if (XTYPE (tem
) == Lisp_String
)
1211 tem
= Ftry_completion (concat2 (Fbuffer_string (), build_string ("-")),
1212 Vminibuffer_completion_table
,
1213 Vminibuffer_completion_predicate
);
1214 if (XTYPE (tem
) == Lisp_String
)
1219 /* Now find first word-break in the stuff found by completion.
1220 i gets index in string of where to stop completing. */
1221 completion_string
= XSTRING (completion
)->data
;
1223 for (; i
< XSTRING (completion
)->size
; i
++)
1224 if (SYNTAX (completion_string
[i
]) != Sword
) break;
1225 if (i
< XSTRING (completion
)->size
)
1228 /* If got no characters, print help for user. */
1233 Fminibuffer_completion_help ();
1237 /* Otherwise insert in minibuffer the chars we got */
1240 insert_from_string (completion
, 0, i
);
1244 DEFUN ("display-completion-list", Fdisplay_completion_list
, Sdisplay_completion_list
,
1246 "Display the list of completions, COMPLETIONS, using `standard-output'.\n\
1247 Each element may be just a symbol or string\n\
1248 or may be a list of two strings to be printed as if concatenated.")
1250 Lisp_Object completions
;
1252 register Lisp_Object tail
, elt
;
1255 /* No GCPRO needed, since (when it matters) every variable
1256 points to a non-string that is pointed to by COMPLETIONS. */
1257 struct buffer
*old
= current_buffer
;
1258 if (XTYPE (Vstandard_output
) == Lisp_Buffer
)
1259 set_buffer_internal (XBUFFER (Vstandard_output
));
1261 if (NILP (completions
))
1262 write_string ("There are no possible completions of what you have typed.",
1266 write_string ("Possible completions are:", -1);
1267 for (tail
= completions
, i
= 0; !NILP (tail
); tail
= Fcdr (tail
), i
++)
1269 /* this needs fixing for the case of long completions
1270 and/or narrow windows */
1271 /* Sadly, the window it will appear in is not known
1272 until after the text has been made. */
1275 if (XTYPE (Vstandard_output
) == Lisp_Buffer
)
1276 Findent_to (make_number (35), make_number (1));
1281 write_string (" ", -1);
1284 while (column
< 35);
1295 if (XTYPE (Vstandard_output
) != Lisp_Buffer
)
1298 tem
= Flength (Fcar (elt
));
1299 column
+= XINT (tem
);
1300 tem
= Flength (Fcar (Fcdr (elt
)));
1301 column
+= XINT (tem
);
1303 Fprinc (Fcar (elt
), Qnil
);
1304 Fprinc (Fcar (Fcdr (elt
)), Qnil
);
1308 if (XTYPE (Vstandard_output
) != Lisp_Buffer
)
1311 tem
= Flength (elt
);
1312 column
+= XINT (tem
);
1319 if (!NILP (Vrun_hooks
))
1320 call1 (Vrun_hooks
, intern ("completion-setup-hook"));
1322 if (XTYPE (Vstandard_output
) == Lisp_Buffer
)
1323 set_buffer_internal (old
);
1327 DEFUN ("minibuffer-completion-help", Fminibuffer_completion_help
, Sminibuffer_completion_help
,
1329 "Display a list of possible completions of the current minibuffer contents.")
1332 Lisp_Object completions
;
1334 message ("Making completion list...");
1335 completions
= Fall_completions (Fbuffer_string (),
1336 Vminibuffer_completion_table
,
1337 Vminibuffer_completion_predicate
);
1338 echo_area_glyphs
= 0;
1340 if (NILP (completions
))
1343 temp_echo_area_glyphs (" [No completions]");
1346 internal_with_output_to_temp_buffer ("*Completions*",
1347 Fdisplay_completion_list
,
1348 Fsort (completions
, Qstring_lessp
));
1352 DEFUN ("self-insert-and-exit", Fself_insert_and_exit
, Sself_insert_and_exit
, 0, 0, "",
1353 "Terminate minibuffer input.")
1356 if (XTYPE (last_command_char
) == Lisp_Int
)
1357 internal_self_insert (last_command_char
, 0);
1361 Fthrow (Qexit
, Qnil
);
1364 DEFUN ("exit-minibuffer", Fexit_minibuffer
, Sexit_minibuffer
, 0, 0, "",
1365 "Terminate this minibuffer argument.")
1368 Fthrow (Qexit
, Qnil
);
1371 DEFUN ("minibuffer-depth", Fminibuffer_depth
, Sminibuffer_depth
, 0, 0, 0,
1372 "Return current depth of activations of minibuffer, a nonnegative integer.")
1375 return make_number (minibuf_level
);
1379 init_minibuf_once ()
1381 Vminibuffer_list
= Qnil
;
1382 staticpro (&Vminibuffer_list
);
1389 minibuf_save_vector_size
= 5;
1390 minibuf_save_vector
= (struct minibuf_save_data
*) malloc (5 * sizeof (struct minibuf_save_data
));
1392 Qminibuffer_completion_table
= intern ("minibuffer-completion-table");
1393 staticpro (&Qminibuffer_completion_table
);
1395 Qminibuffer_completion_confirm
= intern ("minibuffer-completion-confirm");
1396 staticpro (&Qminibuffer_completion_confirm
);
1398 Qminibuffer_completion_predicate
= intern ("minibuffer-completion-predicate");
1399 staticpro (&Qminibuffer_completion_predicate
);
1401 staticpro (&last_minibuf_string
);
1402 last_minibuf_string
= Qnil
;
1404 Quser_variable_p
= intern ("user-variable-p");
1405 staticpro (&Quser_variable_p
);
1407 Qminibuffer_history
= intern ("minibuffer-history");
1408 staticpro (&Qminibuffer_history
);
1410 Qminibuffer_setup_hook
= intern ("minibuffer-setup-hook");
1411 staticpro (&Qminibuffer_setup_hook
);
1413 DEFVAR_LISP ("minibuffer-setup-hook", &Vminibuffer_setup_hook
,
1414 "Normal hook run just after entry to minibuffer.");
1415 Vminibuffer_setup_hook
= Qnil
;
1417 DEFVAR_BOOL ("completion-auto-help", &auto_help
,
1418 "*Non-nil means automatically provide help for invalid completion input.");
1421 DEFVAR_BOOL ("completion-ignore-case", &completion_ignore_case
,
1422 "Non-nil means don't consider case significant in completion.");
1423 completion_ignore_case
= 0;
1425 DEFVAR_BOOL ("enable-recursive-minibuffers", &enable_recursive_minibuffers
,
1426 "*Non-nil means to allow minibuffer commands while in the minibuffer.\n\
1427 More precisely, this variable makes a difference when the minibuffer window\n\
1428 is the selected window. If you are in some other window, minibuffer commands\n\
1429 are allowed even if a minibuffer is active.");
1430 enable_recursive_minibuffers
= 0;
1432 DEFVAR_LISP ("minibuffer-completion-table", &Vminibuffer_completion_table
,
1433 "Alist or obarray used for completion in the minibuffer.\n\
1434 This becomes the ALIST argument to `try-completion' and `all-completion'.\n\
1436 The value may alternatively be a function, which is given three arguments:\n\
1437 STRING, the current buffer contents;\n\
1438 PREDICATE, the predicate for filtering possible matches;\n\
1439 CODE, which says what kind of things to do.\n\
1440 CODE can be nil, t or `lambda'.\n\
1441 nil means to return the best completion of STRING, or nil if there is none.\n\
1442 t means to return a list of all possible completions of STRING.\n\
1443 `lambda' means to return t if STRING is a valid completion as it stands.");
1444 Vminibuffer_completion_table
= Qnil
;
1446 DEFVAR_LISP ("minibuffer-completion-predicate", &Vminibuffer_completion_predicate
,
1447 "Within call to `completing-read', this holds the PREDICATE argument.");
1448 Vminibuffer_completion_predicate
= Qnil
;
1450 DEFVAR_LISP ("minibuffer-completion-confirm", &Vminibuffer_completion_confirm
,
1451 "Non-nil => demand confirmation of completion before exiting minibuffer.");
1452 Vminibuffer_completion_confirm
= Qnil
;
1454 DEFVAR_LISP ("minibuffer-help-form", &Vminibuffer_help_form
,
1455 "Value that `help-form' takes on inside the minibuffer.");
1456 Vminibuffer_help_form
= Qnil
;
1458 DEFVAR_LISP ("minibuffer-history-variable", &Vminibuffer_history_variable
,
1459 "History list symbol to add minibuffer values to.\n\
1460 Each minibuffer output is added with\n\
1461 (set minibuffer-history-variable\n\
1462 (cons STRING (symbol-value minibuffer-history-variable)))");
1463 XFASTINT (Vminibuffer_history_variable
) = 0;
1465 DEFVAR_LISP ("minibuffer-history-position", &Vminibuffer_history_position
,
1466 "Current position of redoing in the history list.");
1467 Vminibuffer_history_position
= Qnil
;
1469 defsubr (&Sread_from_minibuffer
);
1470 defsubr (&Seval_minibuffer
);
1471 defsubr (&Sread_minibuffer
);
1472 defsubr (&Sread_string
);
1473 defsubr (&Sread_command
);
1474 defsubr (&Sread_variable
);
1475 defsubr (&Sread_buffer
);
1476 defsubr (&Sread_no_blanks_input
);
1477 defsubr (&Sminibuffer_depth
);
1479 defsubr (&Stry_completion
);
1480 defsubr (&Sall_completions
);
1481 defsubr (&Scompleting_read
);
1482 defsubr (&Sminibuffer_complete
);
1483 defsubr (&Sminibuffer_complete_word
);
1484 defsubr (&Sminibuffer_complete_and_exit
);
1485 defsubr (&Sdisplay_completion_list
);
1486 defsubr (&Sminibuffer_completion_help
);
1488 defsubr (&Sself_insert_and_exit
);
1489 defsubr (&Sexit_minibuffer
);
1495 initial_define_key (Vminibuffer_local_map
, Ctl ('g'),
1496 "abort-recursive-edit");
1497 initial_define_key (Vminibuffer_local_map
, Ctl ('m'),
1499 initial_define_key (Vminibuffer_local_map
, Ctl ('j'),
1502 initial_define_key (Vminibuffer_local_ns_map
, Ctl ('g'),
1503 "abort-recursive-edit");
1504 initial_define_key (Vminibuffer_local_ns_map
, Ctl ('m'),
1506 initial_define_key (Vminibuffer_local_ns_map
, Ctl ('j'),
1509 initial_define_key (Vminibuffer_local_ns_map
, ' ',
1511 initial_define_key (Vminibuffer_local_ns_map
, '\t',
1513 initial_define_key (Vminibuffer_local_ns_map
, '?',
1514 "self-insert-and-exit");
1516 initial_define_key (Vminibuffer_local_completion_map
, Ctl ('g'),
1517 "abort-recursive-edit");
1518 initial_define_key (Vminibuffer_local_completion_map
, Ctl ('m'),
1520 initial_define_key (Vminibuffer_local_completion_map
, Ctl ('j'),
1523 initial_define_key (Vminibuffer_local_completion_map
, '\t',
1524 "minibuffer-complete");
1525 initial_define_key (Vminibuffer_local_completion_map
, ' ',
1526 "minibuffer-complete-word");
1527 initial_define_key (Vminibuffer_local_completion_map
, '?',
1528 "minibuffer-completion-help");
1530 initial_define_key (Vminibuffer_local_must_match_map
, Ctl ('g'),
1531 "abort-recursive-edit");
1532 initial_define_key (Vminibuffer_local_must_match_map
, Ctl ('m'),
1533 "minibuffer-complete-and-exit");
1534 initial_define_key (Vminibuffer_local_must_match_map
, Ctl ('j'),
1535 "minibuffer-complete-and-exit");
1536 initial_define_key (Vminibuffer_local_must_match_map
, '\t',
1537 "minibuffer-complete");
1538 initial_define_key (Vminibuffer_local_must_match_map
, ' ',
1539 "minibuffer-complete-word");
1540 initial_define_key (Vminibuffer_local_must_match_map
, '?',
1541 "minibuffer-completion-help");