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

Re: Path with spaces in _canonical_paths



On Fri, Nov 18, 2022 at 9:42 AM <thomas@xxxxxxxxxx> wrote:
>
> I'm trying to use `_canonical_paths` (on zsh 5.9) to let the user autocomplete
> a fixed list of files. I hope I'm not using it incorrectly.

Tangentially to -workers:  Is _canonical_paths documented in the wrong
manual section?  It's lumped in with functions that are expected to
appear in the "completer" zstyle, which clearly it is not.

> compdef '_canonical_paths -N files files /tmp/My\ File' cmd
> cmd <Tab>
>
> Shows the following completions:
>
> /tmp/My File    (appears twice)
> /tmp/My\ File
>
> i.e. I get in total 3 entries for the same path

I'm not able to reproduce this using nothing but compinit plus the
compdef above.  I get just one completion, "/tmp/My\ File", regardless
of whether that file exists or not.

Try this:

debug_canonical_paths () {
  _canonical_paths -N files files /tmp/My\ File
}
compdef '_complete_debug debug_canonical_paths' cmd

Pressing TAB then drops a file in /tmp with a debug trace of the
execution of _canonical_paths.  In particular look at which "zstyle"
lookups are being done and which of those might be causing the extra
entries.  You can also look at the context around elements being added
to the "matches" array.




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