summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2016-11-27 14:41:02 -0500
committerNoam Postavsky <npostavs@gmail.com>2016-12-06 22:20:23 -0500
commit2a3420d94206a97f094580e06c25af91d5949516 (patch)
tree725cd913267ceb1cf4dbc0f32671b44876b24f0b /src
parent60fe63015165a03a765852f60367e548c1617f89 (diff)
downloademacs-2a3420d94206a97f094580e06c25af91d5949516.tar.gz
Give test-completion's PREDICATE the hashtable key
For hashtable entries with symbol keys, `test-completion' would convert the key to a string before calling PREDICATE, unlike `try-completion' and `all-completions'. * src/minibuf.c (Ftest_completion): Pass original key from hashtable.
Diffstat (limited to 'src')
-rw-r--r--src/minibuf.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/minibuf.c b/src/minibuf.c
index 6c694cb3123..7c5af34102b 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1736,26 +1736,27 @@ the values STRING, PREDICATE and `lambda'. */)
else if (HASH_TABLE_P (collection))
{
struct Lisp_Hash_Table *h = XHASH_TABLE (collection);
- Lisp_Object key = Qnil;
i = hash_lookup (h, string, NULL);
if (i >= 0)
- tem = HASH_KEY (h, i);
+ {
+ tem = HASH_KEY (h, i);
+ goto found_matching_key;
+ }
else
for (i = 0; i < HASH_TABLE_SIZE (h); ++i)
- if (!NILP (HASH_HASH (h, i))
- && (key = HASH_KEY (h, i),
- SYMBOLP (key) ? key = Fsymbol_name (key) : key,
- STRINGP (key))
- && EQ (Fcompare_strings (string, make_number (0), Qnil,
- key, make_number (0) , Qnil,
- completion_ignore_case ? Qt : Qnil),
- Qt))
- {
- tem = key;
- break;
- }
- if (!STRINGP (tem))
- return Qnil;
+ {
+ if (NILP (HASH_HASH (h, i))) continue;
+ tem = HASH_KEY (h, i);
+ Lisp_Object strkey = (SYMBOLP (tem) ? Fsymbol_name (tem) : tem);
+ if (!STRINGP (strkey)) continue;
+ if (EQ (Fcompare_strings (string, Qnil, Qnil,
+ strkey, Qnil, Qnil,
+ completion_ignore_case ? Qt : Qnil),
+ Qt))
+ goto found_matching_key;
+ }
+ return Qnil;
+ found_matching_key: ;
}
else
return call3 (collection, string, predicate, Qlambda);