From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: _files: -/ causes caller's _alternative to be disregarded
Date: Fri, 2 Sep 2016 04:32:02 +0000 [thread overview]
Message-ID: <20160902043202.GA25458@fujitsu.shahaf.local2> (raw)
I ran into a problem, and found something that was wrong and fixed it
and that made the problem go away, but I don't fully understand why the
patch does in fact fix the problem.
Here's a minimal example:
[[[
% _g() { _files -/ "$@" }
% _f() { _alternative 'x:x:_g' 'y:y:_hosts' }
% compdef _f f
% zstyle \* list-dirs-first true
% f <TAB>
(shows just files, doesn't show hosts)
]]]
Tracing, _files takes this codepath:
.
37 elif [[ $type = */* ]]; then
38 glob="*(-/)"
⋮
66 elif zstyle -t ":completion:${curcontext}:" list-dirs-first; then
67 pats=( " *(-/):directories:directory ${${glob:-*}//:/\\:}(#q^-/):globbed-files" '*:all-files' )
^^^^^^^^^^^^^^^^^^^^
.
and «*(-/)(#q^-/)» is not a valid pattern.
Adding another #q fixes the symptom:
[[[
diff --git Completion/Unix/Type/_files Completion/Unix/Type/_files
index 6987824..2b0c558 100644
--- Completion/Unix/Type/_files
+++ Completion/Unix/Type/_files
@@ -35,7 +35,7 @@ if (( $tmp[(I)-g*] )); then
[[ "$glob" = (#b)(*\()([^\|\~]##\)) && $match[2] != \#q* ]] &&
glob="${match[1]}#q${match[2]}"
elif [[ $type = */* ]]; then
- glob="*(-/)"
+ glob="*(#q-/)"
fi
tmp=$opts[(I)-F]
if (( tmp )); then
]]]
What I'm not clear about is why the invalid pattern for the
"globbed-files" tag caused the "y:y:_hosts" alternative to be skipped.
Cheers,
Daniel
P.S. The non-minimal example was «git push <TAB>» not offering remotes.
next reply other threads:[~2016-09-02 4:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-02 4:32 Daniel Shahaf [this message]
2016-09-02 5:03 ` Bart Schaefer
2016-09-02 18:20 ` Daniel Shahaf
2016-09-02 18:29 ` Daniel Shahaf
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=20160902043202.GA25458@fujitsu.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--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).