[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/minibuf.c
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/src/minibuf.c |
Date: |
Sun, 07 Jul 2002 17:09:40 -0400 |
Index: emacs/src/minibuf.c
diff -c emacs/src/minibuf.c:1.243 emacs/src/minibuf.c:1.244
*** emacs/src/minibuf.c:1.243 Mon Jul 1 03:50:37 2002
--- emacs/src/minibuf.c Sun Jul 7 17:09:14 2002
***************
*** 1089,1096 ****
If there is no match at all, nil is returned.
For a unique match which is exact, t is returned.
! ALIST can be an obarray instead of an alist.
! Then the print names of all symbols in the obarray are the possible matches.
ALIST can also be a function to do the completion itself.
It receives three arguments: the values STRING, PREDICATE and nil.
--- 1089,1097 ----
If there is no match at all, nil is returned.
For a unique match which is exact, t is returned.
! If ALIST is a hash-table, all the string keys are the possible matches.
! If ALIST is an obarray, the names of all symbols in the obarray
! are the possible matches.
ALIST can also be a function to do the completion itself.
It receives three arguments: the values STRING, PREDICATE and nil.
***************
*** 1100,1106 ****
it is used to test each possible match.
The match is a candidate only if PREDICATE returns non-nil.
The argument given to PREDICATE is the alist element
! or the symbol from the obarray.
Additionally to this predicate, `completion-regexp-list'
is used to further constrain the set of candidates. */)
(string, alist, predicate)
--- 1101,1108 ----
it is used to test each possible match.
The match is a candidate only if PREDICATE returns non-nil.
The argument given to PREDICATE is the alist element
! or the symbol from the obarray. If ALIST is a hash-table,
! predicate is called with two arguments: the key and the value.
Additionally to this predicate, `completion-regexp-list'
is used to further constrain the set of candidates. */)
(string, alist, predicate)
***************
*** 1111,1147 ****
int bestmatchsize = 0;
/* These are in bytes, too. */
int compare, matchsize;
! int list = NILP (alist) || (CONSP (alist)
! && (!SYMBOLP (XCAR (alist))
! || NILP (XCAR (alist))));
int index = 0, obsize = 0;
int matchcount = 0;
Lisp_Object bucket, zero, end, tem;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
CHECK_STRING (string);
! if (!list && !VECTORP (alist))
return call3 (alist, string, predicate, Qnil);
bestmatch = bucket = Qnil;
/* If ALIST is not a list, set TAIL just for gc pro. */
tail = alist;
! if (! list)
{
- index = 0;
obsize = XVECTOR (alist)->size;
bucket = XVECTOR (alist)->contents[index];
}
while (1)
{
! /* Get the next element of the alist or obarray. */
/* Exit the loop if the elements are all used up. */
/* elt gets the alist element or symbol.
eltstring gets the name to check as a completion. */
! if (list)
{
if (!CONSP (tail))
break;
--- 1113,1150 ----
int bestmatchsize = 0;
/* These are in bytes, too. */
int compare, matchsize;
! int type = HASH_TABLE_P (alist) ? 3
! : VECTORP (alist) ? 2
! : NILP (alist) || (CONSP (alist)
! && (!SYMBOLP (XCAR (alist))
! || NILP (XCAR (alist))));
int index = 0, obsize = 0;
int matchcount = 0;
Lisp_Object bucket, zero, end, tem;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
CHECK_STRING (string);
! if (type == 0)
return call3 (alist, string, predicate, Qnil);
bestmatch = bucket = Qnil;
/* If ALIST is not a list, set TAIL just for gc pro. */
tail = alist;
! if (type == 2)
{
obsize = XVECTOR (alist)->size;
bucket = XVECTOR (alist)->contents[index];
}
while (1)
{
! /* Get the next element of the alist, obarray, or hash-table. */
/* Exit the loop if the elements are all used up. */
/* elt gets the alist element or symbol.
eltstring gets the name to check as a completion. */
! if (type == 1)
{
if (!CONSP (tail))
break;
***************
*** 1149,1155 ****
eltstring = CONSP (elt) ? XCAR (elt) : elt;
tail = XCDR (tail);
}
! else
{
if (XFASTINT (bucket) != 0)
{
--- 1152,1158 ----
eltstring = CONSP (elt) ? XCAR (elt) : elt;
tail = XCDR (tail);
}
! else if (type == 2)
{
if (XFASTINT (bucket) != 0)
{
***************
*** 1168,1173 ****
--- 1171,1186 ----
continue;
}
}
+ else /* if (type == 3) */
+ {
+ while (index < HASH_TABLE_SIZE (XHASH_TABLE (alist))
+ && NILP (HASH_HASH (XHASH_TABLE (alist), index)))
+ index++;
+ if (index >= HASH_TABLE_SIZE (XHASH_TABLE (alist)))
+ break;
+ else
+ elt = eltstring = HASH_KEY (XHASH_TABLE (alist), index++);
+ }
/* Is this element a possible completion? */
***************
*** 1205,1211 ****
else
{
GCPRO4 (tail, string, eltstring, bestmatch);
! tem = call1 (predicate, elt);
UNGCPRO;
}
if (NILP (tem)) continue;
--- 1218,1227 ----
else
{
GCPRO4 (tail, string, eltstring, bestmatch);
! tem = type == 3
! ? call2 (predicate, elt,
! HASH_VALUE (XHASH_TABLE (alist), index - 1))
! : call1 (predicate, elt);
UNGCPRO;
}
if (NILP (tem)) continue;
***************
*** 1213,1221 ****
/* Update computation of how much all possible completions match */
- matchcount++;
if (NILP (bestmatch))
{
bestmatch = eltstring;
bestmatchsize = XSTRING (eltstring)->size;
}
--- 1229,1237 ----
/* Update computation of how much all possible completions match */
if (NILP (bestmatch))
{
+ matchcount = 1;
bestmatch = eltstring;
bestmatchsize = XSTRING (eltstring)->size;
}
***************
*** 1269,1274 ****
--- 1285,1294 ----
! EQ (Qt, tem))))
bestmatch = eltstring;
}
+ if (bestmatchsize != XSTRING (eltstring)->size
+ || bestmatchsize != matchsize)
+ /* Don't count the same string multiple times. */
+ matchcount++;
bestmatchsize = matchsize;
if (matchsize <= XSTRING (string)->size
&& matchcount > 1)
***************
*** 1308,1315 ****
Each car of each element of ALIST is tested to see if it begins with STRING.
The value is a list of all the strings from ALIST that match.
! ALIST can be an obarray instead of an alist.
! Then the print names of all symbols in the obarray are the possible matches.
ALIST can also be a function to do the completion itself.
It receives three arguments: the values STRING, PREDICATE and t.
--- 1328,1336 ----
Each car of each element of ALIST is tested to see if it begins with STRING.
The value is a list of all the strings from ALIST that match.
! If ALIST is a hash-table, all the string keys are the possible matches.
! If ALIST is an obarray, the names of all symbols in the obarray
! are the possible matches.
ALIST can also be a function to do the completion itself.
It receives three arguments: the values STRING, PREDICATE and t.
***************
*** 1319,1325 ****
it is used to test each possible match.
The match is a candidate only if PREDICATE returns non-nil.
The argument given to PREDICATE is the alist element
! or the symbol from the obarray.
Additionally to this predicate, `completion-regexp-list'
is used to further constrain the set of candidates.
--- 1340,1347 ----
it is used to test each possible match.
The match is a candidate only if PREDICATE returns non-nil.
The argument given to PREDICATE is the alist element
! or the symbol from the obarray. If ALIST is a hash-table,
! predicate is called with two arguments: the key and the value.
Additionally to this predicate, `completion-regexp-list'
is used to further constrain the set of candidates.
***************
*** 1331,1367 ****
{
Lisp_Object tail, elt, eltstring;
Lisp_Object allmatches;
! int list = NILP (alist) || (CONSP (alist)
! && (!SYMBOLP (XCAR (alist))
! || NILP (XCAR (alist))));
int index = 0, obsize = 0;
Lisp_Object bucket, tem;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
CHECK_STRING (string);
! if (!list && !VECTORP (alist))
! {
! return call3 (alist, string, predicate, Qt);
! }
allmatches = bucket = Qnil;
/* If ALIST is not a list, set TAIL just for gc pro. */
tail = alist;
! if (! list)
{
- index = 0;
obsize = XVECTOR (alist)->size;
bucket = XVECTOR (alist)->contents[index];
}
while (1)
{
! /* Get the next element of the alist or obarray. */
/* Exit the loop if the elements are all used up. */
/* elt gets the alist element or symbol.
eltstring gets the name to check as a completion. */
! if (list)
{
if (!CONSP (tail))
break;
--- 1353,1388 ----
{
Lisp_Object tail, elt, eltstring;
Lisp_Object allmatches;
! int type = HASH_TABLE_P (alist) ? 3
! : VECTORP (alist) ? 2
! : NILP (alist) || (CONSP (alist)
! && (!SYMBOLP (XCAR (alist))
! || NILP (XCAR (alist))));
int index = 0, obsize = 0;
Lisp_Object bucket, tem;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
CHECK_STRING (string);
! if (type == 0)
! return call3 (alist, string, predicate, Qt);
allmatches = bucket = Qnil;
/* If ALIST is not a list, set TAIL just for gc pro. */
tail = alist;
! if (type == 2)
{
obsize = XVECTOR (alist)->size;
bucket = XVECTOR (alist)->contents[index];
}
while (1)
{
! /* Get the next element of the alist, obarray, or hash-table. */
/* Exit the loop if the elements are all used up. */
/* elt gets the alist element or symbol.
eltstring gets the name to check as a completion. */
! if (type == 1)
{
if (!CONSP (tail))
break;
***************
*** 1369,1375 ****
eltstring = CONSP (elt) ? XCAR (elt) : elt;
tail = XCDR (tail);
}
! else
{
if (XFASTINT (bucket) != 0)
{
--- 1390,1396 ----
eltstring = CONSP (elt) ? XCAR (elt) : elt;
tail = XCDR (tail);
}
! else if (type == 2)
{
if (XFASTINT (bucket) != 0)
{
***************
*** 1388,1393 ****
--- 1409,1424 ----
continue;
}
}
+ else /* if (type == 3) */
+ {
+ while (index < HASH_TABLE_SIZE (XHASH_TABLE (alist))
+ && NILP (HASH_HASH (XHASH_TABLE (alist), index)))
+ index++;
+ if (index >= HASH_TABLE_SIZE (XHASH_TABLE (alist)))
+ break;
+ else
+ elt = eltstring = HASH_KEY (XHASH_TABLE (alist), index++);
+ }
/* Is this element a possible completion? */
***************
*** 1432,1438 ****
else
{
GCPRO4 (tail, eltstring, allmatches, string);
! tem = call1 (predicate, elt);
UNGCPRO;
}
if (NILP (tem)) continue;
--- 1463,1472 ----
else
{
GCPRO4 (tail, eltstring, allmatches, string);
! tem = type == 3
! ? call2 (predicate, elt,
! HASH_VALUE (XHASH_TABLE (alist), index - 1))
! : call1 (predicate, elt);
UNGCPRO;
}
if (NILP (tem)) continue;
***************
*** 1564,1569 ****
--- 1598,1604 ----
Lisp_Object string, alist, predicate;
{
Lisp_Object regexps, tem = Qnil;
+ int i = 0;
CHECK_STRING (string);
***************
*** 1571,1579 ****
|| NILP (alist))
{
tem = Fassoc_string (string, alist, completion_ignore_case ? Qt : Qnil);
! if (CONSP (tem))
! tem = XCAR (tem);
! else
return Qnil;
}
else if (VECTORP (alist))
--- 1606,1612 ----
|| NILP (alist))
{
tem = Fassoc_string (string, alist, completion_ignore_case ? Qt : Qnil);
! if NILP (tem)
return Qnil;
}
else if (VECTORP (alist))
***************
*** 1598,1603 ****
--- 1631,1644 ----
return Qnil;
}
}
+ else if (HASH_TABLE_P (alist))
+ {
+ i = hash_lookup (XHASH_TABLE (alist), string, NULL);
+ if (i >= 0)
+ tem = HASH_KEY (XHASH_TABLE (alist), i);
+ else
+ return Qnil;
+ }
else
return call3 (alist, string, predicate, Qlambda);
***************
*** 1613,1619 ****
/* Finally, check the predicate. */
if (!NILP (predicate))
! return call1 (predicate, tem);
else
return Qt;
}
--- 1654,1662 ----
/* Finally, check the predicate. */
if (!NILP (predicate))
! return HASH_TABLE_P (alist)
! ? call2 (predicate, tem, HASH_VALUE (XHASH_TABLE (alist), i))
! : call1 (predicate, tem);
else
return Qt;
}
- [Emacs-diffs] Changes to emacs/src/minibuf.c, Richard M. Stallman, 2002/07/01
- [Emacs-diffs] Changes to emacs/src/minibuf.c, Dave Love, 2002/07/03
- [Emacs-diffs] Changes to emacs/src/minibuf.c,
Stefan Monnier <=
- [Emacs-diffs] Changes to emacs/src/minibuf.c, Juanma Barranquero, 2002/07/10
- [Emacs-diffs] Changes to emacs/src/minibuf.c, Juanma Barranquero, 2002/07/11
- [Emacs-diffs] Changes to emacs/src/minibuf.c, Ken Raeburn, 2002/07/14
- [Emacs-diffs] Changes to emacs/src/minibuf.c, Ken Raeburn, 2002/07/16