Subject: bug#59956: 29.0.60: Failure when completing arguments in Eshell after variable interpolation

From: Gregory Heytings <[email-masked]>
Date: Mon, 19 Dec 2022 01:19:32 +0000

>>> A "general" solution might be the one below
>>
>> Why not (format "%s" (nth (+ (pcase ...))))?
>
> Because I prefer to confine the workaround to those rare cases where we 
> actually need it.
>

I see, thanks!  And I agree that it's better.

>>> tho it looks more like a general workaround, I think.
>>
>> Indeed, I think it would be better if pcomplete could see the 
>> unexpanded argument instead of its expansion.
>
> There's a tension here: we want the completion to operate on the actual 
> buffer text obviously, so in some places we definitely want to see the 
> "unexpanded argument" [1], but when it comes to looking at other 
> arguments to decide which completion table to use at point, it's often 
> more useful to see the expanded arguments (i.e. the thing that the 
> command will actually see).  E.g. if the previous arg is `$foo` which 
> expands to `-u` we'd probably prefer to see `-u` in order to know we 
> should complete against user names.
>

Hmmm...  So I guess it would be better, instead of replacing lists (and in 
general non-strings) by their string representation, and instead of always 
looking at an unexpanded argument, to look at the unexpanded argument only 
when the expanded argument is not a string?  E.g. if $foo is "-u" we would 
use "-u", but if $foo is (b a r) we would use "$foo".