# HG changeset patch # User Kim F. Storm # Date 1109104763 0 # Node ID 469c72af5168ee918f026c005a6ab7267fb56d64 # Parent ab5b5d006a8b251d0af7dff2cfe735ea14ec49c8 (Ftry_completion, Fall_completions): Allow both string and symbol keys in alists and hash tables. diff -r ab5b5d006a8b -r 469c72af5168 src/minibuf.c --- a/src/minibuf.c Tue Feb 22 14:11:48 2005 +0000 +++ b/src/minibuf.c Tue Feb 22 20:39:23 2005 +0000 @@ -1181,13 +1181,16 @@ DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0, doc: /* Return common substring of all completions of STRING in ALIST. Each car of each element of ALIST (or each element if it is not a cons cell) -is tested to see if it begins with STRING. +is tested to see if it begins with STRING. The possible matches may be +strings or symbols. Symbols are converted to strings before testing, +see `symbol-name'. All that match are compared together; the longest initial sequence common to all matches is returned as a string. 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 a hash-table, all the string and symbol keys are the +possible matches. If ALIST is an obarray, the names of all symbols in the obarray are the possible matches. @@ -1257,7 +1260,7 @@ if (!EQ (bucket, zero)) { elt = bucket; - eltstring = Fsymbol_name (elt); + eltstring = elt; if (XSYMBOL (bucket)->next) XSETSYMBOL (bucket, XSYMBOL (bucket)->next); else @@ -1284,6 +1287,9 @@ /* Is this element a possible completion? */ + if (SYMBOLP (eltstring)) + eltstring = Fsymbol_name (eltstring); + if (STRINGP (eltstring) && SCHARS (string) <= SCHARS (eltstring) && (tem = Fcompare_strings (eltstring, zero, @@ -1440,10 +1446,13 @@ DEFUN ("all-completions", Fall_completions, Sall_completions, 2, 4, 0, doc: /* Search for partial matches to STRING in ALIST. Each car of each element of ALIST (or each element if it is not a cons cell) -is tested to see if it begins with STRING. +is tested to see if it begins with STRING. The possible matches may be +strings or symbols. Symbols are converted to strings before testing, +see `symbol-name'. 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 a hash-table, all the string and symbol keys are the +possible matches. If ALIST is an obarray, the names of all symbols in the obarray are the possible matches. @@ -1512,7 +1521,7 @@ if (!EQ (bucket, zero)) { elt = bucket; - eltstring = Fsymbol_name (elt); + eltstring = elt; if (XSYMBOL (bucket)->next) XSETSYMBOL (bucket, XSYMBOL (bucket)->next); else @@ -1539,6 +1548,9 @@ /* Is this element a possible completion? */ + if (SYMBOLP (eltstring)) + eltstring = Fsymbol_name (eltstring); + if (STRINGP (eltstring) && SCHARS (string) <= SCHARS (eltstring) /* If HIDE_SPACES, reject alternatives that start with space