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