Subject: bug#51130: 29.0.50; shell completion fails to complete filenames

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 14 Sep 2022 14:28:26 +0200

Stefan Monnier <[email-masked]> writes:

> Look at `shell-dynamic-complete-functions`:
>
>     (defcustom shell-dynamic-complete-functions
>       '(comint-c-a-p-replace-by-expanded-history
>         shell-environment-variable-completion
>         shell-command-completion
>         shell-c-a-p-replace-by-expanded-directory
>         pcomplete-completions-at-point
>         shell-filename-completion
>         comint-filename-completion)
>       "List of functions called to perform completion.
>     This variable is used to initialize `comint-dynamic-complete-functions' in the
>     shell buffer."
>       :type '(repeat function)
>       :group 'shell)
>
> if `pcomplete-default-completion-function` is left at its default value,
> then `pcomplete-completions-at-point` will never return nil, so the
> functions that appear after it in the above list will just never
> be used.

Ah, the detail I missed was that pcomplete-completions-at-point is
(partially) controlled by pcomplete-default-completion-function -- from
the documentation, I assumed that pcomplete-default-completion-function
was run after all of the other completion functions had finished.

> The change I introduced tried to preserve as much of the existing
> completion as possible, by only using the non-fallback pcomplete rules
> and keeping the existing `shell-filename-completion` and
> `comint-filename-completion` thingies as the fallback.
>
> I don't know that it's the best choice.  It was just the
> conservative choice.

Could just put an additional function at the end of the list there that
does what pcomplete-completions-at-point does when
pcomplete-default-completion-function isn't set to #'ignore?