1 /* Minibuffer input and completion.
2 Copyright (C) 1985, 1986, 1993, 1994, 1995, 1996, 1997, 1998
3 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
28 #include "dispextern.h"
34 #define min(a, b) ((a) < (b) ? (a) : (b))
38 /* List of buffers for use as minibuffers.
39 The first element of the list is used for the outermost minibuffer
40 invocation, the next element is used for a recursive minibuffer
41 invocation, etc. The list is extended at the end as deeper
42 minibuffer recursions are encountered. */
43 Lisp_Object Vminibuffer_list
;
45 /* Data to remember during recursive minibuffer invocations */
46 Lisp_Object minibuf_save_list
;
48 /* Depth in minibuffer invocations. */
51 /* Nonzero means display completion help for invalid input. */
54 /* The maximum length of a minibuffer history. */
55 Lisp_Object Qhistory_length
, Vhistory_length
;
57 /* Fread_minibuffer leaves the input here as a string. */
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 /* Nonzero means don't ignore text properties
65 in Fread_from_minibuffer. */
66 int minibuffer_allow_text_properties
;
68 /* help-form is bound to this while in the minibuffer. */
70 Lisp_Object Vminibuffer_help_form
;
72 /* Variable which is the history list to add minibuffer values to. */
74 Lisp_Object Vminibuffer_history_variable
;
76 /* Current position in the history list (adjusted by M-n and M-p). */
78 Lisp_Object Vminibuffer_history_position
;
80 Lisp_Object Qminibuffer_history
, Qbuffer_name_history
;
82 Lisp_Object Qread_file_name_internal
;
84 /* Normal hooks for entry to and exit from minibuffer. */
86 Lisp_Object Qminibuffer_setup_hook
, Vminibuffer_setup_hook
;
87 Lisp_Object Qminibuffer_exit_hook
, Vminibuffer_exit_hook
;
89 /* Function to call to read a buffer name. */
90 Lisp_Object Vread_buffer_function
;
92 /* Nonzero means completion ignores case. */
94 int completion_ignore_case
;
96 /* List of regexps that should restrict possible completions. */
98 Lisp_Object Vcompletion_regexp_list
;
100 /* Nonzero means raise the minibuffer frame when the minibuffer
103 int minibuffer_auto_raise
;
105 /* If last completion attempt reported "Complete but not unique"
106 then this is the string completed then; otherwise this is nil. */
108 static Lisp_Object last_exact_completion
;
110 /* Non-nil means it is the window for C-M-v to scroll
111 when the minibuffer is selected. */
112 extern Lisp_Object Vminibuf_scroll_window
;
114 extern Lisp_Object Voverriding_local_map
;
116 Lisp_Object Quser_variable_p
;
118 Lisp_Object Qminibuffer_default
;
120 Lisp_Object Qcurrent_input_method
, Qactivate_input_method
;
122 extern Lisp_Object Qmouse_face
;
124 /* Put minibuf on currently selected frame's minibuffer.
125 We do this whenever the user starts a new minibuffer
126 or when a minibuffer exits. */
129 choose_minibuf_frame ()
131 if (selected_frame
!= 0
132 && !EQ (minibuf_window
, selected_frame
->minibuffer_window
))
134 /* I don't think that any frames may validly have a null minibuffer
136 if (NILP (selected_frame
->minibuffer_window
))
139 Fset_window_buffer (selected_frame
->minibuffer_window
,
140 XWINDOW (minibuf_window
)->buffer
);
141 minibuf_window
= selected_frame
->minibuffer_window
;
144 /* Make sure no other frame has a minibuffer as its selected window,
145 because the text would not be displayed in it, and that would be
146 confusing. Only allow the selected frame to do this,
147 and that only if the minibuffer is active. */
149 Lisp_Object tail
, frame
;
151 FOR_EACH_FRAME (tail
, frame
)
152 if (MINI_WINDOW_P (XWINDOW (FRAME_SELECTED_WINDOW (XFRAME (frame
))))
153 && !(XFRAME (frame
) == selected_frame
154 && minibuf_level
> 0))
155 Fset_frame_selected_window (frame
, Fframe_first_window (frame
));
160 choose_minibuf_frame_1 (ignore
)
163 choose_minibuf_frame ();
167 DEFUN ("set-minibuffer-window", Fset_minibuffer_window
,
168 Sset_minibuffer_window
, 1, 1, 0,
169 "Specify which minibuffer window to use for the minibuffer.\n\
170 This effects where the minibuffer is displayed if you put text in it\n\
171 without invoking the usual minibuffer commands.")
175 CHECK_WINDOW (window
, 1);
176 if (! MINI_WINDOW_P (XWINDOW (window
)))
177 error ("Window is not a minibuffer window");
179 minibuf_window
= window
;
185 /* Actual minibuffer invocation. */
187 static Lisp_Object read_minibuf_unwind
P_ ((Lisp_Object
));
188 static Lisp_Object read_minibuf
P_ ((Lisp_Object
, Lisp_Object
,
189 Lisp_Object
, Lisp_Object
,
191 Lisp_Object
, Lisp_Object
,
194 /* Read from the minibuffer using keymap MAP, initial contents INITIAL
195 (a string), putting point minus BACKUP_N bytes from the end of INITIAL,
196 prompting with PROMPT (a string), using history list HISTVAR
197 with initial position HISTPOS. (BACKUP_N should be <= 0.)
199 Normally return the result as a string (the text that was read),
200 but if EXPFLAG is nonzero, read it and return the object read.
201 If HISTVAR is given, save the value read on that history only if it doesn't
202 match the front of that history list exactly. The value is pushed onto
203 the list as the string that was read.
205 DEFALT specifies te default value for the sake of history commands.
207 If ALLOW_PROPS is nonzero, we do not throw away text properties.
209 if INHERIT_INPUT_METHOD is nonzeor, the minibuffer inherit the
210 current input method. */
213 read_minibuf (map
, initial
, prompt
, backup_n
, expflag
,
214 histvar
, histpos
, defalt
, allow_props
, inherit_input_method
)
218 Lisp_Object backup_n
;
224 int inherit_input_method
;
227 int count
= specpdl_ptr
- specpdl
;
228 Lisp_Object mini_frame
, ambient_dir
, minibuffer
, input_method
;
229 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
, gcpro5
;
230 Lisp_Object enable_multibyte
;
232 specbind (Qminibuffer_default
, defalt
);
234 single_kboard_state ();
237 ambient_dir
= current_buffer
->directory
;
239 enable_multibyte
= Qnil
;
241 /* Don't need to protect PROMPT, HISTVAR, and HISTPOS because we
242 store them away before we can GC. Don't need to protect
243 BACKUP_N because we use the value only if it is an integer. */
244 GCPRO5 (map
, initial
, val
, ambient_dir
, input_method
);
246 if (!STRINGP (prompt
))
247 prompt
= build_string ("");
249 if (!enable_recursive_minibuffers
250 && minibuf_level
> 0)
252 if (EQ (selected_window
, minibuf_window
))
253 error ("Command attempted to use minibuffer while in minibuffer");
255 /* If we're in another window, cancel the minibuffer that's active. */
257 build_string ("Command attempted to use minibuffer while in minibuffer"));
260 /* Choose the minibuffer window and frame, and take action on them. */
262 choose_minibuf_frame ();
264 record_unwind_protect (choose_minibuf_frame_1
, Qnil
);
266 record_unwind_protect (Fset_window_configuration
,
267 Fcurrent_window_configuration (Qnil
));
269 /* If the minibuffer window is on a different frame, save that
270 frame's configuration too. */
271 mini_frame
= WINDOW_FRAME (XWINDOW (minibuf_window
));
272 if (XFRAME (mini_frame
) != selected_frame
)
273 record_unwind_protect (Fset_window_configuration
,
274 Fcurrent_window_configuration (mini_frame
));
276 /* If the minibuffer is on an iconified or invisible frame,
277 make it visible now. */
278 Fmake_frame_visible (mini_frame
);
280 if (minibuffer_auto_raise
)
281 Fraise_frame (mini_frame
);
283 /* We have to do this after saving the window configuration
284 since that is what restores the current buffer. */
286 /* Arrange to restore a number of minibuffer-related variables.
287 We could bind each variable separately, but that would use lots of
290 = Fcons (Voverriding_local_map
,
291 Fcons (minibuf_window
, minibuf_save_list
));
293 = Fcons (minibuf_prompt
,
294 Fcons (make_number (minibuf_prompt_width
),
296 Fcons (Vcurrent_prefix_arg
,
297 Fcons (Vminibuffer_history_position
,
298 Fcons (Vminibuffer_history_variable
,
299 minibuf_save_list
))))));
301 record_unwind_protect (read_minibuf_unwind
, Qnil
);
304 /* Now that we can restore all those variables, start changing them. */
306 minibuf_prompt_width
= 0; /* xdisp.c puts in the right value. */
307 minibuf_prompt
= Fcopy_sequence (prompt
);
308 Vminibuffer_history_position
= histpos
;
309 Vminibuffer_history_variable
= histvar
;
310 Vhelp_form
= Vminibuffer_help_form
;
312 if (inherit_input_method
)
314 /* `current-input-method' is buffer local. So, remeber it in
315 INPUT_METHOD before changing the current buffer. */
316 input_method
= Fsymbol_value (Qcurrent_input_method
);
317 enable_multibyte
= current_buffer
->enable_multibyte_characters
;
320 /* Switch to the minibuffer. */
322 minibuffer
= get_minibuffer (minibuf_level
);
323 Fset_buffer (minibuffer
);
325 /* The current buffer's default directory is usually the right thing
326 for our minibuffer here. However, if you're typing a command at
327 a minibuffer-only frame when minibuf_level is zero, then buf IS
328 the current_buffer, so reset_buffer leaves buf's default
329 directory unchanged. This is a bummer when you've just started
330 up Emacs and buf's default directory is Qnil. Here's a hack; can
331 you think of something better to do? Find another buffer with a
332 better directory, and use that one instead. */
333 if (STRINGP (ambient_dir
))
334 current_buffer
->directory
= ambient_dir
;
337 Lisp_Object buf_list
;
339 for (buf_list
= Vbuffer_alist
;
341 buf_list
= XCONS (buf_list
)->cdr
)
343 Lisp_Object other_buf
;
345 other_buf
= XCONS (XCONS (buf_list
)->car
)->cdr
;
346 if (STRINGP (XBUFFER (other_buf
)->directory
))
348 current_buffer
->directory
= XBUFFER (other_buf
)->directory
;
354 if (XFRAME (mini_frame
) != selected_frame
)
355 Fredirect_frame_focus (Fselected_frame (), mini_frame
);
357 Vminibuf_scroll_window
= selected_window
;
358 Fset_window_buffer (minibuf_window
, Fcurrent_buffer ());
359 Fselect_window (minibuf_window
);
360 XSETFASTINT (XWINDOW (minibuf_window
)->hscroll
, 0);
362 Fmake_local_variable (Qprint_escape_newlines
);
363 print_escape_newlines
= 1;
365 /* Erase the buffer. */
367 int count1
= specpdl_ptr
- specpdl
;
368 specbind (Qinhibit_read_only
, Qt
);
370 unbind_to (count1
, Qnil
);
373 /* Put in the initial input. */
376 Finsert (1, &initial
);
377 if (INTEGERP (backup_n
))
378 Fforward_char (backup_n
);
381 echo_area_glyphs
= 0;
382 /* This is in case the minibuffer-setup-hook calls Fsit_for. */
383 previous_echo_glyphs
= 0;
385 current_buffer
->keymap
= map
;
387 /* Turn on an input method stored in INPUT_METHOD if any. */
388 if (STRINGP (input_method
) && !NILP (Ffboundp (Qactivate_input_method
)))
389 call1 (Qactivate_input_method
, input_method
);
391 /* If appropriate, copy enable-multibyte-characters into the minibuffer. */
392 if (inherit_input_method
)
393 current_buffer
->enable_multibyte_characters
= enable_multibyte
;
395 if (!NILP (current_buffer
->enable_multibyte_characters
)
396 && ! STRING_MULTIBYTE (minibuf_prompt
))
397 minibuf_prompt
= Fstring_make_multibyte (minibuf_prompt
);
399 /* Run our hook, but not if it is empty.
400 (run-hooks would do nothing if it is empty,
401 but it's important to save time here in the usual case). */
402 if (!NILP (Vminibuffer_setup_hook
) && !EQ (Vminibuffer_setup_hook
, Qunbound
)
403 && !NILP (Vrun_hooks
))
404 call1 (Vrun_hooks
, Qminibuffer_setup_hook
);
408 /* If cursor is on the minibuffer line,
409 show the user we have exited by putting it in column 0. */
410 if ((FRAME_CURSOR_Y (selected_frame
)
411 >= XFASTINT (XWINDOW (minibuf_window
)->top
))
414 FRAME_CURSOR_X (selected_frame
)
415 = FRAME_LEFT_SCROLL_BAR_WIDTH (selected_frame
);
416 update_frame (selected_frame
, 1, 1);
419 /* Make minibuffer contents into a string. */
420 Fset_buffer (minibuffer
);
421 val
= make_buffer_string (1, Z
, allow_props
);
423 /* VAL is the string of minibuffer text. */
425 last_minibuf_string
= val
;
427 /* Add the value to the appropriate history list unless it is empty. */
428 if (XSTRING (val
)->size
!= 0
429 && SYMBOLP (Vminibuffer_history_variable
))
431 /* If the caller wanted to save the value read on a history list,
432 then do so if the value is not already the front of the list. */
435 /* If variable is unbound, make it nil. */
436 if (EQ (XSYMBOL (Vminibuffer_history_variable
)->value
, Qunbound
))
437 Fset (Vminibuffer_history_variable
, Qnil
);
439 histval
= Fsymbol_value (Vminibuffer_history_variable
);
441 /* The value of the history variable must be a cons or nil. Other
442 values are unacceptable. We silently ignore these values. */
445 && NILP (Fequal (last_minibuf_string
, Fcar (histval
)))))
449 histval
= Fcons (last_minibuf_string
, histval
);
450 Fset (Vminibuffer_history_variable
, histval
);
452 /* Truncate if requested. */
453 length
= Fget (Vminibuffer_history_variable
, Qhistory_length
);
454 if (NILP (length
)) length
= Vhistory_length
;
455 if (INTEGERP (length
))
457 if (XINT (length
) <= 0)
458 Fset (Vminibuffer_history_variable
, Qnil
);
463 temp
= Fnthcdr (Fsub1 (length
), histval
);
464 if (CONSP (temp
)) Fsetcdr (temp
, Qnil
);
470 /* If Lisp form desired instead of string, parse it. */
473 Lisp_Object expr_and_pos
;
477 if (STRINGP (val
) && XSTRING (val
)->size
== 0
481 expr_and_pos
= Fread_from_string (val
, Qnil
, Qnil
);
482 pos
= XINT (Fcdr (expr_and_pos
));
483 if (pos
!= XSTRING (val
)->size
)
485 /* Ignore trailing whitespace; any other trailing junk is an error. */
487 pos
= string_char_to_byte (val
, pos
);
488 for (i
= pos
; i
< STRING_BYTES (XSTRING (val
)); i
++)
490 int c
= XSTRING (val
)->data
[i
];
491 if (c
!= ' ' && c
!= '\t' && c
!= '\n')
492 error ("Trailing garbage following expression");
495 val
= Fcar (expr_and_pos
);
498 /* The appropriate frame will get selected
499 in set-window-configuration. */
500 RETURN_UNGCPRO (unbind_to (count
, val
));
503 /* Return a buffer to be used as the minibuffer at depth `depth'.
504 depth = 0 is the lowest allowed argument, and that is the value
505 used for nonrecursive minibuffer invocations */
508 get_minibuffer (depth
)
511 Lisp_Object tail
, num
, buf
;
513 extern Lisp_Object
nconc2 ();
515 XSETFASTINT (num
, depth
);
516 tail
= Fnthcdr (num
, Vminibuffer_list
);
519 tail
= Fcons (Qnil
, Qnil
);
520 Vminibuffer_list
= nconc2 (Vminibuffer_list
, tail
);
523 if (NILP (buf
) || NILP (XBUFFER (buf
)->name
))
525 sprintf (name
, " *Minibuf-%d*", depth
);
526 buf
= Fget_buffer_create (build_string (name
));
528 /* Although the buffer's name starts with a space, undo should be
530 Fbuffer_enable_undo (buf
);
532 XCONS (tail
)->car
= buf
;
536 int count
= specpdl_ptr
- specpdl
;
538 reset_buffer (XBUFFER (buf
));
539 record_unwind_protect (Fset_buffer
, Fcurrent_buffer ());
541 Fkill_all_local_variables ();
542 unbind_to (count
, Qnil
);
548 /* This function is called on exiting minibuffer, whether normally or not,
549 and it restores the current window, buffer, etc. */
552 read_minibuf_unwind (data
)
555 Lisp_Object old_deactivate_mark
;
558 /* We are exiting the minibuffer one way or the other,
560 if (!NILP (Vminibuffer_exit_hook
) && !EQ (Vminibuffer_exit_hook
, Qunbound
)
561 && !NILP (Vrun_hooks
))
562 safe_run_hooks (Qminibuffer_exit_hook
);
564 /* If this was a recursive minibuffer,
565 tie the minibuffer window back to the outer level minibuffer buffer. */
568 window
= minibuf_window
;
569 /* To keep things predictable, in case it matters, let's be in the minibuffer
570 when we reset the relevant variables. */
571 Fset_buffer (XWINDOW (window
)->buffer
);
573 /* Restore prompt, etc, from outer minibuffer level. */
574 minibuf_prompt
= Fcar (minibuf_save_list
);
575 minibuf_save_list
= Fcdr (minibuf_save_list
);
576 minibuf_prompt_width
= XFASTINT (Fcar (minibuf_save_list
));
577 minibuf_save_list
= Fcdr (minibuf_save_list
);
578 Vhelp_form
= Fcar (minibuf_save_list
);
579 minibuf_save_list
= Fcdr (minibuf_save_list
);
580 Vcurrent_prefix_arg
= Fcar (minibuf_save_list
);
581 minibuf_save_list
= Fcdr (minibuf_save_list
);
582 Vminibuffer_history_position
= Fcar (minibuf_save_list
);
583 minibuf_save_list
= Fcdr (minibuf_save_list
);
584 Vminibuffer_history_variable
= Fcar (minibuf_save_list
);
585 minibuf_save_list
= Fcdr (minibuf_save_list
);
586 Voverriding_local_map
= Fcar (minibuf_save_list
);
587 minibuf_save_list
= Fcdr (minibuf_save_list
);
589 temp
= Fcar (minibuf_save_list
);
590 if (FRAME_LIVE_P (XFRAME (WINDOW_FRAME (XWINDOW (temp
)))))
591 minibuf_window
= temp
;
593 minibuf_save_list
= Fcdr (minibuf_save_list
);
595 /* Erase the minibuffer we were using at this level. */
597 int count
= specpdl_ptr
- specpdl
;
598 /* Prevent error in erase-buffer. */
599 specbind (Qinhibit_read_only
, Qt
);
600 old_deactivate_mark
= Vdeactivate_mark
;
602 Vdeactivate_mark
= old_deactivate_mark
;
603 unbind_to (count
, Qnil
);
606 /* Make sure minibuffer window is erased, not ignored. */
607 windows_or_buffers_changed
++;
608 XSETFASTINT (XWINDOW (window
)->last_modified
, 0);
609 XSETFASTINT (XWINDOW (window
)->last_overlay_modified
, 0);
615 /* This comment supplies the doc string for read-from-minibuffer,
616 for make-docfile to see. We cannot put this in the real DEFUN
617 due to limits in the Unix cpp.
619 DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 7, 0,
620 "Read a string from the minibuffer, prompting with string PROMPT.\n\
621 If optional second arg INITIAL-CONTENTS is non-nil, it is a string\n\
622 to be inserted into the minibuffer before reading input.\n\
623 If INITIAL-CONTENTS is (STRING . POSITION), the initial input\n\
624 is STRING, but point is placed at position POSITION in the minibuffer.\n\
625 Third arg KEYMAP is a keymap to use whilst reading;\n\
626 if omitted or nil, the default is `minibuffer-local-map'.\n\
627 If fourth arg READ is non-nil, then interpret the result as a lisp object\n\
628 and return that object:\n\
629 in other words, do `(car (read-from-string INPUT-STRING))'\n\
630 Fifth arg HIST, if non-nil, specifies a history list\n\
631 and optionally the initial position in the list.\n\
632 It can be a symbol, which is the history list variable to use,\n\
633 or it can be a cons cell (HISTVAR . HISTPOS).\n\
634 In that case, HISTVAR is the history list variable to use,\n\
635 and HISTPOS is the initial position (the position in the list\n\
636 which INITIAL-CONTENTS corresponds to).\n\
637 Positions are counted starting from 1 at the beginning of the list.\n\
638 Sixth arg DEFAULT-VALUE is the default value. If non-nil, it is available\n\
639 for history commands; but `read-from-minibuffer' does NOT return DEFAULT-VALUE\n\
640 if the user enters empty input! It returns the empty string.\n\
641 Seventh arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits\n\
642 the current input method and the setting of enable-multibyte-characters.\n\
643 If the variable `minibuffer-allow-text-properties' is non-nil,\n\
644 then the string which is returned includes whatever text properties\n\
645 were present in the minibuffer. Otherwise the value has no text properties.")
646 (prompt, initial_contents, keymap, read, hist, default_value, inherit_input_method)
649 DEFUN ("read-from-minibuffer", Fread_from_minibuffer
, Sread_from_minibuffer
, 1, 7, 0,
650 0 /* See immediately above */)
651 (prompt
, initial_contents
, keymap
, read
, hist
, default_value
, inherit_input_method
)
652 Lisp_Object prompt
, initial_contents
, keymap
, read
, hist
, default_value
;
653 Lisp_Object inherit_input_method
;
656 Lisp_Object histvar
, histpos
, position
, val
;
661 CHECK_STRING (prompt
, 0);
662 if (!NILP (initial_contents
))
664 if (CONSP (initial_contents
))
666 position
= Fcdr (initial_contents
);
667 initial_contents
= Fcar (initial_contents
);
669 CHECK_STRING (initial_contents
, 1);
670 if (!NILP (position
))
672 CHECK_NUMBER (position
, 0);
673 /* Convert to distance from end of input. */
674 if (XINT (position
) < 1)
675 /* A number too small means the beginning of the string. */
676 pos
= - XSTRING (initial_contents
)->size
;
678 pos
= XINT (position
) - 1 - XSTRING (initial_contents
)->size
;
683 keymap
= Vminibuffer_local_map
;
685 keymap
= get_keymap (keymap
);
694 histvar
= Fcar_safe (hist
);
695 histpos
= Fcdr_safe (hist
);
698 histvar
= Qminibuffer_history
;
700 XSETFASTINT (histpos
, 0);
702 GCPRO1 (default_value
);
703 val
= read_minibuf (keymap
, initial_contents
, prompt
,
704 make_number (pos
), !NILP (read
),
705 histvar
, histpos
, default_value
,
706 minibuffer_allow_text_properties
,
707 !NILP (inherit_input_method
));
712 DEFUN ("read-minibuffer", Fread_minibuffer
, Sread_minibuffer
, 1, 2, 0,
713 "Return a Lisp object read using the minibuffer.\n\
714 Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS\n\
715 is a string to insert in the minibuffer before reading.")
716 (prompt
, initial_contents
)
717 Lisp_Object prompt
, initial_contents
;
719 CHECK_STRING (prompt
, 0);
720 if (!NILP (initial_contents
))
721 CHECK_STRING (initial_contents
, 1);
722 return read_minibuf (Vminibuffer_local_map
, initial_contents
,
723 prompt
, Qnil
, 1, Qminibuffer_history
,
724 make_number (0), Qnil
, 0, 0);
727 DEFUN ("eval-minibuffer", Feval_minibuffer
, Seval_minibuffer
, 1, 2, 0,
728 "Return value of Lisp expression read using the minibuffer.\n\
729 Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS\n\
730 is a string to insert in the minibuffer before reading.")
731 (prompt
, initial_contents
)
732 Lisp_Object prompt
, initial_contents
;
734 return Feval (Fread_minibuffer (prompt
, initial_contents
));
737 /* Functions that use the minibuffer to read various things. */
739 DEFUN ("read-string", Fread_string
, Sread_string
, 1, 5, 0,
740 "Read a string from the minibuffer, prompting with string PROMPT.\n\
741 If non-nil, second arg INITIAL-INPUT is a string to insert before reading.\n\
742 The third arg HISTORY, if non-nil, specifies a history list\n\
743 and optionally the initial position in the list.\n\
744 See `read-from-minibuffer' for details of HISTORY argument.\n\
745 Fourth arg DEFAULT-VALUE is the default value. If non-nil, it is used\n\
746 for history commands, and as the value to return if the user enters\n\
748 Fifth arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits\n\
749 the current input method and the setting of enable-multibyte-characters.")
750 (prompt
, initial_input
, history
, default_value
, inherit_input_method
)
751 Lisp_Object prompt
, initial_input
, history
, default_value
;
752 Lisp_Object inherit_input_method
;
755 val
= Fread_from_minibuffer (prompt
, initial_input
, Qnil
,
756 Qnil
, history
, default_value
,
757 inherit_input_method
);
758 if (STRINGP (val
) && XSTRING (val
)->size
== 0 && ! NILP (default_value
))
763 DEFUN ("read-no-blanks-input", Fread_no_blanks_input
, Sread_no_blanks_input
, 1, 3, 0,
764 "Read a string from the terminal, not allowing blanks.\n\
765 Prompt with PROMPT, and provide INITIAL as an initial value of the input string.\n\
766 Third arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits\n\
767 the current input method and the setting of enable-multibyte-characters.")
768 (prompt
, initial
, inherit_input_method
)
769 Lisp_Object prompt
, initial
, inherit_input_method
;
771 CHECK_STRING (prompt
, 0);
772 if (! NILP (initial
))
773 CHECK_STRING (initial
, 1);
775 return read_minibuf (Vminibuffer_local_ns_map
, initial
, prompt
, Qnil
,
776 0, Qminibuffer_history
, make_number (0), Qnil
, 0,
777 !NILP (inherit_input_method
));
780 DEFUN ("read-command", Fread_command
, Sread_command
, 1, 2, 0,
781 "Read the name of a command and return as a symbol.\n\
782 Prompts with PROMPT. By default, return DEFAULT-VALUE.")
783 (prompt
, default_value
)
784 Lisp_Object prompt
, default_value
;
786 Lisp_Object name
, default_string
;
788 if (NILP (default_value
))
789 default_string
= Qnil
;
790 else if (SYMBOLP (default_value
))
791 XSETSTRING (default_string
, XSYMBOL (default_value
)->name
);
793 default_string
= default_value
;
795 name
= Fcompleting_read (prompt
, Vobarray
, Qcommandp
, Qt
,
796 Qnil
, Qnil
, default_string
, Qnil
);
799 return Fintern (name
, Qnil
);
803 DEFUN ("read-function", Fread_function
, Sread_function
, 1, 1, 0,
804 "One arg PROMPT, a string. Read the name of a function and return as a symbol.\n\
805 Prompts with PROMPT.")
809 return Fintern (Fcompleting_read (prompt
, Vobarray
, Qfboundp
, Qt
, Qnil
, Qnil
, Qnil
, Qnil
),
814 DEFUN ("read-variable", Fread_variable
, Sread_variable
, 1, 2, 0,
815 "Read the name of a user variable and return it as a symbol.\n\
816 Prompts with PROMPT. By default, return DEFAULT-VALUE.\n\
817 A user variable is one whose documentation starts with a `*' character.")
818 (prompt
, default_value
)
819 Lisp_Object prompt
, default_value
;
821 Lisp_Object name
, default_string
;
823 if (NILP (default_value
))
824 default_string
= Qnil
;
825 else if (SYMBOLP (default_value
))
826 XSETSTRING (default_string
, XSYMBOL (default_value
)->name
);
828 default_string
= default_value
;
830 name
= Fcompleting_read (prompt
, Vobarray
,
831 Quser_variable_p
, Qt
,
832 Qnil
, Qnil
, default_string
, Qnil
);
835 return Fintern (name
, Qnil
);
838 DEFUN ("read-buffer", Fread_buffer
, Sread_buffer
, 1, 3, 0,
839 "One arg PROMPT, a string. Read the name of a buffer and return as a string.\n\
840 Prompts with PROMPT.\n\
841 Optional second arg DEF is value to return if user enters an empty line.\n\
842 If optional third arg REQUIRE-MATCH is non-nil, only existing buffer names are allowed.")
843 (prompt
, def
, require_match
)
844 Lisp_Object prompt
, def
, require_match
;
850 def
= XBUFFER (def
)->name
;
852 if (NILP (Vread_buffer_function
))
856 args
[0] = build_string ("%s(default %s) ");
859 prompt
= Fformat (3, args
);
862 return Fcompleting_read (prompt
, Vbuffer_alist
, Qnil
,
863 require_match
, Qnil
, Qbuffer_name_history
,
868 args
[0] = Vread_buffer_function
;
871 args
[3] = require_match
;
872 return Ffuncall(4, args
);
877 minibuf_conform_representation (string
, basis
)
878 Lisp_Object string
, basis
;
880 if (STRING_MULTIBYTE (string
) == STRING_MULTIBYTE (basis
))
883 if (STRING_MULTIBYTE (string
))
884 return Fstring_make_unibyte (string
);
886 return Fstring_make_multibyte (string
);
889 DEFUN ("try-completion", Ftry_completion
, Stry_completion
, 2, 3, 0,
890 "Return common substring of all completions of STRING in ALIST.\n\
891 Each car of each element of ALIST is tested to see if it begins with STRING.\n\
892 All that match are compared together; the longest initial sequence\n\
893 common to all matches is returned as a string.\n\
894 If there is no match at all, nil is returned.\n\
895 For an exact match, t is returned.\n\
897 ALIST can be an obarray instead of an alist.\n\
898 Then the print names of all symbols in the obarray are the possible matches.\n\
900 ALIST can also be a function to do the completion itself.\n\
901 It receives three arguments: the values STRING, PREDICATE and nil.\n\
902 Whatever it returns becomes the value of `try-completion'.\n\
904 If optional third argument PREDICATE is non-nil,\n\
905 it is used to test each possible match.\n\
906 The match is a candidate only if PREDICATE returns non-nil.\n\
907 The argument given to PREDICATE is the alist element\n\
908 or the symbol from the obarray.")
909 (string
, alist
, predicate
)
910 Lisp_Object string
, alist
, predicate
;
912 Lisp_Object bestmatch
, tail
, elt
, eltstring
;
913 /* Size in bytes of BESTMATCH. */
915 /* These are in bytes, too. */
916 int compare
, matchsize
;
917 int list
= CONSP (alist
) || NILP (alist
);
920 Lisp_Object bucket
, zero
, end
, tem
;
921 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
;
923 CHECK_STRING (string
, 0);
924 if (!list
&& !VECTORP (alist
))
925 return call3 (alist
, string
, predicate
, Qnil
);
929 /* If ALIST is not a list, set TAIL just for gc pro. */
934 obsize
= XVECTOR (alist
)->size
;
935 bucket
= XVECTOR (alist
)->contents
[index
];
940 /* Get the next element of the alist or obarray. */
941 /* Exit the loop if the elements are all used up. */
942 /* elt gets the alist element or symbol.
943 eltstring gets the name to check as a completion. */
950 eltstring
= Fcar (elt
);
955 if (XFASTINT (bucket
) != 0)
958 eltstring
= Fsymbol_name (elt
);
959 if (XSYMBOL (bucket
)->next
)
960 XSETSYMBOL (bucket
, XSYMBOL (bucket
)->next
);
962 XSETFASTINT (bucket
, 0);
964 else if (++index
>= obsize
)
968 bucket
= XVECTOR (alist
)->contents
[index
];
973 /* Is this element a possible completion? */
975 if (STRINGP (eltstring
)
976 && XSTRING (string
)->size
<= XSTRING (eltstring
)->size
977 && (tem
= Fcompare_strings (eltstring
, make_number (0),
978 make_number (XSTRING (string
)->size
),
979 string
, make_number (0), Qnil
,
980 completion_ignore_case
?Qt
: Qnil
),
986 XSETFASTINT (zero
, 0);
988 /* Ignore this element if it fails to match all the regexps. */
989 for (regexps
= Vcompletion_regexp_list
; CONSP (regexps
);
990 regexps
= XCONS (regexps
)->cdr
)
992 tem
= Fstring_match (XCONS (regexps
)->car
, eltstring
, zero
);
999 /* Ignore this element if there is a predicate
1000 and the predicate doesn't like it. */
1002 if (!NILP (predicate
))
1004 if (EQ (predicate
, Qcommandp
))
1005 tem
= Fcommandp (elt
);
1008 GCPRO4 (tail
, string
, eltstring
, bestmatch
);
1009 tem
= call1 (predicate
, elt
);
1012 if (NILP (tem
)) continue;
1015 /* Update computation of how much all possible completions match */
1018 if (NILP (bestmatch
))
1020 bestmatch
= eltstring
;
1021 bestmatchsize
= XSTRING (eltstring
)->size
;
1025 compare
= min (bestmatchsize
, XSTRING (eltstring
)->size
);
1026 tem
= Fcompare_strings (bestmatch
, make_number (0),
1027 make_number (compare
),
1028 eltstring
, make_number (0),
1029 make_number (compare
),
1030 completion_ignore_case
? Qt
: Qnil
);
1032 matchsize
= compare
;
1033 else if (XINT (tem
) < 0)
1034 matchsize
= - XINT (tem
) - 1;
1036 matchsize
= XINT (tem
) - 1;
1039 matchsize
= compare
;
1040 if (completion_ignore_case
)
1042 /* If this is an exact match except for case,
1043 use it as the best match rather than one that is not an
1044 exact match. This way, we get the case pattern
1045 of the actual match. */
1046 if ((matchsize
== XSTRING (eltstring
)->size
1047 && matchsize
< XSTRING (bestmatch
)->size
)
1049 /* If there is more than one exact match ignoring case,
1050 and one of them is exact including case,
1052 /* If there is no exact match ignoring case,
1053 prefer a match that does not change the case
1055 ((matchsize
== XSTRING (eltstring
)->size
)
1057 (matchsize
== XSTRING (bestmatch
)->size
)
1058 && (tem
= Fcompare_strings (eltstring
, make_number (0),
1059 make_number (XSTRING (string
)->size
),
1060 string
, make_number (0),
1064 && (tem
= Fcompare_strings (bestmatch
, make_number (0),
1065 make_number (XSTRING (string
)->size
),
1066 string
, make_number (0),
1070 bestmatch
= eltstring
;
1072 bestmatchsize
= matchsize
;
1077 if (NILP (bestmatch
))
1078 return Qnil
; /* No completions found */
1079 /* If we are ignoring case, and there is no exact match,
1080 and no additional text was supplied,
1081 don't change the case of what the user typed. */
1082 if (completion_ignore_case
&& bestmatchsize
== XSTRING (string
)->size
1083 && XSTRING (bestmatch
)->size
> bestmatchsize
)
1084 return minibuf_conform_representation (string
, bestmatch
);
1086 /* Return t if the supplied string is an exact match (counting case);
1087 it does not require any change to be made. */
1088 if (matchcount
== 1 && bestmatchsize
== XSTRING (string
)->size
1089 && (tem
= Fcompare_strings (bestmatch
, make_number (0),
1090 make_number (bestmatchsize
),
1091 string
, make_number (0),
1092 make_number (bestmatchsize
),
1097 XSETFASTINT (zero
, 0); /* Else extract the part in which */
1098 XSETFASTINT (end
, bestmatchsize
); /* all completions agree */
1099 return Fsubstring (bestmatch
, zero
, end
);
1102 /* Compare exactly LEN chars of strings at S1 and S2,
1103 ignoring case if appropriate.
1104 Return -1 if strings match,
1105 else number of chars that match at the beginning. */
1109 register unsigned char *s1
, *s2
;
1112 register int l
= len
;
1113 register unsigned char *start
= s1
;
1115 if (completion_ignore_case
)
1117 while (l
&& DOWNCASE (*s1
++) == DOWNCASE (*s2
++))
1122 while (l
&& *s1
++ == *s2
++)
1129 int match
= len
- l
;
1131 /* Now *--S1 is the unmatching byte. If it is in the middle of
1132 multi-byte form, we must say that the multi-byte character
1133 there doesn't match. */
1134 while (match
&& *--s1
>= 0xA0) match
--;
1139 DEFUN ("all-completions", Fall_completions
, Sall_completions
, 2, 4, 0,
1140 "Search for partial matches to STRING in ALIST.\n\
1141 Each car of each element of ALIST is tested to see if it begins with STRING.\n\
1142 The value is a list of all the strings from ALIST that match.\n\
1144 ALIST can be an obarray instead of an alist.\n\
1145 Then the print names of all symbols in the obarray are the possible matches.\n\
1147 ALIST can also be a function to do the completion itself.\n\
1148 It receives three arguments: the values STRING, PREDICATE and t.\n\
1149 Whatever it returns becomes the value of `all-completion'.\n\
1151 If optional third argument PREDICATE is non-nil,\n\
1152 it is used to test each possible match.\n\
1153 The match is a candidate only if PREDICATE returns non-nil.\n\
1154 The argument given to PREDICATE is the alist element\n\
1155 or the symbol from the obarray.\n\
1157 If the optional fourth argument HIDE-SPACES is non-nil,\n\
1158 strings in ALIST that start with a space\n\
1159 are ignored unless STRING itself starts with a space.")
1160 (string
, alist
, predicate
, hide_spaces
)
1161 Lisp_Object string
, alist
, predicate
, hide_spaces
;
1163 Lisp_Object tail
, elt
, eltstring
;
1164 Lisp_Object allmatches
;
1165 int list
= CONSP (alist
) || NILP (alist
);
1167 Lisp_Object bucket
, tem
;
1168 struct gcpro gcpro1
, gcpro2
, gcpro3
, gcpro4
;
1170 CHECK_STRING (string
, 0);
1171 if (!list
&& !VECTORP (alist
))
1173 return call3 (alist
, string
, predicate
, Qt
);
1177 /* If ALIST is not a list, set TAIL just for gc pro. */
1182 obsize
= XVECTOR (alist
)->size
;
1183 bucket
= XVECTOR (alist
)->contents
[index
];
1188 /* Get the next element of the alist or obarray. */
1189 /* Exit the loop if the elements are all used up. */
1190 /* elt gets the alist element or symbol.
1191 eltstring gets the name to check as a completion. */
1198 eltstring
= Fcar (elt
);
1203 if (XFASTINT (bucket
) != 0)
1206 eltstring
= Fsymbol_name (elt
);
1207 if (XSYMBOL (bucket
)->next
)
1208 XSETSYMBOL (bucket
, XSYMBOL (bucket
)->next
);
1210 XSETFASTINT (bucket
, 0);
1212 else if (++index
>= obsize
)
1216 bucket
= XVECTOR (alist
)->contents
[index
];
1221 /* Is this element a possible completion? */
1223 if (STRINGP (eltstring
)
1224 && XSTRING (string
)->size
<= XSTRING (eltstring
)->size
1225 /* If HIDE_SPACES, reject alternatives that start with space
1226 unless the input starts with space. */
1227 && ((STRING_BYTES (XSTRING (string
)) > 0
1228 && XSTRING (string
)->data
[0] == ' ')
1229 || XSTRING (eltstring
)->data
[0] != ' '
1230 || NILP (hide_spaces
))
1231 && (tem
= Fcompare_strings (eltstring
, make_number (0),
1232 make_number (XSTRING (string
)->size
),
1233 string
, make_number (0),
1234 make_number (XSTRING (string
)->size
),
1235 completion_ignore_case
? Qt
: Qnil
),
1239 Lisp_Object regexps
;
1241 XSETFASTINT (zero
, 0);
1243 /* Ignore this element if it fails to match all the regexps. */
1244 for (regexps
= Vcompletion_regexp_list
; CONSP (regexps
);
1245 regexps
= XCONS (regexps
)->cdr
)
1247 tem
= Fstring_match (XCONS (regexps
)->car
, eltstring
, zero
);
1251 if (CONSP (regexps
))
1254 /* Ignore this element if there is a predicate
1255 and the predicate doesn't like it. */
1257 if (!NILP (predicate
))
1259 if (EQ (predicate
, Qcommandp
))
1260 tem
= Fcommandp (elt
);
1263 GCPRO4 (tail
, eltstring
, allmatches
, string
);
1264 tem
= call1 (predicate
, elt
);
1267 if (NILP (tem
)) continue;
1269 /* Ok => put it on the list. */
1270 allmatches
= Fcons (eltstring
, allmatches
);
1274 return Fnreverse (allmatches
);
1277 Lisp_Object Vminibuffer_completion_table
, Qminibuffer_completion_table
;
1278 Lisp_Object Vminibuffer_completion_predicate
, Qminibuffer_completion_predicate
;
1279 Lisp_Object Vminibuffer_completion_confirm
, Qminibuffer_completion_confirm
;
1280 Lisp_Object Vminibuffer_completing_file_name
;
1282 /* This comment supplies the doc string for completing-read,
1283 for make-docfile to see. We cannot put this in the real DEFUN
1284 due to limits in the Unix cpp.
1286 DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0,
1287 "Read a string in the minibuffer, with completion.\n\
1288 PROMPT is a string to prompt with; normally it ends in a colon and a space.\n\
1289 TABLE is an alist whose elements' cars are strings, or an obarray.\n\
1290 PREDICATE limits completion to a subset of TABLE.\n\
1291 See `try-completion' and `all-completions' for more details\n\
1292 on completion, TABLE, and PREDICATE.\n\
1294 If REQUIRE-MATCH is non-nil, the user is not allowed to exit unless\n\
1295 the input is (or completes to) an element of TABLE or is null.\n\
1296 If it is also not t, Return does not exit if it does non-null completion.\n\
1297 If the input is null, `completing-read' returns an empty string,\n\
1298 regardless of the value of REQUIRE-MATCH.\n\
1300 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.\n\
1301 If it is (STRING . POSITION), the initial input\n\
1302 is STRING, but point is placed POSITION characters into the string.\n\
1303 HIST, if non-nil, specifies a history list\n\
1304 and optionally the initial position in the list.\n\
1305 It can be a symbol, which is the history list variable to use,\n\
1306 or it can be a cons cell (HISTVAR . HISTPOS).\n\
1307 In that case, HISTVAR is the history list variable to use,\n\
1308 and HISTPOS is the initial position (the position in the list\n\
1309 which INITIAL-INPUT corresponds to).\n\
1310 Positions are counted starting from 1 at the beginning of the list.\n\
1311 DEF, if non-nil, is the default value.\n\
1313 If INHERIT-INPUT-METHOD is non-nil, the minibuffer inherits\n\
1314 the current input method and the setting of enable-multibyte-characters.\n\
1316 Completion ignores case if the ambient value of\n\
1317 `completion-ignore-case' is non-nil."
1319 DEFUN ("completing-read", Fcompleting_read
, Scompleting_read
, 2, 8, 0,
1320 0 /* See immediately above */)
1321 (prompt
, table
, predicate
, require_match
, init
, hist
, def
, inherit_input_method
)
1322 Lisp_Object prompt
, table
, predicate
, require_match
, init
, hist
, def
;
1323 Lisp_Object inherit_input_method
;
1325 Lisp_Object val
, histvar
, histpos
, position
;
1327 int count
= specpdl_ptr
- specpdl
;
1328 struct gcpro gcpro1
;
1329 int disable_multibyte
= ! NILP (Vminibuffer_completing_file_name
);
1333 specbind (Qminibuffer_completion_table
, table
);
1334 specbind (Qminibuffer_completion_predicate
, predicate
);
1335 specbind (Qminibuffer_completion_confirm
,
1336 EQ (require_match
, Qt
) ? Qnil
: Qt
);
1337 last_exact_completion
= Qnil
;
1344 position
= Fcdr (init
);
1347 CHECK_STRING (init
, 0);
1348 if (!NILP (position
))
1350 CHECK_NUMBER (position
, 0);
1351 /* Convert to distance from end of input. */
1352 pos
= XINT (position
) - XSTRING (init
)->size
;
1363 histvar
= Fcar_safe (hist
);
1364 histpos
= Fcdr_safe (hist
);
1367 histvar
= Qminibuffer_history
;
1369 XSETFASTINT (histpos
, 0);
1371 val
= read_minibuf (NILP (require_match
)
1372 ? Vminibuffer_local_completion_map
1373 : Vminibuffer_local_must_match_map
,
1374 init
, prompt
, make_number (pos
), 0,
1375 histvar
, histpos
, def
, 0,
1376 !NILP (inherit_input_method
));
1378 if (STRINGP (val
) && XSTRING (val
)->size
== 0 && ! NILP (def
))
1381 RETURN_UNGCPRO (unbind_to (count
, val
));
1384 Lisp_Object
Fminibuffer_completion_help ();
1385 Lisp_Object
assoc_for_completion ();
1387 /* Test whether TXT is an exact completion. */
1389 test_completion (txt
)
1394 if (CONSP (Vminibuffer_completion_table
)
1395 || NILP (Vminibuffer_completion_table
))
1396 return assoc_for_completion (txt
, Vminibuffer_completion_table
);
1397 else if (VECTORP (Vminibuffer_completion_table
))
1399 /* Bypass intern-soft as that loses for nil */
1400 tem
= oblookup (Vminibuffer_completion_table
,
1401 XSTRING (txt
)->data
,
1402 XSTRING (txt
)->size
,
1403 STRING_BYTES (XSTRING (txt
)));
1406 if (STRING_MULTIBYTE (txt
))
1407 txt
= Fstring_make_unibyte (txt
);
1409 txt
= Fstring_make_multibyte (txt
);
1411 tem
= oblookup (Vminibuffer_completion_table
,
1412 XSTRING (txt
)->data
,
1413 XSTRING (txt
)->size
,
1414 STRING_BYTES (XSTRING (txt
)));
1418 if (!NILP (Vminibuffer_completion_predicate
))
1419 return call1 (Vminibuffer_completion_predicate
, tem
);
1424 return call3 (Vminibuffer_completion_table
, txt
,
1425 Vminibuffer_completion_predicate
, Qlambda
);
1429 * 0 no possible completion
1430 * 1 was already an exact and unique completion
1431 * 3 was already an exact completion
1432 * 4 completed to an exact completion
1433 * 5 some completion happened
1434 * 6 no completion happened
1439 Lisp_Object completion
, tem
;
1442 struct gcpro gcpro1
, gcpro2
;
1444 completion
= Ftry_completion (Fbuffer_string (), Vminibuffer_completion_table
,
1445 Vminibuffer_completion_predicate
);
1446 last
= last_exact_completion
;
1447 last_exact_completion
= Qnil
;
1449 GCPRO2 (completion
, last
);
1451 if (NILP (completion
))
1454 temp_echo_area_glyphs (" [No match]");
1459 if (EQ (completion
, Qt
)) /* exact and unique match */
1466 tem
= Fstring_equal (completion
, Fbuffer_string());
1467 if (completedp
= NILP (tem
))
1469 Ferase_buffer (); /* Some completion happened */
1470 Finsert (1, &completion
);
1473 /* It did find a match. Do we match some possibility exactly now? */
1474 tem
= test_completion (Fbuffer_string ());
1477 /* not an exact match */
1482 Fminibuffer_completion_help ();
1484 temp_echo_area_glyphs (" [Next char not unique]");
1487 else if (completedp
)
1492 /* If the last exact completion and this one were the same,
1493 it means we've already given a "Complete but not unique"
1494 message and the user's hit TAB again, so now we give him help. */
1495 last_exact_completion
= completion
;
1498 tem
= Fbuffer_string ();
1499 if (!NILP (Fequal (tem
, last
)))
1500 Fminibuffer_completion_help ();
1506 /* Like assoc but assumes KEY is a string, and ignores case if appropriate. */
1509 assoc_for_completion (key
, list
)
1510 register Lisp_Object key
;
1513 register Lisp_Object tail
;
1515 for (tail
= list
; !NILP (tail
); tail
= Fcdr (tail
))
1517 register Lisp_Object elt
, tem
, thiscar
;
1519 if (!CONSP (elt
)) continue;
1520 thiscar
= Fcar (elt
);
1521 if (!STRINGP (thiscar
))
1523 tem
= Fcompare_strings (thiscar
, make_number (0), Qnil
,
1524 key
, make_number (0), Qnil
,
1525 completion_ignore_case
? Qt
: Qnil
);
1533 DEFUN ("minibuffer-complete", Fminibuffer_complete
, Sminibuffer_complete
, 0, 0, "",
1534 "Complete the minibuffer contents as far as possible.\n\
1535 Return nil if there is no valid completion, else t.\n\
1536 If no characters can be completed, display a list of possible completions.\n\
1537 If you repeat this command after it displayed such a list,\n\
1538 scroll the window of possible completions.")
1542 Lisp_Object window
, tem
;
1544 /* If the previous command was not this,
1545 mark the completion buffer obsolete. */
1546 if (! EQ (current_kboard
->Vlast_command
, Vthis_command
))
1547 Vminibuf_scroll_window
= Qnil
;
1549 window
= Vminibuf_scroll_window
;
1550 /* If there's a fresh completion window with a live buffer,
1551 and this command is repeated, scroll that window. */
1552 if (! NILP (window
) && ! NILP (XWINDOW (window
)->buffer
)
1553 && !NILP (XBUFFER (XWINDOW (window
)->buffer
)->name
))
1555 struct buffer
*obuf
= current_buffer
;
1557 Fset_buffer (XWINDOW (window
)->buffer
);
1558 tem
= Fpos_visible_in_window_p (make_number (ZV
), window
);
1560 /* If end is in view, scroll up to the beginning. */
1561 Fset_window_start (window
, make_number (BEGV
), Qnil
);
1563 /* Else scroll down one screen. */
1564 Fscroll_other_window (Qnil
);
1566 set_buffer_internal (obuf
);
1570 i
= do_completion ();
1577 temp_echo_area_glyphs (" [Sole completion]");
1581 temp_echo_area_glyphs (" [Complete, but not unique]");
1588 /* Subroutines of Fminibuffer_complete_and_exit. */
1590 /* This one is called by internal_condition_case to do the real work. */
1593 complete_and_exit_1 ()
1595 return make_number (do_completion ());
1598 /* This one is called by internal_condition_case if an error happens.
1599 Pretend the current value is an exact match. */
1602 complete_and_exit_2 (ignore
)
1605 return make_number (1);
1608 DEFUN ("minibuffer-complete-and-exit", Fminibuffer_complete_and_exit
,
1609 Sminibuffer_complete_and_exit
, 0, 0, "",
1610 "If the minibuffer contents is a valid completion then exit.\n\
1611 Otherwise try to complete it. If completion leads to a valid completion,\n\
1612 a repetition of this command will exit.")
1618 /* Allow user to specify null string */
1622 if (!NILP (test_completion (Fbuffer_string ())))
1625 /* Call do_completion, but ignore errors. */
1626 val
= internal_condition_case (complete_and_exit_1
, Qerror
,
1627 complete_and_exit_2
);
1637 if (!NILP (Vminibuffer_completion_confirm
))
1639 temp_echo_area_glyphs (" [Confirm]");
1649 Fthrow (Qexit
, Qnil
);
1653 DEFUN ("minibuffer-complete-word", Fminibuffer_complete_word
, Sminibuffer_complete_word
,
1655 "Complete the minibuffer contents at most a single word.\n\
1656 After one word is completed as much as possible, a space or hyphen\n\
1657 is added, provided that matches some possible completion.\n\
1658 Return nil if there is no valid completion, else t.")
1661 Lisp_Object completion
, tem
, tem1
;
1662 register int i
, i_byte
;
1663 register unsigned char *completion_string
;
1664 struct gcpro gcpro1
, gcpro2
;
1666 /* We keep calling Fbuffer_string rather than arrange for GC to
1667 hold onto a pointer to one of the strings thus made. */
1669 completion
= Ftry_completion (Fbuffer_string (),
1670 Vminibuffer_completion_table
,
1671 Vminibuffer_completion_predicate
);
1672 if (NILP (completion
))
1675 temp_echo_area_glyphs (" [No match]");
1678 if (EQ (completion
, Qt
))
1681 #if 0 /* How the below code used to look, for reference. */
1682 tem
= Fbuffer_string ();
1683 b
= XSTRING (tem
)->data
;
1684 i
= ZV
- 1 - XSTRING (completion
)->size
;
1685 p
= XSTRING (completion
)->data
;
1687 0 <= scmp (b
, p
, ZV
- 1))
1690 /* Set buffer to longest match of buffer tail and completion head. */
1691 while (0 <= scmp (b
+ i
, p
, ZV
- 1 - i
))
1693 del_range (1, i
+ 1);
1696 #else /* Rewritten code */
1698 int buffer_nchars
, completion_nchars
;
1700 CHECK_STRING (completion
, 0);
1701 tem
= Fbuffer_string ();
1702 GCPRO2 (completion
, tem
);
1703 /* If reading a file name,
1704 expand any $ENVVAR refs in the buffer and in TEM. */
1705 if (! NILP (Vminibuffer_completing_file_name
))
1707 Lisp_Object substituted
;
1708 substituted
= Fsubstitute_in_file_name (tem
);
1709 if (! EQ (substituted
, tem
))
1713 insert_from_string (tem
, 0, 0, XSTRING (tem
)->size
,
1714 STRING_BYTES (XSTRING (tem
)), 0);
1717 buffer_nchars
= XSTRING (tem
)->size
; /* ie ZV - BEGV */
1718 completion_nchars
= XSTRING (completion
)->size
;
1719 i
= buffer_nchars
- completion_nchars
;
1722 (tem1
= Fcompare_strings (tem
, make_number (0),
1723 make_number (buffer_nchars
),
1724 completion
, make_number (0),
1725 make_number (buffer_nchars
),
1726 completion_ignore_case
? Qt
: Qnil
),
1731 /* Set buffer to longest match of buffer tail and completion head. */
1737 tem1
= Fcompare_strings (tem
, make_number (start_pos
), Qnil
,
1738 completion
, make_number (0),
1739 make_number (buffer_nchars
),
1740 completion_ignore_case
? Qt
: Qnil
);
1747 del_range (1, i
+ 1);
1748 SET_PT_BOTH (ZV
, ZV_BYTE
);
1752 #endif /* Rewritten code */
1753 i_byte
= ZV_BYTE
- BEGV_BYTE
;
1756 /* If completion finds next char not unique,
1757 consider adding a space or a hyphen. */
1758 if (i
== XSTRING (completion
)->size
)
1760 GCPRO1 (completion
);
1761 tem
= Ftry_completion (concat2 (Fbuffer_string (), build_string (" ")),
1762 Vminibuffer_completion_table
,
1763 Vminibuffer_completion_predicate
);
1770 GCPRO1 (completion
);
1772 Ftry_completion (concat2 (Fbuffer_string (), build_string ("-")),
1773 Vminibuffer_completion_table
,
1774 Vminibuffer_completion_predicate
);
1782 /* Now find first word-break in the stuff found by completion.
1783 i gets index in string of where to stop completing. */
1787 completion_string
= XSTRING (completion
)->data
;
1788 for (; i_byte
< STRING_BYTES (XSTRING (completion
)); i_byte
+= len
, i
++)
1790 c
= STRING_CHAR_AND_LENGTH (completion_string
+ i_byte
,
1791 XSTRING (completion
)->size
- i_byte
,
1793 if (SYNTAX (c
) != Sword
)
1802 /* If got no characters, print help for user. */
1804 if (i_byte
== ZV_BYTE
- BEGV_BYTE
)
1807 Fminibuffer_completion_help ();
1811 /* Otherwise insert in minibuffer the chars we got */
1814 insert_from_string (completion
, 0, 0, i
, i_byte
, 1);
1818 DEFUN ("display-completion-list", Fdisplay_completion_list
, Sdisplay_completion_list
,
1820 "Display the list of completions, COMPLETIONS, using `standard-output'.\n\
1821 Each element may be just a symbol or string\n\
1822 or may be a list of two strings to be printed as if concatenated.\n\
1823 `standard-output' must be a buffer.\n\
1824 The actual completion alternatives, as inserted, are given `mouse-face'\n\
1825 properties of `highlight'.\n\
1826 At the end, this runs the normal hook `completion-setup-hook'.\n\
1827 It can find the completion buffer in `standard-output'.")
1829 Lisp_Object completions
;
1831 Lisp_Object tail
, elt
;
1834 struct gcpro gcpro1
, gcpro2
;
1835 struct buffer
*old
= current_buffer
;
1838 /* Note that (when it matters) every variable
1839 points to a non-string that is pointed to by COMPLETIONS,
1840 except for ELT. ELT can be pointing to a string
1841 when terpri or Findent_to calls a change hook. */
1843 GCPRO2 (completions
, elt
);
1845 if (BUFFERP (Vstandard_output
))
1846 set_buffer_internal (XBUFFER (Vstandard_output
));
1848 if (NILP (completions
))
1849 write_string ("There are no possible completions of what you have typed.",
1853 write_string ("Possible completions are:", -1);
1854 for (tail
= completions
, i
= 0; !NILP (tail
); tail
= Fcdr (tail
), i
++)
1856 Lisp_Object tem
, string
;
1858 Lisp_Object startpos
, endpos
;
1861 /* Compute the length of this element. */
1865 CHECK_STRING (tem
, 0);
1866 length
= XSTRING (tem
)->size
;
1868 tem
= Fcar (XCDR (elt
));
1869 CHECK_STRING (tem
, 0);
1870 length
+= XSTRING (tem
)->size
;
1874 CHECK_STRING (elt
, 0);
1875 length
= XSTRING (elt
)->size
;
1878 /* This does a bad job for narrower than usual windows.
1879 Sadly, the window it will appear in is not known
1880 until after the text has been made. */
1882 if (BUFFERP (Vstandard_output
))
1883 XSETINT (startpos
, BUF_PT (XBUFFER (Vstandard_output
)));
1885 /* If the previous completion was very wide,
1886 or we have two on this line already,
1887 don't put another on the same line. */
1888 if (column
> 33 || first
1889 /* If this is really wide, don't put it second on a line. */
1890 || column
> 0 && length
> 45)
1895 /* Otherwise advance to column 35. */
1898 if (BUFFERP (Vstandard_output
))
1900 tem
= Findent_to (make_number (35), make_number (2));
1902 column
= XINT (tem
);
1908 write_string (" ", -1);
1911 while (column
< 35);
1915 if (BUFFERP (Vstandard_output
))
1917 XSETINT (endpos
, BUF_PT (XBUFFER (Vstandard_output
)));
1918 Fset_text_properties (startpos
, endpos
,
1919 Qnil
, Vstandard_output
);
1922 /* Output this element.
1923 If necessary, convert it to unibyte or to multibyte first. */
1925 string
= Fcar (elt
);
1928 if (NILP (current_buffer
->enable_multibyte_characters
)
1929 && STRING_MULTIBYTE (string
))
1930 string
= Fstring_make_unibyte (string
);
1931 else if (!NILP (current_buffer
->enable_multibyte_characters
)
1932 && !STRING_MULTIBYTE (string
))
1933 string
= Fstring_make_multibyte (string
);
1935 if (BUFFERP (Vstandard_output
))
1937 XSETINT (startpos
, BUF_PT (XBUFFER (Vstandard_output
)));
1939 Fprinc (string
, Qnil
);
1941 XSETINT (endpos
, BUF_PT (XBUFFER (Vstandard_output
)));
1943 Fput_text_property (startpos
, endpos
,
1944 Qmouse_face
, intern ("highlight"),
1949 Fprinc (string
, Qnil
);
1952 /* Output the annotation for this element. */
1955 if (BUFFERP (Vstandard_output
))
1957 XSETINT (startpos
, BUF_PT (XBUFFER (Vstandard_output
)));
1959 Fprinc (Fcar (Fcdr (elt
)), Qnil
);
1961 XSETINT (endpos
, BUF_PT (XBUFFER (Vstandard_output
)));
1963 Fset_text_properties (startpos
, endpos
, Qnil
,
1968 Fprinc (Fcar (Fcdr (elt
)), Qnil
);
1973 /* Update COLUMN for what we have output. */
1976 /* If output is to a buffer, recompute COLUMN in a way
1977 that takes account of character widths. */
1978 if (BUFFERP (Vstandard_output
))
1980 tem
= Fcurrent_column ();
1981 column
= XINT (tem
);
1990 if (BUFFERP (Vstandard_output
))
1991 set_buffer_internal (old
);
1993 if (!NILP (Vrun_hooks
))
1994 call1 (Vrun_hooks
, intern ("completion-setup-hook"));
1999 DEFUN ("minibuffer-completion-help", Fminibuffer_completion_help
, Sminibuffer_completion_help
,
2001 "Display a list of possible completions of the current minibuffer contents.")
2004 Lisp_Object completions
;
2006 message ("Making completion list...");
2007 completions
= Fall_completions (Fbuffer_string (),
2008 Vminibuffer_completion_table
,
2009 Vminibuffer_completion_predicate
,
2011 echo_area_glyphs
= 0;
2013 if (NILP (completions
))
2016 temp_echo_area_glyphs (" [No completions]");
2019 internal_with_output_to_temp_buffer ("*Completions*",
2020 Fdisplay_completion_list
,
2021 Fsort (completions
, Qstring_lessp
));
2025 DEFUN ("self-insert-and-exit", Fself_insert_and_exit
, Sself_insert_and_exit
, 0, 0, "",
2026 "Terminate minibuffer input.")
2029 if (INTEGERP (last_command_char
))
2030 internal_self_insert (XINT (last_command_char
), 0);
2034 Fthrow (Qexit
, Qnil
);
2037 DEFUN ("exit-minibuffer", Fexit_minibuffer
, Sexit_minibuffer
, 0, 0, "",
2038 "Terminate this minibuffer argument.")
2041 Fthrow (Qexit
, Qnil
);
2044 DEFUN ("minibuffer-depth", Fminibuffer_depth
, Sminibuffer_depth
, 0, 0, 0,
2045 "Return current depth of activations of minibuffer, a nonnegative integer.")
2048 return make_number (minibuf_level
);
2051 DEFUN ("minibuffer-prompt", Fminibuffer_prompt
, Sminibuffer_prompt
, 0, 0, 0,
2052 "Return the prompt string of the currently-active minibuffer.\n\
2053 If no minibuffer is active, return nil.")
2056 return Fcopy_sequence (minibuf_prompt
);
2059 DEFUN ("minibuffer-prompt-width", Fminibuffer_prompt_width
,
2060 Sminibuffer_prompt_width
, 0, 0, 0,
2061 "Return the display width of the minibuffer prompt.")
2065 XSETFASTINT (width
, minibuf_prompt_width
);
2069 /* Temporarily display the string M at the end of the current
2070 minibuffer contents. This is used to display things like
2071 "[No Match]" when the user requests a completion for a prefix
2072 that has no possible completions, and other quick, unobtrusive
2076 temp_echo_area_glyphs (m
)
2080 int osize_byte
= ZV_BYTE
;
2082 int opoint_byte
= PT_BYTE
;
2083 Lisp_Object oinhibit
;
2084 oinhibit
= Vinhibit_quit
;
2086 /* Clear out any old echo-area message to make way for our new thing. */
2089 SET_PT_BOTH (osize
, osize_byte
);
2091 SET_PT_BOTH (opoint
, opoint_byte
);
2093 Fsit_for (make_number (2), Qnil
, Qnil
);
2094 del_range_both (osize
, osize_byte
, ZV
, ZV_BYTE
, 1);
2095 SET_PT_BOTH (opoint
, opoint_byte
);
2096 if (!NILP (Vquit_flag
))
2099 Vunread_command_events
= Fcons (make_number (quit_char
), Qnil
);
2101 Vinhibit_quit
= oinhibit
;
2104 DEFUN ("minibuffer-message", Fminibuffer_message
, Sminibuffer_message
,
2106 "Temporarily display STRING at the end of the minibuffer.\n\
2107 The text is displayed for two seconds,\n\
2108 or until the next input event arrives, whichever comes first.")
2112 temp_echo_area_glyphs (XSTRING (string
)->data
);
2117 init_minibuf_once ()
2119 Vminibuffer_list
= Qnil
;
2120 staticpro (&Vminibuffer_list
);
2127 minibuf_prompt
= Qnil
;
2128 staticpro (&minibuf_prompt
);
2130 minibuf_save_list
= Qnil
;
2131 staticpro (&minibuf_save_list
);
2133 Qread_file_name_internal
= intern ("read-file-name-internal");
2134 staticpro (&Qread_file_name_internal
);
2136 Qminibuffer_default
= intern ("minibuffer-default");
2137 staticpro (&Qminibuffer_default
);
2138 Fset (Qminibuffer_default
, Qnil
);
2140 Qminibuffer_completion_table
= intern ("minibuffer-completion-table");
2141 staticpro (&Qminibuffer_completion_table
);
2143 Qminibuffer_completion_confirm
= intern ("minibuffer-completion-confirm");
2144 staticpro (&Qminibuffer_completion_confirm
);
2146 Qminibuffer_completion_predicate
= intern ("minibuffer-completion-predicate");
2147 staticpro (&Qminibuffer_completion_predicate
);
2149 staticpro (&last_exact_completion
);
2150 last_exact_completion
= Qnil
;
2152 staticpro (&last_minibuf_string
);
2153 last_minibuf_string
= Qnil
;
2155 Quser_variable_p
= intern ("user-variable-p");
2156 staticpro (&Quser_variable_p
);
2158 Qminibuffer_history
= intern ("minibuffer-history");
2159 staticpro (&Qminibuffer_history
);
2161 Qbuffer_name_history
= intern ("buffer-name-history");
2162 staticpro (&Qbuffer_name_history
);
2163 Fset (Qbuffer_name_history
, Qnil
);
2165 Qminibuffer_setup_hook
= intern ("minibuffer-setup-hook");
2166 staticpro (&Qminibuffer_setup_hook
);
2168 Qminibuffer_exit_hook
= intern ("minibuffer-exit-hook");
2169 staticpro (&Qminibuffer_exit_hook
);
2171 Qhistory_length
= intern ("history-length");
2172 staticpro (&Qhistory_length
);
2174 Qcurrent_input_method
= intern ("current-input-method");
2175 staticpro (&Qcurrent_input_method
);
2177 Qactivate_input_method
= intern ("activate-input-method");
2178 staticpro (&Qactivate_input_method
);
2180 DEFVAR_LISP ("read-buffer-function", &Vread_buffer_function
,
2181 "If this is non-nil, `read-buffer' does its work by calling this function.");
2182 Vread_buffer_function
= Qnil
;
2184 DEFVAR_LISP ("minibuffer-setup-hook", &Vminibuffer_setup_hook
,
2185 "Normal hook run just after entry to minibuffer.");
2186 Vminibuffer_setup_hook
= Qnil
;
2188 DEFVAR_LISP ("minibuffer-exit-hook", &Vminibuffer_exit_hook
,
2189 "Normal hook run just after exit from minibuffer.");
2190 Vminibuffer_exit_hook
= Qnil
;
2192 DEFVAR_LISP ("history-length", &Vhistory_length
,
2193 "*Maximum length for history lists before truncation takes place.\n\
2194 A number means that length; t means infinite. Truncation takes place\n\
2195 just after a new element is inserted. Setting the history-length\n\
2196 property of a history variable overrides this default.");
2197 XSETFASTINT (Vhistory_length
, 30);
2199 DEFVAR_BOOL ("completion-auto-help", &auto_help
,
2200 "*Non-nil means automatically provide help for invalid completion input.");
2203 DEFVAR_BOOL ("completion-ignore-case", &completion_ignore_case
,
2204 "Non-nil means don't consider case significant in completion.");
2205 completion_ignore_case
= 0;
2207 DEFVAR_BOOL ("enable-recursive-minibuffers", &enable_recursive_minibuffers
,
2208 "*Non-nil means to allow minibuffer commands while in the minibuffer.\n\
2209 This variable makes a difference whenever the minibuffer window is active.");
2210 enable_recursive_minibuffers
= 0;
2212 DEFVAR_LISP ("minibuffer-completion-table", &Vminibuffer_completion_table
,
2213 "Alist or obarray used for completion in the minibuffer.\n\
2214 This becomes the ALIST argument to `try-completion' and `all-completion'.\n\
2216 The value may alternatively be a function, which is given three arguments:\n\
2217 STRING, the current buffer contents;\n\
2218 PREDICATE, the predicate for filtering possible matches;\n\
2219 CODE, which says what kind of things to do.\n\
2220 CODE can be nil, t or `lambda'.\n\
2221 nil means to return the best completion of STRING, or nil if there is none.\n\
2222 t means to return a list of all possible completions of STRING.\n\
2223 `lambda' means to return t if STRING is a valid completion as it stands.");
2224 Vminibuffer_completion_table
= Qnil
;
2226 DEFVAR_LISP ("minibuffer-completion-predicate", &Vminibuffer_completion_predicate
,
2227 "Within call to `completing-read', this holds the PREDICATE argument.");
2228 Vminibuffer_completion_predicate
= Qnil
;
2230 DEFVAR_LISP ("minibuffer-completion-confirm", &Vminibuffer_completion_confirm
,
2231 "Non-nil => demand confirmation of completion before exiting minibuffer.");
2232 Vminibuffer_completion_confirm
= Qnil
;
2234 DEFVAR_LISP ("minibuffer-completing-file-name",
2235 &Vminibuffer_completing_file_name
,
2236 "Non-nil means completing file names.");
2237 Vminibuffer_completing_file_name
= Qnil
;
2239 DEFVAR_LISP ("minibuffer-help-form", &Vminibuffer_help_form
,
2240 "Value that `help-form' takes on inside the minibuffer.");
2241 Vminibuffer_help_form
= Qnil
;
2243 DEFVAR_LISP ("minibuffer-history-variable", &Vminibuffer_history_variable
,
2244 "History list symbol to add minibuffer values to.\n\
2245 Each string of minibuffer input, as it appears on exit from the minibuffer,\n\
2247 (set minibuffer-history-variable\n\
2248 (cons STRING (symbol-value minibuffer-history-variable)))");
2249 XSETFASTINT (Vminibuffer_history_variable
, 0);
2251 DEFVAR_LISP ("minibuffer-history-position", &Vminibuffer_history_position
,
2252 "Current position of redoing in the history list.");
2253 Vminibuffer_history_position
= Qnil
;
2255 DEFVAR_BOOL ("minibuffer-auto-raise", &minibuffer_auto_raise
,
2256 "*Non-nil means entering the minibuffer raises the minibuffer's frame.\n\
2257 Some uses of the echo area also raise that frame (since they use it too).");
2258 minibuffer_auto_raise
= 0;
2260 DEFVAR_LISP ("completion-regexp-list", &Vcompletion_regexp_list
,
2261 "List of regexps that should restrict possible completions.");
2262 Vcompletion_regexp_list
= Qnil
;
2264 DEFVAR_BOOL ("minibuffer-allow-text-properties",
2265 &minibuffer_allow_text_properties
,
2266 "Non-nil means `read-from-minibuffer' should not discard text properties.\n\
2267 This also affects `read-string', but it does not affect `read-minibuffer',\n\
2268 `read-no-blanks-input', or any of the functions that do minibuffer input\n\
2269 with completion; they always discard text properties.");
2270 minibuffer_allow_text_properties
= 0;
2272 defsubr (&Sset_minibuffer_window
);
2273 defsubr (&Sread_from_minibuffer
);
2274 defsubr (&Seval_minibuffer
);
2275 defsubr (&Sread_minibuffer
);
2276 defsubr (&Sread_string
);
2277 defsubr (&Sread_command
);
2278 defsubr (&Sread_variable
);
2279 defsubr (&Sread_buffer
);
2280 defsubr (&Sread_no_blanks_input
);
2281 defsubr (&Sminibuffer_depth
);
2282 defsubr (&Sminibuffer_prompt
);
2283 defsubr (&Sminibuffer_prompt_width
);
2285 defsubr (&Stry_completion
);
2286 defsubr (&Sall_completions
);
2287 defsubr (&Scompleting_read
);
2288 defsubr (&Sminibuffer_complete
);
2289 defsubr (&Sminibuffer_complete_word
);
2290 defsubr (&Sminibuffer_complete_and_exit
);
2291 defsubr (&Sdisplay_completion_list
);
2292 defsubr (&Sminibuffer_completion_help
);
2294 defsubr (&Sself_insert_and_exit
);
2295 defsubr (&Sexit_minibuffer
);
2297 defsubr (&Sminibuffer_message
);
2303 initial_define_key (Vminibuffer_local_map
, Ctl ('g'),
2304 "abort-recursive-edit");
2305 initial_define_key (Vminibuffer_local_map
, Ctl ('m'),
2307 initial_define_key (Vminibuffer_local_map
, Ctl ('j'),
2310 initial_define_key (Vminibuffer_local_ns_map
, Ctl ('g'),
2311 "abort-recursive-edit");
2312 initial_define_key (Vminibuffer_local_ns_map
, Ctl ('m'),
2314 initial_define_key (Vminibuffer_local_ns_map
, Ctl ('j'),
2317 initial_define_key (Vminibuffer_local_ns_map
, ' ',
2319 initial_define_key (Vminibuffer_local_ns_map
, '\t',
2321 initial_define_key (Vminibuffer_local_ns_map
, '?',
2322 "self-insert-and-exit");
2324 initial_define_key (Vminibuffer_local_completion_map
, Ctl ('g'),
2325 "abort-recursive-edit");
2326 initial_define_key (Vminibuffer_local_completion_map
, Ctl ('m'),
2328 initial_define_key (Vminibuffer_local_completion_map
, Ctl ('j'),
2331 initial_define_key (Vminibuffer_local_completion_map
, '\t',
2332 "minibuffer-complete");
2333 initial_define_key (Vminibuffer_local_completion_map
, ' ',
2334 "minibuffer-complete-word");
2335 initial_define_key (Vminibuffer_local_completion_map
, '?',
2336 "minibuffer-completion-help");
2338 initial_define_key (Vminibuffer_local_must_match_map
, Ctl ('g'),
2339 "abort-recursive-edit");
2340 initial_define_key (Vminibuffer_local_must_match_map
, Ctl ('m'),
2341 "minibuffer-complete-and-exit");
2342 initial_define_key (Vminibuffer_local_must_match_map
, Ctl ('j'),
2343 "minibuffer-complete-and-exit");
2344 initial_define_key (Vminibuffer_local_must_match_map
, '\t',
2345 "minibuffer-complete");
2346 initial_define_key (Vminibuffer_local_must_match_map
, ' ',
2347 "minibuffer-complete-word");
2348 initial_define_key (Vminibuffer_local_must_match_map
, '?',
2349 "minibuffer-completion-help");