Subject: Re: bug#56203: 28.1; completing-read-multiple fails from inside the completion table

From: Harald Judt <[email-masked]>
Date: Fri, 24 Jun 2022 23:58:24 +0200

Hi,

Am 24.06.22 um 23:25 schrieb Lars Ingebrigtsen:
> Harald Judt <[email-masked]> writes:
> 
>> Thanks! I can confirm this on Emacs 28.1. This is an upstream
>> bug. Please report it upstream via report-emacs-bug (maybe cc Stefan
>> Monnier who is the expert on the table quotation mechanism).
>>
>>      1. I argue that Vertico calls the API completion-all-completions
>>      in the correct way.
>>      2. Icomplete use the API completion-all-completions in the same
>>      way and fails too.
>>      3. Default completion fails too if you enter ~, M-x
>>      minibuffer-complete RET. Note that completing-read-multiple
>>      overrides minibuffer-complete with crm-complete which shadows the
>>     underlying bug in the completion table.
>>      4. The error occurs from inside the completion table, and not from
>>      Vertico code.
> 
> Do you have a recipe to reproduce the problem without Vertico?  I tried:
> 
> (completing-read-multiple "Directories: " #'read-file-name-internal #'file-directory-p t nil nil "~/")
> 
> And I didn't see any obvious failures.

Number 2:
emacs -Q
Evaluate the following:
(icomplete-mode)
(completing-read-multiple "Directories: " #'read-file-name-internal 
#'file-directory-p t nil nil "~/")
Enter "~/," and behold the debugger chiming in.

Number 3 is an easy one to replicate too, but you have to enable recursive 
mini-buffers:

emacs -Q
Evaluate the following:
(setq enable-recursive-minibuffers t)
(completing-read-multiple "Directories: " #'read-file-name-internal 
#'file-directory-p t nil nil "~/")

Enter "~, " at the prompt (without quotes), then hit M-x minibuffer-complete RET.

Debugger entered--Lisp error: (args-out-of-range "" 0 2)
   completion--file-name-table("" 2 completion--unquote)
   complete-with-action(completion--unquote completion--file-name-table "" 2)
   #f(compiled-function (table) #<bytecode 
0x17ee37158998d04e>)(completion--file-name-table)
   completion--some(#f(compiled-function (table) #<bytecode 
0x17ee37158998d04e>) (completion--embedded-envvar-table 
completion--file-name-table))
   read-file-name-internal("" 2 completion--unquote)
[...]

-- 
`Experience is the best teacher.'

PGP Key ID: 4FFFAB21B8580ABD
Fingerprint: E073 6DD8 FF40 9CF2 0665 11D4 4FFF AB21 B858 0ABD