if (FUNCTIONP (collection))
return call3 (collection, string, predicate, Qnil);
- if (PACKAGEP (collection))
+ /* Use a package's symbol table for completion, but remember that we
+ are working on a package, because we are called with a predicate
+ that takes only one argument, which is a remnant ob obarrays.
+ Sad that we are receiving predicates of different arity depending
+ on the type of collection. */
+ const bool symbol_table_p = PACKAGEP (collection);
+ if (symbol_table_p)
collection = PACKAGE_SYMBOLS (collection);
ptrdiff_t idx = 0;
{
if (EQ (predicate, Qcommandp))
tem = Fcommandp (elt, Qnil);
- else
+ else if (HASH_TABLE_P (collection))
{
- tem = (HASH_TABLE_P (collection)
- ? call2 (predicate, elt,
- HASH_VALUE (XHASH_TABLE (collection),
- idx - 1))
- : call1 (predicate, elt));
+ const Lisp_Object value = HASH_VALUE (XHASH_TABLE (collection), idx - 1);
+ if (symbol_table_p)
+ tem = call1 (predicate, value);
+ else
+ tem = call2 (predicate, elt, value);
}
- if (NILP (tem)) continue;
+ else
+ tem = call1 (predicate, elt);
+ if (NILP (tem))
+ continue;
}
/* Update computation of how much all possible completions match */
if (type == 0)
return call3 (collection, string, predicate, Qt);
- if (type == 2)
+ /* Use a package's symbol table for completion, but remember that we
+ are working on a package, because we are called with a predicate
+ that takes only one argument, which is a remnant ob obarrays.
+ Sad that we are receiving predicates of different arity depending
+ on the type of collection. */
+ const bool symbol_table_p = PACKAGEP (collection);
+ if (symbol_table_p)
{
collection = PACKAGE_SYMBOLS (collection);
type = 3;
{
if (EQ (predicate, Qcommandp))
tem = Fcommandp (elt, Qnil);
- else
+ else if (HASH_TABLE_P (collection))
{
- tem = type == 3
- ? call2 (predicate, elt,
- HASH_VALUE (XHASH_TABLE (collection), idx - 1))
- : call1 (predicate, elt);
+ const Lisp_Object value = HASH_VALUE (XHASH_TABLE (collection), idx - 1);
+ if (symbol_table_p)
+ tem = call1 (predicate, value);
+ else
+ tem = call2 (predicate, elt, value);
}
+ else
+ tem = call1 (predicate, elt);
if (NILP (tem)) continue;
}
/* Ok => put it on the list. */
CHECK_STRING (string);
- if (PACKAGEP (collection))
+ const bool symbol_table_p = PACKAGEP (collection);
+ if (symbol_table_p)
collection = PACKAGE_SYMBOLS (collection);
if (NILP (collection) || (CONSP (collection) && !FUNCTIONP (collection)))
return Qnil;
/* Finally, check the predicate. */
- if (!NILP (predicate))
+ if (NILP (predicate))
+ return Qt;
+
+ if (HASH_TABLE_P (collection))
{
- return HASH_TABLE_P (collection)
- ? call2 (predicate, tem, HASH_VALUE (XHASH_TABLE (collection), i))
- : call1 (predicate, tem);
+ const Lisp_Object value = HASH_VALUE (XHASH_TABLE (collection), i);
+ if (symbol_table_p)
+ return call1 (predicate, value);
+ return call2 (predicate, tem, value);
}
- else
- return Qt;
+
+ return call1 (predicate, tem);
}
DEFUN ("internal-complete-buffer", Finternal_complete_buffer, Sinternal_complete_buffer, 3, 3, 0,