Mercurial > emacs
comparison src/minibuf.c @ 89943:4c90ffeb71c5
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-15
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-218
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-220
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-221
Restore deleted tagline in etc/TUTORIAL.ru
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-222
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-228
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-229
Remove TeX output files from the archive
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-230
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-247
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-248
src/lisp.h (CYCLE_CHECK): Macro moved from xfaces.c
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-249
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-256
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-258
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-263
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-264
Update from CVS: lispref/display.texi: emacs -> Emacs.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-265
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-274
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-275
Update from CVS: man/makefile.w32-in: Revert last change
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-276
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-295
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-296
Allow restarting an existing debugger session that's exited
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-297
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-299
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-300
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-327
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-328
Update from CVS: src/.gdbinit (xsymbol): Fix last change.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-329
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-344
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-345
Tweak source regexps so that building in place won't cause problems
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-346
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-351
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-352
Update from CVS: lisp/flymake.el: New file.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-361
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-362
Support " [...]" style defaults in minibuffer-electric-default-mode
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-363
(read-number): Use canonical format for default in prompt.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-364
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-367
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-368
Improve display-supports-face-attributes-p on non-ttys
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369
Rewrite face-differs-from-default-p
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-370
Move `display-supports-face-attributes-p' entirely into C code
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-371
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-372
Simplify face-differs-from-default-p; don't consider :stipple.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-373
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-374
(tty_supports_face_attributes_p): Ensure attributes differ from default
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-375
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-376
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-377
(Fdisplay_supports_face_attributes_p): Work around bootstrapping problem
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-378
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-380
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-381
Face merging cleanups
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-382
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-384
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-385
src/xfaces.c (push_named_merge_point): Return 0 if a cycle is detected
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-386
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-395
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-396
Tweak arch tagging to make build/install-in-place less annoying
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Work around vc-arch problems when building eshell
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-398
Tweak permissions
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-399
Tweak directory permissions
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-400
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-401
More build-in-place tweaking of arch tagging
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-402
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-403
Yet more build-in-place tweaking of arch tagging
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-404
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-409
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-410
Make sure image types are initialized for lookup too
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-411
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-416
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 28 Jun 2004 07:56:49 +0000 |
parents | 68c22ea6027c ce63b548f490 |
children | d8411455de48 |
comparison
equal
deleted
inserted
replaced
89942:9cb747ae49af | 89943:4c90ffeb71c5 |
---|---|
1 /* Minibuffer input and completion. | 1 /* Minibuffer input and completion. |
2 Copyright (C) 1985,86,93,94,95,96,97,98,99,2000,01,03 | 2 Copyright (C) 1985,86,93,94,95,96,97,98,99,2000,01,03,04 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GNU Emacs. | 5 This file is part of GNU Emacs. |
6 | 6 |
7 GNU Emacs is free software; you can redistribute it and/or modify | 7 GNU Emacs is free software; you can redistribute it and/or modify |
207 | 207 |
208 | 208 |
209 /* Actual minibuffer invocation. */ | 209 /* Actual minibuffer invocation. */ |
210 | 210 |
211 static Lisp_Object read_minibuf_unwind P_ ((Lisp_Object)); | 211 static Lisp_Object read_minibuf_unwind P_ ((Lisp_Object)); |
212 static Lisp_Object run_exit_minibuf_hook P_ ((Lisp_Object)); | |
212 static Lisp_Object read_minibuf P_ ((Lisp_Object, Lisp_Object, | 213 static Lisp_Object read_minibuf P_ ((Lisp_Object, Lisp_Object, |
213 Lisp_Object, Lisp_Object, | 214 Lisp_Object, Lisp_Object, |
214 int, Lisp_Object, | 215 int, Lisp_Object, |
215 Lisp_Object, Lisp_Object, | 216 Lisp_Object, Lisp_Object, |
216 int, int)); | 217 int, int)); |
561 Fcons (Vminibuffer_history_variable, | 562 Fcons (Vminibuffer_history_variable, |
562 minibuf_save_list)))))); | 563 minibuf_save_list)))))); |
563 | 564 |
564 record_unwind_protect (read_minibuf_unwind, Qnil); | 565 record_unwind_protect (read_minibuf_unwind, Qnil); |
565 minibuf_level++; | 566 minibuf_level++; |
567 /* We are exiting the minibuffer one way or the other, so run the hook. | |
568 It should be run before unwinding the minibuf settings. Do it | |
569 separately from read_minibuf_unwind because we need to make sure that | |
570 read_minibuf_unwind is fully executed even if exit-minibuffer-hook | |
571 signals an error. --Stef */ | |
572 record_unwind_protect (run_exit_minibuf_hook, Qnil); | |
566 | 573 |
567 /* Now that we can restore all those variables, start changing them. */ | 574 /* Now that we can restore all those variables, start changing them. */ |
568 | 575 |
569 minibuf_prompt_width = 0; | 576 minibuf_prompt_width = 0; |
570 minibuf_prompt = Fcopy_sequence (prompt); | 577 minibuf_prompt = Fcopy_sequence (prompt); |
820 } | 827 } |
821 | 828 |
822 return buf; | 829 return buf; |
823 } | 830 } |
824 | 831 |
832 static Lisp_Object | |
833 run_exit_minibuf_hook (data) | |
834 Lisp_Object data; | |
835 { | |
836 if (!NILP (Vminibuffer_exit_hook) && !EQ (Vminibuffer_exit_hook, Qunbound) | |
837 && !NILP (Vrun_hooks)) | |
838 safe_run_hooks (Qminibuffer_exit_hook); | |
839 | |
840 return Qnil; | |
841 } | |
842 | |
825 /* This function is called on exiting minibuffer, whether normally or | 843 /* This function is called on exiting minibuffer, whether normally or |
826 not, and it restores the current window, buffer, etc. */ | 844 not, and it restores the current window, buffer, etc. */ |
827 | 845 |
828 static Lisp_Object | 846 static Lisp_Object |
829 read_minibuf_unwind (data) | 847 read_minibuf_unwind (data) |
830 Lisp_Object data; | 848 Lisp_Object data; |
831 { | 849 { |
832 Lisp_Object old_deactivate_mark; | 850 Lisp_Object old_deactivate_mark; |
833 Lisp_Object window; | 851 Lisp_Object window; |
834 | |
835 /* We are exiting the minibuffer one way or the other, | |
836 so run the hook. */ | |
837 if (!NILP (Vminibuffer_exit_hook) && !EQ (Vminibuffer_exit_hook, Qunbound) | |
838 && !NILP (Vrun_hooks)) | |
839 safe_run_hooks (Qminibuffer_exit_hook); | |
840 | 852 |
841 /* If this was a recursive minibuffer, | 853 /* If this was a recursive minibuffer, |
842 tie the minibuffer window back to the outer level minibuffer buffer. */ | 854 tie the minibuffer window back to the outer level minibuffer buffer. */ |
843 minibuf_level--; | 855 minibuf_level--; |
844 | 856 |
1193 : NILP (alist) || (CONSP (alist) | 1205 : NILP (alist) || (CONSP (alist) |
1194 && (!SYMBOLP (XCAR (alist)) | 1206 && (!SYMBOLP (XCAR (alist)) |
1195 || NILP (XCAR (alist)))); | 1207 || NILP (XCAR (alist)))); |
1196 int index = 0, obsize = 0; | 1208 int index = 0, obsize = 0; |
1197 int matchcount = 0; | 1209 int matchcount = 0; |
1210 int bindcount = -1; | |
1198 Lisp_Object bucket, zero, end, tem; | 1211 Lisp_Object bucket, zero, end, tem; |
1199 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 1212 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
1200 | 1213 |
1201 CHECK_STRING (string); | 1214 CHECK_STRING (string); |
1202 if (type == 0) | 1215 if (type == 0) |
1272 Lisp_Object zero; | 1285 Lisp_Object zero; |
1273 XSETFASTINT (zero, 0); | 1286 XSETFASTINT (zero, 0); |
1274 | 1287 |
1275 /* Ignore this element if it fails to match all the regexps. */ | 1288 /* Ignore this element if it fails to match all the regexps. */ |
1276 { | 1289 { |
1277 int count = SPECPDL_INDEX (); | |
1278 specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil); | |
1279 for (regexps = Vcompletion_regexp_list; CONSP (regexps); | 1290 for (regexps = Vcompletion_regexp_list; CONSP (regexps); |
1280 regexps = XCDR (regexps)) | 1291 regexps = XCDR (regexps)) |
1281 { | 1292 { |
1293 if (bindcount < 0) { | |
1294 bindcount = SPECPDL_INDEX (); | |
1295 specbind (Qcase_fold_search, | |
1296 completion_ignore_case ? Qt : Qnil); | |
1297 } | |
1282 tem = Fstring_match (XCAR (regexps), eltstring, zero); | 1298 tem = Fstring_match (XCAR (regexps), eltstring, zero); |
1283 if (NILP (tem)) | 1299 if (NILP (tem)) |
1284 break; | 1300 break; |
1285 } | 1301 } |
1286 unbind_to (count, Qnil); | |
1287 if (CONSP (regexps)) | 1302 if (CONSP (regexps)) |
1288 continue; | 1303 continue; |
1289 } | 1304 } |
1290 | 1305 |
1291 /* Ignore this element if there is a predicate | 1306 /* Ignore this element if there is a predicate |
1295 { | 1310 { |
1296 if (EQ (predicate, Qcommandp)) | 1311 if (EQ (predicate, Qcommandp)) |
1297 tem = Fcommandp (elt, Qnil); | 1312 tem = Fcommandp (elt, Qnil); |
1298 else | 1313 else |
1299 { | 1314 { |
1315 if (bindcount >= 0) { | |
1316 unbind_to (bindcount, Qnil); | |
1317 bindcount = -1; | |
1318 } | |
1300 GCPRO4 (tail, string, eltstring, bestmatch); | 1319 GCPRO4 (tail, string, eltstring, bestmatch); |
1301 tem = type == 3 | 1320 tem = type == 3 |
1302 ? call2 (predicate, elt, | 1321 ? call2 (predicate, elt, |
1303 HASH_VALUE (XHASH_TABLE (alist), index - 1)) | 1322 HASH_VALUE (XHASH_TABLE (alist), index - 1)) |
1304 : call1 (predicate, elt); | 1323 : call1 (predicate, elt); |
1376 break; | 1395 break; |
1377 } | 1396 } |
1378 } | 1397 } |
1379 } | 1398 } |
1380 | 1399 |
1400 if (bindcount >= 0) { | |
1401 unbind_to (bindcount, Qnil); | |
1402 bindcount = -1; | |
1403 } | |
1404 | |
1381 if (NILP (bestmatch)) | 1405 if (NILP (bestmatch)) |
1382 return Qnil; /* No completions found */ | 1406 return Qnil; /* No completions found */ |
1383 /* If we are ignoring case, and there is no exact match, | 1407 /* If we are ignoring case, and there is no exact match, |
1384 and no additional text was supplied, | 1408 and no additional text was supplied, |
1385 don't change the case of what the user typed. */ | 1409 don't change the case of what the user typed. */ |
1438 : VECTORP (alist) ? 2 | 1462 : VECTORP (alist) ? 2 |
1439 : NILP (alist) || (CONSP (alist) | 1463 : NILP (alist) || (CONSP (alist) |
1440 && (!SYMBOLP (XCAR (alist)) | 1464 && (!SYMBOLP (XCAR (alist)) |
1441 || NILP (XCAR (alist)))); | 1465 || NILP (XCAR (alist)))); |
1442 int index = 0, obsize = 0; | 1466 int index = 0, obsize = 0; |
1467 int bindcount = -1; | |
1443 Lisp_Object bucket, tem; | 1468 Lisp_Object bucket, tem; |
1444 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 1469 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
1445 | 1470 |
1446 CHECK_STRING (string); | 1471 CHECK_STRING (string); |
1447 if (type == 0) | 1472 if (type == 0) |
1523 Lisp_Object zero; | 1548 Lisp_Object zero; |
1524 XSETFASTINT (zero, 0); | 1549 XSETFASTINT (zero, 0); |
1525 | 1550 |
1526 /* Ignore this element if it fails to match all the regexps. */ | 1551 /* Ignore this element if it fails to match all the regexps. */ |
1527 { | 1552 { |
1528 int count = SPECPDL_INDEX (); | |
1529 specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil); | |
1530 for (regexps = Vcompletion_regexp_list; CONSP (regexps); | 1553 for (regexps = Vcompletion_regexp_list; CONSP (regexps); |
1531 regexps = XCDR (regexps)) | 1554 regexps = XCDR (regexps)) |
1532 { | 1555 { |
1556 if (bindcount < 0) { | |
1557 bindcount = SPECPDL_INDEX (); | |
1558 specbind (Qcase_fold_search, | |
1559 completion_ignore_case ? Qt : Qnil); | |
1560 } | |
1533 tem = Fstring_match (XCAR (regexps), eltstring, zero); | 1561 tem = Fstring_match (XCAR (regexps), eltstring, zero); |
1534 if (NILP (tem)) | 1562 if (NILP (tem)) |
1535 break; | 1563 break; |
1536 } | 1564 } |
1537 unbind_to (count, Qnil); | |
1538 if (CONSP (regexps)) | 1565 if (CONSP (regexps)) |
1539 continue; | 1566 continue; |
1540 } | 1567 } |
1541 | 1568 |
1542 /* Ignore this element if there is a predicate | 1569 /* Ignore this element if there is a predicate |
1546 { | 1573 { |
1547 if (EQ (predicate, Qcommandp)) | 1574 if (EQ (predicate, Qcommandp)) |
1548 tem = Fcommandp (elt, Qnil); | 1575 tem = Fcommandp (elt, Qnil); |
1549 else | 1576 else |
1550 { | 1577 { |
1578 if (bindcount >= 0) { | |
1579 unbind_to (bindcount, Qnil); | |
1580 bindcount = -1; | |
1581 } | |
1551 GCPRO4 (tail, eltstring, allmatches, string); | 1582 GCPRO4 (tail, eltstring, allmatches, string); |
1552 tem = type == 3 | 1583 tem = type == 3 |
1553 ? call2 (predicate, elt, | 1584 ? call2 (predicate, elt, |
1554 HASH_VALUE (XHASH_TABLE (alist), index - 1)) | 1585 HASH_VALUE (XHASH_TABLE (alist), index - 1)) |
1555 : call1 (predicate, elt); | 1586 : call1 (predicate, elt); |
1560 /* Ok => put it on the list. */ | 1591 /* Ok => put it on the list. */ |
1561 allmatches = Fcons (eltstring, allmatches); | 1592 allmatches = Fcons (eltstring, allmatches); |
1562 } | 1593 } |
1563 } | 1594 } |
1564 | 1595 |
1596 if (bindcount >= 0) { | |
1597 unbind_to (bindcount, Qnil); | |
1598 bindcount = -1; | |
1599 } | |
1600 | |
1565 return Fnreverse (allmatches); | 1601 return Fnreverse (allmatches); |
1566 } | 1602 } |
1567 | 1603 |
1568 Lisp_Object Vminibuffer_completion_table, Qminibuffer_completion_table; | 1604 Lisp_Object Vminibuffer_completion_table, Qminibuffer_completion_table; |
1569 Lisp_Object Vminibuffer_completion_predicate, Qminibuffer_completion_predicate; | 1605 Lisp_Object Vminibuffer_completion_predicate, Qminibuffer_completion_predicate; |
1600 variable to use, or it can be a cons cell (HISTVAR . HISTPOS). In | 1636 variable to use, or it can be a cons cell (HISTVAR . HISTPOS). In |
1601 that case, HISTVAR is the history list variable to use, and HISTPOS | 1637 that case, HISTVAR is the history list variable to use, and HISTPOS |
1602 is the initial position (the position in the list used by the | 1638 is the initial position (the position in the list used by the |
1603 minibuffer history commands). For consistency, you should also | 1639 minibuffer history commands). For consistency, you should also |
1604 specify that element of the history as the value of | 1640 specify that element of the history as the value of |
1605 INITIAL-CONTENTS. (This is the only case in which you should use | 1641 INITIAL-INPUT. (This is the only case in which you should use |
1606 INITIAL-INPUT instead of DEF.) Positions are counted starting from | 1642 INITIAL-INPUT instead of DEF.) Positions are counted starting from |
1607 1 at the beginning of the list. The variable `history-length' | 1643 1 at the beginning of the list. The variable `history-length' |
1608 controls the maximum length of a history list. | 1644 controls the maximum length of a history list. |
1609 | 1645 |
1610 DEF, if non-nil, is the default value. | 1646 DEF, if non-nil, is the default value. |
1770 } | 1806 } |
1771 else | 1807 else |
1772 return call3 (alist, string, predicate, Qlambda); | 1808 return call3 (alist, string, predicate, Qlambda); |
1773 | 1809 |
1774 /* Reject this element if it fails to match all the regexps. */ | 1810 /* Reject this element if it fails to match all the regexps. */ |
1775 { | 1811 if (CONSP (Vcompletion_regexp_list)) |
1776 int count = SPECPDL_INDEX (); | 1812 { |
1777 specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil); | 1813 int count = SPECPDL_INDEX (); |
1778 for (regexps = Vcompletion_regexp_list; CONSP (regexps); | 1814 specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil); |
1779 regexps = XCDR (regexps)) | 1815 for (regexps = Vcompletion_regexp_list; CONSP (regexps); |
1780 { | 1816 regexps = XCDR (regexps)) |
1781 if (NILP (Fstring_match (XCAR (regexps), | 1817 { |
1782 SYMBOLP (tem) ? string : tem, | 1818 if (NILP (Fstring_match (XCAR (regexps), |
1783 Qnil))) | 1819 SYMBOLP (tem) ? string : tem, |
1784 return unbind_to (count, Qnil); | 1820 Qnil))) |
1785 } | 1821 return unbind_to (count, Qnil); |
1786 unbind_to (count, Qnil); | 1822 } |
1787 } | 1823 unbind_to (count, Qnil); |
1824 } | |
1788 | 1825 |
1789 /* Finally, check the predicate. */ | 1826 /* Finally, check the predicate. */ |
1790 if (!NILP (predicate)) | 1827 if (!NILP (predicate)) |
1791 { | 1828 { |
1792 return HASH_TABLE_P (alist) | 1829 return HASH_TABLE_P (alist) |