Zsh Mailing List Archive
Messages sorted by:
Re: [BUG] Any type of file in command position gets misleadingly completed as 'executable file'
- X-seq: zsh-workers 49562
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Marlon Richert <marlon.richert@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [BUG] Any type of file in command position gets misleadingly completed as 'executable file'
- Date: Thu, 11 Nov 2021 02:41:58 +0100
- Archived-at: <https://zsh.org/workers/49562>
- In-reply-to: <CAH+w=7Y=YsW6Yf9cA1_UK54Y6SOvYkeH1WLpNe3Uh0k6jHu1wA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAHLkEDtscOXas+-Wwj68O29H3_JrKycZ8Rr3wCovnxqk=ioOzg@mail.gmail.com> <CAH+w=7Y=YsW6Yf9cA1_UK54Y6SOvYkeH1WLpNe3Uh0k6jHu1wA@mail.gmail.com>
Marlon Richert wrote:
> % foo^D
> executable file
> % touch bar
> % bar^D
> executable file
I was about to say I cannot reproduce this and you must have something
in a system rc file. However, I can reproduce it by putting . in $PATH.
Is that perhaps the case? If so, I wouldn't think that's a particularly
Bart Schaefer wrote:
> On Wed, Nov 10, 2021 at 2:01 PM Marlon Richert <marlon.richert@xxxxxxxxx> wrote:
> > The problem is in _files and it is two-fold:
> > * _files always adds '*:all-files', which ignores the pattern passed
> > with the -g flag.
> There's a comment:
> # People prefer to have directories shown on first try as default.
> # Even if the calling function didn't use -/.
> In fact the actual assumption is that most people prefer to have
> SOMETHING completed rather than nothing, unless they've specifically
> requested otherwise.
I'm fairly sure that's where the consensus was at the time. If you press
tab you expect something. Globs specified in completions may not always
be perfect. With some other setup like a plugin that does continuous
completion after each key then I can see it being less desirable.
> You can change this behavior by
> zstyle ":completion:*" file-patterns ...
Where the all-files fallback is less ideal is where other things are
completed alongside files, e.g for:
_alternative 'files:file:_files -g "*.png(-.)"' 'others:other:(one two three)'
You can avoid that by using _complete twice. I've never used the feature
to call _complete twice because it used to be too slow but I should
zstyle ':completion:*::::' completer ... _complete _complete:-all ...
zstyle ':completion:*' file-patterns '%p:globbed-files *(-/):directories'
zstyle ':completion:*:complete-all:*' file-patterns '*:all-files'
> > * Even though _files passes its file pattern tags to _next_label, if
> > _files was passed a tag and/or description, it _always_ prefers these
> > over the ones returned by _next_label's call to _description.
It was never intended that file-patterns would divide matches into
separate groups by default.
It doesn't "always" prefer them. Only when the [[ -n "$end" ]] condition
is set. That corresponds to the value in file-patterns including a
description, e.g. *(-/):directories:directory
Without this, it'd be using empty descriptions.
However, it is surely a bug that $end is not reinitialised with each
iteration of the for loop. That makes it difficult to use the
description we were passed for the globbed-files but to put the
globbed-files first and directories second.
It also looks like a bug that the recursive-files style is only
implemented where $end is set.
I'll put together a patch for those two points tomorrow. And add an
example to the documentation.
> > (As an aside, the docs speak of an
> > 'other-files' tag used when zstyle list-directories-first is set, but
> > this is never actually offered. Let's remove that, too.)
> It appears "other-files" was (inadvertently?) removed by workers/36165
> (Oliver, back in 2015).
That was intentional. Leaving it in the documentation wasn't.
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index 89b918d60..a8beece2d 100644
@@ -979,11 +979,6 @@ kindex(other-accounts, completion tag)
used to look up the tt(users-hosts) style
-kindex(other-files, completion tag)
-for the names of any non-directory files. This is used instead
-of tt(all-files) when the tt(list-dirs-first) style is in effect.
kindex(packages, completion tag)
for packages (e.g. tt(rpm) or installed tt(Debian) packages)
@@ -1978,9 +1973,7 @@ kindex(list-dirs-first, completion style)
This is used by file completion. If set, directories to be completed
are listed separately from and before completion for other files,
-regardless of tag ordering. In addition, the tag tt(other-files)
-is used in place of tt(all-files) for the remaining files, to indicate
-that no directories are presented with that tag.
+regardless of tag ordering.
kindex(list-grouped, completion style)
Messages sorted by: