Subject: Re: bug#24966: 26.0.50;

From: [email-masked]
Date: Sun, 20 Nov 2016 23:24:19 -0500

unarchive 23533
# It was marked for 25.2 before master was renumbered to 26
notfixed 23533 25.2
fixed 23533 26.0.50
retitle 24966 26.0.50; test-completion with alist COLLECTION calls PREDICATE incorrectly
tags 24966 confirmed
quit

Mark Oteiza <[email-masked]> writes:

> Hi,
>
> dd98ee8992c3246861e44 appears to be the culprit for breaking the
> following from -Q:

Yup, I didn't fix test-completion correctly.

>
> 1. C-x C-f /tmp/foo.tex
> 2. M-x reftex-mode
> 3. Insert the following: \label{foobar}
> 4. M-x reftex-goto-label
>
> and, when attempting to complete, a wrong-type-argument error occurs.
>
> Debugger entered--Lisp error: (wrong-type-argument listp "argh")
>   #[(x) "@;\207" [x] 1]("argh")
>   test-completion("argh" ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi nil) (bibview-cache) (master-dir . "/tmp/") (label-numbers) (bof "/tmp/lol.tex") ("argh" "s" " " "/tmp/lol.tex" nil) (eof "/tmp/lol.tex")) #[(x) "@;\207" [x] 1])

I tentatively suggest the patch below, but I want to add some tests
before commiting anything.

diff --git i/src/minibuf.c w/src/minibuf.c
index 57eea05..fe187b3 100644
--- i/src/minibuf.c
+++ w/src/minibuf.c
@@ -1686,8 +1686,6 @@ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0,
       tem = Fassoc_string (string, collection, completion_ignore_case ? Qt : Qnil);
       if (NILP (tem))
 	return Qnil;
-      else if (CONSP (tem))
-        tem = XCAR (tem);
     }
   else if (VECTORP (collection))
     {
@@ -1765,14 +1763,16 @@ DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0,
   /* Reject this element if it fails to match all the regexps.  */
   if (CONSP (Vcompletion_regexp_list))
     {
+      Lisp_Object temstr = (CONSP (tem)) ? XCAR (tem) : tem;
+      if (SYMBOLP (temstr))
+        temstr = string;
+
       ptrdiff_t count = SPECPDL_INDEX ();
       specbind (Qcase_fold_search, completion_ignore_case ? Qt : Qnil);
       for (regexps = Vcompletion_regexp_list; CONSP (regexps);
 	   regexps = XCDR (regexps))
 	{
-	  if (NILP (Fstring_match (XCAR (regexps),
-				   SYMBOLP (tem) ? string : tem,
-				   Qnil)))
+	  if (NILP (Fstring_match (XCAR (regexps), temstr, Qnil)))
 	    return unbind_to (count, Qnil);
 	}
       unbind_to (count, Qnil);