diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/minibuf.c | 66 |
1 files changed, 43 insertions, 23 deletions
diff --git a/src/minibuf.c b/src/minibuf.c index 0dc06a99e2a..e951f0bf66b 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -54,7 +54,7 @@ int minibuf_level; | |||
| 54 | /* Nonzero means display completion help for invalid input */ | 54 | /* Nonzero means display completion help for invalid input */ |
| 55 | int auto_help; | 55 | int auto_help; |
| 56 | 56 | ||
| 57 | /* Fread_minibuffer leaves the input, as a string, here */ | 57 | /* Fread_minibuffer leaves the input here as a string. */ |
| 58 | Lisp_Object last_minibuf_string; | 58 | Lisp_Object last_minibuf_string; |
| 59 | 59 | ||
| 60 | /* Nonzero means let functions called when within a minibuffer | 60 | /* Nonzero means let functions called when within a minibuffer |
| @@ -105,7 +105,11 @@ Lisp_Object read_minibuf (); | |||
| 105 | with initial position HISTPOS. (BACKUP_N should be <= 0.) | 105 | with initial position HISTPOS. (BACKUP_N should be <= 0.) |
| 106 | 106 | ||
| 107 | Normally return the result as a string (the text that was read), | 107 | Normally return the result as a string (the text that was read), |
| 108 | but if EXPFLAG is non-nil, read it and return the object read. */ | 108 | but if EXPFLAG is non-nil, read it and return the object read. |
| 109 | If HISTVAR is given, save the value read on that history only if it doesn't | ||
| 110 | match the front of that history list exactly. The value is pushed onto | ||
| 111 | the list as the string that was read, or as the object that resulted iff | ||
| 112 | EXPFLAG is non-nil. */ | ||
| 109 | 113 | ||
| 110 | Lisp_Object | 114 | Lisp_Object |
| 111 | read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos) | 115 | read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos) |
| @@ -252,26 +256,33 @@ read_minibuf (map, initial, prompt, backup_n, expflag, histvar, histpos) | |||
| 252 | val = make_buffer_string (1, Z); | 256 | val = make_buffer_string (1, Z); |
| 253 | bcopy (GAP_END_ADDR, XSTRING (val)->data + GPT - BEG, Z - GPT); | 257 | bcopy (GAP_END_ADDR, XSTRING (val)->data + GPT - BEG, Z - GPT); |
| 254 | 258 | ||
| 259 | /* VAL is the string of minibuffer text. */ | ||
| 260 | last_minibuf_string = val; | ||
| 261 | |||
| 262 | /* If Lisp form desired instead of string, parse it. */ | ||
| 263 | if (expflag) | ||
| 264 | val = Fread (val); | ||
| 265 | |||
| 255 | /* Add the value to the appropriate history list. */ | 266 | /* Add the value to the appropriate history list. */ |
| 256 | if (XTYPE (Vminibuffer_history_variable) == Lisp_Symbol | 267 | if (XTYPE (Vminibuffer_history_variable) == Lisp_Symbol |
| 257 | && ! EQ (XSYMBOL (Vminibuffer_history_variable)->value, Qunbound) | 268 | && ! EQ (XSYMBOL (Vminibuffer_history_variable)->value, Qunbound)) |
| 258 | && NILP (Fstring_equal | 269 | { |
| 259 | (val, Fcar (Fsymbol_value (Vminibuffer_history_variable))))) | 270 | /* If the caller wanted to save the value read on a history list, |
| 260 | Fset (Vminibuffer_history_variable, | 271 | then do so if the value is not already the front of the list. */ |
| 261 | Fcons (val, Fsymbol_value (Vminibuffer_history_variable))); | 272 | Lisp_Object histval = Fsymbol_value (Vminibuffer_history_variable); |
| 273 | |||
| 274 | /* The value of the history variable must be a cons or nil. Other | ||
| 275 | values are unacceptable. We silenty ignore these values. */ | ||
| 276 | if (NILP (histval) | ||
| 277 | || (CONSP (histval) && NILP (Fequal (val, Fcar (histval))))) | ||
| 278 | Fset (Vminibuffer_history_variable, Fcons (val, histval)); | ||
| 279 | } | ||
| 262 | 280 | ||
| 263 | unbind_to (count, Qnil); /* The appropriate frame will get selected | 281 | unbind_to (count, Qnil); /* The appropriate frame will get selected |
| 264 | in set-window-configuration. */ | 282 | in set-window-configuration. */ |
| 265 | 283 | ||
| 266 | UNGCPRO; | 284 | UNGCPRO; |
| 267 | 285 | ||
| 268 | /* VAL is the string of minibuffer text. */ | ||
| 269 | last_minibuf_string = val; | ||
| 270 | |||
| 271 | /* If Lisp form desired instead of string, parse it */ | ||
| 272 | if (expflag) | ||
| 273 | val = Fread (val); | ||
| 274 | |||
| 275 | return val; | 286 | return val; |
| 276 | } | 287 | } |
| 277 | 288 | ||
| @@ -455,7 +466,7 @@ If non-nil second arg INITIAL-INPUT is a string to insert before reading.") | |||
| 455 | return Fread_from_minibuffer (prompt, initial_input, Qnil, Qnil, Qnil); | 466 | return Fread_from_minibuffer (prompt, initial_input, Qnil, Qnil, Qnil); |
| 456 | } | 467 | } |
| 457 | 468 | ||
| 458 | DEFUN ("read-no-blanks-input", Fread_no_blanks_input, Sread_no_blanks_input, 2, 2, 0, | 469 | DEFUN ("read-no-blanks-input", Fread_no_blanks_input, Sread_no_blanks_input, 1, 2, 0, |
| 459 | "Args PROMPT and INIT, strings. Read a string from the terminal, not allowing blanks.\n\ | 470 | "Args PROMPT and INIT, strings. Read a string from the terminal, not allowing blanks.\n\ |
| 460 | Prompt with PROMPT, and provide INIT as an initial value of the input string.") | 471 | Prompt with PROMPT, and provide INIT as an initial value of the input string.") |
| 461 | (prompt, init) | 472 | (prompt, init) |
| @@ -1142,9 +1153,10 @@ is added, provided that matches some possible completion.") | |||
| 1142 | Lisp_Object completion, tem; | 1153 | Lisp_Object completion, tem; |
| 1143 | register int i; | 1154 | register int i; |
| 1144 | register unsigned char *completion_string; | 1155 | register unsigned char *completion_string; |
| 1145 | /* We keep calling Fbuffer_string | 1156 | struct gcpro gcpro1; |
| 1146 | rather than arrange for GC to hold onto a pointer to | 1157 | |
| 1147 | one of the strings thus made. */ | 1158 | /* We keep calling Fbuffer_string rather than arrange for GC to |
| 1159 | hold onto a pointer to one of the strings thus made. */ | ||
| 1148 | 1160 | ||
| 1149 | completion = Ftry_completion (Fbuffer_string (), | 1161 | completion = Ftry_completion (Fbuffer_string (), |
| 1150 | Vminibuffer_completion_table, | 1162 | Vminibuffer_completion_table, |
| @@ -1158,7 +1170,7 @@ is added, provided that matches some possible completion.") | |||
| 1158 | if (EQ (completion, Qt)) | 1170 | if (EQ (completion, Qt)) |
| 1159 | return Qnil; | 1171 | return Qnil; |
| 1160 | 1172 | ||
| 1161 | #if 0 /* How the below code used to look, for reference */ | 1173 | #if 0 /* How the below code used to look, for reference. */ |
| 1162 | tem = Fbuffer_string (); | 1174 | tem = Fbuffer_string (); |
| 1163 | b = XSTRING (tem)->data; | 1175 | b = XSTRING (tem)->data; |
| 1164 | i = ZV - 1 - XSTRING (completion)->size; | 1176 | i = ZV - 1 - XSTRING (completion)->size; |
| @@ -1215,19 +1227,26 @@ is added, provided that matches some possible completion.") | |||
| 1215 | i = ZV - BEGV; | 1227 | i = ZV - BEGV; |
| 1216 | 1228 | ||
| 1217 | /* If completion finds next char not unique, | 1229 | /* If completion finds next char not unique, |
| 1218 | consider adding a space or a hyphen */ | 1230 | consider adding a space or a hyphen. */ |
| 1219 | if (i == XSTRING (completion)->size) | 1231 | if (i == XSTRING (completion)->size) |
| 1220 | { | 1232 | { |
| 1233 | GCPRO1 (completion); | ||
| 1221 | tem = Ftry_completion (concat2 (Fbuffer_string (), build_string (" ")), | 1234 | tem = Ftry_completion (concat2 (Fbuffer_string (), build_string (" ")), |
| 1222 | Vminibuffer_completion_table, | 1235 | Vminibuffer_completion_table, |
| 1223 | Vminibuffer_completion_predicate); | 1236 | Vminibuffer_completion_predicate); |
| 1237 | UNGCPRO; | ||
| 1238 | |||
| 1224 | if (XTYPE (tem) == Lisp_String) | 1239 | if (XTYPE (tem) == Lisp_String) |
| 1225 | completion = tem; | 1240 | completion = tem; |
| 1226 | else | 1241 | else |
| 1227 | { | 1242 | { |
| 1228 | tem = Ftry_completion (concat2 (Fbuffer_string (), build_string ("-")), | 1243 | GCPRO1 (completion); |
| 1229 | Vminibuffer_completion_table, | 1244 | tem = |
| 1230 | Vminibuffer_completion_predicate); | 1245 | Ftry_completion (concat2 (Fbuffer_string (), build_string ("-")), |
| 1246 | Vminibuffer_completion_table, | ||
| 1247 | Vminibuffer_completion_predicate); | ||
| 1248 | UNGCPRO; | ||
| 1249 | |||
| 1231 | if (XTYPE (tem) == Lisp_String) | 1250 | if (XTYPE (tem) == Lisp_String) |
| 1232 | completion = tem; | 1251 | completion = tem; |
| 1233 | } | 1252 | } |
| @@ -1235,6 +1254,7 @@ is added, provided that matches some possible completion.") | |||
| 1235 | 1254 | ||
| 1236 | /* Now find first word-break in the stuff found by completion. | 1255 | /* Now find first word-break in the stuff found by completion. |
| 1237 | i gets index in string of where to stop completing. */ | 1256 | i gets index in string of where to stop completing. */ |
| 1257 | |||
| 1238 | completion_string = XSTRING (completion)->data; | 1258 | completion_string = XSTRING (completion)->data; |
| 1239 | 1259 | ||
| 1240 | for (; i < XSTRING (completion)->size; i++) | 1260 | for (; i < XSTRING (completion)->size; i++) |