1 /* Minibuffer input and completion.
3 Copyright (C) 1985-1986, 1993-2015 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 3 of the License, or
10 (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>. */
25 #include <binary-io.h>
29 #include "character.h"
31 #include "dispextern.h"
36 #include "intervals.h"
38 #include "termhooks.h"
41 /* List of buffers for use as minibuffers.
42 The first element of the list is used for the outermost minibuffer
43 invocation, the next element is used for a recursive minibuffer
44 invocation, etc. The list is extended at the end as deeper
45 minibuffer recursions are encountered. */
47 Lisp_Object Vminibuffer_list
;
49 /* Data to remember during recursive minibuffer invocations. */
51 static Lisp_Object minibuf_save_list
;
53 /* Depth in minibuffer invocations. */
55 EMACS_INT minibuf_level
;
57 /* Fread_minibuffer leaves the input here as a string. */
59 Lisp_Object last_minibuf_string
;
61 /* Prompt to display in front of the mini-buffer contents. */
63 static Lisp_Object minibuf_prompt
;
65 /* Width of current mini-buffer prompt. Only set after display_line
66 of the line that contains the prompt. */
68 static ptrdiff_t minibuf_prompt_width
;
71 /* Put minibuf on currently selected frame's minibuffer.
72 We do this whenever the user starts a new minibuffer
73 or when a minibuffer exits. */
76 choose_minibuf_frame (void)
78 if (FRAMEP (selected_frame
)
79 && FRAME_LIVE_P (XFRAME (selected_frame
))
80 && !EQ (minibuf_window
, XFRAME (selected_frame
)->minibuffer_window
))
82 struct frame
*sf
= XFRAME (selected_frame
);
85 /* I don't think that any frames may validly have a null minibuffer
87 if (NILP (sf
->minibuffer_window
))
90 /* Under X, we come here with minibuf_window being the
91 minibuffer window of the unused termcap window created in
92 init_window_once. That window doesn't have a buffer. */
93 buffer
= XWINDOW (minibuf_window
)->contents
;
95 /* Use set_window_buffer instead of Fset_window_buffer (see
96 discussion of bug#11984, bug#12025, bug#12026). */
97 set_window_buffer (sf
->minibuffer_window
, buffer
, 0, 0);
98 minibuf_window
= sf
->minibuffer_window
;
101 /* Make sure no other frame has a minibuffer as its selected window,
102 because the text would not be displayed in it, and that would be
103 confusing. Only allow the selected frame to do this,
104 and that only if the minibuffer is active. */
106 Lisp_Object tail
, frame
;
108 FOR_EACH_FRAME (tail
, frame
)
109 if (MINI_WINDOW_P (XWINDOW (FRAME_SELECTED_WINDOW (XFRAME (frame
))))
110 && !(EQ (frame
, selected_frame
)
111 && minibuf_level
> 0))
112 Fset_frame_selected_window (frame
, Fframe_first_window (frame
), Qnil
);
116 DEFUN ("active-minibuffer-window", Factive_minibuffer_window
,
117 Sactive_minibuffer_window
, 0, 0, 0,
118 doc
: /* Return the currently active minibuffer window, or nil if none. */)
121 return minibuf_level
? minibuf_window
: Qnil
;
124 DEFUN ("set-minibuffer-window", Fset_minibuffer_window
,
125 Sset_minibuffer_window
, 1, 1, 0,
126 doc
: /* Specify which minibuffer window to use for the minibuffer.
127 This affects where the minibuffer is displayed if you put text in it
128 without invoking the usual minibuffer commands. */)
131 CHECK_WINDOW (window
);
132 if (! MINI_WINDOW_P (XWINDOW (window
)))
133 error ("Window is not a minibuffer window");
135 minibuf_window
= window
;
141 /* Actual minibuffer invocation. */
143 static void read_minibuf_unwind (void);
144 static void run_exit_minibuf_hook (void);
147 /* Read a Lisp object from VAL and return it. If VAL is an empty
148 string, and DEFALT is a string, read from DEFALT instead of VAL. */
151 string_to_object (Lisp_Object val
, Lisp_Object defalt
)
153 Lisp_Object expr_and_pos
;
156 if (STRINGP (val
) && SCHARS (val
) == 0)
158 if (STRINGP (defalt
))
160 else if (CONSP (defalt
) && STRINGP (XCAR (defalt
)))
164 expr_and_pos
= Fread_from_string (val
, Qnil
, Qnil
);
165 pos
= XINT (Fcdr (expr_and_pos
));
166 if (pos
!= SCHARS (val
))
168 /* Ignore trailing whitespace; any other trailing junk
171 pos
= string_char_to_byte (val
, pos
);
172 for (i
= pos
; i
< SBYTES (val
); i
++)
174 int c
= SREF (val
, i
);
175 if (c
!= ' ' && c
!= '\t' && c
!= '\n')
176 error ("Trailing garbage following expression");
180 val
= Fcar (expr_and_pos
);
185 /* Like read_minibuf but reading from stdin. This function is called
186 from read_minibuf to do the job if noninteractive. */
189 read_minibuf_noninteractive (Lisp_Object map
, Lisp_Object initial
,
190 Lisp_Object prompt
, Lisp_Object backup_n
,
192 Lisp_Object histvar
, Lisp_Object histpos
,
194 bool allow_props
, bool inherit_input_method
)
200 unsigned char hide_char
= 0;
201 struct emacs_tty etty
;
204 /* Check, whether we need to suppress echoing. */
205 if (CHARACTERP (Vread_hide_char
))
206 hide_char
= XFASTINT (Vread_hide_char
);
208 /* Manipulate tty. */
211 etty_valid
= emacs_get_tty (fileno (stdin
), &etty
) == 0;
213 set_binary_mode (fileno (stdin
), O_BINARY
);
214 suppress_echo_on_tty (fileno (stdin
));
217 fwrite (SDATA (prompt
), 1, SBYTES (prompt
), stdout
);
223 line
= xmalloc (size
);
225 while ((c
= getchar ()) != '\n' && c
!= '\r')
235 fprintf (stdout
, "%c", hide_char
);
238 if (STRING_BYTES_BOUND
/ 2 < size
)
239 memory_full (SIZE_MAX
);
241 line
= xrealloc (line
, size
);
250 fprintf (stdout
, "\n");
253 emacs_set_tty (fileno (stdin
), &etty
, 0);
254 set_binary_mode (fileno (stdin
), O_TEXT
);
258 if (len
|| c
== '\n' || c
== '\r')
260 val
= make_string (line
, len
);
266 error ("Error reading from stdin");
269 /* If Lisp form desired instead of string, parse it. */
271 val
= string_to_object (val
, CONSP (defalt
) ? XCAR (defalt
) : defalt
);
276 DEFUN ("minibufferp", Fminibufferp
,
277 Sminibufferp
, 0, 1, 0,
278 doc
: /* Return t if BUFFER is a minibuffer.
279 No argument or nil as argument means use current buffer as BUFFER.
280 BUFFER can be a buffer or a buffer name. */)
286 buffer
= Fcurrent_buffer ();
287 else if (STRINGP (buffer
))
288 buffer
= Fget_buffer (buffer
);
290 CHECK_BUFFER (buffer
);
292 tem
= Fmemq (buffer
, Vminibuffer_list
);
293 return ! NILP (tem
) ? Qt
: Qnil
;
296 DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end
,
297 Sminibuffer_prompt_end
, 0, 0, 0,
298 doc
: /* Return the buffer position of the end of the minibuffer prompt.
299 Return (point-min) if current buffer is not a minibuffer. */)
302 /* This function is written to be most efficient when there's a prompt. */
303 Lisp_Object beg
, end
, tem
;
304 beg
= make_number (BEGV
);
306 tem
= Fmemq (Fcurrent_buffer (), Vminibuffer_list
);
310 end
= Ffield_end (beg
, Qnil
, Qnil
);
312 if (XINT (end
) == ZV
&& NILP (Fget_char_property (beg
, Qfield
, Qnil
)))
318 DEFUN ("minibuffer-contents", Fminibuffer_contents
,
319 Sminibuffer_contents
, 0, 0, 0,
320 doc
: /* Return the user input in a minibuffer as a string.
321 If the current buffer is not a minibuffer, return its entire contents. */)
324 ptrdiff_t prompt_end
= XINT (Fminibuffer_prompt_end ());
325 return make_buffer_string (prompt_end
, ZV
, 1);
328 DEFUN ("minibuffer-contents-no-properties", Fminibuffer_contents_no_properties
,
329 Sminibuffer_contents_no_properties
, 0, 0, 0,
330 doc
: /* Return the user input in a minibuffer as a string, without text-properties.
331 If the current buffer is not a minibuffer, return its entire contents. */)
334 ptrdiff_t prompt_end
= XINT (Fminibuffer_prompt_end ());
335 return make_buffer_string (prompt_end
, ZV
, 0);
338 DEFUN ("minibuffer-completion-contents", Fminibuffer_completion_contents
,
339 Sminibuffer_completion_contents
, 0, 0, 0,
340 doc
: /* Return the user input in a minibuffer before point as a string.
341 That is what completion commands operate on.
342 If the current buffer is not a minibuffer, return its entire contents. */)
345 ptrdiff_t prompt_end
= XINT (Fminibuffer_prompt_end ());
347 error ("Cannot do completion in the prompt");
348 return make_buffer_string (prompt_end
, PT
, 1);
352 /* Read from the minibuffer using keymap MAP and initial contents INITIAL,
353 putting point minus BACKUP_N bytes from the end of INITIAL,
354 prompting with PROMPT (a string), using history list HISTVAR
355 with initial position HISTPOS. INITIAL should be a string or a
356 cons of a string and an integer. BACKUP_N should be <= 0, or
357 Qnil, which is equivalent to 0. If INITIAL is a cons, BACKUP_N is
358 ignored and replaced with an integer that puts point at one-indexed
359 position N in INITIAL, where N is the CDR of INITIAL, or at the
360 beginning of INITIAL if N <= 0.
362 Normally return the result as a string (the text that was read),
363 but if EXPFLAG, read it and return the object read.
364 If HISTVAR is given, save the value read on that history only if it doesn't
365 match the front of that history list exactly. The value is pushed onto
366 the list as the string that was read.
368 DEFALT specifies the default value for the sake of history commands.
370 If ALLOW_PROPS, do not throw away text properties.
372 if INHERIT_INPUT_METHOD, the minibuffer inherits the
373 current input method. */
376 read_minibuf (Lisp_Object map
, Lisp_Object initial
, Lisp_Object prompt
,
378 Lisp_Object histvar
, Lisp_Object histpos
, Lisp_Object defalt
,
379 bool allow_props
, bool inherit_input_method
)
382 ptrdiff_t count
= SPECPDL_INDEX ();
383 Lisp_Object mini_frame
, ambient_dir
, minibuffer
, input_method
;
384 Lisp_Object enable_multibyte
;
386 /* String to add to the history. */
387 Lisp_Object histstring
;
390 Lisp_Object empty_minibuf
;
391 Lisp_Object dummy
, frame
;
393 specbind (Qminibuffer_default
, defalt
);
394 specbind (Qinhibit_read_only
, Qnil
);
396 /* If Vminibuffer_completing_file_name is `lambda' on entry, it was t
397 in previous recursive minibuffer, but was not set explicitly
398 to t for this invocation, so set it to nil in this minibuffer.
399 Save the old value now, before we change it. */
400 specbind (intern ("minibuffer-completing-file-name"),
401 Vminibuffer_completing_file_name
);
402 if (EQ (Vminibuffer_completing_file_name
, Qlambda
))
403 Vminibuffer_completing_file_name
= Qnil
;
405 #ifdef HAVE_WINDOW_SYSTEM
406 if (display_hourglass_p
)
414 Lisp_Object backup_n
= XCDR (initial
);
415 initial
= XCAR (initial
);
416 CHECK_STRING (initial
);
417 if (!NILP (backup_n
))
419 CHECK_NUMBER (backup_n
);
420 /* Convert to distance from end of input. */
421 if (XINT (backup_n
) < 1)
422 /* A number too small means the beginning of the string. */
423 pos
= - SCHARS (initial
);
425 pos
= XINT (backup_n
) - 1 - SCHARS (initial
);
429 CHECK_STRING (initial
);
432 ambient_dir
= BVAR (current_buffer
, directory
);
434 enable_multibyte
= Qnil
;
436 if (!STRINGP (prompt
))
437 prompt
= empty_unibyte_string
;
439 if (!enable_recursive_minibuffers
440 && minibuf_level
> 0)
442 if (EQ (selected_window
, minibuf_window
))
443 error ("Command attempted to use minibuffer while in minibuffer");
445 /* If we're in another window, cancel the minibuffer that's active. */
447 build_string ("Command attempted to use minibuffer while in minibuffer"));
451 /* In case we are running as a daemon, only do this before
452 detaching from the terminal. */
453 || (IS_DAEMON
&& DAEMON_RUNNING
))
454 && NILP (Vexecuting_kbd_macro
))
456 val
= read_minibuf_noninteractive (map
, initial
, prompt
,
458 expflag
, histvar
, histpos
, defalt
,
459 allow_props
, inherit_input_method
);
460 return unbind_to (count
, val
);
463 /* Choose the minibuffer window and frame, and take action on them. */
465 /* Prepare for restoring the current buffer since choose_minibuf_frame
466 calling Fset_frame_selected_window may change it (Bug#12766). */
467 record_unwind_protect (restore_buffer
, Fcurrent_buffer ());
469 choose_minibuf_frame ();
471 record_unwind_protect_void (choose_minibuf_frame
);
473 record_unwind_protect (restore_window_configuration
,
474 Fcurrent_window_configuration (Qnil
));
476 /* If the minibuffer window is on a different frame, save that
477 frame's configuration too. */
478 mini_frame
= WINDOW_FRAME (XWINDOW (minibuf_window
));
479 if (!EQ (mini_frame
, selected_frame
))
480 record_unwind_protect (restore_window_configuration
,
481 Fcurrent_window_configuration (mini_frame
));
483 /* If the minibuffer is on an iconified or invisible frame,
484 make it visible now. */
485 Fmake_frame_visible (mini_frame
);
487 if (minibuffer_auto_raise
)
488 Fraise_frame (mini_frame
);
490 temporarily_switch_to_single_kboard (XFRAME (mini_frame
));
492 /* We have to do this after saving the window configuration
493 since that is what restores the current buffer. */
495 /* Arrange to restore a number of minibuffer-related variables.
496 We could bind each variable separately, but that would use lots of
499 = Fcons (Voverriding_local_map
,
500 Fcons (minibuf_window
,
503 = Fcons (minibuf_prompt
,
504 Fcons (make_number (minibuf_prompt_width
),
506 Fcons (Vcurrent_prefix_arg
,
507 Fcons (Vminibuffer_history_position
,
508 Fcons (Vminibuffer_history_variable
,
509 minibuf_save_list
))))));
511 record_unwind_protect_void (read_minibuf_unwind
);
513 /* We are exiting the minibuffer one way or the other, so run the hook.
514 It should be run before unwinding the minibuf settings. Do it
515 separately from read_minibuf_unwind because we need to make sure that
516 read_minibuf_unwind is fully executed even if exit-minibuffer-hook
517 signals an error. --Stef */
518 record_unwind_protect_void (run_exit_minibuf_hook
);
520 /* Now that we can restore all those variables, start changing them. */
522 minibuf_prompt_width
= 0;
523 minibuf_prompt
= Fcopy_sequence (prompt
);
524 Vminibuffer_history_position
= histpos
;
525 Vminibuffer_history_variable
= histvar
;
526 Vhelp_form
= Vminibuffer_help_form
;
527 /* If this minibuffer is reading a file name, that doesn't mean
528 recursive ones are. But we cannot set it to nil, because
529 completion code still need to know the minibuffer is completing a
530 file name. So use `lambda' as intermediate value meaning
531 "t" in this minibuffer, but "nil" in next minibuffer. */
532 if (!NILP (Vminibuffer_completing_file_name
))
533 Vminibuffer_completing_file_name
= Qlambda
;
535 /* If variable is unbound, make it nil. */
536 histval
= find_symbol_value (Vminibuffer_history_variable
);
537 if (EQ (histval
, Qunbound
))
539 Fset (Vminibuffer_history_variable
, Qnil
);
543 if (inherit_input_method
)
545 /* `current-input-method' is buffer local. So, remember it in
546 INPUT_METHOD before changing the current buffer. */
547 input_method
= Fsymbol_value (Qcurrent_input_method
);
548 enable_multibyte
= BVAR (current_buffer
, enable_multibyte_characters
);
551 /* Switch to the minibuffer. */
553 minibuffer
= get_minibuffer (minibuf_level
);
554 Fset_buffer (minibuffer
);
556 /* Defeat (setq-default truncate-lines t), since truncated lines do
557 not work correctly in minibuffers. (Bug#5715, etc) */
558 bset_truncate_lines (current_buffer
, Qnil
);
560 /* If appropriate, copy enable-multibyte-characters into the minibuffer. */
561 if (inherit_input_method
)
562 bset_enable_multibyte_characters (current_buffer
, enable_multibyte
);
564 /* The current buffer's default directory is usually the right thing
565 for our minibuffer here. However, if you're typing a command at
566 a minibuffer-only frame when minibuf_level is zero, then buf IS
567 the current_buffer, so reset_buffer leaves buf's default
568 directory unchanged. This is a bummer when you've just started
569 up Emacs and buf's default directory is Qnil. Here's a hack; can
570 you think of something better to do? Find another buffer with a
571 better directory, and use that one instead. */
572 if (STRINGP (ambient_dir
))
573 bset_directory (current_buffer
, ambient_dir
);
576 Lisp_Object tail
, buf
;
578 FOR_EACH_LIVE_BUFFER (tail
, buf
)
579 if (STRINGP (BVAR (XBUFFER (buf
), directory
)))
581 bset_directory (current_buffer
,
582 BVAR (XBUFFER (buf
), directory
));
587 if (!EQ (mini_frame
, selected_frame
))
588 Fredirect_frame_focus (selected_frame
, mini_frame
);
590 Vminibuf_scroll_window
= selected_window
;
591 if (minibuf_level
== 1 || !EQ (minibuf_window
, selected_window
))
592 minibuf_selected_window
= selected_window
;
594 /* Empty out the minibuffers of all frames other than the one
595 where we are going to display one now.
596 Set them to point to ` *Minibuf-0*', which is always empty. */
597 empty_minibuf
= get_minibuffer (0);
599 FOR_EACH_FRAME (dummy
, frame
)
601 Lisp_Object root_window
= Fframe_root_window (frame
);
602 Lisp_Object mini_window
= XWINDOW (root_window
)->next
;
604 if (! NILP (mini_window
) && ! EQ (mini_window
, minibuf_window
)
605 && !NILP (Fwindow_minibuffer_p (mini_window
)))
606 /* Use set_window_buffer instead of Fset_window_buffer (see
607 discussion of bug#11984, bug#12025, bug#12026). */
608 set_window_buffer (mini_window
, empty_minibuf
, 0, 0);
611 /* Display this minibuffer in the proper window. */
612 /* Use set_window_buffer instead of Fset_window_buffer (see
613 discussion of bug#11984, bug#12025, bug#12026). */
614 set_window_buffer (minibuf_window
, Fcurrent_buffer (), 0, 0);
615 Fselect_window (minibuf_window
, Qnil
);
616 XWINDOW (minibuf_window
)->hscroll
= 0;
617 XWINDOW (minibuf_window
)->suspend_auto_hscroll
= 0;
619 Fmake_local_variable (Qprint_escape_newlines
);
620 print_escape_newlines
= 1;
622 /* Erase the buffer. */
624 ptrdiff_t count1
= SPECPDL_INDEX ();
625 specbind (Qinhibit_read_only
, Qt
);
626 specbind (Qinhibit_modification_hooks
, Qt
);
629 if (!NILP (BVAR (current_buffer
, enable_multibyte_characters
))
630 && ! STRING_MULTIBYTE (minibuf_prompt
))
631 minibuf_prompt
= Fstring_make_multibyte (minibuf_prompt
);
633 /* Insert the prompt, record where it ends. */
634 Finsert (1, &minibuf_prompt
);
637 Fput_text_property (make_number (BEG
), make_number (PT
),
638 Qfront_sticky
, Qt
, Qnil
);
639 Fput_text_property (make_number (BEG
), make_number (PT
),
640 Qrear_nonsticky
, Qt
, Qnil
);
641 Fput_text_property (make_number (BEG
), make_number (PT
),
643 Fadd_text_properties (make_number (BEG
), make_number (PT
),
644 Vminibuffer_prompt_properties
, Qnil
);
646 unbind_to (count1
, Qnil
);
649 minibuf_prompt_width
= current_column ();
651 /* Put in the initial input. */
654 Finsert (1, &initial
);
655 Fforward_char (make_number (pos
));
658 clear_message (1, 1);
659 bset_keymap (current_buffer
, map
);
661 /* Turn on an input method stored in INPUT_METHOD if any. */
662 if (STRINGP (input_method
) && !NILP (Ffboundp (Qactivate_input_method
)))
663 call1 (Qactivate_input_method
, input_method
);
665 run_hook (Qminibuffer_setup_hook
);
667 /* Don't allow the user to undo past this point. */
668 bset_undo_list (current_buffer
, Qnil
);
672 /* If cursor is on the minibuffer line,
673 show the user we have exited by putting it in column 0. */
674 if (XWINDOW (minibuf_window
)->cursor
.vpos
>= 0
677 XWINDOW (minibuf_window
)->cursor
.hpos
= 0;
678 XWINDOW (minibuf_window
)->cursor
.x
= 0;
679 XWINDOW (minibuf_window
)->must_be_updated_p
= true;
680 update_frame (XFRAME (selected_frame
), true, true);
681 flush_frame (XFRAME (XWINDOW (minibuf_window
)->frame
));
684 /* Make minibuffer contents into a string. */
685 Fset_buffer (minibuffer
);
687 val
= Fminibuffer_contents ();
689 val
= Fminibuffer_contents_no_properties ();
691 /* VAL is the string of minibuffer text. */
693 last_minibuf_string
= val
;
695 /* Choose the string to add to the history. */
696 if (SCHARS (val
) != 0)
698 else if (STRINGP (defalt
))
700 else if (CONSP (defalt
) && STRINGP (XCAR (defalt
)))
701 histstring
= XCAR (defalt
);
705 /* Add the value to the appropriate history list, if any. */
706 if (!NILP (Vhistory_add_new_input
)
707 && SYMBOLP (Vminibuffer_history_variable
)
708 && !NILP (histstring
))
710 /* If the caller wanted to save the value read on a history list,
711 then do so if the value is not already the front of the list. */
713 /* The value of the history variable must be a cons or nil. Other
714 values are unacceptable. We silently ignore these values. */
718 /* Don't duplicate the most recent entry in the history. */
719 && (NILP (Fequal (histstring
, Fcar (histval
))))))
723 if (history_delete_duplicates
) Fdelete (histstring
, histval
);
724 histval
= Fcons (histstring
, histval
);
725 Fset (Vminibuffer_history_variable
, histval
);
727 /* Truncate if requested. */
728 length
= Fget (Vminibuffer_history_variable
, Qhistory_length
);
729 if (NILP (length
)) length
= Vhistory_length
;
730 if (INTEGERP (length
))
732 if (XINT (length
) <= 0)
733 Fset (Vminibuffer_history_variable
, Qnil
);
738 temp
= Fnthcdr (Fsub1 (length
), histval
);
739 if (CONSP (temp
)) Fsetcdr (temp
, Qnil
);
745 /* If Lisp form desired instead of string, parse it. */
747 val
= string_to_object (val
, defalt
);
749 /* The appropriate frame will get selected
750 in set-window-configuration. */
751 return unbind_to (count
, val
);
754 /* Return a buffer to be used as the minibuffer at depth `depth'.
755 depth = 0 is the lowest allowed argument, and that is the value
756 used for nonrecursive minibuffer invocations. */
759 get_minibuffer (EMACS_INT depth
)
761 Lisp_Object tail
, num
, buf
;
762 char name
[sizeof " *Minibuf-*" + INT_STRLEN_BOUND (EMACS_INT
)];
764 XSETFASTINT (num
, depth
);
765 tail
= Fnthcdr (num
, Vminibuffer_list
);
769 Vminibuffer_list
= nconc2 (Vminibuffer_list
, tail
);
772 if (NILP (buf
) || !BUFFER_LIVE_P (XBUFFER (buf
)))
774 buf
= Fget_buffer_create
775 (make_formatted_string (name
, " *Minibuf-%"pI
"d*", depth
));
777 /* Although the buffer's name starts with a space, undo should be
779 Fbuffer_enable_undo (buf
);
785 ptrdiff_t count
= SPECPDL_INDEX ();
786 /* We have to empty both overlay lists. Otherwise we end
787 up with overlays that think they belong to this buffer
788 while the buffer doesn't know about them any more. */
789 delete_all_overlays (XBUFFER (buf
));
790 reset_buffer (XBUFFER (buf
));
791 record_unwind_current_buffer ();
793 if (!NILP (Ffboundp (intern ("minibuffer-inactive-mode"))))
794 call0 (intern ("minibuffer-inactive-mode"));
796 Fkill_all_local_variables ();
797 unbind_to (count
, Qnil
);
804 run_exit_minibuf_hook (void)
806 safe_run_hooks (Qminibuffer_exit_hook
);
809 /* This function is called on exiting minibuffer, whether normally or
810 not, and it restores the current window, buffer, etc. */
813 read_minibuf_unwind (void)
815 Lisp_Object old_deactivate_mark
;
818 /* If this was a recursive minibuffer,
819 tie the minibuffer window back to the outer level minibuffer buffer. */
822 window
= minibuf_window
;
823 /* To keep things predictable, in case it matters, let's be in the
824 minibuffer when we reset the relevant variables. */
825 Fset_buffer (XWINDOW (window
)->contents
);
827 /* Restore prompt, etc, from outer minibuffer level. */
828 minibuf_prompt
= Fcar (minibuf_save_list
);
829 minibuf_save_list
= Fcdr (minibuf_save_list
);
830 minibuf_prompt_width
= XFASTINT (Fcar (minibuf_save_list
));
831 minibuf_save_list
= Fcdr (minibuf_save_list
);
832 Vhelp_form
= Fcar (minibuf_save_list
);
833 minibuf_save_list
= Fcdr (minibuf_save_list
);
834 Vcurrent_prefix_arg
= Fcar (minibuf_save_list
);
835 minibuf_save_list
= Fcdr (minibuf_save_list
);
836 Vminibuffer_history_position
= Fcar (minibuf_save_list
);
837 minibuf_save_list
= Fcdr (minibuf_save_list
);
838 Vminibuffer_history_variable
= Fcar (minibuf_save_list
);
839 minibuf_save_list
= Fcdr (minibuf_save_list
);
840 Voverriding_local_map
= Fcar (minibuf_save_list
);
841 minibuf_save_list
= Fcdr (minibuf_save_list
);
843 temp
= Fcar (minibuf_save_list
);
844 if (FRAME_LIVE_P (XFRAME (WINDOW_FRAME (XWINDOW (temp
)))))
845 minibuf_window
= temp
;
847 minibuf_save_list
= Fcdr (minibuf_save_list
);
849 /* Erase the minibuffer we were using at this level. */
851 ptrdiff_t count
= SPECPDL_INDEX ();
852 /* Prevent error in erase-buffer. */
853 specbind (Qinhibit_read_only
, Qt
);
854 specbind (Qinhibit_modification_hooks
, Qt
);
855 old_deactivate_mark
= Vdeactivate_mark
;
857 Vdeactivate_mark
= old_deactivate_mark
;
858 unbind_to (count
, Qnil
);
861 /* When we get to the outmost level, make sure we resize the
862 mini-window back to its normal size. */
863 if (minibuf_level
== 0)
864 resize_mini_window (XWINDOW (window
), 0);
866 /* In case the previous minibuffer displayed in this miniwindow is
867 dead, we may keep displaying this buffer (tho it's inactive), so reset it,
868 to make sure we don't leave around bindings and stuff which only
869 made sense during the read_minibuf invocation. */
870 call0 (intern ("minibuffer-inactive-mode"));
874 DEFUN ("read-from-minibuffer", Fread_from_minibuffer
,
875 Sread_from_minibuffer
, 1, 7, 0,
876 doc
: /* Read a string from the minibuffer, prompting with string PROMPT.
877 The optional second arg INITIAL-CONTENTS is an obsolete alternative to
878 DEFAULT-VALUE. It normally should be nil in new code, except when
879 HIST is a cons. It is discussed in more detail below.
881 Third arg KEYMAP is a keymap to use whilst reading;
882 if omitted or nil, the default is `minibuffer-local-map'.
884 If fourth arg READ is non-nil, interpret the result as a Lisp object
885 and return that object:
886 in other words, do `(car (read-from-string INPUT-STRING))'
888 Fifth arg HIST, if non-nil, specifies a history list and optionally
889 the initial position in the list. It can be a symbol, which is the
890 history list variable to use, or a cons cell (HISTVAR . HISTPOS).
891 In that case, HISTVAR is the history list variable to use, and
892 HISTPOS is the initial position for use by the minibuffer history
893 commands. For consistency, you should also specify that element of
894 the history as the value of INITIAL-CONTENTS. Positions are counted
895 starting from 1 at the beginning of the list.
897 Sixth arg DEFAULT-VALUE, if non-nil, should be a string, which is used
898 as the default to `read' if READ is non-nil and the user enters
899 empty input. But if READ is nil, this function does _not_ return
900 DEFAULT-VALUE for empty input! Instead, it returns the empty string.
902 Whatever the value of READ, DEFAULT-VALUE is made available via the
903 minibuffer history commands. DEFAULT-VALUE can also be a list of
904 strings, in which case all the strings are available in the history,
905 and the first string is the default to `read' if READ is non-nil.
907 Seventh arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
908 the current input method and the setting of `enable-multibyte-characters'.
910 If the variable `minibuffer-allow-text-properties' is non-nil,
911 then the string which is returned includes whatever text properties
912 were present in the minibuffer. Otherwise the value has no text properties.
914 The remainder of this documentation string describes the
915 INITIAL-CONTENTS argument in more detail. It is only relevant when
916 studying existing code, or when HIST is a cons. If non-nil,
917 INITIAL-CONTENTS is a string to be inserted into the minibuffer before
918 reading input. Normally, point is put at the end of that string.
919 However, if INITIAL-CONTENTS is (STRING . POSITION), the initial
920 input is STRING, but point is placed at _one-indexed_ position
921 POSITION in the minibuffer. Any integer value less than or equal to
922 one puts point at the beginning of the string. *Note* that this
923 behavior differs from the way such arguments are used in `completing-read'
924 and some related functions, which use zero-indexing for POSITION. */)
925 (Lisp_Object prompt
, Lisp_Object initial_contents
, Lisp_Object keymap
, Lisp_Object read
, Lisp_Object hist
, Lisp_Object default_value
, Lisp_Object inherit_input_method
)
927 Lisp_Object histvar
, histpos
, val
;
929 CHECK_STRING (prompt
);
931 keymap
= Vminibuffer_local_map
;
933 keymap
= get_keymap (keymap
, 1, 0);
942 histvar
= Fcar_safe (hist
);
943 histpos
= Fcdr_safe (hist
);
946 histvar
= Qminibuffer_history
;
948 XSETFASTINT (histpos
, 0);
950 val
= read_minibuf (keymap
, initial_contents
, prompt
,
952 histvar
, histpos
, default_value
,
953 minibuffer_allow_text_properties
,
954 !NILP (inherit_input_method
));
958 /* Functions that use the minibuffer to read various things. */
960 DEFUN ("read-string", Fread_string
, Sread_string
, 1, 5, 0,
961 doc
: /* Read a string from the minibuffer, prompting with string PROMPT.
962 If non-nil, second arg INITIAL-INPUT is a string to insert before reading.
963 This argument has been superseded by DEFAULT-VALUE and should normally be nil
964 in new code. It behaves as INITIAL-CONTENTS in `read-from-minibuffer' (which
966 The third arg HISTORY, if non-nil, specifies a history list
967 and optionally the initial position in the list.
968 See `read-from-minibuffer' for details of HISTORY argument.
969 Fourth arg DEFAULT-VALUE is the default value or the list of default values.
970 If non-nil, it is used for history commands, and as the value (or the first
971 element of the list of default values) to return if the user enters the
973 Fifth arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
974 the current input method and the setting of `enable-multibyte-characters'. */)
975 (Lisp_Object prompt
, Lisp_Object initial_input
, Lisp_Object history
, Lisp_Object default_value
, Lisp_Object inherit_input_method
)
978 ptrdiff_t count
= SPECPDL_INDEX ();
980 /* Just in case we're in a recursive minibuffer, make it clear that the
981 previous minibuffer's completion table does not apply to the new
983 FIXME: `minibuffer-completion-table' should be buffer-local instead. */
984 specbind (Qminibuffer_completion_table
, Qnil
);
986 val
= Fread_from_minibuffer (prompt
, initial_input
, Qnil
,
987 Qnil
, history
, default_value
,
988 inherit_input_method
);
989 if (STRINGP (val
) && SCHARS (val
) == 0 && ! NILP (default_value
))
990 val
= CONSP (default_value
) ? XCAR (default_value
) : default_value
;
991 return unbind_to (count
, val
);
994 DEFUN ("read-no-blanks-input", Fread_no_blanks_input
, Sread_no_blanks_input
, 1, 3, 0,
995 doc
: /* Read a string from the terminal, not allowing blanks.
996 Prompt with PROMPT. Whitespace terminates the input. If INITIAL is
997 non-nil, it should be a string, which is used as initial input, with
998 point positioned at the end, so that SPACE will accept the input.
999 (Actually, INITIAL can also be a cons of a string and an integer.
1000 Such values are treated as in `read-from-minibuffer', but are normally
1001 not useful in this function.)
1002 Third arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
1003 the current input method and the setting of`enable-multibyte-characters'. */)
1004 (Lisp_Object prompt
, Lisp_Object initial
, Lisp_Object inherit_input_method
)
1006 CHECK_STRING (prompt
);
1007 return read_minibuf (Vminibuffer_local_ns_map
, initial
, prompt
,
1008 0, Qminibuffer_history
, make_number (0), Qnil
, 0,
1009 !NILP (inherit_input_method
));
1012 DEFUN ("read-command", Fread_command
, Sread_command
, 1, 2, 0,
1013 doc
: /* Read the name of a command and return as a symbol.
1014 Prompt with PROMPT. By default, return DEFAULT-VALUE or its first element
1015 if it is a list. */)
1016 (Lisp_Object prompt
, Lisp_Object default_value
)
1018 Lisp_Object name
, default_string
;
1020 if (NILP (default_value
))
1021 default_string
= Qnil
;
1022 else if (SYMBOLP (default_value
))
1023 default_string
= SYMBOL_NAME (default_value
);
1025 default_string
= default_value
;
1027 name
= Fcompleting_read (prompt
, Vobarray
, Qcommandp
, Qt
,
1028 Qnil
, Qnil
, default_string
, Qnil
);
1031 return Fintern (name
, Qnil
);
1035 DEFUN ("read-function", Fread_function
, Sread_function
, 1, 1, 0,
1036 doc
: /* One arg PROMPT, a string. Read the name of a function and return as a symbol.
1037 Prompt with PROMPT. */)
1038 (Lisp_Object prompt
)
1040 return Fintern (Fcompleting_read (prompt
, Vobarray
, Qfboundp
, Qt
, Qnil
, Qnil
, Qnil
, Qnil
),
1045 DEFUN ("read-variable", Fread_variable
, Sread_variable
, 1, 2, 0,
1046 doc
: /* Read the name of a user option and return it as a symbol.
1047 Prompt with PROMPT. By default, return DEFAULT-VALUE or its first element
1049 A user option, or customizable variable, is one for which
1050 `custom-variable-p' returns non-nil. */)
1051 (Lisp_Object prompt
, Lisp_Object default_value
)
1053 Lisp_Object name
, default_string
;
1055 if (NILP (default_value
))
1056 default_string
= Qnil
;
1057 else if (SYMBOLP (default_value
))
1058 default_string
= SYMBOL_NAME (default_value
);
1060 default_string
= default_value
;
1062 name
= Fcompleting_read (prompt
, Vobarray
,
1063 Qcustom_variable_p
, Qt
,
1064 Qnil
, Qnil
, default_string
, Qnil
);
1067 return Fintern (name
, Qnil
);
1070 DEFUN ("read-buffer", Fread_buffer
, Sread_buffer
, 1, 4, 0,
1071 doc
: /* Read the name of a buffer and return as a string.
1073 Optional second arg DEF is value to return if user enters an empty line.
1074 If DEF is a list of default values, return its first element.
1075 Optional third arg REQUIRE-MATCH determines whether non-existing
1076 buffer names are allowed. It has the same meaning as the
1077 REQUIRE-MATCH argument of `completing-read'.
1078 The argument PROMPT should be a string ending with a colon and a space.
1079 If `read-buffer-completion-ignore-case' is non-nil, completion ignores
1080 case while reading the buffer name.
1081 If `read-buffer-function' is non-nil, this works by calling it as a
1082 function, instead of the usual behavior.
1083 Optional arg PREDICATE if non-nil is a function limiting the buffers that can
1085 (Lisp_Object prompt
, Lisp_Object def
, Lisp_Object require_match
,
1086 Lisp_Object predicate
)
1091 ptrdiff_t count
= SPECPDL_INDEX ();
1094 def
= BVAR (XBUFFER (def
), name
);
1096 specbind (Qcompletion_ignore_case
,
1097 read_buffer_completion_ignore_case
? Qt
: Qnil
);
1099 if (NILP (Vread_buffer_function
))
1103 /* A default value was provided: we must change PROMPT,
1104 editing the default value in before the colon. To achieve
1105 this, we replace PROMPT with a substring that doesn't
1106 contain the terminal space and colon (if present). They
1107 are then added back using Fformat. */
1109 if (STRINGP (prompt
))
1111 s
= SSDATA (prompt
);
1112 len
= SBYTES (prompt
);
1113 if (len
>= 2 && s
[len
- 2] == ':' && s
[len
- 1] == ' ')
1115 else if (len
>= 1 && (s
[len
- 1] == ':' || s
[len
- 1] == ' '))
1118 prompt
= make_specified_string (s
, -1, len
,
1119 STRING_MULTIBYTE (prompt
));
1122 AUTO_STRING (format
, "%s (default %s): ");
1123 prompt
= CALLN (Fformat
, format
, prompt
,
1124 CONSP (def
) ? XCAR (def
) : def
);
1127 result
= Fcompleting_read (prompt
, intern ("internal-complete-buffer"),
1128 predicate
, require_match
, Qnil
,
1129 Qbuffer_name_history
, def
, Qnil
);
1132 result
= (NILP (predicate
)
1133 /* Partial backward compatibility for older read_buffer_functions
1134 which don't expect a `predicate' argument. */
1135 ? call3 (Vread_buffer_function
, prompt
, def
, require_match
)
1136 : call4 (Vread_buffer_function
, prompt
, def
, require_match
,
1138 return unbind_to (count
, result
);
1142 minibuf_conform_representation (Lisp_Object string
, Lisp_Object basis
)
1144 if (STRING_MULTIBYTE (string
) == STRING_MULTIBYTE (basis
))
1147 if (STRING_MULTIBYTE (string
))
1148 return Fstring_make_unibyte (string
);
1150 return Fstring_make_multibyte (string
);
1153 DEFUN ("try-completion", Ftry_completion
, Stry_completion
, 2, 3, 0,
1154 doc
: /* Return common substring of all completions of STRING in COLLECTION.
1155 Test each possible completion specified by COLLECTION
1156 to see if it begins with STRING. The possible completions may be
1157 strings or symbols. Symbols are converted to strings before testing,
1159 All that match STRING are compared together; the longest initial sequence
1160 common to all these matches is the return value.
1161 If there is no match at all, the return value is nil.
1162 For a unique match which is exact, the return value is t.
1164 If COLLECTION is an alist, the keys (cars of elements) are the
1165 possible completions. If an element is not a cons cell, then the
1166 element itself is the possible completion.
1167 If COLLECTION is a hash-table, all the keys that are strings or symbols
1168 are the possible completions.
1169 If COLLECTION is an obarray, the names of all symbols in the obarray
1170 are the possible completions.
1172 COLLECTION can also be a function to do the completion itself.
1173 It receives three arguments: the values STRING, PREDICATE and nil.
1174 Whatever it returns becomes the value of `try-completion'.
1176 If optional third argument PREDICATE is non-nil,
1177 it is used to test each possible match.
1178 The match is a candidate only if PREDICATE returns non-nil.
1179 The argument given to PREDICATE is the alist element
1180 or the symbol from the obarray. If COLLECTION is a hash-table,
1181 predicate is called with two arguments: the key and the value.
1182 Additionally to this predicate, `completion-regexp-list'
1183 is used to further constrain the set of candidates. */)
1184 (Lisp_Object string
, Lisp_Object collection
, Lisp_Object predicate
)
1186 Lisp_Object bestmatch
, tail
, elt
, eltstring
;
1187 /* Size in bytes of BESTMATCH. */
1188 ptrdiff_t bestmatchsize
= 0;
1189 /* These are in bytes, too. */
1190 ptrdiff_t compare
, matchsize
;
1191 enum { function_table
, list_table
, obarray_table
, hash_table
}
1192 type
= (HASH_TABLE_P (collection
) ? hash_table
1193 : VECTORP (collection
) ? obarray_table
1194 : ((NILP (collection
)
1195 || (CONSP (collection
) && !FUNCTIONP (collection
)))
1196 ? list_table
: function_table
));
1197 ptrdiff_t idx
= 0, obsize
= 0;
1199 ptrdiff_t bindcount
= -1;
1200 Lisp_Object bucket
, zero
, end
, tem
;
1202 CHECK_STRING (string
);
1203 if (type
== function_table
)
1204 return call3 (collection
, string
, predicate
, Qnil
);
1206 bestmatch
= bucket
= Qnil
;
1207 zero
= make_number (0);
1209 /* If COLLECTION is not a list, set TAIL just for gc pro. */
1211 if (type
== obarray_table
)
1213 collection
= check_obarray (collection
);
1214 obsize
= ASIZE (collection
);
1215 bucket
= AREF (collection
, idx
);
1220 /* Get the next element of the alist, obarray, or hash-table. */
1221 /* Exit the loop if the elements are all used up. */
1222 /* elt gets the alist element or symbol.
1223 eltstring gets the name to check as a completion. */
1225 if (type
== list_table
)
1230 eltstring
= CONSP (elt
) ? XCAR (elt
) : elt
;
1233 else if (type
== obarray_table
)
1235 if (!EQ (bucket
, zero
))
1237 if (!SYMBOLP (bucket
))
1238 error ("Bad data in guts of obarray");
1241 if (XSYMBOL (bucket
)->next
)
1242 XSETSYMBOL (bucket
, XSYMBOL (bucket
)->next
);
1244 XSETFASTINT (bucket
, 0);
1246 else if (++idx
>= obsize
)
1250 bucket
= AREF (collection
, idx
);
1254 else /* if (type == hash_table) */
1256 while (idx
< HASH_TABLE_SIZE (XHASH_TABLE (collection
))
1257 && NILP (HASH_HASH (XHASH_TABLE (collection
), idx
)))
1259 if (idx
>= HASH_TABLE_SIZE (XHASH_TABLE (collection
)))
1262 elt
= eltstring
= HASH_KEY (XHASH_TABLE (collection
), idx
++);
1265 /* Is this element a possible completion? */
1267 if (SYMBOLP (eltstring
))
1268 eltstring
= Fsymbol_name (eltstring
);
1270 if (STRINGP (eltstring
)
1271 && SCHARS (string
) <= SCHARS (eltstring
)
1272 && (tem
= Fcompare_strings (eltstring
, zero
,
1273 make_number (SCHARS (string
)),
1275 completion_ignore_case
? Qt
: Qnil
),
1279 Lisp_Object regexps
;
1281 /* Ignore this element if it fails to match all the regexps. */
1283 for (regexps
= Vcompletion_regexp_list
; CONSP (regexps
);
1284 regexps
= XCDR (regexps
))
1286 if (bindcount
< 0) {
1287 bindcount
= SPECPDL_INDEX ();
1288 specbind (Qcase_fold_search
,
1289 completion_ignore_case
? Qt
: Qnil
);
1291 tem
= Fstring_match (XCAR (regexps
), eltstring
, zero
);
1295 if (CONSP (regexps
))
1299 /* Ignore this element if there is a predicate
1300 and the predicate doesn't like it. */
1302 if (!NILP (predicate
))
1304 if (EQ (predicate
, Qcommandp
))
1305 tem
= Fcommandp (elt
, Qnil
);
1310 unbind_to (bindcount
, Qnil
);
1313 tem
= (type
== hash_table
1314 ? call2 (predicate
, elt
,
1315 HASH_VALUE (XHASH_TABLE (collection
),
1317 : call1 (predicate
, elt
));
1319 if (NILP (tem
)) continue;
1322 /* Update computation of how much all possible completions match */
1324 if (NILP (bestmatch
))
1327 bestmatch
= eltstring
;
1328 bestmatchsize
= SCHARS (eltstring
);
1332 compare
= min (bestmatchsize
, SCHARS (eltstring
));
1333 tem
= Fcompare_strings (bestmatch
, zero
,
1334 make_number (compare
),
1336 make_number (compare
),
1337 completion_ignore_case
? Qt
: Qnil
);
1338 matchsize
= EQ (tem
, Qt
) ? compare
: eabs (XINT (tem
)) - 1;
1340 if (completion_ignore_case
)
1342 /* If this is an exact match except for case,
1343 use it as the best match rather than one that is not an
1344 exact match. This way, we get the case pattern
1345 of the actual match. */
1346 if ((matchsize
== SCHARS (eltstring
)
1347 && matchsize
< SCHARS (bestmatch
))
1349 /* If there is more than one exact match ignoring case,
1350 and one of them is exact including case,
1352 /* If there is no exact match ignoring case,
1353 prefer a match that does not change the case
1355 ((matchsize
== SCHARS (eltstring
))
1357 (matchsize
== SCHARS (bestmatch
))
1358 && (tem
= Fcompare_strings (eltstring
, zero
,
1359 make_number (SCHARS (string
)),
1364 && (tem
= Fcompare_strings (bestmatch
, zero
,
1365 make_number (SCHARS (string
)),
1370 bestmatch
= eltstring
;
1372 if (bestmatchsize
!= SCHARS (eltstring
)
1373 || bestmatchsize
!= matchsize
)
1374 /* Don't count the same string multiple times. */
1375 matchcount
+= matchcount
<= 1;
1376 bestmatchsize
= matchsize
;
1377 if (matchsize
<= SCHARS (string
)
1378 /* If completion-ignore-case is non-nil, don't
1379 short-circuit because we want to find the best
1380 possible match *including* case differences. */
1381 && !completion_ignore_case
1383 /* No need to look any further. */
1389 if (bindcount
>= 0) {
1390 unbind_to (bindcount
, Qnil
);
1394 if (NILP (bestmatch
))
1395 return Qnil
; /* No completions found. */
1396 /* If we are ignoring case, and there is no exact match,
1397 and no additional text was supplied,
1398 don't change the case of what the user typed. */
1399 if (completion_ignore_case
&& bestmatchsize
== SCHARS (string
)
1400 && SCHARS (bestmatch
) > bestmatchsize
)
1401 return minibuf_conform_representation (string
, bestmatch
);
1403 /* Return t if the supplied string is an exact match (counting case);
1404 it does not require any change to be made. */
1405 if (matchcount
== 1 && !NILP (Fequal (bestmatch
, string
)))
1408 XSETFASTINT (zero
, 0); /* Else extract the part in which */
1409 XSETFASTINT (end
, bestmatchsize
); /* all completions agree. */
1410 return Fsubstring (bestmatch
, zero
, end
);
1413 DEFUN ("all-completions", Fall_completions
, Sall_completions
, 2, 4, 0,
1414 doc
: /* Search for partial matches to STRING in COLLECTION.
1415 Test each of the possible completions specified by COLLECTION
1416 to see if it begins with STRING. The possible completions may be
1417 strings or symbols. Symbols are converted to strings before testing,
1419 The value is a list of all the possible completions that match STRING.
1421 If COLLECTION is an alist, the keys (cars of elements) are the
1422 possible completions. If an element is not a cons cell, then the
1423 element itself is the possible completion.
1424 If COLLECTION is a hash-table, all the keys that are strings or symbols
1425 are the possible completions.
1426 If COLLECTION is an obarray, the names of all symbols in the obarray
1427 are the possible completions.
1429 COLLECTION can also be a function to do the completion itself.
1430 It receives three arguments: the values STRING, PREDICATE and t.
1431 Whatever it returns becomes the value of `all-completions'.
1433 If optional third argument PREDICATE is non-nil,
1434 it is used to test each possible match.
1435 The match is a candidate only if PREDICATE returns non-nil.
1436 The argument given to PREDICATE is the alist element
1437 or the symbol from the obarray. If COLLECTION is a hash-table,
1438 predicate is called with two arguments: the key and the value.
1439 Additionally to this predicate, `completion-regexp-list'
1440 is used to further constrain the set of candidates.
1442 An obsolete optional fourth argument HIDE-SPACES is still accepted for
1443 backward compatibility. If non-nil, strings in COLLECTION that start
1444 with a space are ignored unless STRING itself starts with a space. */)
1445 (Lisp_Object string
, Lisp_Object collection
, Lisp_Object predicate
, Lisp_Object hide_spaces
)
1447 Lisp_Object tail
, elt
, eltstring
;
1448 Lisp_Object allmatches
;
1449 int type
= HASH_TABLE_P (collection
) ? 3
1450 : VECTORP (collection
) ? 2
1451 : NILP (collection
) || (CONSP (collection
) && !FUNCTIONP (collection
));
1452 ptrdiff_t idx
= 0, obsize
= 0;
1453 ptrdiff_t bindcount
= -1;
1454 Lisp_Object bucket
, tem
, zero
;
1456 CHECK_STRING (string
);
1458 return call3 (collection
, string
, predicate
, Qt
);
1459 allmatches
= bucket
= Qnil
;
1460 zero
= make_number (0);
1462 /* If COLLECTION is not a list, set TAIL just for gc pro. */
1466 collection
= check_obarray (collection
);
1467 obsize
= ASIZE (collection
);
1468 bucket
= AREF (collection
, idx
);
1473 /* Get the next element of the alist, obarray, or hash-table. */
1474 /* Exit the loop if the elements are all used up. */
1475 /* elt gets the alist element or symbol.
1476 eltstring gets the name to check as a completion. */
1483 eltstring
= CONSP (elt
) ? XCAR (elt
) : elt
;
1488 if (!EQ (bucket
, zero
))
1490 if (!SYMBOLP (bucket
))
1491 error ("Bad data in guts of obarray");
1494 if (XSYMBOL (bucket
)->next
)
1495 XSETSYMBOL (bucket
, XSYMBOL (bucket
)->next
);
1497 XSETFASTINT (bucket
, 0);
1499 else if (++idx
>= obsize
)
1503 bucket
= AREF (collection
, idx
);
1507 else /* if (type == 3) */
1509 while (idx
< HASH_TABLE_SIZE (XHASH_TABLE (collection
))
1510 && NILP (HASH_HASH (XHASH_TABLE (collection
), idx
)))
1512 if (idx
>= HASH_TABLE_SIZE (XHASH_TABLE (collection
)))
1515 elt
= eltstring
= HASH_KEY (XHASH_TABLE (collection
), idx
++);
1518 /* Is this element a possible completion? */
1520 if (SYMBOLP (eltstring
))
1521 eltstring
= Fsymbol_name (eltstring
);
1523 if (STRINGP (eltstring
)
1524 && SCHARS (string
) <= SCHARS (eltstring
)
1525 /* If HIDE_SPACES, reject alternatives that start with space
1526 unless the input starts with space. */
1527 && (NILP (hide_spaces
)
1528 || (SBYTES (string
) > 0
1529 && SREF (string
, 0) == ' ')
1530 || SREF (eltstring
, 0) != ' ')
1531 && (tem
= Fcompare_strings (eltstring
, zero
,
1532 make_number (SCHARS (string
)),
1534 make_number (SCHARS (string
)),
1535 completion_ignore_case
? Qt
: Qnil
),
1539 Lisp_Object regexps
;
1541 /* Ignore this element if it fails to match all the regexps. */
1543 for (regexps
= Vcompletion_regexp_list
; CONSP (regexps
);
1544 regexps
= XCDR (regexps
))
1546 if (bindcount
< 0) {
1547 bindcount
= SPECPDL_INDEX ();
1548 specbind (Qcase_fold_search
,
1549 completion_ignore_case
? Qt
: Qnil
);
1551 tem
= Fstring_match (XCAR (regexps
), eltstring
, zero
);
1555 if (CONSP (regexps
))
1559 /* Ignore this element if there is a predicate
1560 and the predicate doesn't like it. */
1562 if (!NILP (predicate
))
1564 if (EQ (predicate
, Qcommandp
))
1565 tem
= Fcommandp (elt
, Qnil
);
1568 if (bindcount
>= 0) {
1569 unbind_to (bindcount
, Qnil
);
1573 ? call2 (predicate
, elt
,
1574 HASH_VALUE (XHASH_TABLE (collection
), idx
- 1))
1575 : call1 (predicate
, elt
);
1577 if (NILP (tem
)) continue;
1579 /* Ok => put it on the list. */
1580 allmatches
= Fcons (eltstring
, allmatches
);
1584 if (bindcount
>= 0) {
1585 unbind_to (bindcount
, Qnil
);
1589 return Fnreverse (allmatches
);
1592 DEFUN ("completing-read", Fcompleting_read
, Scompleting_read
, 2, 8, 0,
1593 doc
: /* Read a string in the minibuffer, with completion.
1594 PROMPT is a string to prompt with; normally it ends in a colon and a space.
1595 COLLECTION can be a list of strings, an alist, an obarray or a hash table.
1596 COLLECTION can also be a function to do the completion itself.
1597 PREDICATE limits completion to a subset of COLLECTION.
1598 See `try-completion' and `all-completions' for more details
1599 on completion, COLLECTION, and PREDICATE.
1601 REQUIRE-MATCH can take the following values:
1602 - t means that the user is not allowed to exit unless
1603 the input is (or completes to) an element of COLLECTION or is null.
1604 - nil means that the user can exit with any input.
1605 - `confirm' means that the user can exit with any input, but she needs
1606 to confirm her choice if the input is not an element of COLLECTION.
1607 - `confirm-after-completion' means that the user can exit with any
1608 input, but she needs to confirm her choice if she called
1609 `minibuffer-complete' right before `minibuffer-complete-and-exit'
1610 and the input is not an element of COLLECTION.
1611 - anything else behaves like t except that typing RET does not exit if it
1612 does non-null completion.
1614 If the input is null, `completing-read' returns DEF, or the first element
1615 of the list of default values, or an empty string if DEF is nil,
1616 regardless of the value of REQUIRE-MATCH.
1618 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially,
1619 with point positioned at the end.
1620 If it is (STRING . POSITION), the initial input is STRING, but point
1621 is placed at _zero-indexed_ position POSITION in STRING. (*Note*
1622 that this is different from `read-from-minibuffer' and related
1623 functions, which use one-indexing for POSITION.) This feature is
1624 deprecated--it is best to pass nil for INITIAL-INPUT and supply the
1625 default value DEF instead. The user can yank the default value into
1626 the minibuffer easily using \\<minibuffer-local-map>\\[next-history-element].
1628 HIST, if non-nil, specifies a history list and optionally the initial
1629 position in the list. It can be a symbol, which is the history list
1630 variable to use, or it can be a cons cell (HISTVAR . HISTPOS). In
1631 that case, HISTVAR is the history list variable to use, and HISTPOS
1632 is the initial position (the position in the list used by the
1633 minibuffer history commands). For consistency, you should also
1634 specify that element of the history as the value of
1635 INITIAL-INPUT. (This is the only case in which you should use
1636 INITIAL-INPUT instead of DEF.) Positions are counted starting from
1637 1 at the beginning of the list. The variable `history-length'
1638 controls the maximum length of a history list.
1640 DEF, if non-nil, is the default value or the list of default values.
1642 If INHERIT-INPUT-METHOD is non-nil, the minibuffer inherits
1643 the current input method and the setting of `enable-multibyte-characters'.
1645 Completion ignores case if the ambient value of
1646 `completion-ignore-case' is non-nil.
1648 See also `completing-read-function'. */)
1649 (Lisp_Object prompt
, Lisp_Object collection
, Lisp_Object predicate
, Lisp_Object require_match
, Lisp_Object initial_input
, Lisp_Object hist
, Lisp_Object def
, Lisp_Object inherit_input_method
)
1651 return CALLN (Ffuncall
,
1652 Fsymbol_value (intern ("completing-read-function")),
1653 prompt
, collection
, predicate
, require_match
, initial_input
,
1654 hist
, def
, inherit_input_method
);
1657 /* Test whether TXT is an exact completion. */
1658 DEFUN ("test-completion", Ftest_completion
, Stest_completion
, 2, 3, 0,
1659 doc
: /* Return non-nil if STRING is a valid completion.
1660 Takes the same arguments as `all-completions' and `try-completion'.
1661 If COLLECTION is a function, it is called with three arguments:
1662 the values STRING, PREDICATE and `lambda'. */)
1663 (Lisp_Object string
, Lisp_Object collection
, Lisp_Object predicate
)
1665 Lisp_Object regexps
, tail
, tem
= Qnil
;
1668 CHECK_STRING (string
);
1670 if (NILP (collection
) || (CONSP (collection
) && !FUNCTIONP (collection
)))
1672 tem
= Fassoc_string (string
, collection
, completion_ignore_case
? Qt
: Qnil
);
1676 else if (VECTORP (collection
))
1678 /* Bypass intern-soft as that loses for nil. */
1679 tem
= oblookup (collection
,
1685 if (STRING_MULTIBYTE (string
))
1686 string
= Fstring_make_unibyte (string
);
1688 string
= Fstring_make_multibyte (string
);
1690 tem
= oblookup (collection
,
1696 if (completion_ignore_case
&& !SYMBOLP (tem
))
1698 for (i
= ASIZE (collection
) - 1; i
>= 0; i
--)
1700 tail
= AREF (collection
, i
);
1704 if (EQ (Fcompare_strings (string
, make_number (0), Qnil
,
1705 Fsymbol_name (tail
),
1706 make_number (0) , Qnil
, Qt
),
1712 if (XSYMBOL (tail
)->next
== 0)
1714 XSETSYMBOL (tail
, XSYMBOL (tail
)->next
);
1722 else if (HASH_TABLE_P (collection
))
1724 struct Lisp_Hash_Table
*h
= XHASH_TABLE (collection
);
1725 Lisp_Object key
= Qnil
;
1726 i
= hash_lookup (h
, string
, NULL
);
1728 tem
= HASH_KEY (h
, i
);
1730 for (i
= 0; i
< HASH_TABLE_SIZE (h
); ++i
)
1731 if (!NILP (HASH_HASH (h
, i
))
1732 && (key
= HASH_KEY (h
, i
),
1733 SYMBOLP (key
) ? key
= Fsymbol_name (key
) : key
,
1735 && EQ (Fcompare_strings (string
, make_number (0), Qnil
,
1736 key
, make_number (0) , Qnil
,
1737 completion_ignore_case
? Qt
: Qnil
),
1747 return call3 (collection
, string
, predicate
, Qlambda
);
1749 /* Reject this element if it fails to match all the regexps. */
1750 if (CONSP (Vcompletion_regexp_list
))
1752 ptrdiff_t count
= SPECPDL_INDEX ();
1753 specbind (Qcase_fold_search
, completion_ignore_case
? Qt
: Qnil
);
1754 for (regexps
= Vcompletion_regexp_list
; CONSP (regexps
);
1755 regexps
= XCDR (regexps
))
1757 if (NILP (Fstring_match (XCAR (regexps
),
1758 SYMBOLP (tem
) ? string
: tem
,
1760 return unbind_to (count
, Qnil
);
1762 unbind_to (count
, Qnil
);
1765 /* Finally, check the predicate. */
1766 if (!NILP (predicate
))
1768 return HASH_TABLE_P (collection
)
1769 ? call2 (predicate
, tem
, HASH_VALUE (XHASH_TABLE (collection
), i
))
1770 : call1 (predicate
, tem
);
1776 DEFUN ("internal-complete-buffer", Finternal_complete_buffer
, Sinternal_complete_buffer
, 3, 3, 0,
1777 doc
: /* Perform completion on buffer names.
1778 STRING and PREDICATE have the same meanings as in `try-completion',
1779 `all-completions', and `test-completion'.
1781 If FLAG is nil, invoke `try-completion'; if it is t, invoke
1782 `all-completions'; otherwise invoke `test-completion'. */)
1783 (Lisp_Object string
, Lisp_Object predicate
, Lisp_Object flag
)
1786 return Ftry_completion (string
, Vbuffer_alist
, predicate
);
1787 else if (EQ (flag
, Qt
))
1789 Lisp_Object res
= Fall_completions (string
, Vbuffer_alist
, predicate
, Qnil
);
1790 if (SCHARS (string
) > 0)
1793 { /* Strip out internal buffers. */
1794 Lisp_Object bufs
= res
;
1795 /* First, look for a non-internal buffer in `res'. */
1796 while (CONSP (bufs
) && SREF (XCAR (bufs
), 0) == ' ')
1799 return (EQ (Flength (res
), Flength (Vbuffer_alist
))
1800 /* If all bufs are internal don't strip them out. */
1803 while (CONSP (XCDR (bufs
)))
1804 if (SREF (XCAR (XCDR (bufs
)), 0) == ' ')
1805 XSETCDR (bufs
, XCDR (XCDR (bufs
)));
1811 else if (EQ (flag
, Qlambda
))
1812 return Ftest_completion (string
, Vbuffer_alist
, predicate
);
1813 else if (EQ (flag
, Qmetadata
))
1814 return list2 (Qmetadata
, Fcons (Qcategory
, Qbuffer
));
1819 /* Like assoc but assumes KEY is a string, and ignores case if appropriate. */
1821 DEFUN ("assoc-string", Fassoc_string
, Sassoc_string
, 2, 3, 0,
1822 doc
: /* Like `assoc' but specifically for strings (and symbols).
1824 This returns the first element of LIST whose car matches the string or
1825 symbol KEY, or nil if no match exists. When performing the
1826 comparison, symbols are first converted to strings, and unibyte
1827 strings to multibyte. If the optional arg CASE-FOLD is non-nil, case
1830 Unlike `assoc', KEY can also match an entry in LIST consisting of a
1831 single string, rather than a cons cell whose car is a string. */)
1832 (register Lisp_Object key
, Lisp_Object list
, Lisp_Object case_fold
)
1834 register Lisp_Object tail
;
1837 key
= Fsymbol_name (key
);
1839 for (tail
= list
; CONSP (tail
); tail
= XCDR (tail
))
1841 register Lisp_Object elt
, tem
, thiscar
;
1843 thiscar
= CONSP (elt
) ? XCAR (elt
) : elt
;
1844 if (SYMBOLP (thiscar
))
1845 thiscar
= Fsymbol_name (thiscar
);
1846 else if (!STRINGP (thiscar
))
1848 tem
= Fcompare_strings (thiscar
, make_number (0), Qnil
,
1849 key
, make_number (0), Qnil
,
1859 DEFUN ("minibuffer-depth", Fminibuffer_depth
, Sminibuffer_depth
, 0, 0, 0,
1860 doc
: /* Return current depth of activations of minibuffer, a nonnegative integer. */)
1863 return make_number (minibuf_level
);
1866 DEFUN ("minibuffer-prompt", Fminibuffer_prompt
, Sminibuffer_prompt
, 0, 0, 0,
1867 doc
: /* Return the prompt string of the currently-active minibuffer.
1868 If no minibuffer is active, return nil. */)
1871 return Fcopy_sequence (minibuf_prompt
);
1876 init_minibuf_once (void)
1878 Vminibuffer_list
= Qnil
;
1879 staticpro (&Vminibuffer_list
);
1883 syms_of_minibuf (void)
1886 minibuf_prompt
= Qnil
;
1887 staticpro (&minibuf_prompt
);
1889 minibuf_save_list
= Qnil
;
1890 staticpro (&minibuf_save_list
);
1892 DEFSYM (Qcompletion_ignore_case
, "completion-ignore-case");
1893 DEFSYM (Qminibuffer_default
, "minibuffer-default");
1894 Fset (Qminibuffer_default
, Qnil
);
1896 DEFSYM (Qminibuffer_completion_table
, "minibuffer-completion-table");
1898 staticpro (&last_minibuf_string
);
1899 last_minibuf_string
= Qnil
;
1901 DEFSYM (Qminibuffer_history
, "minibuffer-history");
1902 DEFSYM (Qbuffer_name_history
, "buffer-name-history");
1903 Fset (Qbuffer_name_history
, Qnil
);
1905 DEFSYM (Qcustom_variable_p
, "custom-variable-p");
1907 /* Normal hooks for entry to and exit from minibuffer. */
1908 DEFSYM (Qminibuffer_setup_hook
, "minibuffer-setup-hook");
1909 DEFSYM (Qminibuffer_exit_hook
, "minibuffer-exit-hook");
1911 /* The maximum length of a minibuffer history. */
1912 DEFSYM (Qhistory_length
, "history-length");
1914 DEFSYM (Qcurrent_input_method
, "current-input-method");
1915 DEFSYM (Qactivate_input_method
, "activate-input-method");
1916 DEFSYM (Qcase_fold_search
, "case-fold-search");
1917 DEFSYM (Qmetadata
, "metadata");
1919 DEFVAR_LISP ("read-expression-history", Vread_expression_history
,
1920 doc
: /* A history list for arguments that are Lisp expressions to evaluate.
1921 For example, `eval-expression' uses this. */);
1922 Vread_expression_history
= Qnil
;
1924 DEFVAR_LISP ("read-buffer-function", Vread_buffer_function
,
1925 doc
: /* If this is non-nil, `read-buffer' does its work by calling this function.
1926 The function is called with the arguments passed to `read-buffer'. */);
1927 Vread_buffer_function
= Qnil
;
1929 DEFVAR_BOOL ("read-buffer-completion-ignore-case",
1930 read_buffer_completion_ignore_case
,
1931 doc
: /* Non-nil means completion ignores case when reading a buffer name. */);
1932 read_buffer_completion_ignore_case
= 0;
1934 DEFVAR_LISP ("minibuffer-setup-hook", Vminibuffer_setup_hook
,
1935 doc
: /* Normal hook run just after entry to minibuffer. */);
1936 Vminibuffer_setup_hook
= Qnil
;
1938 DEFVAR_LISP ("minibuffer-exit-hook", Vminibuffer_exit_hook
,
1939 doc
: /* Normal hook run just after exit from minibuffer. */);
1940 Vminibuffer_exit_hook
= Qnil
;
1942 DEFVAR_LISP ("history-length", Vhistory_length
,
1943 doc
: /* Maximum length of history lists before truncation takes place.
1944 A number means truncate to that length; truncation deletes old
1945 elements, and is done just after inserting a new element.
1946 A value of t means no truncation.
1948 This variable only affects history lists that don't specify their own
1949 maximum lengths. Setting the `history-length' property of a history
1950 variable overrides this default. */);
1951 XSETFASTINT (Vhistory_length
, 100);
1953 DEFVAR_BOOL ("history-delete-duplicates", history_delete_duplicates
,
1954 doc
: /* Non-nil means to delete duplicates in history.
1955 If set to t when adding a new history element, all previous identical
1956 elements are deleted from the history list. */);
1957 history_delete_duplicates
= 0;
1959 DEFVAR_LISP ("history-add-new-input", Vhistory_add_new_input
,
1960 doc
: /* Non-nil means to add new elements in history.
1961 If set to nil, minibuffer reading functions don't add new elements to the
1962 history list, so it is possible to do this afterwards by calling
1963 `add-to-history' explicitly. */);
1964 Vhistory_add_new_input
= Qt
;
1966 DEFVAR_BOOL ("completion-ignore-case", completion_ignore_case
,
1967 doc
: /* Non-nil means don't consider case significant in completion.
1968 For file-name completion, `read-file-name-completion-ignore-case'
1969 controls the behavior, rather than this variable.
1970 For buffer name completion, `read-buffer-completion-ignore-case'
1971 controls the behavior, rather than this variable. */);
1972 completion_ignore_case
= 0;
1974 DEFVAR_BOOL ("enable-recursive-minibuffers", enable_recursive_minibuffers
,
1975 doc
: /* Non-nil means to allow minibuffer commands while in the minibuffer.
1976 This variable makes a difference whenever the minibuffer window is active. */);
1977 enable_recursive_minibuffers
= 0;
1979 DEFVAR_LISP ("minibuffer-completion-table", Vminibuffer_completion_table
,
1980 doc
: /* Alist or obarray used for completion in the minibuffer.
1981 This becomes the ALIST argument to `try-completion' and `all-completions'.
1982 The value can also be a list of strings or a hash table.
1984 The value may alternatively be a function, which is given three arguments:
1985 STRING, the current buffer contents;
1986 PREDICATE, the predicate for filtering possible matches;
1987 CODE, which says what kind of things to do.
1988 CODE can be nil, t or `lambda':
1989 nil -- return the best completion of STRING, or nil if there is none.
1990 t -- return a list of all possible completions of STRING.
1991 lambda -- return t if STRING is a valid completion as it stands. */);
1992 Vminibuffer_completion_table
= Qnil
;
1994 DEFVAR_LISP ("minibuffer-completion-predicate", Vminibuffer_completion_predicate
,
1995 doc
: /* Within call to `completing-read', this holds the PREDICATE argument. */);
1996 Vminibuffer_completion_predicate
= Qnil
;
1998 DEFVAR_LISP ("minibuffer-completion-confirm", Vminibuffer_completion_confirm
,
1999 doc
: /* Whether to demand confirmation of completion before exiting minibuffer.
2000 If nil, confirmation is not required.
2001 If the value is `confirm', the user may exit with an input that is not
2002 a valid completion alternative, but Emacs asks for confirmation.
2003 If the value is `confirm-after-completion', the user may exit with an
2004 input that is not a valid completion alternative, but Emacs asks for
2005 confirmation if the user submitted the input right after any of the
2006 completion commands listed in `minibuffer-confirm-exit-commands'. */);
2007 Vminibuffer_completion_confirm
= Qnil
;
2009 DEFVAR_LISP ("minibuffer-completing-file-name",
2010 Vminibuffer_completing_file_name
,
2011 doc
: /* Non-nil means completing file names. */);
2012 Vminibuffer_completing_file_name
= Qnil
;
2014 DEFVAR_LISP ("minibuffer-help-form", Vminibuffer_help_form
,
2015 doc
: /* Value that `help-form' takes on inside the minibuffer. */);
2016 Vminibuffer_help_form
= Qnil
;
2018 DEFVAR_LISP ("minibuffer-history-variable", Vminibuffer_history_variable
,
2019 doc
: /* History list symbol to add minibuffer values to.
2020 Each string of minibuffer input, as it appears on exit from the minibuffer,
2022 (set minibuffer-history-variable
2023 (cons STRING (symbol-value minibuffer-history-variable))) */);
2024 XSETFASTINT (Vminibuffer_history_variable
, 0);
2026 DEFVAR_LISP ("minibuffer-history-position", Vminibuffer_history_position
,
2027 doc
: /* Current position of redoing in the history list. */);
2028 Vminibuffer_history_position
= Qnil
;
2030 DEFVAR_BOOL ("minibuffer-auto-raise", minibuffer_auto_raise
,
2031 doc
: /* Non-nil means entering the minibuffer raises the minibuffer's frame.
2032 Some uses of the echo area also raise that frame (since they use it too). */);
2033 minibuffer_auto_raise
= 0;
2035 DEFVAR_LISP ("completion-regexp-list", Vcompletion_regexp_list
,
2036 doc
: /* List of regexps that should restrict possible completions.
2037 The basic completion functions only consider a completion acceptable
2038 if it matches all regular expressions in this list, with
2039 `case-fold-search' bound to the value of `completion-ignore-case'.
2040 See Info node `(elisp)Basic Completion', for a description of these
2042 Vcompletion_regexp_list
= Qnil
;
2044 DEFVAR_BOOL ("minibuffer-allow-text-properties",
2045 minibuffer_allow_text_properties
,
2046 doc
: /* Non-nil means `read-from-minibuffer' should not discard text properties.
2047 This also affects `read-string', but it does not affect `read-minibuffer',
2048 `read-no-blanks-input', or any of the functions that do minibuffer input
2049 with completion; they always discard text properties. */);
2050 minibuffer_allow_text_properties
= 0;
2052 DEFVAR_LISP ("minibuffer-prompt-properties", Vminibuffer_prompt_properties
,
2053 doc
: /* Text properties that are added to minibuffer prompts.
2054 These are in addition to the basic `field' property, and stickiness
2056 Vminibuffer_prompt_properties
= list2 (Qread_only
, Qt
);
2058 DEFVAR_LISP ("read-hide-char", Vread_hide_char
,
2059 doc
: /* Whether to hide input characters in noninteractive mode.
2060 It must be a character, which will be used to mask the input
2061 characters. This variable should never be set globally. */);
2062 Vread_hide_char
= Qnil
;
2064 defsubr (&Sactive_minibuffer_window
);
2065 defsubr (&Sset_minibuffer_window
);
2066 defsubr (&Sread_from_minibuffer
);
2067 defsubr (&Sread_string
);
2068 defsubr (&Sread_command
);
2069 defsubr (&Sread_variable
);
2070 defsubr (&Sinternal_complete_buffer
);
2071 defsubr (&Sread_buffer
);
2072 defsubr (&Sread_no_blanks_input
);
2073 defsubr (&Sminibuffer_depth
);
2074 defsubr (&Sminibuffer_prompt
);
2076 defsubr (&Sminibufferp
);
2077 defsubr (&Sminibuffer_prompt_end
);
2078 defsubr (&Sminibuffer_contents
);
2079 defsubr (&Sminibuffer_contents_no_properties
);
2080 defsubr (&Sminibuffer_completion_contents
);
2082 defsubr (&Stry_completion
);
2083 defsubr (&Sall_completions
);
2084 defsubr (&Stest_completion
);
2085 defsubr (&Sassoc_string
);
2086 defsubr (&Scompleting_read
);