Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: patterns in braces (was: Re: PATCH: Re: 3.1.6-dev-22)
- X-seq: zsh-workers 10695
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: patterns in braces (was: Re: PATCH: Re: 3.1.6-dev-22)
- Date: Wed, 12 Apr 2000 14:29:02 +0200 (MET DST)
- In-reply-to: "Bart Schaefer"'s message of Tue, 11 Apr 2000 14:58:17 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Bart Schaefer wrote:
> On Apr 11, 9:54am, Sven Wischnowsky wrote:
> ...
>
> } Giving more than one pattern per string, with different tags. Small
> } problem: one can still give more than one pattern per tag -- and has
> } to separate them with commas. I don't like that, it's different from
> } every other separation character we have.
>
> One possibility is to use the familiar brace expansion syntax:
>
> ... file-patterns '{*.(a|o),*(*)}:compiled-files *(-/):dirs' ...
>
> In fact, that syntax could be used everywhere that multiple glob patterns
> are presently separated by spaces, which would e.g. make it clearer that
> all the patterns in a PATTERNS:TAG form were associated with the TAG.
> However, that's a much bigger change, and I don't know whether it makes
> parsing a lot more difficult.
Here is the patch for that. I added it for both file-patterns and
tag-order (for the latter it is probably not needed very often, but to
make things more consistent...).
Bye
Sven
Index: Completion/Core/_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_files,v
retrieving revision 1.8
diff -u -r1.8 _files
--- Completion/Core/_files 2000/04/11 11:21:13 1.8
+++ Completion/Core/_files 2000/04/12 12:26:19
@@ -6,7 +6,11 @@
'/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+:
type="${(@j::M)${(@)tmp#-}#?}"
-(( $tmp[(I)-g*] )) && glob="${(j:,:)${(@M)tmp:#-g*}#-g}"
+if (( $tmp[(I)-g*] )); then
+ glob="${${${${(@M)tmp:#-g*}#-g}##[[:blank:]]#}%%[[:blank:]]#}"
+ [[ "$glob" = *[^\\][[:blank:]]* ]] &&
+ glob="{${glob//(#b)([^\\])[[:blank:]]##/${match[1]},}}"
+fi
ign=$opts[(I)-F]
if (( ign )); then
ign=( $=opts[ign+1] )
@@ -22,7 +26,7 @@
if zstyle -a ":completion:${curcontext}:" file-patterns tmp; then
[[ "$type" = */* ]] && glob="$glob,*(-/)"
pats=()
- for i in ${tmp//\\%p/ ${${glob:-\*}//:/\\:} }; do
+ for i in ${tmp//\\%p/${${glob:-\*}//:/\\:} }; do
if [[ $i = *[^\\]:* ]]; then
pats=( "$pats[@]" " $i " )
else
@@ -45,9 +49,9 @@
fi
for def in "$pats[@]"; do
- def="${def##[[:blank:]]#}"
- while [[ "$def" = *[^\\][[:blank:]]* ]]; do
- sdef="${${(M)def#*[^\\][[:blank:]]}%%[[:blank:]]#}"
+ eval "def=( ${${def:s/\\:/\\\\\\\\\\\\:}//(#b)([][()|*?^#~<>])/\\${match[1]}} )"
+ for sdef in "$def[@]"; do
+
tag="${${sdef#*[^\\]:}%%:*}"
pat="${${${sdef%%:${tag}*}//\\\\:/:}//,/ }"
@@ -70,7 +74,6 @@
fi
done
done
- def="${${def#${sdef}}##[[:blank:]]#}"
done
(( ret )) || return 0
done
Index: Completion/Core/_tags
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_tags,v
retrieving revision 1.2
diff -u -r1.2 _tags
--- Completion/Core/_tags 2000/04/01 20:43:43 1.2
+++ Completion/Core/_tags 2000/04/12 12:26:19
@@ -64,7 +64,8 @@
fi
;;
\!*) comptry "${(@)argv:#(${(j:|:)~${=~tag[2,-1]}})}";;
- ?*) comptry -m "$tag";;
+ ?*) eval "tag=( ${${tag:s/\\:/\\\\\\\\\\\\:}//(#b)([][()|*?^#~<>])/\\${match[1]}} )"
+ comptry -m "${${(@)tag// /\\ }}";;
esac
done
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.15
diff -u -r1.15 compsys.yo
--- Doc/Zsh/compsys.yo 2000/04/11 07:57:57 1.15
+++ Doc/Zsh/compsys.yo 2000/04/12 12:26:26
@@ -947,13 +947,15 @@
used. Instead, the value of the style says which tags and which
patterns are to be offered. The strings in the value contain
specifications of the form
-`var(patterns)tt(:)var(tag)'; each string may contain any number of
-such specifications. The var(patterns) give one or more glob
-patterns separated by commas that are to be used to generate
+`var(pattern)tt(:)var(tag)'; each string may contain any number of
+such specifications. The var(pattern) gives a glob
+pattern that is to be used to generate
filenames. If it contains the sequence `tt(%p)', that is replaced by
the pattern(s) given by the calling function.
Colons in the pattern have to be preceded by a backslash to
-make them distinguishable from the colon before the var(tag). The
+make them distinguishable from the colon before the var(tag). If more
+than one pattern is needed, the patterns can be given inside braces,
+separated by commas. The
var(tag)s of all strings in the value will be offered by tt(_files)
(again, one after another) and used when looking up other styles. For
strings containing more than one specification, the filenames for all
@@ -1707,8 +1709,9 @@
)
enditem()
-In each of the cases above, the tag may also be a pattern. In this
-case all of the offered tags matching this pattern will be used except
+In each of the cases above, the tag may also be a pattern or more than
+one pattern inside braces and separated by commas. In this
+case all of the offered tags matching the pattern(s) will be used except
for those that are given explicitly in the same string. There are
probably two main uses of this. One is the case where one wants to try
one of the tags more than once, setting other styles differently for
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author