Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completion in pwd before subdirecories
- X-seq: zsh-workers 19309
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: Completion in pwd before subdirecories
- Date: Thu, 18 Dec 2003 10:47:29 +0100
- In-reply-to: <1031217183837.ZM16074@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20031213154651.GR18859@xxxxxxxxxxxxxxxxxxxx> <1031213191918.ZM5325@xxxxxxxxxxxxxxxxxxxxxxx> <20031213233905.GW18859@xxxxxxxxxxxxxxxxxxxx> <3213.1071488991@xxxxxxxxxxx> <1031215170258.ZM12804@xxxxxxxxxxxxxxxxxxxxxxx> <1772.1071676636@xxxxxxxxxxx> <1031217183837.ZM16074@xxxxxxxxxxxxxxxxxxxxxxx>
Bart wrote:
>
> Hrm. I thought I'd found it the other day but now I can't any more. I
> believe it _used_ to be there (or in _path_files) because Sven grumbled
> at least once about how difficult it was to write. But maybe something
> changed so that it was possible for it to be taken out again.
Doing a bit of a search in the archives, the nearest I can find is
11635. That deals with _path_files and glob qualifiers on the
command-line when doing pattern based matching. Is that perhaps what
you were thinking of?
> In fact, that may have been what led to the introduction of (#q) in the
> first place.
It was a comment by me in 16447 that led to (#q). I was suggesting
using things like -g '*.png(.)' back then so must have been thinking
clearer than earlier this week. I managed to forget why I had wanted to
add qualifiers in series but it might have been for the file-patterns
style.
> } So either we need to add #q when using glob qualifiers or _files should
> } attempt to merge trailing glob qualifiers. I favour the latter.
>
> Good luck, then.
>
The documentation is fairly clear that a glob qualifier is a trailing
set of parentheses containing no `|', `(' (or `~' if it is special).
Not sure I understand what the "if it is special" means - anyone? The
_path_files stuff from 11635 believes the documentation, using the
pattern \([^\|\~]##\)
So the patch below (to _files) uses that pattern to find a glob
qualifier in the argument to the -g option and sticks a #q in.
Unfortunately, the documentation doesn't give the whole story:
*(e:'[[ -d ~/$REPLY || -d ../$REPLY ]]':) and
*(e:'(( 1 ))':)
both work. Seems to me that anything is valid just so long as it is
quoted. *(e'|'true'|') works while *(e|true|) doesn't.
So how do I match a quoted string with a glob? Does anyone have something
already? Is it even possible given nested quoting?
The only thing I can think of would be to dig into the C and add a
globbing flag which matches quoted characters, unquoting them before
matching so I could do something like:
\(([^\|\~]|(#U)*(#u))##\)
I'm inclined to apply this patch as it is for now. I can't see any
existing uses of qualifiers with quotes and we could always add `#q'
manually for the odd case and exclude quotes along with |, ( and ~ in
_files.
My tip for the day for taking advantage of this change is this style:
zstyle ':completion:*:approximate*:*' file-patterns \
'%p(D):globbed-files *(D-/):directories' '*(D):all-files'
With that, _approximate can correct `,zshrc' to `.zshrc'.
Now for the dull job of adding lots of (-.) qualifiers.
Oliver
PS. Hope you get well soon Bart.
Index: Completion/Unix/Type/_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_files,v
retrieving revision 1.8
diff -u -r1.8 _files
--- Completion/Unix/Type/_files 4 Jul 2003 18:19:20 -0000 1.8
+++ Completion/Unix/Type/_files 18 Dec 2003 09:24:24 -0000
@@ -11,6 +11,10 @@
glob="${${${${(@M)tmp:#-g*}#-g}##[[:blank:]]#}%%[[:blank:]]#}"
[[ "$glob" = *[^\\][[:blank:]]* ]] &&
glob="{${glob//(#b)([^\\])[[:blank:]]##/${match[1]},}}"
+
+ # add `#q' to the beginning of any glob qualifier if not there already
+ [[ "$glob" = (#b)(*\()([^\|\~]##\)) && $match[2] != \#q* ]] &&
+ glob="${match[1]}#q${match[2]}"
fi
tmp=$opts[(I)-F]
if (( tmp )); then
Messages sorted by:
Reverse Date,
Date,
Thread,
Author