zsh-workers
 help / color / mirror / code / Atom feed
From: <thomas@coldfix.de>
To: zsh-workers@zsh.org
Subject: Path with spaces in _canonical_paths
Date: Fri, 18 Nov 2022 17:41:37 +0000	[thread overview]
Message-ID: <sympa.1668791373.628329.85325.773@zsh.org> (raw)

Hi all,

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. Otherwise: It
seems to not escape spaces in paths appropriately. Short example:

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, and notably, the first option
is without escaping the space, i.e. it will result in a command line:

cmd /tmp/My File

which is obviously not as intended.

I tried scanning the code in /usr/share/zsh/functions/Completion/Unix/
_canonical_paths for the problem, but it is quite confusing to me. I was able
to gather that by removing the `-Q` from the line

   _wanted "$tag" expl "$desc" compadd $__gopts -Q -U -a matches && ret=0

it adds escapes to all the entries, i.e. the new completions are:

  /tmp/My\ File   (twice)
  /tmp/My\\\ File

which is still not as desired.

Much appreciated if anyone can help.

Best, Thomas

             reply	other threads:[~2022-11-18 17:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18 17:41 thomas [this message]
2022-11-21  3:57 ` Bart Schaefer
2022-11-21 10:47   ` thomas
2022-11-21 16:30     ` Bart Schaefer
2022-11-21 17:41       ` Thomas Gläßle
2022-11-21 21:32         ` Bart Schaefer
2022-11-23 14:13           ` Daniel Shahaf
2022-11-23 21:36             ` Bart Schaefer
2022-11-23 22:24               ` Daniel Shahaf
2022-11-23 22:42                 ` Bart Schaefer
2022-11-23 23:06                   ` Daniel Shahaf
2022-11-23 23:12                     ` Bart Schaefer
2022-11-24  0:12                       ` Daniel Shahaf
2022-11-24 18:42                         ` Bart Schaefer
2022-11-23 23:36                   ` Thomas Gläßle
2022-11-23 23:40                     ` Thomas Gläßle
2022-11-24 18:51                     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sympa.1668791373.628329.85325.773@zsh.org \
    --to=thomas@coldfix.de \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).