427 |
GCPRO5 (map, initial, val, ambient_dir, input_method); |
GCPRO5 (map, initial, val, ambient_dir, input_method); |
428 |
|
|
429 |
if (!STRINGP (prompt)) |
if (!STRINGP (prompt)) |
430 |
prompt = build_string (""); |
prompt = empty_string; |
431 |
|
|
432 |
if (!enable_recursive_minibuffers |
if (!enable_recursive_minibuffers |
433 |
&& minibuf_level > 0) |
&& minibuf_level > 0) |
1103 |
int bestmatchsize = 0; |
int bestmatchsize = 0; |
1104 |
/* These are in bytes, too. */ |
/* These are in bytes, too. */ |
1105 |
int compare, matchsize; |
int compare, matchsize; |
1106 |
int list = CONSP (alist) || NILP (alist); |
int list = NILP (alist) || (CONSP (alist) |
1107 |
|
&& (!SYMBOLP (XCAR (alist)) |
1108 |
|
|| NILP (XCAR (alist)))); |
1109 |
int index = 0, obsize = 0; |
int index = 0, obsize = 0; |
1110 |
int matchcount = 0; |
int matchcount = 0; |
1111 |
Lisp_Object bucket, zero, end, tem; |
Lisp_Object bucket, zero, end, tem; |
1135 |
|
|
1136 |
if (list) |
if (list) |
1137 |
{ |
{ |
1138 |
if (NILP (tail)) |
if (!CONSP (tail)) |
1139 |
break; |
break; |
1140 |
elt = Fcar (tail); |
elt = XCAR (tail); |
1141 |
eltstring = Fcar (elt); |
eltstring = CONSP (elt) ? XCAR (elt) : elt; |
1142 |
tail = Fcdr (tail); |
tail = XCDR (tail); |
1143 |
} |
} |
1144 |
else |
else |
1145 |
{ |
{ |
1227 |
matchsize = XINT (tem) - 1; |
matchsize = XINT (tem) - 1; |
1228 |
|
|
1229 |
if (matchsize < 0) |
if (matchsize < 0) |
1230 |
|
/* When can this happen ? -stef */ |
1231 |
matchsize = compare; |
matchsize = compare; |
1232 |
if (completion_ignore_case) |
if (completion_ignore_case) |
1233 |
{ |
{ |
1262 |
bestmatch = eltstring; |
bestmatch = eltstring; |
1263 |
} |
} |
1264 |
bestmatchsize = matchsize; |
bestmatchsize = matchsize; |
1265 |
|
if (matchsize <= XSTRING (string)->size |
1266 |
|
&& matchcount > 1) |
1267 |
|
/* No need to look any further. */ |
1268 |
|
break; |
1269 |
} |
} |
1270 |
} |
} |
1271 |
} |
} |
1323 |
{ |
{ |
1324 |
Lisp_Object tail, elt, eltstring; |
Lisp_Object tail, elt, eltstring; |
1325 |
Lisp_Object allmatches; |
Lisp_Object allmatches; |
1326 |
int list = CONSP (alist) || NILP (alist); |
int list = NILP (alist) || (CONSP (alist) |
1327 |
|
&& (!SYMBOLP (XCAR (alist)) |
1328 |
|
|| NILP (XCAR (alist)))); |
1329 |
int index = 0, obsize = 0; |
int index = 0, obsize = 0; |
1330 |
Lisp_Object bucket, tem; |
Lisp_Object bucket, tem; |
1331 |
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
1355 |
|
|
1356 |
if (list) |
if (list) |
1357 |
{ |
{ |
1358 |
if (NILP (tail)) |
if (!CONSP (tail)) |
1359 |
break; |
break; |
1360 |
elt = Fcar (tail); |
elt = XCAR (tail); |
1361 |
eltstring = Fcar (elt); |
eltstring = CONSP (elt) ? XCAR (elt) : elt; |
1362 |
tail = Fcdr (tail); |
tail = XCDR (tail); |
1363 |
} |
} |
1364 |
else |
else |
1365 |
{ |
{ |
1495 |
specbind (Qminibuffer_completion_table, table); |
specbind (Qminibuffer_completion_table, table); |
1496 |
specbind (Qminibuffer_completion_predicate, predicate); |
specbind (Qminibuffer_completion_predicate, predicate); |
1497 |
specbind (Qminibuffer_completion_confirm, |
specbind (Qminibuffer_completion_confirm, |
1498 |
EQ (require_match, Qt) ? Qnil : Qt); |
EQ (require_match, Qt) ? Qnil : require_match); |
1499 |
last_exact_completion = Qnil; |
last_exact_completion = Qnil; |
1500 |
|
|
1501 |
position = Qnil; |
position = Qnil; |
1544 |
} |
} |
1545 |
|
|
1546 |
Lisp_Object Fminibuffer_completion_help (); |
Lisp_Object Fminibuffer_completion_help (); |
1547 |
Lisp_Object assoc_for_completion (); |
Lisp_Object Fassoc_string (); |
1548 |
|
|
1549 |
/* Test whether TXT is an exact completion. */ |
/* Test whether TXT is an exact completion. */ |
1550 |
Lisp_Object |
DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, |
1551 |
test_completion (txt) |
doc: /* Return non-nil if STRING is a valid completion. |
1552 |
Lisp_Object txt; |
Takes the same arguments as `all-completions' and `try-completion'. |
1553 |
|
If ALIST is a function, it is called with three arguments: |
1554 |
|
the values STRING, PREDICATE and `lambda'. */) |
1555 |
|
(string, alist, predicate) |
1556 |
|
Lisp_Object string, alist, predicate; |
1557 |
{ |
{ |
1558 |
Lisp_Object tem; |
Lisp_Object regexps, tem = Qnil; |
1559 |
|
|
1560 |
if (CONSP (Vminibuffer_completion_table) |
CHECK_STRING (string); |
1561 |
|| NILP (Vminibuffer_completion_table)) |
|
1562 |
return assoc_for_completion (txt, Vminibuffer_completion_table); |
if ((CONSP (alist) && (!SYMBOLP (XCAR (alist)) || NILP (XCAR (alist)))) |
1563 |
else if (VECTORP (Vminibuffer_completion_table)) |
|| NILP (alist)) |
1564 |
{ |
{ |
1565 |
/* Bypass intern-soft as that loses for nil */ |
tem = Fassoc_string (string, alist, completion_ignore_case ? Qt : Qnil); |
1566 |
tem = oblookup (Vminibuffer_completion_table, |
if (CONSP (tem)) |
1567 |
XSTRING (txt)->data, |
tem = XCAR (tem); |
1568 |
XSTRING (txt)->size, |
else |
1569 |
STRING_BYTES (XSTRING (txt))); |
return Qnil; |
1570 |
|
} |
1571 |
|
else if (VECTORP (alist)) |
1572 |
|
{ |
1573 |
|
/* Bypass intern-soft as that loses for nil. */ |
1574 |
|
tem = oblookup (alist, |
1575 |
|
XSTRING (string)->data, |
1576 |
|
XSTRING (string)->size, |
1577 |
|
STRING_BYTES (XSTRING (string))); |
1578 |
if (!SYMBOLP (tem)) |
if (!SYMBOLP (tem)) |
1579 |
{ |
{ |
1580 |
if (STRING_MULTIBYTE (txt)) |
if (STRING_MULTIBYTE (string)) |
1581 |
txt = Fstring_make_unibyte (txt); |
string = Fstring_make_unibyte (string); |
1582 |
else |
else |
1583 |
txt = Fstring_make_multibyte (txt); |
string = Fstring_make_multibyte (string); |
1584 |
|
|
1585 |
tem = oblookup (Vminibuffer_completion_table, |
tem = oblookup (Vminibuffer_completion_table, |
1586 |
XSTRING (txt)->data, |
XSTRING (string)->data, |
1587 |
XSTRING (txt)->size, |
XSTRING (string)->size, |
1588 |
STRING_BYTES (XSTRING (txt))); |
STRING_BYTES (XSTRING (string))); |
1589 |
if (!SYMBOLP (tem)) |
if (!SYMBOLP (tem)) |
1590 |
return Qnil; |
return Qnil; |
1591 |
} |
} |
|
if (!NILP (Vminibuffer_completion_predicate)) |
|
|
return call1 (Vminibuffer_completion_predicate, tem); |
|
|
else |
|
|
return Qt; |
|
1592 |
} |
} |
1593 |
else |
else |
1594 |
return call3 (Vminibuffer_completion_table, txt, |
return call3 (alist, string, predicate, Qlambda); |
1595 |
Vminibuffer_completion_predicate, Qlambda); |
|
1596 |
|
/* Reject this element if it fails to match all the regexps. */ |
1597 |
|
for (regexps = Vcompletion_regexp_list; CONSP (regexps); |
1598 |
|
regexps = XCDR (regexps)) |
1599 |
|
{ |
1600 |
|
if (NILP (Fstring_match (XCAR (regexps), |
1601 |
|
SYMBOLP (tem) ? string : tem, |
1602 |
|
Qnil))) |
1603 |
|
return Qnil; |
1604 |
|
} |
1605 |
|
|
1606 |
|
/* Finally, check the predicate. */ |
1607 |
|
if (!NILP (predicate)) |
1608 |
|
return call1 (predicate, tem); |
1609 |
|
else |
1610 |
|
return Qt; |
1611 |
} |
} |
1612 |
|
|
1613 |
/* returns: |
/* returns: |
1677 |
} |
} |
1678 |
|
|
1679 |
/* It did find a match. Do we match some possibility exactly now? */ |
/* It did find a match. Do we match some possibility exactly now? */ |
1680 |
tem = test_completion (Fminibuffer_contents ()); |
tem = Ftest_completion (Fminibuffer_contents (), |
1681 |
|
Vminibuffer_completion_table, |
1682 |
|
Vminibuffer_completion_predicate); |
1683 |
if (NILP (tem)) |
if (NILP (tem)) |
1684 |
{ |
{ |
1685 |
/* not an exact match */ |
/* not an exact match */ |
1713 |
|
|
1714 |
/* Like assoc but assumes KEY is a string, and ignores case if appropriate. */ |
/* Like assoc but assumes KEY is a string, and ignores case if appropriate. */ |
1715 |
|
|
1716 |
Lisp_Object |
DEFUN ("assoc-string", Fassoc_string, Sassoc_string, 2, 3, 0, |
1717 |
assoc_for_completion (key, list) |
doc: /* Like `assoc' but specifically for strings. |
1718 |
|
Unibyte strings are converted to multibyte for comparison. |
1719 |
|
And case is ignored if CASE-FOLD is non-nil. |
1720 |
|
As opposed to `assoc', it will also match an entry consisting of a single |
1721 |
|
string rather than a cons cell whose car is a string. */) |
1722 |
|
(key, list, case_fold) |
1723 |
register Lisp_Object key; |
register Lisp_Object key; |
1724 |
Lisp_Object list; |
Lisp_Object list, case_fold; |
1725 |
{ |
{ |
1726 |
register Lisp_Object tail; |
register Lisp_Object tail; |
1727 |
|
|
1729 |
{ |
{ |
1730 |
register Lisp_Object elt, tem, thiscar; |
register Lisp_Object elt, tem, thiscar; |
1731 |
elt = Fcar (tail); |
elt = Fcar (tail); |
1732 |
if (!CONSP (elt)) continue; |
thiscar = CONSP (elt) ? XCAR (elt) : elt; |
|
thiscar = Fcar (elt); |
|
1733 |
if (!STRINGP (thiscar)) |
if (!STRINGP (thiscar)) |
1734 |
continue; |
continue; |
1735 |
tem = Fcompare_strings (thiscar, make_number (0), Qnil, |
tem = Fcompare_strings (thiscar, make_number (0), Qnil, |
1736 |
key, make_number (0), Qnil, |
key, make_number (0), Qnil, |
1737 |
completion_ignore_case ? Qt : Qnil); |
case_fold); |
1738 |
if (EQ (tem, Qt)) |
if (EQ (tem, Qt)) |
1739 |
return elt; |
return elt; |
1740 |
QUIT; |
QUIT; |
1835 |
if (XINT (Fminibuffer_prompt_end ()) == ZV) |
if (XINT (Fminibuffer_prompt_end ()) == ZV) |
1836 |
goto exit; |
goto exit; |
1837 |
|
|
1838 |
if (!NILP (test_completion (Fminibuffer_contents ()))) |
if (!NILP (Ftest_completion (Fminibuffer_contents (), |
1839 |
|
Vminibuffer_completion_table, |
1840 |
|
Vminibuffer_completion_predicate))) |
1841 |
goto exit; |
goto exit; |
1842 |
|
|
1843 |
/* Call do_completion, but ignore errors. */ |
/* Call do_completion, but ignore errors. */ |
2516 |
|
|
2517 |
defsubr (&Stry_completion); |
defsubr (&Stry_completion); |
2518 |
defsubr (&Sall_completions); |
defsubr (&Sall_completions); |
2519 |
|
defsubr (&Stest_completion); |
2520 |
|
defsubr (&Sassoc_string); |
2521 |
defsubr (&Scompleting_read); |
defsubr (&Scompleting_read); |
2522 |
defsubr (&Sminibuffer_complete); |
defsubr (&Sminibuffer_complete); |
2523 |
defsubr (&Sminibuffer_complete_word); |
defsubr (&Sminibuffer_complete_word); |