Mercurial > emacs
comparison src/minibuf.c @ 9120:ed766dfb4efe
(read_minibuf, Fread_from_minibuffer, Fread_buffer, Ftry_completion,
Ftry_completion, Fall_completions, Fcompleting_read, do_completion,
assoc_for_completion, Fminibuffer_complete_word, Fdisplay_completion_list,
Fself_insert_and_exit): Use type test macros.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 27 Sep 1994 02:12:02 +0000 |
parents | 522a9e03ca05 |
children | f49aca34b7ae |
comparison
equal
deleted
inserted
replaced
9119:0c3c25c2456e | 9120:ed766dfb4efe |
---|---|
129 { | 129 { |
130 register Lisp_Object val; | 130 register Lisp_Object val; |
131 int count = specpdl_ptr - specpdl; | 131 int count = specpdl_ptr - specpdl; |
132 Lisp_Object mini_frame; | 132 Lisp_Object mini_frame; |
133 | 133 |
134 if (XTYPE (prompt) != Lisp_String) | 134 if (!STRINGP (prompt)) |
135 prompt = build_string (""); | 135 prompt = build_string (""); |
136 | 136 |
137 /* Emacs in -batch mode calls minibuffer: print the prompt. */ | 137 /* Emacs in -batch mode calls minibuffer: print the prompt. */ |
138 if (noninteractive && XTYPE (prompt) == Lisp_String) | 138 if (noninteractive && STRINGP (prompt)) |
139 printf ("%s", XSTRING (prompt)->data); | 139 printf ("%s", XSTRING (prompt)->data); |
140 | 140 |
141 if (!enable_recursive_minibuffers | 141 if (!enable_recursive_minibuffers |
142 && minibuf_level > 0 | 142 && minibuf_level > 0 |
143 && (EQ (selected_window, minibuf_window))) | 143 && (EQ (selected_window, minibuf_window))) |
185 the current_buffer, so reset_buffer leaves buf's default | 185 the current_buffer, so reset_buffer leaves buf's default |
186 directory unchanged. This is a bummer when you've just started | 186 directory unchanged. This is a bummer when you've just started |
187 up Emacs and buf's default directory is Qnil. Here's a hack; can | 187 up Emacs and buf's default directory is Qnil. Here's a hack; can |
188 you think of something better to do? Find another buffer with a | 188 you think of something better to do? Find another buffer with a |
189 better directory, and use that one instead. */ | 189 better directory, and use that one instead. */ |
190 if (XTYPE (val) == Lisp_String) | 190 if (STRINGP (val)) |
191 current_buffer->directory = val; | 191 current_buffer->directory = val; |
192 else | 192 else |
193 { | 193 { |
194 Lisp_Object buf_list; | 194 Lisp_Object buf_list; |
195 | 195 |
198 buf_list = XCONS (buf_list)->cdr) | 198 buf_list = XCONS (buf_list)->cdr) |
199 { | 199 { |
200 Lisp_Object other_buf; | 200 Lisp_Object other_buf; |
201 | 201 |
202 other_buf = XCONS (XCONS (buf_list)->car)->cdr; | 202 other_buf = XCONS (XCONS (buf_list)->car)->cdr; |
203 if (XTYPE (XBUFFER (other_buf)->directory) == Lisp_String) | 203 if (STRINGP (XBUFFER (other_buf)->directory)) |
204 { | 204 { |
205 current_buffer->directory = XBUFFER (other_buf)->directory; | 205 current_buffer->directory = XBUFFER (other_buf)->directory; |
206 break; | 206 break; |
207 } | 207 } |
208 } | 208 } |
226 minibuf_level++; | 226 minibuf_level++; |
227 | 227 |
228 if (!NILP (initial)) | 228 if (!NILP (initial)) |
229 { | 229 { |
230 Finsert (1, &initial); | 230 Finsert (1, &initial); |
231 if (!NILP (backup_n) && XTYPE (backup_n) == Lisp_Int) | 231 if (!NILP (backup_n) && INTEGERP (backup_n)) |
232 Fforward_char (backup_n); | 232 Fforward_char (backup_n); |
233 } | 233 } |
234 | 234 |
235 minibuf_prompt = Fcopy_sequence (prompt); | 235 minibuf_prompt = Fcopy_sequence (prompt); |
236 echo_area_glyphs = 0; | 236 echo_area_glyphs = 0; |
269 /* VAL is the string of minibuffer text. */ | 269 /* VAL is the string of minibuffer text. */ |
270 last_minibuf_string = val; | 270 last_minibuf_string = val; |
271 | 271 |
272 /* Add the value to the appropriate history list unless it is empty. */ | 272 /* Add the value to the appropriate history list unless it is empty. */ |
273 if (XSTRING (val)->size != 0 | 273 if (XSTRING (val)->size != 0 |
274 && XTYPE (Vminibuffer_history_variable) == Lisp_Symbol | 274 && SYMBOLP (Vminibuffer_history_variable) |
275 && ! EQ (XSYMBOL (Vminibuffer_history_variable)->value, Qunbound)) | 275 && ! EQ (XSYMBOL (Vminibuffer_history_variable)->value, Qunbound)) |
276 { | 276 { |
277 /* If the caller wanted to save the value read on a history list, | 277 /* If the caller wanted to save the value read on a history list, |
278 then do so if the value is not already the front of the list. */ | 278 then do so if the value is not already the front of the list. */ |
279 Lisp_Object histval; | 279 Lisp_Object histval; |
434 position = Qnil; | 434 position = Qnil; |
435 | 435 |
436 CHECK_STRING (prompt, 0); | 436 CHECK_STRING (prompt, 0); |
437 if (!NILP (initial_contents)) | 437 if (!NILP (initial_contents)) |
438 { | 438 { |
439 if (XTYPE (initial_contents) == Lisp_Cons) | 439 if (CONSP (initial_contents)) |
440 { | 440 { |
441 position = Fcdr (initial_contents); | 441 position = Fcdr (initial_contents); |
442 initial_contents = Fcar (initial_contents); | 442 initial_contents = Fcar (initial_contents); |
443 } | 443 } |
444 CHECK_STRING (initial_contents, 1); | 444 CHECK_STRING (initial_contents, 1); |
453 if (NILP (keymap)) | 453 if (NILP (keymap)) |
454 keymap = Vminibuffer_local_map; | 454 keymap = Vminibuffer_local_map; |
455 else | 455 else |
456 keymap = get_keymap (keymap,2); | 456 keymap = get_keymap (keymap,2); |
457 | 457 |
458 if (XTYPE (hist) == Lisp_Symbol) | 458 if (SYMBOLP (hist)) |
459 { | 459 { |
460 histvar = hist; | 460 histvar = hist; |
461 histpos = Qnil; | 461 histpos = Qnil; |
462 } | 462 } |
463 else | 463 else |
567 { | 567 { |
568 Lisp_Object tem; | 568 Lisp_Object tem; |
569 Lisp_Object args[3]; | 569 Lisp_Object args[3]; |
570 struct gcpro gcpro1; | 570 struct gcpro gcpro1; |
571 | 571 |
572 if (XTYPE (def) == Lisp_Buffer) | 572 if (BUFFERP (def)) |
573 def = XBUFFER (def)->name; | 573 def = XBUFFER (def)->name; |
574 if (!NILP (def)) | 574 if (!NILP (def)) |
575 { | 575 { |
576 args[0] = build_string ("%s(default %s) "); | 576 args[0] = build_string ("%s(default %s) "); |
577 args[1] = prompt; | 577 args[1] = prompt; |
616 int matchcount = 0; | 616 int matchcount = 0; |
617 Lisp_Object bucket, zero, end, tem; | 617 Lisp_Object bucket, zero, end, tem; |
618 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 618 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
619 | 619 |
620 CHECK_STRING (string, 0); | 620 CHECK_STRING (string, 0); |
621 if (!list && XTYPE (alist) != Lisp_Vector) | 621 if (!list && !VECTORP (alist)) |
622 return call3 (alist, string, pred, Qnil); | 622 return call3 (alist, string, pred, Qnil); |
623 | 623 |
624 bestmatch = Qnil; | 624 bestmatch = Qnil; |
625 | 625 |
626 /* If ALIST is not a list, set TAIL just for gc pro. */ | 626 /* If ALIST is not a list, set TAIL just for gc pro. */ |
667 } | 667 } |
668 } | 668 } |
669 | 669 |
670 /* Is this element a possible completion? */ | 670 /* Is this element a possible completion? */ |
671 | 671 |
672 if (XTYPE (eltstring) == Lisp_String | 672 if (STRINGP (eltstring) |
673 && XSTRING (string)->size <= XSTRING (eltstring)->size | 673 && XSTRING (string)->size <= XSTRING (eltstring)->size |
674 && 0 > scmp (XSTRING (eltstring)->data, XSTRING (string)->data, | 674 && 0 > scmp (XSTRING (eltstring)->data, XSTRING (string)->data, |
675 XSTRING (string)->size)) | 675 XSTRING (string)->size)) |
676 { | 676 { |
677 /* Yes. */ | 677 /* Yes. */ |
819 int index, obsize; | 819 int index, obsize; |
820 Lisp_Object bucket, tem; | 820 Lisp_Object bucket, tem; |
821 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 821 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
822 | 822 |
823 CHECK_STRING (string, 0); | 823 CHECK_STRING (string, 0); |
824 if (!list && XTYPE (alist) != Lisp_Vector) | 824 if (!list && !VECTORP (alist)) |
825 { | 825 { |
826 return call3 (alist, string, pred, Qt); | 826 return call3 (alist, string, pred, Qt); |
827 } | 827 } |
828 allmatches = Qnil; | 828 allmatches = Qnil; |
829 | 829 |
871 } | 871 } |
872 } | 872 } |
873 | 873 |
874 /* Is this element a possible completion? */ | 874 /* Is this element a possible completion? */ |
875 | 875 |
876 if (XTYPE (eltstring) == Lisp_String | 876 if (STRINGP (eltstring) |
877 && XSTRING (string)->size <= XSTRING (eltstring)->size | 877 && XSTRING (string)->size <= XSTRING (eltstring)->size |
878 /* Reject alternatives that start with space | 878 /* Reject alternatives that start with space |
879 unless the input starts with space. */ | 879 unless the input starts with space. */ |
880 && ((XSTRING (string)->size > 0 && XSTRING (string)->data[0] == ' ') | 880 && ((XSTRING (string)->size > 0 && XSTRING (string)->data[0] == ' ') |
881 || XSTRING (eltstring)->data[0] != ' ') | 881 || XSTRING (eltstring)->data[0] != ' ') |
973 last_exact_completion = Qnil; | 973 last_exact_completion = Qnil; |
974 | 974 |
975 position = Qnil; | 975 position = Qnil; |
976 if (!NILP (init)) | 976 if (!NILP (init)) |
977 { | 977 { |
978 if (XTYPE (init) == Lisp_Cons) | 978 if (CONSP (init)) |
979 { | 979 { |
980 position = Fcdr (init); | 980 position = Fcdr (init); |
981 init = Fcar (init); | 981 init = Fcar (init); |
982 } | 982 } |
983 CHECK_STRING (init, 0); | 983 CHECK_STRING (init, 0); |
987 /* Convert to distance from end of input. */ | 987 /* Convert to distance from end of input. */ |
988 pos = XINT (position) - XSTRING (init)->size; | 988 pos = XINT (position) - XSTRING (init)->size; |
989 } | 989 } |
990 } | 990 } |
991 | 991 |
992 if (XTYPE (hist) == Lisp_Symbol) | 992 if (SYMBOLP (hist)) |
993 { | 993 { |
994 histvar = hist; | 994 histvar = hist; |
995 histpos = Qnil; | 995 histpos = Qnil; |
996 } | 996 } |
997 else | 997 else |
1093 /* It did find a match. Do we match some possibility exactly now? */ | 1093 /* It did find a match. Do we match some possibility exactly now? */ |
1094 if (CONSP (Vminibuffer_completion_table) | 1094 if (CONSP (Vminibuffer_completion_table) |
1095 || NILP (Vminibuffer_completion_table)) | 1095 || NILP (Vminibuffer_completion_table)) |
1096 tem = assoc_for_completion (Fbuffer_string (), | 1096 tem = assoc_for_completion (Fbuffer_string (), |
1097 Vminibuffer_completion_table); | 1097 Vminibuffer_completion_table); |
1098 else if (XTYPE (Vminibuffer_completion_table) == Lisp_Vector) | 1098 else if (VECTORP (Vminibuffer_completion_table)) |
1099 { | 1099 { |
1100 /* the primitive used by Fintern_soft */ | 1100 /* the primitive used by Fintern_soft */ |
1101 extern Lisp_Object oblookup (); | 1101 extern Lisp_Object oblookup (); |
1102 | 1102 |
1103 tem = Fbuffer_string (); | 1103 tem = Fbuffer_string (); |
1104 /* Bypass intern-soft as that loses for nil */ | 1104 /* Bypass intern-soft as that loses for nil */ |
1105 tem = oblookup (Vminibuffer_completion_table, | 1105 tem = oblookup (Vminibuffer_completion_table, |
1106 XSTRING (tem)->data, XSTRING (tem)->size); | 1106 XSTRING (tem)->data, XSTRING (tem)->size); |
1107 if (XTYPE (tem) != Lisp_Symbol) | 1107 if (!SYMBOLP (tem)) |
1108 tem = Qnil; | 1108 tem = Qnil; |
1109 else if (!NILP (Vminibuffer_completion_predicate)) | 1109 else if (!NILP (Vminibuffer_completion_predicate)) |
1110 tem = call1 (Vminibuffer_completion_predicate, tem); | 1110 tem = call1 (Vminibuffer_completion_predicate, tem); |
1111 else | 1111 else |
1112 tem = Qt; | 1112 tem = Qt; |
1164 { | 1164 { |
1165 register Lisp_Object elt, tem, thiscar; | 1165 register Lisp_Object elt, tem, thiscar; |
1166 elt = Fcar (tail); | 1166 elt = Fcar (tail); |
1167 if (!CONSP (elt)) continue; | 1167 if (!CONSP (elt)) continue; |
1168 thiscar = Fcar (elt); | 1168 thiscar = Fcar (elt); |
1169 if (XTYPE (thiscar) != Lisp_String) | 1169 if (!STRINGP (thiscar)) |
1170 continue; | 1170 continue; |
1171 if (completion_ignore_case) | 1171 if (completion_ignore_case) |
1172 thiscar = Fupcase (thiscar); | 1172 thiscar = Fupcase (thiscar); |
1173 tem = Fequal (thiscar, key); | 1173 tem = Fequal (thiscar, key); |
1174 if (!NILP (tem)) return elt; | 1174 if (!NILP (tem)) return elt; |
1364 tem = Ftry_completion (concat2 (Fbuffer_string (), build_string (" ")), | 1364 tem = Ftry_completion (concat2 (Fbuffer_string (), build_string (" ")), |
1365 Vminibuffer_completion_table, | 1365 Vminibuffer_completion_table, |
1366 Vminibuffer_completion_predicate); | 1366 Vminibuffer_completion_predicate); |
1367 UNGCPRO; | 1367 UNGCPRO; |
1368 | 1368 |
1369 if (XTYPE (tem) == Lisp_String) | 1369 if (STRINGP (tem)) |
1370 completion = tem; | 1370 completion = tem; |
1371 else | 1371 else |
1372 { | 1372 { |
1373 GCPRO1 (completion); | 1373 GCPRO1 (completion); |
1374 tem = | 1374 tem = |
1375 Ftry_completion (concat2 (Fbuffer_string (), build_string ("-")), | 1375 Ftry_completion (concat2 (Fbuffer_string (), build_string ("-")), |
1376 Vminibuffer_completion_table, | 1376 Vminibuffer_completion_table, |
1377 Vminibuffer_completion_predicate); | 1377 Vminibuffer_completion_predicate); |
1378 UNGCPRO; | 1378 UNGCPRO; |
1379 | 1379 |
1380 if (XTYPE (tem) == Lisp_String) | 1380 if (STRINGP (tem)) |
1381 completion = tem; | 1381 completion = tem; |
1382 } | 1382 } |
1383 } | 1383 } |
1384 | 1384 |
1385 /* Now find first word-break in the stuff found by completion. | 1385 /* Now find first word-break in the stuff found by completion. |
1427 | 1427 |
1428 /* Note that (when it matters) every variable | 1428 /* Note that (when it matters) every variable |
1429 points to a non-string that is pointed to by COMPLETIONS. */ | 1429 points to a non-string that is pointed to by COMPLETIONS. */ |
1430 GCPRO1 (completions); | 1430 GCPRO1 (completions); |
1431 | 1431 |
1432 if (XTYPE (Vstandard_output) == Lisp_Buffer) | 1432 if (BUFFERP (Vstandard_output)) |
1433 set_buffer_internal (XBUFFER (Vstandard_output)); | 1433 set_buffer_internal (XBUFFER (Vstandard_output)); |
1434 | 1434 |
1435 if (NILP (completions)) | 1435 if (NILP (completions)) |
1436 write_string ("There are no possible completions of what you have typed.", | 1436 write_string ("There are no possible completions of what you have typed.", |
1437 -1); | 1437 -1); |
1444 and/or narrow windows */ | 1444 and/or narrow windows */ |
1445 /* Sadly, the window it will appear in is not known | 1445 /* Sadly, the window it will appear in is not known |
1446 until after the text has been made. */ | 1446 until after the text has been made. */ |
1447 if (i & 1) | 1447 if (i & 1) |
1448 { | 1448 { |
1449 if (XTYPE (Vstandard_output) == Lisp_Buffer) | 1449 if (BUFFERP (Vstandard_output)) |
1450 Findent_to (make_number (35), make_number (2)); | 1450 Findent_to (make_number (35), make_number (2)); |
1451 else | 1451 else |
1452 { | 1452 { |
1453 do | 1453 do |
1454 { | 1454 { |
1464 column = 0; | 1464 column = 0; |
1465 } | 1465 } |
1466 elt = Fcar (tail); | 1466 elt = Fcar (tail); |
1467 if (CONSP (elt)) | 1467 if (CONSP (elt)) |
1468 { | 1468 { |
1469 if (XTYPE (Vstandard_output) != Lisp_Buffer) | 1469 if (!BUFFERP (Vstandard_output)) |
1470 { | 1470 { |
1471 Lisp_Object tem; | 1471 Lisp_Object tem; |
1472 tem = Flength (Fcar (elt)); | 1472 tem = Flength (Fcar (elt)); |
1473 column += XINT (tem); | 1473 column += XINT (tem); |
1474 tem = Flength (Fcar (Fcdr (elt))); | 1474 tem = Flength (Fcar (Fcdr (elt))); |
1477 Fprinc (Fcar (elt), Qnil); | 1477 Fprinc (Fcar (elt), Qnil); |
1478 Fprinc (Fcar (Fcdr (elt)), Qnil); | 1478 Fprinc (Fcar (Fcdr (elt)), Qnil); |
1479 } | 1479 } |
1480 else | 1480 else |
1481 { | 1481 { |
1482 if (XTYPE (Vstandard_output) != Lisp_Buffer) | 1482 if (!BUFFERP (Vstandard_output)) |
1483 { | 1483 { |
1484 Lisp_Object tem; | 1484 Lisp_Object tem; |
1485 tem = Flength (elt); | 1485 tem = Flength (elt); |
1486 column += XINT (tem); | 1486 column += XINT (tem); |
1487 } | 1487 } |
1490 } | 1490 } |
1491 } | 1491 } |
1492 | 1492 |
1493 UNGCPRO; | 1493 UNGCPRO; |
1494 | 1494 |
1495 if (XTYPE (Vstandard_output) == Lisp_Buffer) | 1495 if (BUFFERP (Vstandard_output)) |
1496 set_buffer_internal (old); | 1496 set_buffer_internal (old); |
1497 | 1497 |
1498 if (!NILP (Vrun_hooks)) | 1498 if (!NILP (Vrun_hooks)) |
1499 call1 (Vrun_hooks, intern ("completion-setup-hook")); | 1499 call1 (Vrun_hooks, intern ("completion-setup-hook")); |
1500 | 1500 |
1528 | 1528 |
1529 DEFUN ("self-insert-and-exit", Fself_insert_and_exit, Sself_insert_and_exit, 0, 0, "", | 1529 DEFUN ("self-insert-and-exit", Fself_insert_and_exit, Sself_insert_and_exit, 0, 0, "", |
1530 "Terminate minibuffer input.") | 1530 "Terminate minibuffer input.") |
1531 () | 1531 () |
1532 { | 1532 { |
1533 if (XTYPE (last_command_char) == Lisp_Int) | 1533 if (INTEGERP (last_command_char)) |
1534 internal_self_insert (last_command_char, 0); | 1534 internal_self_insert (last_command_char, 0); |
1535 else | 1535 else |
1536 bitch_at_user (); | 1536 bitch_at_user (); |
1537 | 1537 |
1538 Fthrow (Qexit, Qnil); | 1538 Fthrow (Qexit, Qnil); |