This source file includes following definitions.
- minibuf_follows_frame
- minibuf_stays_put
- minibuf_moves_frame_when_opened
- choose_minibuf_frame
- minibuffer_ent_greater
- zip_minibuffer_stacks
- move_minibuffers_onto_frame
- DEFUN
- DEFUN
- string_to_object
- read_minibuf_noninteractive
- live_minibuffer_p
- DEFUN
- DEFUN
- this_minibuffer_depth
- DEFUN
- DEFUN
- DEFUN
- DEFUN
- read_minibuf
- is_minibuffer
- nth_minibuffer
- set_minibuffer_mode
- get_minibuffer
- minibuf_c_loop_level
- run_exit_minibuf_hook
- read_minibuf_unwind
- minibuffer_unwind
- barf_if_interaction_inhibited
- DEFUN
- match_regexps
- DEFUN
- DEFUN
- set_initial_minibuffer_mode
- init_minibuf_once
- init_minibuf_once_for_pdumper
- syms_of_minibuf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include <config.h>
22 #include <errno.h>
23
24 #include <binary-io.h>
25
26 #include "lisp.h"
27 #include "character.h"
28 #include "buffer.h"
29 #include "keyboard.h"
30 #include "frame.h"
31 #include "window.h"
32 #include "keymap.h"
33 #include "sysstdio.h"
34 #include "systty.h"
35 #include "pdumper.h"
36
37 #ifdef HAVE_NTGUI
38 #include "w32term.h"
39 #endif
40
41
42
43
44
45
46
47 Lisp_Object Vminibuffer_list;
48 static Lisp_Object Vcommand_loop_level_list;
49
50
51
52 static Lisp_Object minibuf_save_list;
53
54
55
56 EMACS_INT minibuf_level;
57
58
59
60 Lisp_Object last_minibuf_string;
61
62
63
64 static Lisp_Object minibuf_prompt;
65
66
67
68
69
70 static Lisp_Object MB_frame;
71
72
73
74
75 static ptrdiff_t minibuf_prompt_width;
76
77 static Lisp_Object nth_minibuffer (EMACS_INT depth);
78 static EMACS_INT minibuf_c_loop_level (EMACS_INT depth);
79 static void set_minibuffer_mode (Lisp_Object buf, EMACS_INT depth);
80 static bool live_minibuffer_p (Lisp_Object);
81
82
83
84
85 static bool
86 minibuf_follows_frame (void)
87 {
88 return EQ (Fdefault_toplevel_value (Qminibuffer_follows_selected_frame),
89 Qt);
90 }
91
92 #if 0
93
94
95 static bool
96 minibuf_stays_put (void)
97 {
98 return NILP (Fdefault_toplevel_value (Qminibuffer_follows_selected_frame));
99 }
100 #endif
101
102
103
104 static bool
105 minibuf_moves_frame_when_opened (void)
106 {
107 return !NILP (Fdefault_toplevel_value (Qminibuffer_follows_selected_frame));
108 }
109
110
111
112
113
114 static void
115 choose_minibuf_frame (void)
116 {
117 if (FRAMEP (selected_frame)
118 && FRAME_LIVE_P (XFRAME (selected_frame))
119 && WINDOW_LIVE_P (XFRAME (selected_frame)->minibuffer_window)
120 && !EQ (minibuf_window, XFRAME (selected_frame)->minibuffer_window))
121 {
122 struct frame *sf = XFRAME (selected_frame);
123
124
125
126
127
128
129 minibuf_window = sf->minibuffer_window;
130 }
131 }
132
133
134
135
136 static bool
137 minibuffer_ent_greater (Lisp_Object ent1, Lisp_Object ent2)
138 {
139 return this_minibuffer_depth (Fcar (ent1))
140 > this_minibuffer_depth (Fcar (ent2)) ;
141 }
142
143
144
145
146
147
148
149 static void
150 zip_minibuffer_stacks (Lisp_Object dest_window, Lisp_Object source_window)
151 {
152 struct window *dw = XWINDOW (dest_window);
153 struct window *sw = XWINDOW (source_window);
154 Lisp_Object acc;
155 Lisp_Object d_ent;
156
157 if (!live_minibuffer_p (dw->contents)
158 && NILP (dw->prev_buffers))
159 {
160 set_window_buffer (dest_window, sw->contents, 0, 0);
161 Fset_window_start (dest_window, Fwindow_start (source_window), Qnil);
162 Fset_window_point (dest_window, Fwindow_point (source_window));
163 dw->prev_buffers = sw->prev_buffers;
164 set_window_buffer (source_window, nth_minibuffer (0), 0, 0);
165 sw->prev_buffers = Qnil;
166 return;
167 }
168
169 if (live_minibuffer_p (dw->contents))
170 call1 (Qpush_window_buffer_onto_prev, dest_window);
171 if (live_minibuffer_p (sw->contents))
172 call1 (Qpush_window_buffer_onto_prev, source_window);
173 acc = merge_c (dw->prev_buffers, sw->prev_buffers, minibuffer_ent_greater);
174
175 if (!NILP (acc))
176 {
177 d_ent = Fcar (acc);
178 acc = Fcdr (acc);
179 set_window_buffer (dest_window, Fcar (d_ent), 0, 0);
180 Fset_window_start (dest_window, Fcar (Fcdr (d_ent)), Qnil);
181 Fset_window_point (dest_window, Fcar (Fcdr (Fcdr (d_ent))));
182 }
183 dw->prev_buffers = acc;
184 sw->prev_buffers = Qnil;
185 set_window_buffer (source_window, nth_minibuffer (0), 0, 0);
186 }
187
188
189
190
191
192
193
194 void
195 move_minibuffers_onto_frame (struct frame *of, Lisp_Object frame,
196 bool for_deletion)
197 {
198 struct frame *f = XFRAME (frame);
199
200 minibuf_window = f->minibuffer_window;
201 if (!(minibuf_level
202 && (for_deletion || minibuf_follows_frame () || FRAME_INITIAL_P (of))))
203 return;
204 if (FRAME_LIVE_P (f)
205 && !EQ (f->minibuffer_window, of->minibuffer_window)
206 && WINDOW_LIVE_P (f->minibuffer_window)
207 && WINDOW_LIVE_P (of->minibuffer_window))
208 {
209 zip_minibuffer_stacks (f->minibuffer_window, of->minibuffer_window);
210 if (for_deletion && XFRAME (MB_frame) != of)
211 MB_frame = frame;
212 }
213 }
214
215 DEFUN ("active-minibuffer-window", Factive_minibuffer_window,
216 Sactive_minibuffer_window, 0, 0, 0,
217 doc: )
218 (void)
219 {
220 Lisp_Object frames, frame;
221 struct frame *f;
222 Lisp_Object innermost_MB;
223
224 if (!minibuf_level)
225 return Qnil;
226
227 innermost_MB = nth_minibuffer (minibuf_level);
228 if (NILP (innermost_MB))
229 emacs_abort ();
230 FOR_EACH_FRAME (frames, frame)
231 {
232 f = XFRAME (frame);
233 if (FRAME_LIVE_P (f)
234 && WINDOW_LIVE_P (f->minibuffer_window)
235 && EQ (XWINDOW (f->minibuffer_window)->contents, innermost_MB))
236 return f->minibuffer_window;
237 }
238 return minibuf_window;
239 }
240
241 DEFUN ("set-minibuffer-window", Fset_minibuffer_window,
242 Sset_minibuffer_window, 1, 1, 0,
243 doc:
244
245 )
246 (Lisp_Object window)
247 {
248 CHECK_WINDOW (window);
249 if (! MINI_WINDOW_P (XWINDOW (window)))
250 error ("Window is not a minibuffer window");
251
252 minibuf_window = window;
253
254 return window;
255 }
256
257
258
259
260 static void read_minibuf_unwind (void);
261 static void minibuffer_unwind (void);
262 static void run_exit_minibuf_hook (Lisp_Object minibuf);
263
264
265
266
267
268 static Lisp_Object
269 string_to_object (Lisp_Object val, Lisp_Object defalt)
270 {
271 Lisp_Object expr_and_pos;
272 ptrdiff_t pos;
273
274 if (STRINGP (val) && SCHARS (val) == 0)
275 {
276 if (STRINGP (defalt))
277 val = defalt;
278 else if (CONSP (defalt) && STRINGP (XCAR (defalt)))
279 val = XCAR (defalt);
280 }
281
282 expr_and_pos = Fread_from_string (val, Qnil, Qnil);
283 pos = XFIXNUM (Fcdr (expr_and_pos));
284 if (pos != SCHARS (val))
285 {
286
287
288 ptrdiff_t i;
289 pos = string_char_to_byte (val, pos);
290 for (i = pos; i < SBYTES (val); i++)
291 {
292 int c = SREF (val, i);
293 if (c != ' ' && c != '\t' && c != '\n')
294 xsignal1 (Qinvalid_read_syntax,
295 build_string ("Trailing garbage following expression"));
296 }
297 }
298
299 val = Fcar (expr_and_pos);
300 return val;
301 }
302
303
304
305
306
307 static Lisp_Object
308 read_minibuf_noninteractive (Lisp_Object prompt, bool expflag,
309 Lisp_Object defalt)
310 {
311 ptrdiff_t size, len;
312 char *line;
313 Lisp_Object val;
314 int c;
315 unsigned char hide_char = 0;
316 struct emacs_tty etty;
317 bool etty_valid UNINIT;
318
319
320 if (CHARACTERP (Vread_hide_char))
321 hide_char = XFIXNAT (Vread_hide_char);
322
323
324 if (hide_char)
325 {
326 etty_valid = emacs_get_tty (STDIN_FILENO, &etty) == 0;
327 if (etty_valid)
328 set_binary_mode (STDIN_FILENO, O_BINARY);
329 suppress_echo_on_tty (STDIN_FILENO);
330 }
331
332 fwrite (SDATA (prompt), 1, SBYTES (prompt), stdout);
333 fflush (stdout);
334
335 val = Qnil;
336 size = 100;
337 len = 0;
338 line = xmalloc (size);
339
340 while ((c = getchar ()) != '\n' && c != '\r')
341 {
342 if (c == EOF)
343 {
344 if (errno != EINTR)
345 break;
346 }
347 else
348 {
349 if (hide_char)
350 putchar (hide_char);
351 if (len == size)
352 line = xpalloc (line, &size, 1, -1, sizeof *line);
353 line[len++] = c;
354 }
355 }
356
357
358 if (hide_char)
359 {
360 putc ('\n', stdout);
361 if (etty_valid)
362 {
363 emacs_set_tty (STDIN_FILENO, &etty, 0);
364 set_binary_mode (STDIN_FILENO, O_TEXT);
365 }
366 }
367
368 if (len || c == '\n' || c == '\r')
369 {
370 val = make_string (line, len);
371 xfree (line);
372 }
373 else
374 {
375 xfree (line);
376 xsignal1 (Qend_of_file, build_string ("Error reading from stdin"));
377 }
378
379
380 if (expflag)
381 val = string_to_object (val, CONSP (defalt) ? XCAR (defalt) : defalt);
382
383 return val;
384 }
385
386
387 static bool
388 live_minibuffer_p (Lisp_Object buffer)
389 {
390 Lisp_Object tem;
391 EMACS_INT i;
392
393 if (EQ (buffer, Fcar (Vminibuffer_list)))
394
395 return false;
396 tem = Fcdr (Vminibuffer_list);
397 for (i = 1; i <= minibuf_level; i++, tem = Fcdr (tem))
398 if (EQ (Fcar (tem), buffer))
399 return true;
400 return false;
401 }
402
403 DEFUN ("minibufferp", Fminibufferp,
404 Sminibufferp, 0, 2, 0,
405 doc:
406
407
408 )
409 (Lisp_Object buffer, Lisp_Object live)
410 {
411 if (NILP (buffer))
412 buffer = Fcurrent_buffer ();
413 else if (STRINGP (buffer))
414 buffer = Fget_buffer (buffer);
415 else
416 CHECK_BUFFER (buffer);
417
418 return (NILP (live)
419 ? !NILP (Fmemq (buffer, Vminibuffer_list))
420 : live_minibuffer_p (buffer))
421 ? Qt : Qnil;
422 }
423
424 DEFUN ("innermost-minibuffer-p", Finnermost_minibuffer_p,
425 Sinnermost_minibuffer_p, 0, 1, 0,
426 doc:
427 )
428 (Lisp_Object buffer)
429 {
430 if (NILP (buffer))
431 buffer = Fcurrent_buffer ();
432 return BASE_EQ (buffer, (Fcar (Fnthcdr (make_fixnum (minibuf_level),
433 Vminibuffer_list))))
434 ? Qt
435 : Qnil;
436 }
437
438 DEFUN ("minibuffer-innermost-command-loop-p", Fminibuffer_innermost_command_loop_p,
439 Sminibuffer_innermost_command_loop_p, 0, 1, 0,
440 doc:
441 )
442 (Lisp_Object buffer)
443 {
444 EMACS_INT depth;
445 if (NILP (buffer))
446 buffer = Fcurrent_buffer ();
447 depth = this_minibuffer_depth (buffer);
448 return depth && minibuf_c_loop_level (depth) == command_loop_level
449 ? Qt
450 : Qnil;
451 }
452
453
454
455
456 EMACS_INT
457 this_minibuffer_depth (Lisp_Object buffer)
458 {
459 EMACS_INT i;
460 Lisp_Object bufs;
461
462 if (NILP (buffer))
463 buffer = Fcurrent_buffer ();
464 for (i = 1, bufs = Fcdr (Vminibuffer_list);
465 i <= minibuf_level;
466 i++, bufs = Fcdr (bufs))
467 if (EQ (Fcar (bufs), buffer))
468 return i;
469 return 0;
470 }
471
472 DEFUN ("abort-minibuffers", Fabort_minibuffers, Sabort_minibuffers, 0, 0, "",
473 doc:
474
475 )
476 (void)
477 {
478 EMACS_INT minibuf_depth = this_minibuffer_depth (Qnil);
479 Lisp_Object array[2];
480 AUTO_STRING (fmt, "Abort %s minibuffer levels? ");
481
482 if (!minibuf_depth)
483 error ("Not in a minibuffer");
484 if (NILP (Fminibuffer_innermost_command_loop_p (Qnil)))
485 error ("Not in most nested command loop");
486 if (minibuf_depth < minibuf_level)
487 {
488 array[0] = fmt;
489 array[1] = make_fixnum (minibuf_level - minibuf_depth + 1);
490 if (!NILP (Fyes_or_no_p (Fformat (2, array))))
491 {
492
493
494
495
496
497 CALLN (Ffuncall, intern ("minibuffer-quit-recursive-edit"),
498 array[1]);
499 }
500 }
501 else
502 CALLN (Ffuncall, intern ("minibuffer-quit-recursive-edit"));
503 return Qnil;
504 }
505
506 DEFUN ("minibuffer-prompt-end", Fminibuffer_prompt_end,
507 Sminibuffer_prompt_end, 0, 0, 0,
508 doc:
509 )
510 (void)
511 {
512
513 Lisp_Object beg, end, tem;
514 beg = make_fixnum (BEGV);
515
516 tem = Fmemq (Fcurrent_buffer (), Vminibuffer_list);
517 if (NILP (tem))
518 return beg;
519
520 end = Ffield_end (beg, Qnil, Qnil);
521
522 if (XFIXNUM (end) == ZV && NILP (Fget_char_property (beg, Qfield, Qnil)))
523 return beg;
524 else
525 return end;
526 }
527
528 DEFUN ("minibuffer-contents", Fminibuffer_contents,
529 Sminibuffer_contents, 0, 0, 0,
530 doc:
531 )
532 (void)
533 {
534 ptrdiff_t prompt_end = XFIXNUM (Fminibuffer_prompt_end ());
535 return make_buffer_string (prompt_end, ZV, 1);
536 }
537
538 DEFUN ("minibuffer-contents-no-properties", Fminibuffer_contents_no_properties,
539 Sminibuffer_contents_no_properties, 0, 0, 0,
540 doc:
541 )
542 (void)
543 {
544 ptrdiff_t prompt_end = XFIXNUM (Fminibuffer_prompt_end ());
545 return make_buffer_string (prompt_end, ZV, 0);
546 }
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572 static Lisp_Object
573 read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
574 bool expflag,
575 Lisp_Object histvar, Lisp_Object histpos, Lisp_Object defalt,
576 bool allow_props, bool inherit_input_method)
577 {
578 Lisp_Object val;
579 specpdl_ref count = SPECPDL_INDEX ();
580 Lisp_Object mini_frame, ambient_dir, minibuffer, input_method;
581 Lisp_Object calling_frame = selected_frame;
582 Lisp_Object calling_window = selected_window;
583 Lisp_Object enable_multibyte;
584 EMACS_INT pos = 0;
585
586 Lisp_Object histstring;
587 Lisp_Object histval;
588
589 Lisp_Object empty_minibuf;
590
591 specbind (Qminibuffer_default, defalt);
592 specbind (Qinhibit_read_only, Qnil);
593
594
595
596
597
598 specbind (Qminibuffer_completing_file_name,
599 Vminibuffer_completing_file_name);
600 if (EQ (Vminibuffer_completing_file_name, Qlambda))
601 Vminibuffer_completing_file_name = Qnil;
602
603 #ifdef HAVE_WINDOW_SYSTEM
604 if (display_hourglass_p)
605 cancel_hourglass ();
606 #endif
607
608 if (!NILP (initial))
609 {
610 if (CONSP (initial))
611 {
612 Lisp_Object backup_n = XCDR (initial);
613 initial = XCAR (initial);
614 CHECK_STRING (initial);
615 if (!NILP (backup_n))
616 {
617 CHECK_FIXNUM (backup_n);
618
619 if (XFIXNUM (backup_n) < 1)
620
621 pos = - SCHARS (initial);
622 else
623 pos = XFIXNUM (backup_n) - 1 - SCHARS (initial);
624 }
625 }
626 else
627 CHECK_STRING (initial);
628 }
629 val = Qnil;
630 ambient_dir = BVAR (current_buffer, directory);
631 input_method = Qnil;
632 enable_multibyte = Qnil;
633
634 if (!STRINGP (prompt))
635 prompt = empty_unibyte_string;
636
637 if (!enable_recursive_minibuffers
638 && minibuf_level > 0)
639 {
640 Lisp_Object str
641 = build_string ("Command attempted to use minibuffer while in minibuffer");
642 if (EQ (selected_window, minibuf_window))
643 Fsignal (Quser_error, (list1 (str)));
644 else
645
646 Fthrow (Qexit, str);
647 }
648
649 if ((noninteractive
650
651
652 || (IS_DAEMON && DAEMON_RUNNING))
653 && NILP (Vexecuting_kbd_macro))
654 {
655 val = read_minibuf_noninteractive (prompt, expflag, defalt);
656 return unbind_to (count, val);
657 }
658
659
660
661
662
663 minibuffer = get_minibuffer (minibuf_level + 1);
664 minibuf_level++;
665
666
667
668
669
670 record_unwind_protect (restore_buffer, Fcurrent_buffer ());
671
672 choose_minibuf_frame ();
673 mini_frame = WINDOW_FRAME (XWINDOW (minibuf_window));
674
675 if (minibuf_level > 1
676 && WINDOW_LIVE_P (XFRAME (MB_frame)->minibuffer_window)
677 && !EQ (XWINDOW (XFRAME (selected_frame)->minibuffer_window)->frame,
678 MB_frame)
679 && minibuf_moves_frame_when_opened ()
680 && (!minibuf_follows_frame ()))
681 {
682 struct frame *of = XFRAME (MB_frame);
683
684 zip_minibuffer_stacks (minibuf_window, of->minibuffer_window);
685
686 if (MINI_WINDOW_P (XWINDOW (FRAME_SELECTED_WINDOW (of))))
687 Fset_frame_selected_window (MB_frame,
688 Fframe_first_window (MB_frame), Qnil);
689 }
690 MB_frame = XWINDOW (XFRAME (selected_frame)->minibuffer_window)->frame;
691 if (live_minibuffer_p (XWINDOW (minibuf_window)->contents))
692 call1 (Qpush_window_buffer_onto_prev, minibuf_window);
693
694 record_unwind_protect_void (minibuffer_unwind);
695 if (read_minibuffer_restore_windows)
696 record_unwind_protect (restore_window_configuration,
697 list3 (Fcurrent_window_configuration (Qnil),
698 Qt, Qt));
699
700
701
702 if (read_minibuffer_restore_windows &&
703 !EQ (mini_frame, selected_frame))
704 record_unwind_protect (restore_window_configuration,
705 list3 (Fcurrent_window_configuration (mini_frame),
706 Qnil, Qt));
707
708
709
710 Fmake_frame_visible (mini_frame);
711
712 if (minibuffer_auto_raise)
713 Fraise_frame (mini_frame);
714
715 temporarily_switch_to_single_kboard (XFRAME (mini_frame));
716
717
718
719
720
721
722
723 minibuf_save_list
724 = Fcons (Voverriding_local_map,
725 Fcons (minibuf_window,
726 Fcons (calling_frame,
727 Fcons (calling_window,
728 minibuf_save_list))));
729 minibuf_save_list
730 = Fcons (minibuf_prompt,
731 Fcons (make_fixnum (minibuf_prompt_width),
732 Fcons (Vhelp_form,
733 Fcons (Vcurrent_prefix_arg,
734 Fcons (Vminibuffer_history_position,
735 Fcons (Vminibuffer_history_variable,
736 minibuf_save_list))))));
737 minibuf_save_list
738 = Fcons (Fthis_command_keys_vector (), minibuf_save_list);
739
740 record_unwind_protect_void (read_minibuf_unwind);
741
742
743
744
745
746 record_unwind_protect (run_exit_minibuf_hook, minibuffer);
747
748
749
750 minibuf_prompt_width = 0;
751 minibuf_prompt = Fcopy_sequence (prompt);
752 Vminibuffer_history_position = histpos;
753 Vminibuffer_history_variable = histvar;
754 Vhelp_form = Vminibuffer_help_form;
755
756
757
758
759
760 if (!NILP (Vminibuffer_completing_file_name))
761 Vminibuffer_completing_file_name = Qlambda;
762
763
764 histval = find_symbol_value (histvar);
765 if (BASE_EQ (histval, Qunbound))
766 {
767 Fset (histvar, Qnil);
768 histval = Qnil;
769 }
770
771 if (inherit_input_method)
772 {
773
774
775 input_method = Fsymbol_value (Qcurrent_input_method);
776 enable_multibyte = BVAR (current_buffer, enable_multibyte_characters);
777 }
778
779
780
781 set_minibuffer_mode (minibuffer, minibuf_level);
782 Fset_buffer (minibuffer);
783
784
785
786 bset_truncate_lines (current_buffer, Qnil);
787
788
789
790
791
792
793
794
795
796 if (STRINGP (ambient_dir))
797 bset_directory (current_buffer, ambient_dir);
798 else
799 {
800 Lisp_Object tail, buf;
801
802 FOR_EACH_LIVE_BUFFER (tail, buf)
803 if (STRINGP (BVAR (XBUFFER (buf), directory)))
804 {
805 bset_directory (current_buffer,
806 BVAR (XBUFFER (buf), directory));
807 break;
808 }
809 }
810
811 if (!EQ (mini_frame, selected_frame))
812 Fredirect_frame_focus (selected_frame, mini_frame);
813
814 Vminibuf_scroll_window = selected_window;
815 if (minibuf_level == 1 || !EQ (minibuf_window, selected_window))
816 minibuf_selected_window = selected_window;
817
818
819
820
821 empty_minibuf = nth_minibuffer (0);
822 set_minibuffer_mode (empty_minibuf, 0);
823
824
825
826
827 set_window_buffer (minibuf_window, Fcurrent_buffer (), 0, 0);
828 Fselect_window (minibuf_window, Qnil);
829 XWINDOW (minibuf_window)->hscroll = 0;
830 XWINDOW (minibuf_window)->suspend_auto_hscroll = 0;
831
832
833 {
834 specpdl_ref count1 = SPECPDL_INDEX ();
835 specbind (Qinhibit_read_only, Qt);
836 specbind (Qinhibit_modification_hooks, Qt);
837 Ferase_buffer ();
838
839
840
841 bset_enable_multibyte_characters (current_buffer,
842 inherit_input_method ? enable_multibyte
843 : Qt);
844
845
846 Finsert (1, &minibuf_prompt);
847 if (PT > BEG)
848 {
849 Fput_text_property (make_fixnum (BEG), make_fixnum (PT),
850 Qfront_sticky, Qt, Qnil);
851 Fput_text_property (make_fixnum (BEG), make_fixnum (PT),
852 Qrear_nonsticky, Qt, Qnil);
853 Fput_text_property (make_fixnum (BEG), make_fixnum (PT),
854 Qfield, Qt, Qnil);
855 if (CONSP (Vminibuffer_prompt_properties))
856 {
857
858
859
860
861
862 Lisp_Object list = Vminibuffer_prompt_properties;
863 while (CONSP (list))
864 {
865 Lisp_Object key = XCAR (list);
866 list = XCDR (list);
867 if (CONSP (list))
868 {
869 Lisp_Object val = XCAR (list);
870 list = XCDR (list);
871 if (EQ (key, Qface))
872 Fadd_face_text_property (make_fixnum (BEG),
873 make_fixnum (PT), val, Qt, Qnil);
874 else
875 Fput_text_property (make_fixnum (BEG), make_fixnum (PT),
876 key, val, Qnil);
877 }
878 }
879 }
880 }
881 unbind_to (count1, Qnil);
882 }
883
884 minibuf_prompt_width = current_column ();
885
886
887 if (!NILP (initial))
888 {
889 Finsert (1, &initial);
890 Fforward_char (make_fixnum (pos));
891 }
892
893 clear_message (1, 1);
894 bset_keymap (current_buffer, map);
895
896
897 if (STRINGP (input_method) && !NILP (Ffboundp (Qactivate_input_method)))
898 call1 (Qactivate_input_method, input_method);
899
900 run_hook (Qminibuffer_setup_hook);
901
902
903 bset_undo_list (current_buffer, Qnil);
904
905 recursive_edit_1 ();
906
907
908
909 if (XWINDOW (minibuf_window)->cursor.vpos >= 0
910 && !noninteractive
911 && !FRAME_INITIAL_P (SELECTED_FRAME ()))
912 {
913 XWINDOW (minibuf_window)->cursor.hpos = 0;
914 XWINDOW (minibuf_window)->cursor.x = 0;
915 XWINDOW (minibuf_window)->must_be_updated_p = true;
916 update_frame (XFRAME (selected_frame), true, true);
917 #ifndef HAVE_NTGUI
918 flush_frame (XFRAME (XWINDOW (minibuf_window)->frame));
919 #else
920
921
922
923
924
925
926 w32_flip_buffers_if_dirty (XFRAME (XWINDOW (minibuf_window)->frame));
927 #endif
928 }
929
930
931 Fset_buffer (minibuffer);
932 if (allow_props)
933 val = Fminibuffer_contents ();
934 else
935 val = Fminibuffer_contents_no_properties ();
936
937
938
939 last_minibuf_string = val;
940
941
942 if (SCHARS (val) != 0)
943 histstring = val;
944 else if (STRINGP (defalt))
945 histstring = defalt;
946 else if (CONSP (defalt) && STRINGP (XCAR (defalt)))
947 histstring = XCAR (defalt);
948 else
949 histstring = Qnil;
950
951
952
953 unbind_to (count, Qnil);
954
955
956 if (FRAMEP (calling_frame)
957 && FRAME_LIVE_P (XFRAME (calling_frame))
958 && (!EQ (selected_frame, calling_frame)
959 || (WINDOW_LIVE_P (XFRAME (calling_frame)->minibuffer_window)
960 && !EQ (XWINDOW (XFRAME (calling_frame)->minibuffer_window)
961 ->frame,
962 calling_frame))))
963 call2 (Qselect_frame_set_input_focus, calling_frame, Qnil);
964
965
966
967
968 if (! (NILP (Vhistory_add_new_input) || NILP (histstring)))
969 call2 (Qadd_to_history, histvar, histstring);
970
971
972 if (expflag)
973 val = string_to_object (val, defalt);
974
975 return val;
976 }
977
978
979 bool
980 is_minibuffer (EMACS_INT depth, Lisp_Object buf)
981 {
982 Lisp_Object tail = Fnthcdr (make_fixnum (depth), Vminibuffer_list);
983 return
984 !NILP (tail)
985 && EQ (Fcar (tail), buf);
986 }
987
988
989 static Lisp_Object
990 nth_minibuffer (EMACS_INT depth)
991 {
992 Lisp_Object tail = Fnthcdr (make_fixnum (depth), Vminibuffer_list);
993 return Fcar (tail);
994 }
995
996
997
998
999 static void
1000 set_minibuffer_mode (Lisp_Object buf, EMACS_INT depth)
1001 {
1002 specpdl_ref count = SPECPDL_INDEX ();
1003
1004 record_unwind_current_buffer ();
1005 Fset_buffer (buf);
1006 if (depth > 0)
1007 {
1008 if (!NILP (Ffboundp (Qminibuffer_mode)))
1009 call0 (Qminibuffer_mode);
1010 }
1011 else
1012 {
1013 if (!NILP (Ffboundp (Qminibuffer_inactive_mode)))
1014 call0 (Qminibuffer_inactive_mode);
1015 else
1016 Fkill_all_local_variables (Qnil);
1017 }
1018 buf = unbind_to (count, buf);
1019 }
1020
1021
1022
1023
1024
1025 Lisp_Object
1026 get_minibuffer (EMACS_INT depth)
1027 {
1028 Lisp_Object tail = Fnthcdr (make_fixnum (depth), Vminibuffer_list);
1029 Lisp_Object cll_tail = Fnthcdr (make_fixnum (depth),
1030 Vcommand_loop_level_list);
1031 if (NILP (tail))
1032 {
1033 tail = list1 (Qnil);
1034 Vminibuffer_list = nconc2 (Vminibuffer_list, tail);
1035 cll_tail = list1 (Qnil);
1036 Vcommand_loop_level_list = nconc2 (Vcommand_loop_level_list, cll_tail);
1037 }
1038 XSETCAR (cll_tail, make_fixnum (depth ? command_loop_level : 0));
1039 Lisp_Object buf = Fcar (tail);
1040 if (NILP (buf) || !BUFFER_LIVE_P (XBUFFER (buf)))
1041 {
1042 static char const name_fmt[] = " *Minibuf-%"pI"d*";
1043 char name[sizeof name_fmt + INT_STRLEN_BOUND (EMACS_INT)];
1044 AUTO_STRING_WITH_LEN (lname, name, sprintf (name, name_fmt, depth));
1045 buf = Fget_buffer_create (lname, Qnil);
1046
1047 XSETCAR (tail, buf);
1048
1049
1050 Fbuffer_enable_undo (buf);
1051 }
1052 else
1053 {
1054
1055
1056
1057 delete_all_overlays (XBUFFER (buf));
1058 reset_buffer (XBUFFER (buf));
1059 }
1060
1061 return buf;
1062 }
1063
1064 static EMACS_INT minibuf_c_loop_level (EMACS_INT depth)
1065 {
1066 Lisp_Object cll = Fnth (make_fixnum (depth), Vcommand_loop_level_list);
1067 if (FIXNUMP (cll))
1068 return XFIXNUM (cll);
1069 return 0;
1070 }
1071
1072 static void
1073 run_exit_minibuf_hook (Lisp_Object minibuf)
1074 {
1075 specpdl_ref count = SPECPDL_INDEX ();
1076 record_unwind_current_buffer ();
1077 if (BUFFER_LIVE_P (XBUFFER (minibuf)))
1078 Fset_buffer (minibuf);
1079 safe_run_hooks (Qminibuffer_exit_hook);
1080 unbind_to (count, Qnil);
1081 }
1082
1083
1084
1085
1086
1087
1088
1089 static Lisp_Object exp_MB_frame;
1090
1091
1092
1093
1094 static void
1095 read_minibuf_unwind (void)
1096 {
1097 Lisp_Object old_deactivate_mark;
1098 Lisp_Object calling_frame;
1099 Lisp_Object calling_window;
1100 Lisp_Object future_mini_window;
1101 Lisp_Object saved_selected_frame = selected_frame;
1102 Lisp_Object window, frames;
1103 Lisp_Object expired_MB = nth_minibuffer (minibuf_level);
1104 struct window *w;
1105 struct frame *f;
1106
1107 if (NILP (expired_MB))
1108 emacs_abort ();
1109
1110
1111 FOR_EACH_FRAME (frames, exp_MB_frame)
1112 {
1113 f = XFRAME (exp_MB_frame);
1114 window = f->minibuffer_window;
1115 if (WINDOW_LIVE_P (window))
1116 {
1117 w = XWINDOW (window);
1118 if (EQ (w->frame, exp_MB_frame)
1119 && EQ (w->contents, expired_MB))
1120 goto found;
1121 }
1122 }
1123 exp_MB_frame = Qnil;
1124
1125 found:
1126 if (!EQ (exp_MB_frame, saved_selected_frame)
1127 && !NILP (exp_MB_frame))
1128 do_switch_frame (exp_MB_frame, 0, 0, Qt);
1129
1130
1131
1132
1133
1134
1135 Fset_buffer (expired_MB);
1136 minibuf_level--;
1137
1138
1139 Lisp_Object key_vec = Fcar (minibuf_save_list);
1140 this_command_key_count = ASIZE (key_vec);
1141 this_command_keys = key_vec;
1142 minibuf_save_list = Fcdr (minibuf_save_list);
1143 minibuf_prompt = Fcar (minibuf_save_list);
1144 minibuf_save_list = Fcdr (minibuf_save_list);
1145 minibuf_prompt_width = XFIXNAT (Fcar (minibuf_save_list));
1146 minibuf_save_list = Fcdr (minibuf_save_list);
1147 Vhelp_form = Fcar (minibuf_save_list);
1148 minibuf_save_list = Fcdr (minibuf_save_list);
1149 Vcurrent_prefix_arg = Fcar (minibuf_save_list);
1150 minibuf_save_list = Fcdr (minibuf_save_list);
1151 Vminibuffer_history_position = Fcar (minibuf_save_list);
1152 minibuf_save_list = Fcdr (minibuf_save_list);
1153 Vminibuffer_history_variable = Fcar (minibuf_save_list);
1154 minibuf_save_list = Fcdr (minibuf_save_list);
1155 Voverriding_local_map = Fcar (minibuf_save_list);
1156 minibuf_save_list = Fcdr (minibuf_save_list);
1157 #if 0
1158 temp = Fcar (minibuf_save_list);
1159 if (FRAME_LIVE_P (XFRAME (WINDOW_FRAME (XWINDOW (temp)))))
1160 minibuf_window = temp;
1161 #endif
1162 future_mini_window = Fcar (minibuf_save_list);
1163 minibuf_save_list = Fcdr (minibuf_save_list);
1164 calling_frame = Fcar (minibuf_save_list);
1165 minibuf_save_list = Fcdr (minibuf_save_list);
1166 calling_window = Fcar (minibuf_save_list);
1167 minibuf_save_list = Fcdr (minibuf_save_list);
1168
1169
1170 {
1171 specpdl_ref count = SPECPDL_INDEX ();
1172
1173 specbind (Qinhibit_read_only, Qt);
1174 specbind (Qinhibit_modification_hooks, Qt);
1175 old_deactivate_mark = Vdeactivate_mark;
1176 Ferase_buffer ();
1177 Vdeactivate_mark = old_deactivate_mark;
1178 unbind_to (count, Qnil);
1179 }
1180
1181
1182
1183 if (minibuf_level == 0
1184 || !EQ (selected_frame, WINDOW_FRAME (XWINDOW (future_mini_window))))
1185 resize_mini_window (XWINDOW (minibuf_window), 0);
1186
1187
1188
1189 {
1190 Lisp_Object frames, frame1, val;
1191 struct frame *f1;
1192
1193 FOR_EACH_FRAME (frames, frame1)
1194 {
1195 f1 = XFRAME (frame1);
1196
1197 if ((FRAME_PARENT_FRAME (f1)
1198 || !NILP (get_frame_param (f1, Qdelete_before)))
1199 && !NILP (val = (get_frame_param (f1, Qminibuffer_exit))))
1200 {
1201 if (EQ (val, Qiconify_frame))
1202 Ficonify_frame (frame1);
1203 else if (EQ (val, Qdelete_frame))
1204 Fdelete_frame (frame1, Qnil);
1205 else
1206 Fmake_frame_invisible (frame1, Qnil);
1207 }
1208 }
1209 }
1210
1211
1212
1213
1214
1215 call0 (Qminibuffer_inactive_mode);
1216
1217
1218
1219
1220 choose_minibuf_frame ();
1221 if (NILP (XWINDOW (minibuf_window)->prev_buffers))
1222 {
1223 if (!EQ (WINDOW_FRAME (XWINDOW (minibuf_window)), calling_frame))
1224 {
1225 Lisp_Object prev = Fprevious_window (minibuf_window, Qnil, Qnil);
1226
1227
1228
1229 if (!EQ (prev, minibuf_window)
1230 && EQ (WINDOW_FRAME (XWINDOW (prev)),
1231 WINDOW_FRAME (XWINDOW (minibuf_window))))
1232 Fset_frame_selected_window (selected_frame, prev, Qnil);
1233 }
1234 else if (WINDOW_LIVE_P (calling_window))
1235 Fset_frame_selected_window (calling_frame, calling_window, Qnil);
1236 }
1237
1238
1239 if (!EQ (exp_MB_frame, saved_selected_frame)
1240 && !NILP (exp_MB_frame))
1241 do_switch_frame (saved_selected_frame, 0, 0, Qt);
1242 }
1243
1244
1245
1246
1247 static void
1248 minibuffer_unwind (void)
1249 {
1250 struct frame *f;
1251 struct window *w;
1252 Lisp_Object window;
1253 Lisp_Object entry;
1254
1255 if (NILP (exp_MB_frame)) return;
1256 f = XFRAME (exp_MB_frame);
1257 window = f->minibuffer_window;
1258 w = XWINDOW (window);
1259 if (FRAME_LIVE_P (f))
1260 {
1261
1262 if (!NILP (w->prev_buffers))
1263 {
1264 entry = Fcar (w->prev_buffers);
1265 w->prev_buffers = Fcdr (w->prev_buffers);
1266 set_window_buffer (window, Fcar (entry), 0, 0);
1267 Fset_window_start (window, Fcar (Fcdr (entry)), Qnil);
1268 Fset_window_point (window, Fcar (Fcdr (Fcdr (entry))));
1269 }
1270 else
1271 set_window_buffer (window, nth_minibuffer (0), 0, 0);
1272 }
1273 }
1274
1275
1276
1277 void
1278 barf_if_interaction_inhibited (void)
1279 {
1280 if (inhibit_interaction)
1281 xsignal0 (Qinhibited_interaction);
1282 }
1283
1284 DEFUN ("read-from-minibuffer", Fread_from_minibuffer,
1285 Sread_from_minibuffer, 1, 7, 0,
1286 doc:
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342 )
1343 (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)
1344 {
1345 Lisp_Object histvar, histpos, val;
1346
1347 barf_if_interaction_inhibited ();
1348
1349 CHECK_STRING (prompt);
1350 if (NILP (keymap))
1351 keymap = Vminibuffer_local_map;
1352 else
1353 keymap = get_keymap (keymap, 1, 0);
1354
1355 if (SYMBOLP (hist))
1356 {
1357 histvar = hist;
1358 histpos = Qnil;
1359 }
1360 else
1361 {
1362 histvar = Fcar_safe (hist);
1363 histpos = Fcdr_safe (hist);
1364 }
1365 if (NILP (histvar))
1366 histvar = Qminibuffer_history;
1367 if (NILP (histpos))
1368 XSETFASTINT (histpos, 0);
1369
1370 val = read_minibuf (keymap, initial_contents, prompt,
1371 !NILP (read),
1372 histvar, histpos, default_value,
1373 minibuffer_allow_text_properties,
1374 !NILP (inherit_input_method));
1375 return val;
1376 }
1377
1378
1379
1380 DEFUN ("read-string", Fread_string, Sread_string, 1, 5, 0,
1381 doc:
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394 )
1395 (Lisp_Object prompt, Lisp_Object initial_input, Lisp_Object history, Lisp_Object default_value, Lisp_Object inherit_input_method)
1396 {
1397 Lisp_Object val;
1398 specpdl_ref count = SPECPDL_INDEX ();
1399
1400
1401
1402
1403
1404 specbind (Qminibuffer_completion_table, Qnil);
1405
1406 val = Fread_from_minibuffer (prompt, initial_input, Qnil,
1407 Qnil, history, default_value,
1408 inherit_input_method);
1409 if (STRINGP (val) && SCHARS (val) == 0 && ! NILP (default_value))
1410 val = CONSP (default_value) ? XCAR (default_value) : default_value;
1411 return unbind_to (count, val);
1412 }
1413
1414 DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0,
1415 doc:
1416
1417
1418 )
1419 (Lisp_Object prompt, Lisp_Object default_value)
1420 {
1421 Lisp_Object name, default_string;
1422
1423 if (NILP (default_value))
1424 default_string = Qnil;
1425 else if (SYMBOLP (default_value))
1426 default_string = SYMBOL_NAME (default_value);
1427 else
1428 default_string = default_value;
1429
1430 name = Fcompleting_read (prompt, Vobarray, Qcommandp, Qt,
1431 Qnil, Qnil, default_string, Qnil);
1432 if (NILP (name))
1433 return name;
1434 return Fintern (name, Qnil);
1435 }
1436
1437 #ifdef NOTDEF
1438 DEFUN ("read-function", Fread_function, Sread_function, 1, 1, 0,
1439 doc:
1440 )
1441 (Lisp_Object prompt)
1442 {
1443 return Fintern (Fcompleting_read (prompt, Vobarray, Qfboundp, Qt, Qnil, Qnil, Qnil, Qnil),
1444 Qnil);
1445 }
1446 #endif
1447
1448 DEFUN ("read-variable", Fread_variable, Sread_variable, 1, 2, 0,
1449 doc:
1450
1451
1452
1453 )
1454 (Lisp_Object prompt, Lisp_Object default_value)
1455 {
1456 Lisp_Object name, default_string;
1457
1458 if (NILP (default_value))
1459 default_string = Qnil;
1460 else if (SYMBOLP (default_value))
1461 default_string = SYMBOL_NAME (default_value);
1462 else
1463 default_string = default_value;
1464
1465 name = Fcompleting_read (prompt, Vobarray,
1466 Qcustom_variable_p, Qt,
1467 Qnil, Qcustom_variable_history,
1468 default_string, Qnil);
1469 if (NILP (name))
1470 return name;
1471 return Fintern (name, Qnil);
1472 }
1473
1474 DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1, 4, 0,
1475 doc:
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490 )
1491 (Lisp_Object prompt, Lisp_Object def, Lisp_Object require_match,
1492 Lisp_Object predicate)
1493 {
1494 Lisp_Object result;
1495 char *s;
1496 ptrdiff_t len;
1497 specpdl_ref count = SPECPDL_INDEX ();
1498
1499 if (BUFFERP (def))
1500 def = BVAR (XBUFFER (def), name);
1501
1502 specbind (Qcompletion_ignore_case,
1503 read_buffer_completion_ignore_case ? Qt : Qnil);
1504
1505 if (NILP (Vread_buffer_function))
1506 {
1507 if (!NILP (def))
1508 {
1509
1510
1511
1512
1513
1514
1515 if (STRINGP (prompt))
1516 {
1517 s = SSDATA (prompt);
1518 len = SBYTES (prompt);
1519 if (len >= 2 && s[len - 2] == ':' && s[len - 1] == ' ')
1520 len = len - 2;
1521 else if (len >= 1 && (s[len - 1] == ':' || s[len - 1] == ' '))
1522 len--;
1523
1524 prompt = make_specified_string (s, -1, len,
1525 STRING_MULTIBYTE (prompt));
1526 }
1527
1528 prompt = CALLN (Ffuncall, intern("format-prompt"),
1529 prompt,
1530 CONSP (def) ? XCAR (def) : def);
1531 }
1532
1533 result = Fcompleting_read (prompt, intern ("internal-complete-buffer"),
1534 predicate, require_match, Qnil,
1535 Qbuffer_name_history, def, Qnil);
1536 }
1537 else
1538 result = (NILP (predicate)
1539
1540
1541 ? call3 (Vread_buffer_function, prompt, def, require_match)
1542 : call4 (Vread_buffer_function, prompt, def, require_match,
1543 predicate));
1544 return unbind_to (count, result);
1545 }
1546
1547 static bool
1548 match_regexps (Lisp_Object string, Lisp_Object regexps,
1549 bool ignore_case)
1550 {
1551 ptrdiff_t val;
1552 for (; CONSP (regexps); regexps = XCDR (regexps))
1553 {
1554 CHECK_STRING (XCAR (regexps));
1555
1556 val = fast_string_match_internal
1557 (XCAR (regexps), string,
1558 (ignore_case ? BVAR (current_buffer, case_canon_table) : Qnil));
1559
1560 if (val == -2)
1561 error ("Stack overflow in regexp matcher");
1562 if (val < 0)
1563 return false;
1564 }
1565 return true;
1566 }
1567
1568 DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0,
1569 doc:
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609 )
1610 (Lisp_Object string, Lisp_Object collection, Lisp_Object predicate)
1611 {
1612
1613 Lisp_Object bestmatch, tail, elt, eltstring;
1614
1615 ptrdiff_t bestmatchsize = 0;
1616
1617 ptrdiff_t compare, matchsize;
1618 enum { function_table, list_table, obarray_table, hash_table}
1619 type = (HASH_TABLE_P (collection) ? hash_table
1620 : VECTORP (collection) ? obarray_table
1621 : ((NILP (collection)
1622 || (CONSP (collection) && !FUNCTIONP (collection)))
1623 ? list_table : function_table));
1624 ptrdiff_t idx = 0, obsize = 0;
1625 int matchcount = 0;
1626 Lisp_Object bucket, zero, end, tem;
1627
1628 CHECK_STRING (string);
1629 if (type == function_table)
1630 return call3 (collection, string, predicate, Qnil);
1631
1632 bestmatch = bucket = Qnil;
1633 zero = make_fixnum (0);
1634
1635
1636 tail = collection;
1637 if (type == obarray_table)
1638 {
1639 collection = check_obarray (collection);
1640 obsize = ASIZE (collection);
1641 bucket = AREF (collection, idx);
1642 }
1643
1644 while (1)
1645 {
1646
1647
1648
1649
1650
1651 if (type == list_table)
1652 {
1653 if (!CONSP (tail))
1654 break;
1655 elt = XCAR (tail);
1656 eltstring = CONSP (elt) ? XCAR (elt) : elt;
1657 tail = XCDR (tail);
1658 }
1659 else if (type == obarray_table)
1660 {
1661 if (!EQ (bucket, zero))
1662 {
1663 if (!SYMBOLP (bucket))
1664 error ("Bad data in guts of obarray");
1665 elt = bucket;
1666 eltstring = elt;
1667 if (XSYMBOL (bucket)->u.s.next)
1668 XSETSYMBOL (bucket, XSYMBOL (bucket)->u.s.next);
1669 else
1670 XSETFASTINT (bucket, 0);
1671 }
1672 else if (++idx >= obsize)
1673 break;
1674 else
1675 {
1676 bucket = AREF (collection, idx);
1677 continue;
1678 }
1679 }
1680 else
1681 {
1682 while (idx < HASH_TABLE_SIZE (XHASH_TABLE (collection))
1683 && BASE_EQ (HASH_KEY (XHASH_TABLE (collection), idx),
1684 Qunbound))
1685 idx++;
1686 if (idx >= HASH_TABLE_SIZE (XHASH_TABLE (collection)))
1687 break;
1688 else
1689 elt = eltstring = HASH_KEY (XHASH_TABLE (collection), idx++);
1690 }
1691
1692
1693
1694 if (SYMBOLP (eltstring))
1695 eltstring = Fsymbol_name (eltstring);
1696
1697 if (STRINGP (eltstring)
1698 && SCHARS (string) <= SCHARS (eltstring)
1699 && (tem = Fcompare_strings (eltstring, zero,
1700 make_fixnum (SCHARS (string)),
1701 string, zero, Qnil,
1702 completion_ignore_case ? Qt : Qnil),
1703 EQ (Qt, tem)))
1704 {
1705
1706 if (!match_regexps (eltstring, Vcompletion_regexp_list,
1707 completion_ignore_case))
1708 continue;
1709
1710
1711
1712
1713 if (!NILP (predicate))
1714 {
1715 if (EQ (predicate, Qcommandp))
1716 tem = Fcommandp (elt, Qnil);
1717 else
1718 {
1719 tem = (type == hash_table
1720 ? call2 (predicate, elt,
1721 HASH_VALUE (XHASH_TABLE (collection),
1722 idx - 1))
1723 : call1 (predicate, elt));
1724 }
1725 if (NILP (tem)) continue;
1726 }
1727
1728
1729
1730 if (NILP (bestmatch))
1731 {
1732 matchcount = 1;
1733 bestmatch = eltstring;
1734 bestmatchsize = SCHARS (eltstring);
1735 }
1736 else
1737 {
1738 compare = min (bestmatchsize, SCHARS (eltstring));
1739 Lisp_Object lcompare = make_fixnum (compare);
1740 tem = Fcompare_strings (bestmatch, zero, lcompare,
1741 eltstring, zero, lcompare,
1742 completion_ignore_case ? Qt : Qnil);
1743 matchsize = EQ (tem, Qt) ? compare : eabs (XFIXNUM (tem)) - 1;
1744
1745 Lisp_Object old_bestmatch = bestmatch;
1746 if (completion_ignore_case)
1747 {
1748
1749
1750
1751
1752 if ((matchsize == SCHARS (eltstring)
1753 && matchsize < SCHARS (bestmatch))
1754 ||
1755
1756
1757
1758
1759
1760
1761 ((matchsize == SCHARS (eltstring))
1762 ==
1763 (matchsize == SCHARS (bestmatch))
1764 && (tem = Fcompare_strings (eltstring, zero,
1765 make_fixnum (SCHARS (string)),
1766 string, zero,
1767 Qnil,
1768 Qnil),
1769 EQ (Qt, tem))
1770 && (tem = Fcompare_strings (bestmatch, zero,
1771 make_fixnum (SCHARS (string)),
1772 string, zero,
1773 Qnil,
1774 Qnil),
1775 ! EQ (Qt, tem))))
1776 bestmatch = eltstring;
1777 }
1778 if (bestmatchsize != SCHARS (eltstring)
1779 || bestmatchsize != matchsize
1780 || (completion_ignore_case
1781 && !BASE_EQ (Fcompare_strings (old_bestmatch, zero,
1782 lcompare, eltstring, zero,
1783 lcompare, Qnil),
1784 Qt)))
1785
1786 matchcount += matchcount <= 1;
1787 bestmatchsize = matchsize;
1788 if (matchsize <= SCHARS (string)
1789
1790
1791
1792 && !completion_ignore_case
1793 && matchcount > 1)
1794
1795 break;
1796 }
1797 }
1798 }
1799
1800 if (NILP (bestmatch))
1801 return Qnil;
1802
1803
1804
1805 if (completion_ignore_case && bestmatchsize == SCHARS (string)
1806 && SCHARS (bestmatch) > bestmatchsize)
1807 return string;
1808
1809
1810
1811 if (matchcount == 1 && !NILP (Fequal (bestmatch, string)))
1812 return Qt;
1813
1814 XSETFASTINT (zero, 0);
1815 XSETFASTINT (end, bestmatchsize);
1816 return Fsubstring (bestmatch, zero, end);
1817 }
1818
1819 DEFUN ("all-completions", Fall_completions, Sall_completions, 2, 4, 0,
1820 doc:
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856 )
1857 (Lisp_Object string, Lisp_Object collection, Lisp_Object predicate, Lisp_Object hide_spaces)
1858 {
1859 Lisp_Object tail, elt, eltstring;
1860 Lisp_Object allmatches;
1861 int type = HASH_TABLE_P (collection) ? 3
1862 : VECTORP (collection) ? 2
1863 : NILP (collection) || (CONSP (collection) && !FUNCTIONP (collection));
1864 ptrdiff_t idx = 0, obsize = 0;
1865 Lisp_Object bucket, tem, zero;
1866
1867 CHECK_STRING (string);
1868 if (type == 0)
1869 return call3 (collection, string, predicate, Qt);
1870 allmatches = bucket = Qnil;
1871 zero = make_fixnum (0);
1872
1873
1874 tail = collection;
1875 if (type == 2)
1876 {
1877 collection = check_obarray (collection);
1878 obsize = ASIZE (collection);
1879 bucket = AREF (collection, idx);
1880 }
1881
1882 while (1)
1883 {
1884
1885
1886
1887
1888
1889 if (type == 1)
1890 {
1891 if (!CONSP (tail))
1892 break;
1893 elt = XCAR (tail);
1894 eltstring = CONSP (elt) ? XCAR (elt) : elt;
1895 tail = XCDR (tail);
1896 }
1897 else if (type == 2)
1898 {
1899 if (!EQ (bucket, zero))
1900 {
1901 if (!SYMBOLP (bucket))
1902 error ("Bad data in guts of obarray");
1903 elt = bucket;
1904 eltstring = elt;
1905 if (XSYMBOL (bucket)->u.s.next)
1906 XSETSYMBOL (bucket, XSYMBOL (bucket)->u.s.next);
1907 else
1908 XSETFASTINT (bucket, 0);
1909 }
1910 else if (++idx >= obsize)
1911 break;
1912 else
1913 {
1914 bucket = AREF (collection, idx);
1915 continue;
1916 }
1917 }
1918 else
1919 {
1920 while (idx < HASH_TABLE_SIZE (XHASH_TABLE (collection))
1921 && BASE_EQ (HASH_KEY (XHASH_TABLE (collection), idx),
1922 Qunbound))
1923 idx++;
1924 if (idx >= HASH_TABLE_SIZE (XHASH_TABLE (collection)))
1925 break;
1926 else
1927 elt = eltstring = HASH_KEY (XHASH_TABLE (collection), idx++);
1928 }
1929
1930
1931
1932 if (SYMBOLP (eltstring))
1933 eltstring = Fsymbol_name (eltstring);
1934
1935 if (STRINGP (eltstring)
1936 && SCHARS (string) <= SCHARS (eltstring)
1937
1938
1939 && (NILP (hide_spaces)
1940 || (SBYTES (string) > 0
1941 && SREF (string, 0) == ' ')
1942 || SREF (eltstring, 0) != ' ')
1943 && (tem = Fcompare_strings (eltstring, zero,
1944 make_fixnum (SCHARS (string)),
1945 string, zero,
1946 make_fixnum (SCHARS (string)),
1947 completion_ignore_case ? Qt : Qnil),
1948 EQ (Qt, tem)))
1949 {
1950
1951 if (!match_regexps (eltstring, Vcompletion_regexp_list,
1952 completion_ignore_case))
1953 continue;
1954
1955
1956
1957
1958 if (!NILP (predicate))
1959 {
1960 if (EQ (predicate, Qcommandp))
1961 tem = Fcommandp (elt, Qnil);
1962 else
1963 {
1964 tem = type == 3
1965 ? call2 (predicate, elt,
1966 HASH_VALUE (XHASH_TABLE (collection), idx - 1))
1967 : call1 (predicate, elt);
1968 }
1969 if (NILP (tem)) continue;
1970 }
1971
1972 allmatches = Fcons (eltstring, allmatches);
1973 }
1974 }
1975
1976 return Fnreverse (allmatches);
1977 }
1978
1979 DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0,
1980 doc:
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041 )
2042 (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)
2043 {
2044 return CALLN (Ffuncall,
2045 Fsymbol_value (intern ("completing-read-function")),
2046 prompt, collection, predicate, require_match, initial_input,
2047 hist, def, inherit_input_method);
2048 }
2049
2050
2051 DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0,
2052 doc:
2053
2054
2055
2056
2057
2058
2059 )
2060 (Lisp_Object string, Lisp_Object collection, Lisp_Object predicate)
2061 {
2062 Lisp_Object tail, tem = Qnil;
2063 ptrdiff_t i = 0;
2064
2065 CHECK_STRING (string);
2066
2067 if (NILP (collection) || (CONSP (collection) && !FUNCTIONP (collection)))
2068 {
2069 tem = Fassoc_string (string, collection, completion_ignore_case ? Qt : Qnil);
2070 if (NILP (tem))
2071 return Qnil;
2072 }
2073 else if (VECTORP (collection))
2074 {
2075
2076 tem = oblookup (collection,
2077 SSDATA (string),
2078 SCHARS (string),
2079 SBYTES (string));
2080 if (completion_ignore_case && !SYMBOLP (tem))
2081 {
2082 for (i = ASIZE (collection) - 1; i >= 0; i--)
2083 {
2084 tail = AREF (collection, i);
2085 if (SYMBOLP (tail))
2086 while (1)
2087 {
2088 if (BASE_EQ (Fcompare_strings (string, make_fixnum (0),
2089 Qnil,
2090 Fsymbol_name (tail),
2091 make_fixnum (0) , Qnil, Qt),
2092 Qt))
2093 {
2094 tem = tail;
2095 break;
2096 }
2097 if (XSYMBOL (tail)->u.s.next == 0)
2098 break;
2099 XSETSYMBOL (tail, XSYMBOL (tail)->u.s.next);
2100 }
2101 }
2102 }
2103
2104 if (!SYMBOLP (tem))
2105 return Qnil;
2106 }
2107 else if (HASH_TABLE_P (collection))
2108 {
2109 struct Lisp_Hash_Table *h = XHASH_TABLE (collection);
2110 i = hash_lookup (h, string, NULL);
2111 if (i >= 0)
2112 {
2113 tem = HASH_KEY (h, i);
2114 goto found_matching_key;
2115 }
2116 else
2117 for (i = 0; i < HASH_TABLE_SIZE (h); ++i)
2118 {
2119 tem = HASH_KEY (h, i);
2120 if (BASE_EQ (tem, Qunbound)) continue;
2121 Lisp_Object strkey = (SYMBOLP (tem) ? Fsymbol_name (tem) : tem);
2122 if (!STRINGP (strkey)) continue;
2123 if (BASE_EQ (Fcompare_strings (string, Qnil, Qnil,
2124 strkey, Qnil, Qnil,
2125 completion_ignore_case ? Qt : Qnil),
2126 Qt))
2127 goto found_matching_key;
2128 }
2129 return Qnil;
2130 found_matching_key: ;
2131 }
2132 else
2133 return call3 (collection, string, predicate, Qlambda);
2134
2135
2136 if (!match_regexps (string, Vcompletion_regexp_list,
2137 completion_ignore_case))
2138 return Qnil;
2139
2140
2141 if (!NILP (predicate))
2142 {
2143 return HASH_TABLE_P (collection)
2144 ? call2 (predicate, tem, HASH_VALUE (XHASH_TABLE (collection), i))
2145 : call1 (predicate, tem);
2146 }
2147 else
2148 return Qt;
2149 }
2150
2151 DEFUN ("internal-complete-buffer", Finternal_complete_buffer, Sinternal_complete_buffer, 3, 3, 0,
2152 doc:
2153
2154
2155
2156
2157 )
2158 (Lisp_Object string, Lisp_Object predicate, Lisp_Object flag)
2159 {
2160 if (NILP (flag))
2161 return Ftry_completion (string, Vbuffer_alist, predicate);
2162 else if (EQ (flag, Qt))
2163 {
2164 Lisp_Object res = Fall_completions (string, Vbuffer_alist, predicate, Qnil);
2165 if (SCHARS (string) > 0)
2166 return res;
2167 else
2168 {
2169 Lisp_Object bufs = res;
2170
2171 while (CONSP (bufs) && SREF (XCAR (bufs), 0) == ' ')
2172 bufs = XCDR (bufs);
2173 if (NILP (bufs))
2174 return (list_length (res) == list_length (Vbuffer_alist)
2175
2176 ? res : bufs);
2177 res = bufs;
2178 while (CONSP (XCDR (bufs)))
2179 if (SREF (XCAR (XCDR (bufs)), 0) == ' ')
2180 XSETCDR (bufs, XCDR (XCDR (bufs)));
2181 else
2182 bufs = XCDR (bufs);
2183 return res;
2184 }
2185 }
2186 else if (EQ (flag, Qlambda))
2187 return Ftest_completion (string, Vbuffer_alist, predicate);
2188 else if (EQ (flag, Qmetadata))
2189 return list3 (Qmetadata,
2190 Fcons (Qcategory, Qbuffer),
2191 Fcons (Qcycle_sort_function, Qidentity));
2192 else
2193 return Qnil;
2194 }
2195
2196
2197
2198 DEFUN ("assoc-string", Fassoc_string, Sassoc_string, 2, 3, 0,
2199 doc:
2200
2201
2202
2203
2204
2205
2206
2207
2208 )
2209 (register Lisp_Object key, Lisp_Object list, Lisp_Object case_fold)
2210 {
2211 register Lisp_Object tail;
2212
2213 if (SYMBOLP (key))
2214 key = Fsymbol_name (key);
2215
2216 for (tail = list; CONSP (tail); tail = XCDR (tail))
2217 {
2218 register Lisp_Object elt, tem, thiscar;
2219 elt = XCAR (tail);
2220 thiscar = CONSP (elt) ? XCAR (elt) : elt;
2221 if (SYMBOLP (thiscar))
2222 thiscar = Fsymbol_name (thiscar);
2223 else if (!STRINGP (thiscar))
2224 continue;
2225 tem = Fcompare_strings (thiscar, make_fixnum (0), Qnil,
2226 key, make_fixnum (0), Qnil,
2227 case_fold);
2228 if (EQ (tem, Qt))
2229 return elt;
2230 maybe_quit ();
2231 }
2232 return Qnil;
2233 }
2234
2235
2236 DEFUN ("minibuffer-depth", Fminibuffer_depth, Sminibuffer_depth, 0, 0, 0,
2237 doc: )
2238 (void)
2239 {
2240 return make_fixnum (minibuf_level);
2241 }
2242
2243 DEFUN ("minibuffer-prompt", Fminibuffer_prompt, Sminibuffer_prompt, 0, 0, 0,
2244 doc:
2245 )
2246 (void)
2247 {
2248 return Fcopy_sequence (minibuf_prompt);
2249 }
2250
2251
2252
2253 void
2254 set_initial_minibuffer_mode (void)
2255 {
2256 Lisp_Object minibuf = get_minibuffer (0);
2257 set_minibuffer_mode (minibuf, 0);
2258 }
2259
2260 static void init_minibuf_once_for_pdumper (void);
2261
2262 void
2263 init_minibuf_once (void)
2264 {
2265 staticpro (&Vminibuffer_list);
2266 staticpro (&Vcommand_loop_level_list);
2267 pdumper_do_now_and_after_load (init_minibuf_once_for_pdumper);
2268
2269 get_minibuffer (0);
2270 }
2271
2272 static void
2273 init_minibuf_once_for_pdumper (void)
2274 {
2275 PDUMPER_IGNORE (minibuf_level);
2276 PDUMPER_IGNORE (minibuf_prompt_width);
2277
2278
2279
2280
2281 Vminibuffer_list = Qnil;
2282 Vcommand_loop_level_list = Qnil;
2283 minibuf_level = 0;
2284 minibuf_prompt = Qnil;
2285 minibuf_save_list = Qnil;
2286 last_minibuf_string = Qnil;
2287 }
2288
2289 void
2290 syms_of_minibuf (void)
2291 {
2292 staticpro (&minibuf_prompt);
2293 staticpro (&minibuf_save_list);
2294 staticpro (&MB_frame);
2295 MB_frame = Qnil;
2296 staticpro (&exp_MB_frame);
2297
2298 DEFSYM (Qminibuffer_follows_selected_frame,
2299 "minibuffer-follows-selected-frame");
2300 DEFSYM (Qcompletion_ignore_case, "completion-ignore-case");
2301 DEFSYM (Qminibuffer_default, "minibuffer-default");
2302 Fset (Qminibuffer_default, Qnil);
2303
2304 DEFSYM (Qminibuffer_completion_table, "minibuffer-completion-table");
2305
2306 staticpro (&last_minibuf_string);
2307
2308 DEFSYM (Qcustom_variable_history, "custom-variable-history");
2309 Fset (Qcustom_variable_history, Qnil);
2310
2311 DEFSYM (Qminibuffer_history, "minibuffer-history");
2312 DEFSYM (Qbuffer_name_history, "buffer-name-history");
2313 Fset (Qbuffer_name_history, Qnil);
2314
2315 DEFSYM (Qcustom_variable_p, "custom-variable-p");
2316
2317
2318 DEFSYM (Qminibuffer_setup_hook, "minibuffer-setup-hook");
2319 DEFSYM (Qminibuffer_exit_hook, "minibuffer-exit-hook");
2320
2321 DEFSYM (Qcurrent_input_method, "current-input-method");
2322 DEFSYM (Qactivate_input_method, "activate-input-method");
2323 DEFSYM (Qcase_fold_search, "case-fold-search");
2324 DEFSYM (Qmetadata, "metadata");
2325 DEFSYM (Qcycle_sort_function, "cycle-sort-function");
2326
2327
2328 DEFSYM (Qminibuffer_exit, "minibuffer-exit");
2329
2330 DEFSYM (Qminibuffer_mode, "minibuffer-mode");
2331 DEFSYM (Qminibuffer_inactive_mode, "minibuffer-inactive-mode");
2332 DEFSYM (Qminibuffer_completing_file_name, "minibuffer-completing-file-name");
2333 DEFSYM (Qselect_frame_set_input_focus, "select-frame-set-input-focus");
2334 DEFSYM (Qadd_to_history, "add-to-history");
2335 DEFSYM (Qpush_window_buffer_onto_prev, "push-window-buffer-onto-prev");
2336
2337 DEFVAR_LISP ("read-expression-history", Vread_expression_history,
2338 doc:
2339 );
2340 Vread_expression_history = Qnil;
2341
2342 DEFVAR_LISP ("read-buffer-function", Vread_buffer_function,
2343 doc:
2344 );
2345 Vread_buffer_function = Qnil;
2346
2347 DEFVAR_LISP ("minibuffer-follows-selected-frame", minibuffer_follows_selected_frame,
2348 doc:
2349
2350
2351
2352
2353
2354 );
2355 minibuffer_follows_selected_frame = Qt;
2356
2357 DEFVAR_BOOL ("read-buffer-completion-ignore-case",
2358 read_buffer_completion_ignore_case,
2359 doc: );
2360 read_buffer_completion_ignore_case = 0;
2361
2362 DEFVAR_LISP ("minibuffer-setup-hook", Vminibuffer_setup_hook,
2363 doc: );
2364 Vminibuffer_setup_hook = Qnil;
2365
2366 DEFVAR_LISP ("minibuffer-exit-hook", Vminibuffer_exit_hook,
2367 doc: );
2368 Vminibuffer_exit_hook = Qnil;
2369
2370 DEFVAR_LISP ("history-length", Vhistory_length,
2371 doc:
2372
2373
2374
2375
2376
2377
2378 );
2379 XSETFASTINT (Vhistory_length, 100);
2380
2381 DEFVAR_BOOL ("history-delete-duplicates", history_delete_duplicates,
2382 doc:
2383
2384 );
2385 history_delete_duplicates = 0;
2386
2387 DEFVAR_LISP ("history-add-new-input", Vhistory_add_new_input,
2388 doc:
2389
2390
2391 );
2392 Vhistory_add_new_input = Qt;
2393
2394 DEFVAR_BOOL ("completion-ignore-case", completion_ignore_case,
2395 doc:
2396
2397
2398
2399 );
2400 completion_ignore_case = 0;
2401
2402 DEFVAR_BOOL ("enable-recursive-minibuffers", enable_recursive_minibuffers,
2403 doc:
2404
2405
2406 );
2407 enable_recursive_minibuffers = 0;
2408
2409 DEFVAR_LISP ("minibuffer-completion-table", Vminibuffer_completion_table,
2410 doc:
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421 );
2422 Vminibuffer_completion_table = Qnil;
2423
2424 DEFVAR_LISP ("minibuffer-completion-predicate", Vminibuffer_completion_predicate,
2425 doc: );
2426 Vminibuffer_completion_predicate = Qnil;
2427
2428 DEFVAR_LISP ("minibuffer-completion-confirm", Vminibuffer_completion_confirm,
2429 doc:
2430
2431
2432
2433
2434
2435
2436 );
2437 Vminibuffer_completion_confirm = Qnil;
2438
2439 DEFVAR_LISP ("minibuffer-completing-file-name",
2440 Vminibuffer_completing_file_name,
2441 doc: );
2442 Vminibuffer_completing_file_name = Qnil;
2443
2444 DEFVAR_LISP ("minibuffer-help-form", Vminibuffer_help_form,
2445 doc: );
2446 Vminibuffer_help_form = Qnil;
2447
2448 DEFVAR_LISP ("minibuffer-history-variable", Vminibuffer_history_variable,
2449 doc:
2450
2451
2452
2453
2454
2455
2456 );
2457 XSETFASTINT (Vminibuffer_history_variable, 0);
2458
2459 DEFVAR_LISP ("minibuffer-history-position", Vminibuffer_history_position,
2460 doc: );
2461 Vminibuffer_history_position = Qnil;
2462
2463 DEFVAR_BOOL ("minibuffer-auto-raise", minibuffer_auto_raise,
2464 doc:
2465 );
2466 minibuffer_auto_raise = 0;
2467
2468 DEFVAR_LISP ("completion-regexp-list", Vcompletion_regexp_list,
2469 doc:
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479 );
2480 Vcompletion_regexp_list = Qnil;
2481
2482 DEFVAR_BOOL ("minibuffer-allow-text-properties",
2483 minibuffer_allow_text_properties,
2484 doc:
2485
2486
2487 );
2488 minibuffer_allow_text_properties = 0;
2489
2490 DEFVAR_LISP ("minibuffer-prompt-properties", Vminibuffer_prompt_properties,
2491 doc:
2492
2493 );
2494 Vminibuffer_prompt_properties = list2 (Qread_only, Qt);
2495
2496 DEFVAR_LISP ("read-hide-char", Vread_hide_char,
2497 doc:
2498
2499
2500
2501
2502 );
2503 Vread_hide_char = Qnil;
2504
2505 DEFVAR_BOOL ("inhibit-interaction",
2506 inhibit_interaction,
2507 doc:
2508
2509
2510
2511 );
2512 inhibit_interaction = 0;
2513
2514 DEFVAR_BOOL ("read-minibuffer-restore-windows", read_minibuffer_restore_windows,
2515 doc:
2516
2517
2518
2519
2520
2521
2522
2523
2524 );
2525 read_minibuffer_restore_windows = true;
2526
2527 defsubr (&Sactive_minibuffer_window);
2528 defsubr (&Sset_minibuffer_window);
2529 defsubr (&Sread_from_minibuffer);
2530 defsubr (&Sread_string);
2531 defsubr (&Sread_command);
2532 defsubr (&Sread_variable);
2533 defsubr (&Sinternal_complete_buffer);
2534 defsubr (&Sread_buffer);
2535 defsubr (&Sminibuffer_depth);
2536 defsubr (&Sminibuffer_prompt);
2537
2538 defsubr (&Sminibufferp);
2539 defsubr (&Sinnermost_minibuffer_p);
2540 defsubr (&Sminibuffer_innermost_command_loop_p);
2541 defsubr (&Sabort_minibuffers);
2542 defsubr (&Sminibuffer_prompt_end);
2543 defsubr (&Sminibuffer_contents);
2544 defsubr (&Sminibuffer_contents_no_properties);
2545
2546 defsubr (&Stry_completion);
2547 defsubr (&Sall_completions);
2548 defsubr (&Stest_completion);
2549 defsubr (&Sassoc_string);
2550 defsubr (&Scompleting_read);
2551 }