zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Johan Grande <nahoj@crans.org>
Cc: zsh-workers@zsh.org
Subject: Re: _files -g <pattern> offers files that don't match the pattern and conversely
Date: Sat, 15 Jul 2023 09:16:47 -0700	[thread overview]
Message-ID: <CAH+w=7YjU_M39G+odhuhCMUz_uyGB2J7c3f1iej-uPkzEgvc2Q@mail.gmail.com> (raw)
In-Reply-To: <bc471b8a-7338-9f11-367a-abfb9d1a510b@crans.org>

On Sat, Jul 15, 2023 at 6:32 AM Johan Grande <nahoj@crans.org> wrote:
>
> % _f() { _files -g 'c(.)' }; compdef _f f
> % f <tab>
> a  b       # even though 'a' and 'b' don't match the pattern

The only way I can make this happen is if "a" and "b" are directories.
_files will complete local directory names if there are no matching
files.

> % _f() { _path_files -g 'c(.)' }; compdef _f f
> % f <tab>  # nothing

_path_files expects the pattern to match directories too.

> % _f() { _files -g '^(a #)(.)' }; compdef _f f
> % f <tab>  # nothing, even though 'b' matches the pattern

The space in the pattern needs to be quoted, it's being taken as a
word separator.

_f() { _files -g '^(a\ #)(.)' }

I haven't investigated possible fixes.

> % _f() { _path_files -g '^(a #)(.)' }; compdef _f f
> % f <tab>  # becomes
> % f b

Unlike _files, _path_files is applying the pattern directly and
doesn't have a problem with the space.

> Also, and this is the same for _files and _path_files:
>
> % f() { echo $@ }
> % _f() { _files -g 'c' }; compdef _f f
> % f <tab>  # becomes
> % f c      # even though there is no such file

There's only one possible completion, so it's offered.


  parent reply	other threads:[~2023-07-15 16:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-15 13:31 Johan Grande
2023-07-15 13:34 ` Johan Grande
2023-07-15 16:16 ` Bart Schaefer [this message]
2023-07-15 16:51   ` Johan Grande
2023-07-15 21:28     ` 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='CAH+w=7YjU_M39G+odhuhCMUz_uyGB2J7c3f1iej-uPkzEgvc2Q@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=nahoj@crans.org \
    --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).