Subject: bug#60464: 29.0.60; Regression - pcomplete-arg fails with argument 'last

From: Gregory Heytings <[email-masked]>
Date: Wed, 04 Jan 2023 16:08:32 +0000

>> I'm not the one who wrote that code.  According to my analysis of the 
>> code, the only place where pcomplete-arg is called with a 'last' 
>> argument is pcomplete-parse-arguments, where you will see the 
>> following:
>>
>> (defun pcomplete-parse-arguments (&optional expand-p)
>>   ...
>>   (let ((results (funcall pcomplete-parse-arguments-function)))
>>     (when results
>>       (setq ...
>> 	    pcomplete-stub (pcomplete-arg 'last))
>>       (let ...
>> 	(if (and (listp pcomplete-stub) ;??
>> 		 (not pcomplete-expand-only-p))
>> 	    ;; If `pcomplete-stub' is a list, it means it's a list of
>>             ;; completions computed during parsing, e.g. Eshell uses
>>             ;; that to turn globs into lists of completions.
>
> That's also my understanding.  So I think The Right Fix (or at least The 
> Better Fix) is to pay no special attention to `last` in `pcomplete-arg` 
> and instead in the above code of `pcomplete-parse-arguments` to look for 
> the `pcomplete-arg-value` property.
>

That would be even better, indeed.  But it would be a larger change.

>
> Maybe for `emacs-29` we can use your patch (with a comment about why 
> `last` is handled specially pointing to its handling in 
> `pcomplete-parse-arguments`) and then in `master` we remove this special 
> handling of `last`?
>

I'm fine with that.

Unless someone objects, I'll push that patch in a day or two, and I'll do 
that change on master afterwards.