Mercurial > emacs
annotate src/minibuf.c @ 3376:898d7a33c038
(outline-flag-region): Pass t as NOUNDO arg
to subst-char-in-region. No need to restore buffer-modified-p by hand.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 01 Jun 1993 03:24:24 +0000 |
parents | e94a593c3952 |
children | 2d6cd35210f3 |
rev | line source |
---|---|
284 | 1 /* Minibuffer input and completion. |
2961 | 2 Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc. |
284 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
648 | 8 the Free Software Foundation; either version 2, or (at your option) |
284 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 | |
21 #include "config.h" | |
22 #include "lisp.h" | |
23 #include "commands.h" | |
24 #include "buffer.h" | |
25 #include "dispextern.h" | |
765 | 26 #include "frame.h" |
284 | 27 #include "window.h" |
28 #include "syntax.h" | |
29 | |
30 #define min(a, b) ((a) < (b) ? (a) : (b)) | |
31 | |
32 /* List of buffers for use as minibuffers. | |
33 The first element of the list is used for the outermost minibuffer invocation, | |
34 the next element is used for a recursive minibuffer invocation, etc. | |
35 The list is extended at the end as deeped minibuffer recursions are encountered. */ | |
36 Lisp_Object Vminibuffer_list; | |
37 | |
38 struct minibuf_save_data | |
39 { | |
40 char *prompt; | |
41 int prompt_width; | |
42 Lisp_Object help_form; | |
43 Lisp_Object current_prefix_arg; | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
44 Lisp_Object history_position; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
45 Lisp_Object history_variable; |
284 | 46 }; |
47 | |
48 int minibuf_save_vector_size; | |
49 struct minibuf_save_data *minibuf_save_vector; | |
50 | |
51 /* Depth in minibuffer invocations. */ | |
52 int minibuf_level; | |
53 | |
54 /* Nonzero means display completion help for invalid input */ | |
55 int auto_help; | |
56 | |
57 /* Fread_minibuffer leaves the input, as a string, here */ | |
58 Lisp_Object last_minibuf_string; | |
59 | |
60 /* Nonzero means let functions called when within a minibuffer | |
61 invoke recursive minibuffers (to read arguments, or whatever) */ | |
62 int enable_recursive_minibuffers; | |
63 | |
64 /* help-form is bound to this while in the minibuffer. */ | |
65 | |
66 Lisp_Object Vminibuffer_help_form; | |
67 | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
68 /* Variable which is the history list to add minibuffer values to. */ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
69 |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
70 Lisp_Object Vminibuffer_history_variable; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
71 |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
72 /* Current position in the history list (adjusted by M-n and M-p). */ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
73 |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
74 Lisp_Object Vminibuffer_history_position; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
75 |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
76 Lisp_Object Qminibuffer_history; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
77 |
284 | 78 /* Nonzero means completion ignores case. */ |
79 | |
80 int completion_ignore_case; | |
81 | |
82 /* If last completion attempt reported "Complete but not unique" | |
83 then this is the string completed then; otherwise this is nil. */ | |
84 | |
85 static Lisp_Object last_exact_completion; | |
86 | |
87 Lisp_Object Quser_variable_p; | |
88 | |
89 | |
90 /* Actual minibuffer invocation. */ | |
91 | |
92 void read_minibuf_unwind (); | |
93 Lisp_Object get_minibuffer (); | |
94 Lisp_Object read_minibuf (); | |
95 | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
96 /* Read from the minibuffer using keymap MAP, initial contents INITIAL |
866 | 97 (a string), putting point minus BACKUP_N chars from the end of INITIAL, |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
98 prompting with PROMPT (a string), using history list HISTVAR |
866 | 99 with initial position HISTPOS. (BACKUP_N should be <= 0.) |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
100 |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
101 Normally return the result as a string (the text that was read), |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
102 but if EXPFLAG is non-nil, read it and return the object read. */ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
103 |
284 | 104 Lisp_Object |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
105 read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos) |
284 | 106 Lisp_Object map; |
107 Lisp_Object initial; | |
108 Lisp_Object prompt; | |
866 | 109 int backup_n; |
284 | 110 int expflag; |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
111 Lisp_Object histvar; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
112 Lisp_Object histpos; |
284 | 113 { |
114 register Lisp_Object val; | |
115 int count = specpdl_ptr - specpdl; | |
765 | 116 Lisp_Object mini_frame = WINDOW_FRAME (XWINDOW (minibuf_window)); |
284 | 117 struct gcpro gcpro1, gcpro2; |
118 | |
119 if (XTYPE (prompt) != Lisp_String) | |
120 prompt = build_string (""); | |
121 | |
122 /* Emacs in -batch mode calls minibuffer: print the prompt. */ | |
123 if (noninteractive && XTYPE (prompt) == Lisp_String) | |
124 printf ("%s", XSTRING (prompt)->data); | |
125 | |
126 if (!enable_recursive_minibuffers | |
127 && minibuf_level > 0 | |
128 && (EQ (selected_window, minibuf_window))) | |
129 #if 0 | |
765 | 130 || selected_frame != XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))) |
284 | 131 #endif |
132 error ("Command attempted to use minibuffer while in minibuffer"); | |
133 | |
134 if (minibuf_level == minibuf_save_vector_size) | |
135 minibuf_save_vector = | |
136 (struct minibuf_save_data *) | |
137 xrealloc (minibuf_save_vector, | |
138 (minibuf_save_vector_size *= 2) | |
139 * sizeof (struct minibuf_save_data)); | |
140 minibuf_save_vector[minibuf_level].prompt = minibuf_prompt; | |
141 minibuf_save_vector[minibuf_level].prompt_width = minibuf_prompt_width; | |
142 minibuf_prompt_width = 0; | |
143 /* >> Why is this done this way rather than binding these variables? */ | |
144 minibuf_save_vector[minibuf_level].help_form = Vhelp_form; | |
145 minibuf_save_vector[minibuf_level].current_prefix_arg = Vcurrent_prefix_arg; | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
146 minibuf_save_vector[minibuf_level].history_position = Vminibuffer_history_position; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
147 minibuf_save_vector[minibuf_level].history_variable = Vminibuffer_history_variable; |
284 | 148 GCPRO2 (minibuf_save_vector[minibuf_level].help_form, |
149 minibuf_save_vector[minibuf_level].current_prefix_arg); | |
150 | |
151 record_unwind_protect (Fset_window_configuration, | |
345 | 152 Fcurrent_window_configuration (Qnil)); |
153 | |
765 | 154 /* If the minibuffer window is on a different frame, save that |
155 frame's configuration too. */ | |
156 if (XFRAME (mini_frame) != selected_frame) | |
358 | 157 { |
158 record_unwind_protect (Fset_window_configuration, | |
765 | 159 Fcurrent_window_configuration (mini_frame)); |
358 | 160 } |
284 | 161 |
162 val = current_buffer->directory; | |
163 Fset_buffer (get_minibuffer (minibuf_level)); | |
1593
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
164 |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
165 /* The current buffer's default directory is usually the right thing |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
166 for our minibuffer here. However, if you're typing a command at |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
167 a minibuffer-only frame when minibuf_level is zero, then buf IS |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
168 the current_buffer, so reset_buffer leaves buf's default |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
169 directory unchanged. This is a bummer when you've just started |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
170 up Emacs and buf's default directory is Qnil. Here's a hack; can |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
171 you think of something better to do? Find another buffer with a |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
172 better directory, and use that one instead. */ |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
173 if (XTYPE (val) == Lisp_String) |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
174 current_buffer->directory = val; |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
175 else |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
176 { |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
177 Lisp_Object buf_list; |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
178 |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
179 for (buf_list = Vbuffer_alist; |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
180 CONSP (buf_list); |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
181 buf_list = XCONS (buf_list)->cdr) |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
182 { |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
183 Lisp_Object other_buf = XCONS (XCONS (buf_list)->car)->cdr; |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
184 |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
185 if (XTYPE (XBUFFER (other_buf)->directory) == Lisp_String) |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
186 { |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
187 current_buffer->directory = XBUFFER (other_buf)->directory; |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
188 break; |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
189 } |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
190 } |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
191 } |
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
192 |
1568
f55c75c6806d
* minibuf.c (read_minibuf): Protect call to Fredirect_frame_focus
Jim Blandy <jimb@redhat.com>
parents:
1520
diff
changeset
|
193 #ifdef MULTI_FRAME |
1317
b74069f669cc
* minibuf.c (read_minibuf): Don't bother to save the current
Jim Blandy <jimb@redhat.com>
parents:
1198
diff
changeset
|
194 Fredirect_frame_focus (Fselected_frame (), mini_frame); |
1568
f55c75c6806d
* minibuf.c (read_minibuf): Protect call to Fredirect_frame_focus
Jim Blandy <jimb@redhat.com>
parents:
1520
diff
changeset
|
195 #endif |
284 | 196 Fmake_local_variable (Qprint_escape_newlines); |
197 print_escape_newlines = 1; | |
198 | |
358 | 199 record_unwind_protect (read_minibuf_unwind, Qnil); |
200 | |
284 | 201 Vminibuf_scroll_window = selected_window; |
202 Fset_window_buffer (minibuf_window, Fcurrent_buffer ()); | |
203 Fselect_window (minibuf_window); | |
204 XFASTINT (XWINDOW (minibuf_window)->hscroll) = 0; | |
205 | |
206 Ferase_buffer (); | |
207 minibuf_level++; | |
208 | |
488 | 209 if (!NILP (initial)) |
284 | 210 { |
211 Finsert (1, &initial); | |
488 | 212 if (!NILP (backup_n) && XTYPE (backup_n) == Lisp_Int) |
284 | 213 Fforward_char (backup_n); |
214 } | |
215 | |
216 minibuf_prompt = (char *) alloca (XSTRING (prompt)->size + 1); | |
217 bcopy (XSTRING (prompt)->data, minibuf_prompt, XSTRING (prompt)->size + 1); | |
218 echo_area_glyphs = 0; | |
219 | |
220 Vhelp_form = Vminibuffer_help_form; | |
221 current_buffer->keymap = map; | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
222 Vminibuffer_history_position = histpos; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
223 Vminibuffer_history_variable = histvar; |
284 | 224 |
225 /* ??? MCC did redraw_screen here if switching screens. */ | |
226 recursive_edit_1 (); | |
227 | |
228 /* If cursor is on the minibuffer line, | |
229 show the user we have exited by putting it in column 0. */ | |
765 | 230 if ((FRAME_CURSOR_Y (selected_frame) |
284 | 231 >= XFASTINT (XWINDOW (minibuf_window)->top)) |
232 && !noninteractive) | |
233 { | |
765 | 234 FRAME_CURSOR_X (selected_frame) = 0; |
235 update_frame (selected_frame, 1, 1); | |
284 | 236 } |
237 | |
238 /* Make minibuffer contents into a string */ | |
648 | 239 val = make_buffer_string (1, Z); |
284 | 240 bcopy (GAP_END_ADDR, XSTRING (val)->data + GPT - BEG, Z - GPT); |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
241 |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
242 /* Add the value to the appropriate history list. */ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
243 if (XTYPE (Vminibuffer_history_variable) == Lisp_Symbol |
1520
8f4575a04825
* minibuf.c (read_minibuf): Use EQ to compare, not ==.
Jim Blandy <jimb@redhat.com>
parents:
1443
diff
changeset
|
244 && ! EQ (XSYMBOL (Vminibuffer_history_variable)->value, Qunbound)) |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
245 Fset (Vminibuffer_history_variable, |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
246 Fcons (val, Fsymbol_value (Vminibuffer_history_variable))); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
247 |
765 | 248 unbind_to (count, Qnil); /* The appropriate frame will get selected |
358 | 249 in set-window-configuration. */ |
284 | 250 |
251 UNGCPRO; | |
252 | |
253 /* VAL is the string of minibuffer text. */ | |
254 last_minibuf_string = val; | |
255 | |
256 /* If Lisp form desired instead of string, parse it */ | |
257 if (expflag) | |
258 val = Fread (val); | |
259 | |
260 return val; | |
261 } | |
262 | |
263 /* Return a buffer to be used as the minibuffer at depth `depth'. | |
264 depth = 0 is the lowest allowed argument, and that is the value | |
265 used for nonrecursive minibuffer invocations */ | |
266 | |
267 Lisp_Object | |
268 get_minibuffer (depth) | |
269 int depth; | |
270 { | |
271 Lisp_Object tail, num, buf; | |
272 char name[14]; | |
273 extern Lisp_Object nconc2 (); | |
274 | |
275 XFASTINT (num) = depth; | |
276 tail = Fnthcdr (num, Vminibuffer_list); | |
488 | 277 if (NILP (tail)) |
284 | 278 { |
279 tail = Fcons (Qnil, Qnil); | |
280 Vminibuffer_list = nconc2 (Vminibuffer_list, tail); | |
281 } | |
282 buf = Fcar (tail); | |
488 | 283 if (NILP (buf) || NILP (XBUFFER (buf)->name)) |
284 | 284 { |
285 sprintf (name, " *Minibuf-%d*", depth); | |
286 buf = Fget_buffer_create (build_string (name)); | |
1198
7c4519722020
Thu Sep 17 15:51:18 1992 Jim Blandy (jimb@pogo.cs.oberlin.edu)
Jim Blandy <jimb@redhat.com>
parents:
1010
diff
changeset
|
287 |
7c4519722020
Thu Sep 17 15:51:18 1992 Jim Blandy (jimb@pogo.cs.oberlin.edu)
Jim Blandy <jimb@redhat.com>
parents:
1010
diff
changeset
|
288 /* Although the buffer's name starts with a space, undo should be |
7c4519722020
Thu Sep 17 15:51:18 1992 Jim Blandy (jimb@pogo.cs.oberlin.edu)
Jim Blandy <jimb@redhat.com>
parents:
1010
diff
changeset
|
289 enabled in it. */ |
7c4519722020
Thu Sep 17 15:51:18 1992 Jim Blandy (jimb@pogo.cs.oberlin.edu)
Jim Blandy <jimb@redhat.com>
parents:
1010
diff
changeset
|
290 Fbuffer_enable_undo (buf); |
7c4519722020
Thu Sep 17 15:51:18 1992 Jim Blandy (jimb@pogo.cs.oberlin.edu)
Jim Blandy <jimb@redhat.com>
parents:
1010
diff
changeset
|
291 |
284 | 292 XCONS (tail)->car = buf; |
293 } | |
294 else | |
295 reset_buffer (XBUFFER (buf)); | |
1593
a3862c6dfcd0
* minibuf.c (temp_echo_area_glyphs): Change reference to
Jim Blandy <jimb@redhat.com>
parents:
1568
diff
changeset
|
296 |
284 | 297 return buf; |
298 } | |
299 | |
300 /* This function is called on exiting minibuffer, whether normally or not, | |
301 and it restores the current window, buffer, etc. */ | |
302 | |
303 void | |
358 | 304 read_minibuf_unwind (data) |
305 Lisp_Object data; | |
284 | 306 { |
307 /* Erase the minibuffer we were using at this level. */ | |
308 Fset_buffer (XWINDOW (minibuf_window)->buffer); | |
309 | |
310 /* Prevent error in erase-buffer. */ | |
311 current_buffer->read_only = Qnil; | |
312 Ferase_buffer (); | |
313 | |
314 /* If this was a recursive minibuffer, | |
315 tie the minibuffer window back to the outer level minibuffer buffer */ | |
316 minibuf_level--; | |
317 /* Make sure minibuffer window is erased, not ignored */ | |
318 windows_or_buffers_changed++; | |
319 XFASTINT (XWINDOW (minibuf_window)->last_modified) = 0; | |
320 | |
321 /* Restore prompt from outer minibuffer */ | |
322 minibuf_prompt = minibuf_save_vector[minibuf_level].prompt; | |
323 minibuf_prompt_width = minibuf_save_vector[minibuf_level].prompt_width; | |
324 Vhelp_form = minibuf_save_vector[minibuf_level].help_form; | |
325 Vcurrent_prefix_arg = minibuf_save_vector[minibuf_level].current_prefix_arg; | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
326 Vminibuffer_history_position |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
327 = minibuf_save_vector[minibuf_level].history_position; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
328 Vminibuffer_history_variable |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
329 = minibuf_save_vector[minibuf_level].history_variable; |
284 | 330 } |
331 | |
1010
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
332 |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
333 /* This comment supplies the doc string for read-from-minibuffer, |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
334 for make-docfile to see. We cannot put this in the real DEFUN |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
335 due to limits in the Unix cpp. |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
336 |
284 | 337 DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 5, 0, |
338 "Read a string from the minibuffer, prompting with string PROMPT.\n\ | |
339 If optional second arg INITIAL-CONTENTS is non-nil, it is a string\n\ | |
340 to be inserted into the minibuffer before reading input.\n\ | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
341 If INITIAL-CONTENTS is (STRING . POSITION), the initial input\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
342 is STRING, but point is placed POSITION characters into the string.\n\ |
284 | 343 Third arg KEYMAP is a keymap to use whilst reading;\n\ |
344 if omitted or nil, the default is `minibuffer-local-map'.\n\ | |
345 If fourth arg READ is non-nil, then interpret the result as a lisp object\n\ | |
346 and return that object:\n\ | |
347 in other words, do `(car (read-from-string INPUT-STRING))'\n\ | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
348 Fifth arg HIST, if non-nil, specifies a history list\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
349 and optionally the initial position in the list.\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
350 It can be a symbol, which is the history list variable to use,\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
351 or it can be a cons cell (HISTVAR . HISTPOS).\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
352 In that case, HISTVAR is the history list variable to use,\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
353 and HISTPOS is the initial position (the position in the list\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
354 which INITIAL-CONTENTS corresponds to).\n\ |
1010
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
355 Positions are counted starting from 1 at the beginning of the list." |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
356 */ |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
357 |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
358 DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 5, 0, |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
359 0 /* See immediately above */) |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
360 (prompt, initial_input, keymap, read, hist) |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
361 Lisp_Object prompt, initial_input, keymap, read, hist; |
284 | 362 { |
363 int pos = 0; | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
364 Lisp_Object histvar, histpos, position; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
365 position = Qnil; |
284 | 366 |
367 CHECK_STRING (prompt, 0); | |
488 | 368 if (!NILP (initial_input)) |
284 | 369 { |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
370 if (XTYPE (initial_input) == Lisp_Cons) |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
371 { |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
372 position = Fcdr (initial_input); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
373 initial_input = Fcar (initial_input); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
374 } |
284 | 375 CHECK_STRING (initial_input, 1); |
488 | 376 if (!NILP (position)) |
284 | 377 { |
378 CHECK_NUMBER (position, 0); | |
379 /* Convert to distance from end of input. */ | |
380 pos = XINT (position) - 1 - XSTRING (initial_input)->size; | |
381 } | |
382 } | |
383 | |
488 | 384 if (NILP (keymap)) |
284 | 385 keymap = Vminibuffer_local_map; |
386 else | |
387 keymap = get_keymap (keymap,2); | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
388 |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
389 if (XTYPE (hist) == Lisp_Symbol) |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
390 { |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
391 histvar = hist; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
392 histpos = Qnil; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
393 } |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
394 else |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
395 { |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
396 histvar = Fcar_safe (hist); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
397 histpos = Fcdr_safe (hist); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
398 } |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
399 if (NILP (histvar)) |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
400 histvar = Qminibuffer_history; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
401 if (NILP (histpos)) |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
402 XFASTINT (histpos) = 0; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
403 |
284 | 404 return read_minibuf (keymap, initial_input, prompt, |
866 | 405 make_number (pos), !NILP (read), histvar, histpos); |
284 | 406 } |
407 | |
408 DEFUN ("read-minibuffer", Fread_minibuffer, Sread_minibuffer, 1, 2, 0, | |
409 "Return a Lisp object read using the minibuffer.\n\ | |
410 Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS\n\ | |
411 is a string to insert in the minibuffer before reading.") | |
412 (prompt, initial_contents) | |
413 Lisp_Object prompt, initial_contents; | |
414 { | |
415 CHECK_STRING (prompt, 0); | |
488 | 416 if (!NILP (initial_contents)) |
284 | 417 CHECK_STRING (initial_contents, 1) |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
418 return read_minibuf (Vminibuffer_local_map, initial_contents, |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
419 prompt, Qnil, 1, Qminibuffer_history, make_number (0)); |
284 | 420 } |
421 | |
422 DEFUN ("eval-minibuffer", Feval_minibuffer, Seval_minibuffer, 1, 2, 0, | |
423 "Return value of Lisp expression read using the minibuffer.\n\ | |
424 Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS\n\ | |
425 is a string to insert in the minibuffer before reading.") | |
426 (prompt, initial_contents) | |
427 Lisp_Object prompt, initial_contents; | |
428 { | |
429 return Feval (Fread_minibuffer (prompt, initial_contents)); | |
430 } | |
431 | |
432 /* Functions that use the minibuffer to read various things. */ | |
433 | |
434 DEFUN ("read-string", Fread_string, Sread_string, 1, 2, 0, | |
435 "Read a string from the minibuffer, prompting with string PROMPT.\n\ | |
436 If non-nil second arg INITIAL-INPUT is a string to insert before reading.") | |
437 (prompt, initial_input) | |
438 Lisp_Object prompt, initial_input; | |
439 { | |
440 return Fread_from_minibuffer (prompt, initial_input, Qnil, Qnil, Qnil); | |
441 } | |
442 | |
732 | 443 DEFUN ("read-no-blanks-input", Fread_no_blanks_input, Sread_no_blanks_input, 2, 2, 0, |
284 | 444 "Args PROMPT and INIT, strings. Read a string from the terminal, not allowing blanks.\n\ |
445 Prompt with PROMPT, and provide INIT as an initial value of the input string.") | |
446 (prompt, init) | |
447 Lisp_Object prompt, init; | |
448 { | |
449 CHECK_STRING (prompt, 0); | |
488 | 450 if (! NILP (init)) |
284 | 451 CHECK_STRING (init, 1); |
452 | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
453 return read_minibuf (Vminibuffer_local_ns_map, init, prompt, Qnil, 0, |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
454 Qminibuffer_history, make_number (0)); |
284 | 455 } |
456 | |
457 DEFUN ("read-command", Fread_command, Sread_command, 1, 1, 0, | |
458 "One arg PROMPT, a string. Read the name of a command and return as a symbol.\n\ | |
459 Prompts with PROMPT.") | |
460 (prompt) | |
461 Lisp_Object prompt; | |
462 { | |
463 return Fintern (Fcompleting_read (prompt, Vobarray, Qcommandp, Qt, Qnil, Qnil), | |
464 Qnil); | |
465 } | |
466 | |
467 #ifdef NOTDEF | |
468 DEFUN ("read-function", Fread_function, Sread_function, 1, 1, 0, | |
469 "One arg PROMPT, a string. Read the name of a function and return as a symbol.\n\ | |
470 Prompts with PROMPT.") | |
471 (prompt) | |
472 Lisp_Object prompt; | |
473 { | |
474 return Fintern (Fcompleting_read (prompt, Vobarray, Qfboundp, Qt, Qnil, Qnil), | |
475 Qnil); | |
476 } | |
477 #endif /* NOTDEF */ | |
478 | |
479 DEFUN ("read-variable", Fread_variable, Sread_variable, 1, 1, 0, | |
480 "One arg PROMPT, a string. Read the name of a user variable and return\n\ | |
481 it as a symbol. Prompts with PROMPT.\n\ | |
482 A user variable is one whose documentation starts with a `*' character.") | |
483 (prompt) | |
484 Lisp_Object prompt; | |
485 { | |
486 return Fintern (Fcompleting_read (prompt, Vobarray, | |
487 Quser_variable_p, Qt, Qnil, Qnil), | |
488 Qnil); | |
489 } | |
490 | |
491 DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1, 3, 0, | |
492 "One arg PROMPT, a string. Read the name of a buffer and return as a string.\n\ | |
493 Prompts with PROMPT.\n\ | |
494 Optional second arg is value to return if user enters an empty line.\n\ | |
495 If optional third arg REQUIRE-MATCH is non-nil, only existing buffer names are allowed.") | |
496 (prompt, def, require_match) | |
497 Lisp_Object prompt, def, require_match; | |
498 { | |
499 Lisp_Object tem; | |
500 Lisp_Object args[3]; | |
501 struct gcpro gcpro1; | |
502 | |
503 if (XTYPE (def) == Lisp_Buffer) | |
504 def = XBUFFER (def)->name; | |
488 | 505 if (!NILP (def)) |
284 | 506 { |
507 args[0] = build_string ("%s(default %s) "); | |
508 args[1] = prompt; | |
509 args[2] = def; | |
510 prompt = Fformat (3, args); | |
511 } | |
512 GCPRO1 (def); | |
513 tem = Fcompleting_read (prompt, Vbuffer_alist, Qnil, require_match, Qnil, Qnil); | |
514 UNGCPRO; | |
515 if (XSTRING (tem)->size) | |
516 return tem; | |
517 return def; | |
518 } | |
519 | |
520 DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0, | |
521 "Return common substring of all completions of STRING in ALIST.\n\ | |
522 Each car of each element of ALIST is tested to see if it begins with STRING.\n\ | |
523 All that match are compared together; the longest initial sequence\n\ | |
524 common to all matches is returned as a string.\n\ | |
525 If there is no match at all, nil is returned.\n\ | |
526 For an exact match, t is returned.\n\ | |
527 \n\ | |
528 ALIST can be an obarray instead of an alist.\n\ | |
529 Then the print names of all symbols in the obarray are the possible matches.\n\ | |
530 \n\ | |
531 ALIST can also be a function to do the completion itself.\n\ | |
532 It receives three arguments: the values STRING, PREDICATE and nil.\n\ | |
533 Whatever it returns becomes the value of `try-completion'.\n\ | |
534 \n\ | |
535 If optional third argument PREDICATE is non-nil,\n\ | |
536 it is used to test each possible match.\n\ | |
537 The match is a candidate only if PREDICATE returns non-nil.\n\ | |
538 The argument given to PREDICATE is the alist element or the symbol from the obarray.") | |
539 (string, alist, pred) | |
540 Lisp_Object string, alist, pred; | |
541 { | |
542 Lisp_Object bestmatch, tail, elt, eltstring; | |
543 int bestmatchsize; | |
544 int compare, matchsize; | |
488 | 545 int list = CONSP (alist) || NILP (alist); |
284 | 546 int index, obsize; |
547 int matchcount = 0; | |
548 Lisp_Object bucket, zero, end, tem; | |
549 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | |
550 | |
551 CHECK_STRING (string, 0); | |
552 if (!list && XTYPE (alist) != Lisp_Vector) | |
553 return call3 (alist, string, pred, Qnil); | |
554 | |
555 bestmatch = Qnil; | |
556 | |
557 /* If ALIST is not a list, set TAIL just for gc pro. */ | |
558 tail = alist; | |
559 if (! list) | |
560 { | |
561 index = 0; | |
562 obsize = XVECTOR (alist)->size; | |
563 bucket = XVECTOR (alist)->contents[index]; | |
564 } | |
565 | |
566 while (1) | |
567 { | |
568 /* Get the next element of the alist or obarray. */ | |
569 /* Exit the loop if the elements are all used up. */ | |
570 /* elt gets the alist element or symbol. | |
571 eltstring gets the name to check as a completion. */ | |
572 | |
573 if (list) | |
574 { | |
488 | 575 if (NILP (tail)) |
284 | 576 break; |
577 elt = Fcar (tail); | |
578 eltstring = Fcar (elt); | |
579 tail = Fcdr (tail); | |
580 } | |
581 else | |
582 { | |
583 if (XFASTINT (bucket) != 0) | |
584 { | |
585 elt = bucket; | |
586 eltstring = Fsymbol_name (elt); | |
587 if (XSYMBOL (bucket)->next) | |
588 XSETSYMBOL (bucket, XSYMBOL (bucket)->next); | |
589 else | |
590 XFASTINT (bucket) = 0; | |
591 } | |
592 else if (++index >= obsize) | |
593 break; | |
594 else | |
595 { | |
596 bucket = XVECTOR (alist)->contents[index]; | |
597 continue; | |
598 } | |
599 } | |
600 | |
601 /* Is this element a possible completion? */ | |
602 | |
603 if (XTYPE (eltstring) == Lisp_String && | |
604 XSTRING (string)->size <= XSTRING (eltstring)->size && | |
605 0 > scmp (XSTRING (eltstring)->data, XSTRING (string)->data, | |
606 XSTRING (string)->size)) | |
607 { | |
608 /* Yes. */ | |
609 /* Ignore this element if there is a predicate | |
610 and the predicate doesn't like it. */ | |
611 | |
488 | 612 if (!NILP (pred)) |
284 | 613 { |
614 if (EQ (pred, Qcommandp)) | |
615 tem = Fcommandp (elt); | |
616 else | |
617 { | |
618 GCPRO4 (tail, string, eltstring, bestmatch); | |
619 tem = call1 (pred, elt); | |
620 UNGCPRO; | |
621 } | |
488 | 622 if (NILP (tem)) continue; |
284 | 623 } |
624 | |
625 /* Update computation of how much all possible completions match */ | |
626 | |
627 matchcount++; | |
488 | 628 if (NILP (bestmatch)) |
284 | 629 bestmatch = eltstring, bestmatchsize = XSTRING (eltstring)->size; |
630 else | |
631 { | |
632 compare = min (bestmatchsize, XSTRING (eltstring)->size); | |
633 matchsize = scmp (XSTRING (bestmatch)->data, | |
634 XSTRING (eltstring)->data, | |
635 compare); | |
330 | 636 if (matchsize < 0) |
637 matchsize = compare; | |
638 if (completion_ignore_case) | |
639 { | |
640 /* If this is an exact match except for case, | |
641 use it as the best match rather than one that is not an | |
642 exact match. This way, we get the case pattern | |
643 of the actual match. */ | |
644 if ((matchsize == XSTRING (eltstring)->size | |
645 && matchsize < XSTRING (bestmatch)->size) | |
646 || | |
647 /* If there is more than one exact match ignoring case, | |
648 and one of them is exact including case, | |
649 prefer that one. */ | |
650 /* If there is no exact match ignoring case, | |
651 prefer a match that does not change the case | |
652 of the input. */ | |
653 ((matchsize == XSTRING (eltstring)->size) | |
654 == | |
655 (matchsize == XSTRING (bestmatch)->size) | |
656 && !bcmp (XSTRING (eltstring)->data, | |
657 XSTRING (string)->data, XSTRING (string)->size) | |
658 && bcmp (XSTRING (bestmatch)->data, | |
659 XSTRING (string)->data, XSTRING (string)->size))) | |
660 bestmatch = eltstring; | |
661 } | |
662 bestmatchsize = matchsize; | |
284 | 663 } |
664 } | |
665 } | |
666 | |
488 | 667 if (NILP (bestmatch)) |
284 | 668 return Qnil; /* No completions found */ |
330 | 669 /* If we are ignoring case, and there is no exact match, |
670 and no additional text was supplied, | |
671 don't change the case of what the user typed. */ | |
672 if (completion_ignore_case && bestmatchsize == XSTRING (string)->size | |
673 && XSTRING (bestmatch)->size > bestmatchsize) | |
674 return string; | |
675 | |
676 /* Return t if the supplied string is an exact match (counting case); | |
677 it does not require any change to be made. */ | |
678 if (matchcount == 1 && bestmatchsize == XSTRING (string)->size | |
679 && !bcmp (XSTRING (bestmatch)->data, XSTRING (string)->data, | |
680 bestmatchsize)) | |
284 | 681 return Qt; |
682 | |
683 XFASTINT (zero) = 0; /* Else extract the part in which */ | |
684 XFASTINT (end) = bestmatchsize; /* all completions agree */ | |
685 return Fsubstring (bestmatch, zero, end); | |
686 } | |
687 | |
688 /* Compare exactly LEN chars of strings at S1 and S2, | |
689 ignoring case if appropriate. | |
690 Return -1 if strings match, | |
691 else number of chars that match at the beginning. */ | |
692 | |
693 scmp (s1, s2, len) | |
694 register char *s1, *s2; | |
695 int len; | |
696 { | |
697 register int l = len; | |
698 | |
699 if (completion_ignore_case) | |
700 { | |
701 while (l && DOWNCASE (*s1++) == DOWNCASE (*s2++)) | |
702 l--; | |
703 } | |
704 else | |
705 { | |
706 while (l && *s1++ == *s2++) | |
707 l--; | |
708 } | |
709 if (l == 0) | |
710 return -1; | |
711 else return len - l; | |
712 } | |
713 | |
714 DEFUN ("all-completions", Fall_completions, Sall_completions, 2, 3, 0, | |
715 "Search for partial matches to STRING in ALIST.\n\ | |
716 Each car of each element of ALIST is tested to see if it begins with STRING.\n\ | |
717 The value is a list of all the strings from ALIST that match.\n\ | |
718 ALIST can be an obarray instead of an alist.\n\ | |
719 Then the print names of all symbols in the obarray are the possible matches.\n\ | |
720 \n\ | |
721 ALIST can also be a function to do the completion itself.\n\ | |
722 It receives three arguments: the values STRING, PREDICATE and t.\n\ | |
723 Whatever it returns becomes the value of `all-completion'.\n\ | |
724 \n\ | |
725 If optional third argument PREDICATE is non-nil,\n\ | |
726 it is used to test each possible match.\n\ | |
727 The match is a candidate only if PREDICATE returns non-nil.\n\ | |
728 The argument given to PREDICATE is the alist element or the symbol from the obarray.") | |
729 (string, alist, pred) | |
730 Lisp_Object string, alist, pred; | |
731 { | |
732 Lisp_Object tail, elt, eltstring; | |
733 Lisp_Object allmatches; | |
488 | 734 int list = CONSP (alist) || NILP (alist); |
284 | 735 int index, obsize; |
736 Lisp_Object bucket, tem; | |
737 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | |
738 | |
739 CHECK_STRING (string, 0); | |
740 if (!list && XTYPE (alist) != Lisp_Vector) | |
741 { | |
742 return call3 (alist, string, pred, Qt); | |
743 } | |
744 allmatches = Qnil; | |
745 | |
746 /* If ALIST is not a list, set TAIL just for gc pro. */ | |
747 tail = alist; | |
748 if (! list) | |
749 { | |
750 index = 0; | |
751 obsize = XVECTOR (alist)->size; | |
752 bucket = XVECTOR (alist)->contents[index]; | |
753 } | |
754 | |
755 while (1) | |
756 { | |
757 /* Get the next element of the alist or obarray. */ | |
758 /* Exit the loop if the elements are all used up. */ | |
759 /* elt gets the alist element or symbol. | |
760 eltstring gets the name to check as a completion. */ | |
761 | |
762 if (list) | |
763 { | |
488 | 764 if (NILP (tail)) |
284 | 765 break; |
766 elt = Fcar (tail); | |
767 eltstring = Fcar (elt); | |
768 tail = Fcdr (tail); | |
769 } | |
770 else | |
771 { | |
772 if (XFASTINT (bucket) != 0) | |
773 { | |
774 elt = bucket; | |
775 eltstring = Fsymbol_name (elt); | |
776 if (XSYMBOL (bucket)->next) | |
777 XSETSYMBOL (bucket, XSYMBOL (bucket)->next); | |
778 else | |
779 XFASTINT (bucket) = 0; | |
780 } | |
781 else if (++index >= obsize) | |
782 break; | |
783 else | |
784 { | |
785 bucket = XVECTOR (alist)->contents[index]; | |
786 continue; | |
787 } | |
788 } | |
789 | |
790 /* Is this element a possible completion? */ | |
791 | |
792 if (XTYPE (eltstring) == Lisp_String && | |
793 XSTRING (string)->size <= XSTRING (eltstring)->size && | |
794 XSTRING (eltstring)->data[0] != ' ' && | |
795 0 > scmp (XSTRING (eltstring)->data, XSTRING (string)->data, | |
796 XSTRING (string)->size)) | |
797 { | |
798 /* Yes. */ | |
799 /* Ignore this element if there is a predicate | |
800 and the predicate doesn't like it. */ | |
801 | |
488 | 802 if (!NILP (pred)) |
284 | 803 { |
804 if (EQ (pred, Qcommandp)) | |
805 tem = Fcommandp (elt); | |
806 else | |
807 { | |
808 GCPRO4 (tail, eltstring, allmatches, string); | |
809 tem = call1 (pred, elt); | |
810 UNGCPRO; | |
811 } | |
488 | 812 if (NILP (tem)) continue; |
284 | 813 } |
814 /* Ok => put it on the list. */ | |
815 allmatches = Fcons (eltstring, allmatches); | |
816 } | |
817 } | |
818 | |
819 return Fnreverse (allmatches); | |
820 } | |
821 | |
822 Lisp_Object Vminibuffer_completion_table, Qminibuffer_completion_table; | |
823 Lisp_Object Vminibuffer_completion_predicate, Qminibuffer_completion_predicate; | |
824 Lisp_Object Vminibuffer_completion_confirm, Qminibuffer_completion_confirm; | |
825 | |
1010
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
826 /* This comment supplies the doc string for completing-read, |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
827 for make-docfile to see. We cannot put this in the real DEFUN |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
828 due to limits in the Unix cpp. |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
829 |
284 | 830 DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 6, 0, |
831 "Read a string in the minibuffer, with completion.\n\ | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
832 Args: PROMPT, TABLE, PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST.\n\ |
284 | 833 PROMPT is a string to prompt with; normally it ends in a colon and a space.\n\ |
834 TABLE is an alist whose elements' cars are strings, or an obarray.\n\ | |
835 PREDICATE limits completion to a subset of TABLE.\n\ | |
836 See `try-completion' for more details on completion, TABLE, and PREDICATE.\n\ | |
837 If REQUIRE-MATCH is non-nil, the user is not allowed to exit unless\n\ | |
838 the input is (or completes to) an element of TABLE.\n\ | |
839 If it is also not t, Return does not exit if it does non-null completion.\n\ | |
840 If INITIAL-INPUT is non-nil, insert it in the minibuffer initially.\n\ | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
841 If it is (STRING . POSITION), the initial input\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
842 is STRING, but point is placed POSITION characters into the string.\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
843 HIST, if non-nil, specifies a history list\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
844 and optionally the initial position in the list.\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
845 It can be a symbol, which is the history list variable to use,\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
846 or it can be a cons cell (HISTVAR . HISTPOS).\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
847 In that case, HISTVAR is the history list variable to use,\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
848 and HISTPOS is the initial position (the position in the list\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
849 which INITIAL-CONTENTS corresponds to).\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
850 Positions are counted starting from 1 at the beginning of the list.\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
851 Completion ignores case if the ambient value of\n\ |
1010
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
852 `completion-ignore-case' is non-nil." |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
853 */ |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
854 DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 6, 0, |
b6a67ffc7536
* minibuf.c (Fread_from_minibuffer): Put this function's doc
Jim Blandy <jimb@redhat.com>
parents:
967
diff
changeset
|
855 0 /* See immediately above */) |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
856 (prompt, table, pred, require_match, init, hist) |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
857 Lisp_Object prompt, table, pred, require_match, init, hist; |
284 | 858 { |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
859 Lisp_Object val, histvar, histpos, position; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
860 int pos = 0; |
284 | 861 int count = specpdl_ptr - specpdl; |
862 specbind (Qminibuffer_completion_table, table); | |
863 specbind (Qminibuffer_completion_predicate, pred); | |
864 specbind (Qminibuffer_completion_confirm, | |
865 EQ (require_match, Qt) ? Qnil : Qt); | |
866 last_exact_completion = Qnil; | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
867 |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
868 position = Qnil; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
869 if (!NILP (init)) |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
870 { |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
871 if (XTYPE (init) == Lisp_Cons) |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
872 { |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
873 position = Fcdr (init); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
874 init = Fcar (init); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
875 } |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
876 CHECK_STRING (init, 0); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
877 if (!NILP (position)) |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
878 { |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
879 CHECK_NUMBER (position, 0); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
880 /* Convert to distance from end of input. */ |
967
6df04dcbd2e9
* minibuf.c (Fcompleting_read): Stop subtracting one from the
Jim Blandy <jimb@redhat.com>
parents:
866
diff
changeset
|
881 pos = XINT (position) - XSTRING (init)->size; |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
882 } |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
883 } |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
884 |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
885 if (XTYPE (hist) == Lisp_Symbol) |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
886 { |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
887 histvar = hist; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
888 histpos = Qnil; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
889 } |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
890 else |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
891 { |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
892 histvar = Fcar_safe (hist); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
893 histpos = Fcdr_safe (hist); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
894 } |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
895 if (NILP (histvar)) |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
896 histvar = Qminibuffer_history; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
897 if (NILP (histpos)) |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
898 XFASTINT (histpos) = 0; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
899 |
488 | 900 val = read_minibuf (NILP (require_match) |
284 | 901 ? Vminibuffer_local_completion_map |
902 : Vminibuffer_local_must_match_map, | |
866 | 903 init, prompt, make_number (pos), 0, |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
904 histvar, histpos); |
284 | 905 return unbind_to (count, val); |
906 } | |
907 | |
908 /* Temporarily display the string M at the end of the current | |
909 minibuffer contents. This is used to display things like | |
910 "[No Match]" when the user requests a completion for a prefix | |
911 that has no possible completions, and other quick, unobtrusive | |
912 messages. */ | |
913 | |
914 temp_echo_area_glyphs (m) | |
915 char *m; | |
916 { | |
917 int osize = ZV; | |
918 Lisp_Object oinhibit; | |
919 oinhibit = Vinhibit_quit; | |
920 | |
1443
b359c67a9194
* minibuf.c (temp_echo_area_glyphs): Don't clear echo_area_glyphs
Jim Blandy <jimb@redhat.com>
parents:
1317
diff
changeset
|
921 /* Clear out any old echo-area message to make way for our new thing. */ |
b359c67a9194
* minibuf.c (temp_echo_area_glyphs): Don't clear echo_area_glyphs
Jim Blandy <jimb@redhat.com>
parents:
1317
diff
changeset
|
922 message (0); |
284 | 923 |
924 SET_PT (osize); | |
925 insert_string (m); | |
926 SET_PT (osize); | |
927 Vinhibit_quit = Qt; | |
928 Fsit_for (make_number (2), Qnil, Qnil); | |
929 del_range (point, ZV); | |
488 | 930 if (!NILP (Vquit_flag)) |
284 | 931 { |
932 Vquit_flag = Qnil; | |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1593
diff
changeset
|
933 unread_command_events = Fcons (make_number (Ctl ('g')), Qnil); |
284 | 934 } |
935 Vinhibit_quit = oinhibit; | |
936 } | |
937 | |
938 Lisp_Object Fminibuffer_completion_help (); | |
330 | 939 Lisp_Object assoc_for_completion (); |
284 | 940 |
941 /* returns: | |
942 * 0 no possible completion | |
943 * 1 was already an exact and unique completion | |
944 * 3 was already an exact completion | |
945 * 4 completed to an exact completion | |
946 * 5 some completion happened | |
947 * 6 no completion happened | |
948 */ | |
949 int | |
950 do_completion () | |
951 { | |
952 Lisp_Object completion, tem; | |
953 int completedp; | |
954 Lisp_Object last; | |
955 | |
956 completion = Ftry_completion (Fbuffer_string (), Vminibuffer_completion_table, | |
957 Vminibuffer_completion_predicate); | |
958 last = last_exact_completion; | |
959 last_exact_completion = Qnil; | |
960 | |
488 | 961 if (NILP (completion)) |
284 | 962 { |
963 bitch_at_user (); | |
964 temp_echo_area_glyphs (" [No match]"); | |
965 return 0; | |
966 } | |
967 | |
968 if (EQ (completion, Qt)) /* exact and unique match */ | |
969 return 1; | |
970 | |
971 /* compiler bug */ | |
972 tem = Fstring_equal (completion, Fbuffer_string()); | |
488 | 973 if (completedp = NILP (tem)) |
284 | 974 { |
975 Ferase_buffer (); /* Some completion happened */ | |
976 Finsert (1, &completion); | |
977 } | |
978 | |
979 /* It did find a match. Do we match some possibility exactly now? */ | |
980 if (CONSP (Vminibuffer_completion_table) | |
488 | 981 || NILP (Vminibuffer_completion_table)) |
330 | 982 tem = assoc_for_completion (Fbuffer_string (), |
983 Vminibuffer_completion_table); | |
284 | 984 else if (XTYPE (Vminibuffer_completion_table) == Lisp_Vector) |
985 { | |
986 /* the primitive used by Fintern_soft */ | |
987 extern Lisp_Object oblookup (); | |
988 | |
989 tem = Fbuffer_string (); | |
990 /* Bypass intern-soft as that loses for nil */ | |
991 tem = oblookup (Vminibuffer_completion_table, | |
992 XSTRING (tem)->data, XSTRING (tem)->size); | |
993 if (XTYPE (tem) != Lisp_Symbol) | |
994 tem = Qnil; | |
488 | 995 else if (!NILP (Vminibuffer_completion_predicate)) |
284 | 996 tem = call1 (Vminibuffer_completion_predicate, tem); |
997 else | |
998 tem = Qt; | |
999 } | |
1000 else | |
1001 tem = call3 (Vminibuffer_completion_table, | |
1002 Fbuffer_string (), | |
1003 Vminibuffer_completion_predicate, | |
1004 Qlambda); | |
1005 | |
488 | 1006 if (NILP (tem)) |
284 | 1007 { /* not an exact match */ |
1008 if (completedp) | |
1009 return 5; | |
1010 else if (auto_help) | |
1011 Fminibuffer_completion_help (); | |
1012 else | |
1013 temp_echo_area_glyphs (" [Next char not unique]"); | |
1014 return 6; | |
1015 } | |
1016 else if (completedp) | |
1017 return 4; | |
1018 /* If the last exact completion and this one were the same, | |
1019 it means we've already given a "Complete but not unique" | |
330 | 1020 message and the user's hit TAB again, so now we give him help. */ |
284 | 1021 last_exact_completion = completion; |
488 | 1022 if (!NILP (last)) |
284 | 1023 { |
1024 tem = Fbuffer_string (); | |
488 | 1025 if (!NILP (Fequal (tem, last))) |
284 | 1026 Fminibuffer_completion_help (); |
1027 } | |
1028 return 3; | |
1029 } | |
1030 | |
330 | 1031 /* Like assoc but assumes KEY is a string, and ignores case if appropriate. */ |
1032 | |
1033 Lisp_Object | |
1034 assoc_for_completion (key, list) | |
1035 register Lisp_Object key; | |
1036 Lisp_Object list; | |
1037 { | |
1038 register Lisp_Object tail; | |
1039 | |
1040 if (completion_ignore_case) | |
1041 key = Fupcase (key); | |
1042 | |
488 | 1043 for (tail = list; !NILP (tail); tail = Fcdr (tail)) |
330 | 1044 { |
1045 register Lisp_Object elt, tem, thiscar; | |
1046 elt = Fcar (tail); | |
1047 if (!CONSP (elt)) continue; | |
1048 thiscar = Fcar (elt); | |
1049 if (XTYPE (thiscar) != Lisp_String) | |
1050 continue; | |
1051 if (completion_ignore_case) | |
1052 thiscar = Fupcase (thiscar); | |
1053 tem = Fequal (thiscar, key); | |
488 | 1054 if (!NILP (tem)) return elt; |
330 | 1055 QUIT; |
1056 } | |
1057 return Qnil; | |
1058 } | |
284 | 1059 |
1060 DEFUN ("minibuffer-complete", Fminibuffer_complete, Sminibuffer_complete, 0, 0, "", | |
1061 "Complete the minibuffer contents as far as possible.") | |
1062 () | |
1063 { | |
1064 register int i = do_completion (); | |
1065 switch (i) | |
1066 { | |
1067 case 0: | |
1068 return Qnil; | |
1069 | |
1070 case 1: | |
1071 temp_echo_area_glyphs (" [Sole completion]"); | |
1072 break; | |
1073 | |
1074 case 3: | |
1075 temp_echo_area_glyphs (" [Complete, but not unique]"); | |
1076 break; | |
1077 } | |
1078 | |
1079 return Qt; | |
1080 } | |
1081 | |
1082 DEFUN ("minibuffer-complete-and-exit", Fminibuffer_complete_and_exit, | |
1083 Sminibuffer_complete_and_exit, 0, 0, "", | |
1084 "Complete the minibuffer contents, and maybe exit.\n\ | |
1085 Exit if the name is valid with no completion needed.\n\ | |
1086 If name was completed to a valid match,\n\ | |
1087 a repetition of this command will exit.") | |
1088 () | |
1089 { | |
1090 register int i; | |
1091 | |
1092 /* Allow user to specify null string */ | |
1093 if (BEGV == ZV) | |
1094 goto exit; | |
1095 | |
1096 i = do_completion (); | |
1097 switch (i) | |
1098 { | |
1099 case 1: | |
1100 case 3: | |
1101 goto exit; | |
1102 | |
1103 case 4: | |
488 | 1104 if (!NILP (Vminibuffer_completion_confirm)) |
284 | 1105 { |
1106 temp_echo_area_glyphs (" [Confirm]"); | |
1107 return Qnil; | |
1108 } | |
1109 else | |
1110 goto exit; | |
1111 | |
1112 default: | |
1113 return Qnil; | |
1114 } | |
1115 exit: | |
1116 Fthrow (Qexit, Qnil); | |
1117 /* NOTREACHED */ | |
1118 } | |
1119 | |
1120 DEFUN ("minibuffer-complete-word", Fminibuffer_complete_word, Sminibuffer_complete_word, | |
1121 0, 0, "", | |
1122 "Complete the minibuffer contents at most a single word.\n\ | |
1123 After one word is completed as much as possible, a space or hyphen\n\ | |
1124 is added, provided that matches some possible completion.") | |
1125 () | |
1126 { | |
1127 Lisp_Object completion, tem; | |
1128 register int i; | |
1129 register unsigned char *completion_string; | |
1130 /* We keep calling Fbuffer_string | |
1131 rather than arrange for GC to hold onto a pointer to | |
1132 one of the strings thus made. */ | |
1133 | |
1134 completion = Ftry_completion (Fbuffer_string (), | |
1135 Vminibuffer_completion_table, | |
1136 Vminibuffer_completion_predicate); | |
488 | 1137 if (NILP (completion)) |
284 | 1138 { |
1139 bitch_at_user (); | |
1140 temp_echo_area_glyphs (" [No match]"); | |
1141 return Qnil; | |
1142 } | |
1143 if (EQ (completion, Qt)) | |
1144 return Qnil; | |
1145 | |
1146 #if 0 /* How the below code used to look, for reference */ | |
1147 tem = Fbuffer_string (); | |
1148 b = XSTRING (tem)->data; | |
1149 i = ZV - 1 - XSTRING (completion)->size; | |
1150 p = XSTRING (completion)->data; | |
1151 if (i > 0 || | |
1152 0 <= scmp (b, p, ZV - 1)) | |
1153 { | |
1154 i = 1; | |
1155 /* Set buffer to longest match of buffer tail and completion head. */ | |
1156 while (0 <= scmp (b + i, p, ZV - 1 - i)) | |
1157 i++; | |
1158 del_range (1, i + 1); | |
1159 SET_PT (ZV); | |
1160 } | |
1161 #else /* Rewritten code */ | |
1162 { | |
1163 register unsigned char *buffer_string; | |
1164 int buffer_length, completion_length; | |
1165 | |
1166 tem = Fbuffer_string (); | |
1167 buffer_string = XSTRING (tem)->data; | |
1168 completion_string = XSTRING (completion)->data; | |
1169 buffer_length = XSTRING (tem)->size; /* ie ZV - BEGV */ | |
1170 completion_length = XSTRING (completion)->size; | |
1171 i = buffer_length - completion_length; | |
1172 /* Mly: I don't understand what this is supposed to do AT ALL */ | |
1173 if (i > 0 || | |
1174 0 <= scmp (buffer_string, completion_string, buffer_length)) | |
1175 { | |
1176 /* Set buffer to longest match of buffer tail and completion head. */ | |
1177 if (i <= 0) i = 1; | |
1178 buffer_string += i; | |
1179 buffer_length -= i; | |
1180 while (0 <= scmp (buffer_string++, completion_string, buffer_length--)) | |
1181 i++; | |
1182 del_range (1, i + 1); | |
1183 SET_PT (ZV); | |
1184 } | |
1185 } | |
1186 #endif /* Rewritten code */ | |
1187 i = ZV - BEGV; | |
1188 | |
1189 /* If completion finds next char not unique, | |
1190 consider adding a space or a hyphen */ | |
1191 if (i == XSTRING (completion)->size) | |
1192 { | |
1193 tem = Ftry_completion (concat2 (Fbuffer_string (), build_string (" ")), | |
1194 Vminibuffer_completion_table, | |
1195 Vminibuffer_completion_predicate); | |
1196 if (XTYPE (tem) == Lisp_String) | |
1197 completion = tem; | |
1198 else | |
1199 { | |
1200 tem = Ftry_completion (concat2 (Fbuffer_string (), build_string ("-")), | |
1201 Vminibuffer_completion_table, | |
1202 Vminibuffer_completion_predicate); | |
1203 if (XTYPE (tem) == Lisp_String) | |
1204 completion = tem; | |
1205 } | |
1206 } | |
1207 | |
1208 /* Now find first word-break in the stuff found by completion. | |
1209 i gets index in string of where to stop completing. */ | |
1210 completion_string = XSTRING (completion)->data; | |
1211 | |
1212 for (; i < XSTRING (completion)->size; i++) | |
1213 if (SYNTAX (completion_string[i]) != Sword) break; | |
1214 if (i < XSTRING (completion)->size) | |
1215 i = i + 1; | |
1216 | |
1217 /* If got no characters, print help for user. */ | |
1218 | |
1219 if (i == ZV - BEGV) | |
1220 { | |
1221 if (auto_help) | |
1222 Fminibuffer_completion_help (); | |
1223 return Qnil; | |
1224 } | |
1225 | |
1226 /* Otherwise insert in minibuffer the chars we got */ | |
1227 | |
1228 Ferase_buffer (); | |
1229 insert_from_string (completion, 0, i); | |
1230 return Qt; | |
1231 } | |
1232 | |
1233 DEFUN ("display-completion-list", Fdisplay_completion_list, Sdisplay_completion_list, | |
1234 1, 1, 0, | |
736
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1235 "Display the list of completions, COMPLETIONS, using `standard-output'.\n\ |
284 | 1236 Each element may be just a symbol or string\n\ |
1237 or may be a list of two strings to be printed as if concatenated.") | |
1238 (completions) | |
1239 Lisp_Object completions; | |
1240 { | |
1241 register Lisp_Object tail, elt; | |
1242 register int i; | |
736
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1243 int column = 0; |
284 | 1244 /* No GCPRO needed, since (when it matters) every variable |
1245 points to a non-string that is pointed to by COMPLETIONS. */ | |
736
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1246 struct buffer *old = current_buffer; |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1247 if (XTYPE (Vstandard_output) == Lisp_Buffer) |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1248 set_buffer_internal (XBUFFER (Vstandard_output)); |
284 | 1249 |
488 | 1250 if (NILP (completions)) |
736
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1251 write_string ("There are no possible completions of what you have typed.", -1); |
284 | 1252 else |
1253 { | |
736
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1254 write_string ("Possible completions are:", -1); |
488 | 1255 for (tail = completions, i = 0; !NILP (tail); tail = Fcdr (tail), i++) |
284 | 1256 { |
1257 /* this needs fixing for the case of long completions | |
1258 and/or narrow windows */ | |
1259 /* Sadly, the window it will appear in is not known | |
1260 until after the text has been made. */ | |
1261 if (i & 1) | |
736
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1262 { |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1263 if (XTYPE (Vstandard_output) == Lisp_Buffer) |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1264 Findent_to (make_number (35), make_number (1)); |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1265 else |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1266 { |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1267 do |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1268 { |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1269 write_string (" ", -1); |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1270 column++; |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1271 } |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1272 while (column < 35); |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1273 } |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1274 } |
284 | 1275 else |
736
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1276 { |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1277 Fterpri (Qnil); |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1278 column = 0; |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1279 } |
284 | 1280 elt = Fcar (tail); |
1281 if (CONSP (elt)) | |
1282 { | |
736
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1283 if (XTYPE (Vstandard_output) != Lisp_Buffer) |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1284 { |
737 | 1285 Lisp_Object tem; |
736
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1286 tem = Flength (Fcar (elt)); |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1287 column += XINT (tem); |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1288 tem = Flength (Fcar (Fcdr (elt))); |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1289 column += XINT (tem); |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1290 } |
284 | 1291 Fprinc (Fcar (elt), Qnil); |
1292 Fprinc (Fcar (Fcdr (elt)), Qnil); | |
1293 } | |
1294 else | |
736
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1295 { |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1296 if (XTYPE (Vstandard_output) != Lisp_Buffer) |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1297 { |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1298 Lisp_Object tem; |
1933
63ba4f555b90
* minibuf.c (Fdisplay_completion_list): Pass the proper number of
Jim Blandy <jimb@redhat.com>
parents:
1821
diff
changeset
|
1299 tem = Flength (elt); |
736
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1300 column += XINT (tem); |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1301 } |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1302 Fprinc (elt, Qnil); |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1303 } |
284 | 1304 } |
1305 } | |
736
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1306 |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1307 if (XTYPE (Vstandard_output) == Lisp_Buffer) |
18b892513cb7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1308 set_buffer_internal (old); |
284 | 1309 return Qnil; |
1310 } | |
1311 | |
1312 DEFUN ("minibuffer-completion-help", Fminibuffer_completion_help, Sminibuffer_completion_help, | |
1313 0, 0, "", | |
1314 "Display a list of possible completions of the current minibuffer contents.") | |
1315 () | |
1316 { | |
1317 Lisp_Object completions; | |
1318 | |
1319 message ("Making completion list..."); | |
1320 completions = Fall_completions (Fbuffer_string (), | |
1321 Vminibuffer_completion_table, | |
1322 Vminibuffer_completion_predicate); | |
1323 echo_area_glyphs = 0; | |
1324 | |
488 | 1325 if (NILP (completions)) |
284 | 1326 { |
1327 bitch_at_user (); | |
1328 temp_echo_area_glyphs (" [No completions]"); | |
1329 } | |
1330 else | |
1331 internal_with_output_to_temp_buffer ("*Completions*", | |
1332 Fdisplay_completion_list, | |
1333 Fsort (completions, Qstring_lessp)); | |
1334 return Qnil; | |
1335 } | |
1336 | |
1337 DEFUN ("self-insert-and-exit", Fself_insert_and_exit, Sself_insert_and_exit, 0, 0, "", | |
1338 "Terminate minibuffer input.") | |
1339 () | |
1340 { | |
1341 if (XTYPE (last_command_char) == Lisp_Int) | |
1342 internal_self_insert (last_command_char, 0); | |
1343 else | |
1344 bitch_at_user (); | |
1345 | |
1346 Fthrow (Qexit, Qnil); | |
1347 } | |
1348 | |
1349 DEFUN ("exit-minibuffer", Fexit_minibuffer, Sexit_minibuffer, 0, 0, "", | |
1350 "Terminate this minibuffer argument.") | |
1351 () | |
1352 { | |
1353 Fthrow (Qexit, Qnil); | |
1354 } | |
1355 | |
1356 DEFUN ("minibuffer-depth", Fminibuffer_depth, Sminibuffer_depth, 0, 0, 0, | |
1357 "Return current depth of activations of minibuffer, a nonnegative integer.") | |
1358 () | |
1359 { | |
1360 return make_number (minibuf_level); | |
1361 } | |
1362 | |
1363 | |
1364 init_minibuf_once () | |
1365 { | |
1366 Vminibuffer_list = Qnil; | |
1367 staticpro (&Vminibuffer_list); | |
1368 } | |
1369 | |
1370 syms_of_minibuf () | |
1371 { | |
1372 minibuf_level = 0; | |
1373 minibuf_prompt = 0; | |
1374 minibuf_save_vector_size = 5; | |
1375 minibuf_save_vector = (struct minibuf_save_data *) malloc (5 * sizeof (struct minibuf_save_data)); | |
1376 | |
1377 Qminibuffer_completion_table = intern ("minibuffer-completion-table"); | |
1378 staticpro (&Qminibuffer_completion_table); | |
1379 | |
1380 Qminibuffer_completion_confirm = intern ("minibuffer-completion-confirm"); | |
1381 staticpro (&Qminibuffer_completion_confirm); | |
1382 | |
1383 Qminibuffer_completion_predicate = intern ("minibuffer-completion-predicate"); | |
1384 staticpro (&Qminibuffer_completion_predicate); | |
1385 | |
1386 staticpro (&last_minibuf_string); | |
1387 last_minibuf_string = Qnil; | |
1388 | |
1389 Quser_variable_p = intern ("user-variable-p"); | |
1390 staticpro (&Quser_variable_p); | |
1391 | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1392 Qminibuffer_history = intern ("minibuffer-history"); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1393 staticpro (&Qminibuffer_history); |
284 | 1394 |
1395 DEFVAR_BOOL ("completion-auto-help", &auto_help, | |
1396 "*Non-nil means automatically provide help for invalid completion input."); | |
1397 auto_help = 1; | |
1398 | |
1399 DEFVAR_BOOL ("completion-ignore-case", &completion_ignore_case, | |
1400 "Non-nil means don't consider case significant in completion."); | |
1401 completion_ignore_case = 0; | |
1402 | |
1403 DEFVAR_BOOL ("enable-recursive-minibuffers", &enable_recursive_minibuffers, | |
1404 "*Non-nil means to allow minibuffer commands while in the minibuffer.\n\ | |
1405 More precisely, this variable makes a difference when the minibuffer window\n\ | |
1406 is the selected window. If you are in some other window, minibuffer commands\n\ | |
1407 are allowed even if a minibuffer is active."); | |
1408 enable_recursive_minibuffers = 0; | |
1409 | |
1410 DEFVAR_LISP ("minibuffer-completion-table", &Vminibuffer_completion_table, | |
1411 "Alist or obarray used for completion in the minibuffer.\n\ | |
1412 This becomes the ALIST argument to `try-completion' and `all-completion'.\n\ | |
1413 \n\ | |
1414 The value may alternatively be a function, which is given three arguments:\n\ | |
1415 STRING, the current buffer contents;\n\ | |
1416 PREDICATE, the predicate for filtering possible matches;\n\ | |
1417 CODE, which says what kind of things to do.\n\ | |
1418 CODE can be nil, t or `lambda'.\n\ | |
1419 nil means to return the best completion of STRING, or nil if there is none.\n\ | |
1420 t means to return a list of all possible completions of STRING.\n\ | |
1421 `lambda' means to return t if STRING is a valid completion as it stands."); | |
1422 Vminibuffer_completion_table = Qnil; | |
1423 | |
1424 DEFVAR_LISP ("minibuffer-completion-predicate", &Vminibuffer_completion_predicate, | |
1425 "Within call to `completing-read', this holds the PREDICATE argument."); | |
1426 Vminibuffer_completion_predicate = Qnil; | |
1427 | |
1428 DEFVAR_LISP ("minibuffer-completion-confirm", &Vminibuffer_completion_confirm, | |
1429 "Non-nil => demand confirmation of completion before exiting minibuffer."); | |
1430 Vminibuffer_completion_confirm = Qnil; | |
1431 | |
1432 DEFVAR_LISP ("minibuffer-help-form", &Vminibuffer_help_form, | |
1433 "Value that `help-form' takes on inside the minibuffer."); | |
1434 Vminibuffer_help_form = Qnil; | |
1435 | |
864
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1436 DEFVAR_LISP ("minibuffer-history-variable", &Vminibuffer_history_variable, |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1437 "History list symbol to add minibuffer values to.\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1438 Each minibuffer output is added with\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1439 (set minibuffer-history-variable\n\ |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1440 (cons STRING (symbol-value minibuffer-history-variable)))"); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1441 XFASTINT (Vminibuffer_history_variable) = 0; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1442 |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1443 DEFVAR_LISP ("minibuffer-history-position", &Vminibuffer_history_position, |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1444 "Current position of redoing in the history list."); |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1445 Vminibuffer_history_position = Qnil; |
fe5f6b7c9727
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
765
diff
changeset
|
1446 |
284 | 1447 defsubr (&Sread_from_minibuffer); |
1448 defsubr (&Seval_minibuffer); | |
1449 defsubr (&Sread_minibuffer); | |
1450 defsubr (&Sread_string); | |
1451 defsubr (&Sread_command); | |
1452 defsubr (&Sread_variable); | |
1453 defsubr (&Sread_buffer); | |
1454 defsubr (&Sread_no_blanks_input); | |
1455 defsubr (&Sminibuffer_depth); | |
1456 | |
1457 defsubr (&Stry_completion); | |
1458 defsubr (&Sall_completions); | |
1459 defsubr (&Scompleting_read); | |
1460 defsubr (&Sminibuffer_complete); | |
1461 defsubr (&Sminibuffer_complete_word); | |
1462 defsubr (&Sminibuffer_complete_and_exit); | |
1463 defsubr (&Sdisplay_completion_list); | |
1464 defsubr (&Sminibuffer_completion_help); | |
1465 | |
1466 defsubr (&Sself_insert_and_exit); | |
1467 defsubr (&Sexit_minibuffer); | |
1468 | |
1469 } | |
1470 | |
1471 keys_of_minibuf () | |
1472 { | |
1473 initial_define_key (Vminibuffer_local_map, Ctl ('g'), | |
1474 "abort-recursive-edit"); | |
1475 initial_define_key (Vminibuffer_local_map, Ctl ('m'), | |
1476 "exit-minibuffer"); | |
1477 initial_define_key (Vminibuffer_local_map, Ctl ('j'), | |
1478 "exit-minibuffer"); | |
1479 | |
1480 initial_define_key (Vminibuffer_local_ns_map, Ctl ('g'), | |
1481 "abort-recursive-edit"); | |
1482 initial_define_key (Vminibuffer_local_ns_map, Ctl ('m'), | |
1483 "exit-minibuffer"); | |
1484 initial_define_key (Vminibuffer_local_ns_map, Ctl ('j'), | |
1485 "exit-minibuffer"); | |
1486 | |
1487 initial_define_key (Vminibuffer_local_ns_map, ' ', | |
1488 "exit-minibuffer"); | |
1489 initial_define_key (Vminibuffer_local_ns_map, '\t', | |
1490 "exit-minibuffer"); | |
1491 initial_define_key (Vminibuffer_local_ns_map, '?', | |
1492 "self-insert-and-exit"); | |
1493 | |
1494 initial_define_key (Vminibuffer_local_completion_map, Ctl ('g'), | |
1495 "abort-recursive-edit"); | |
1496 initial_define_key (Vminibuffer_local_completion_map, Ctl ('m'), | |
1497 "exit-minibuffer"); | |
1498 initial_define_key (Vminibuffer_local_completion_map, Ctl ('j'), | |
1499 "exit-minibuffer"); | |
1500 | |
1501 initial_define_key (Vminibuffer_local_completion_map, '\t', | |
1502 "minibuffer-complete"); | |
1503 initial_define_key (Vminibuffer_local_completion_map, ' ', | |
1504 "minibuffer-complete-word"); | |
1505 initial_define_key (Vminibuffer_local_completion_map, '?', | |
1506 "minibuffer-completion-help"); | |
1507 | |
1508 initial_define_key (Vminibuffer_local_must_match_map, Ctl ('g'), | |
1509 "abort-recursive-edit"); | |
1510 initial_define_key (Vminibuffer_local_must_match_map, Ctl ('m'), | |
1511 "minibuffer-complete-and-exit"); | |
1512 initial_define_key (Vminibuffer_local_must_match_map, Ctl ('j'), | |
1513 "minibuffer-complete-and-exit"); | |
1514 initial_define_key (Vminibuffer_local_must_match_map, '\t', | |
1515 "minibuffer-complete"); | |
1516 initial_define_key (Vminibuffer_local_must_match_map, ' ', | |
1517 "minibuffer-complete-word"); | |
1518 initial_define_key (Vminibuffer_local_must_match_map, '?', | |
1519 "minibuffer-completion-help"); | |
1520 } |