Subject: Re: bug#14054: completing against a hash-table doesn't work as documented

From: Stefan Monnier <[email-masked]>
Date: Wed, 27 Mar 2013 15:55:07 -0400

> (1) To my this implies that all other keys are simply ignored, as it
>     doesn't say that all keys _have to by_ strings or symbols.
> (2) It explicity sais that a key can be a symbol.

Indeed, test-completion was too strict.  The patch below should
fix this.  Can you confirm?

        Stefan

=== modified file 'src/minibuf.c'
--- src/minibuf.c	2013-01-02 16:13:04 +0000
+++ src/minibuf.c	2013-03-27 19:52:34 +0000
@@ -1800,17 +1800,21 @@
     {
       struct Lisp_Hash_Table *h = XHASH_TABLE (collection);
       i = hash_lookup (h, string, NULL);
+      Lisp_Object key = Qnil;
       if (i >= 0)
 	tem = HASH_KEY (h, i);
       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,
-				       HASH_KEY (h, i), make_number (0) , Qnil,
+				       key, make_number (0) , Qnil,
 				       completion_ignore_case ? Qt : Qnil),
 		     Qt))
 	    {
-	      tem = HASH_KEY (h, i);
+	      tem = key;
 	      break;
 	    }
       if (!STRINGP (tem))