Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bug: _files depends on extendedglob



On Fri, Mar 29, 2024 at 4:51 PM D. Ben Knoble <ben.knoble@xxxxxxxxx> wrote:
>
> Here's a transcript from a session after I finally pieced together
> what was breaking in
> https://github.com/benknoble/Dotfiles/commit/9c7dd6d1ec8b3caac670f1a2a030769a4c90c06c,
> which contains in its message more details about how I debugged this
> particular failure.
>
> zsh --version
> zsh 5.9 (x86_64-apple-darwin20.6.0)
> # macOS 12.7.2
> zsh -f
> temp=$(mktemp -d)
> fpath+=($temp)
> wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.zsh
> -o $temp/_git
> autoload -Uz compinit && compinit
> _git_doc () { emulate -L zsh
>   _files -W $(git --html-path)/
> }
> git doc <TAB>
> # (eval):1: no matches found: *:globbed-files
> # completion results still produced
> _git_doc () { emulate -L zsh
>   setopt extendedglob
>   _files -W $(git --html-path)/
> }
> git doc <TAB>
> # works like a charm
>
> I'm not sure what the appropriate fix is, though I think some
> combination of localopts and extendedglob might work? I see that some
> parts of _files test for extendedglob, but the part that sets pats
> that leads to the failure (line 78 for me) seems to be affected
> without any test.

The completion system sets up the options it uses on entry, if you
change them you get to keep the pieces. (Why are you setting the
emulation mode in a completer function anyway?) If you for whatever
reason insist on doing this, then you can setopt $_comp_options to
restore the correct option set before calling _files.

-- 
Mikael Magnusson




Messages sorted by: Reverse Date, Date, Thread, Author