Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH 3/5: _imagemagick: complete all files if image files didn't match
- X-seq: zsh-workers 36172
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: PATCH 3/5: _imagemagick: complete all files if image files didn't match
- Date: Sat, 15 Aug 2015 00:31:15 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=6iL51/JDHb3Oy7rbiMX9W9ySpzeVpP+KPV7iewaMsQw=; b=oStcnfZhOKKMXwMpGK5UHDU5saP2CB9nzDDwOqQLz2FpMYzkl+KA2Fx9mXY6+4IMCk LeYhp0jDYGYcQPiPb1mdhhxzGjP3VbrNXh5vz9XASLkWbTCcrQnEy+gj7lh5Ott9ghvv m0UupGR3lnIE7z98G0VQ75nxqss3bxExEFQ0KdC5mMfbrcZEHDj8IKsXsod4WUh1waYt 1hjjxvnLQ1IZFkwK7uiriUJ0w0YakgGH4yIgGQTJjqCtXsF5HIAACeYGmFCtu4DfUGbL bsgZBCDOnZlGa1+XtfgEc/6YIwL7wjDhJ0vPy59uWyCEg/lnIzJjowFRU0CEtMATpJZ7 MGIQ==
- In-reply-to: <1439348703-8268-3-git-send-email-mikachu@gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1439348703-8268-1-git-send-email-mikachu@gmail.com> <1439348703-8268-3-git-send-email-mikachu@gmail.com>
On Wed, Aug 12, 2015 at 5:05 AM, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> ---
> Completion/Unix/Command/_imagemagick | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Completion/Unix/Command/_imagemagick b/Completion/Unix/Command/_imagemagick
> index 115cb01..c43086c 100644
> --- a/Completion/Unix/Command/_imagemagick
> +++ b/Completion/Unix/Command/_imagemagick
> @@ -14,7 +14,7 @@ typeset -A opt_args
> formats=jpg:jpeg:jp2:j2k:jpc:jpx:jpf:tiff:miff:ras:bmp:cgm:dcx:ps:eps:fig:fits:fpx:gif:mpeg:pbm:pgm:ppm:pcd:pcl:pdf:pcx:png:rad:rgb:rgba:rle:sgi:html:shtml:tga:ttf:uil:xcf:xwd:xbm:xpm:yuv
>
> if (( $# )); then
> - _files "$@" -g "*.(#i)(${~formats//:/|})(-.)"
> + _files "$@" -g "*.(#i)(${~formats//:/|})(-.)" || _files "$@"
> return
> fi
Now that I'm looking at this line for the 500th time, I realize that
the ~ in there makes absolutely no sense, and shouldn't really work.
However, it seems to be totally ignored and harmless. I tried changing
formats to an array, and using this instead,
_files "$@" -g "*.(#i)(${(j:|:)~formats})(-.)"
And it works the same, next I tried (actually I did the other way
around but this is easier to follow)
_files "$@" -g "*.(#i)(${(~j:|:)formats})(-.)"
but this fails because for some reason this ~ is not ignored and the
pattern is evaluated at this point, expands to nothing, because
NULL_GLOB is set in completion, and we don't pass anything as an
argument to -g (because the * is quoted. If there was a literal *.jpg
it would probably do something else).
Long story short, let's do this while we're messing around in this
file, so this semi-anti-pattern doesn't spread when people look at
this file for modeling other completions.
diff --git i/Completion/Unix/Command/_imagemagick
w/Completion/Unix/Command/_imagemagick
index 115cb01..3b0b877 100644
--- i/Completion/Unix/Command/_imagemagick
+++ w/Completion/Unix/Command/_imagemagick
@@ -11,10 +11,10 @@ typeset -A opt_args
#
# and certainly many other things...
-formats=jpg:jpeg:jp2:j2k:jpc:jpx:jpf:tiff:miff:ras:bmp:cgm:dcx:ps:eps:fig:fits:fpx:gif:mpeg:pbm:pgm:ppm:pcd:pcl:pdf:pcx:png:rad:rgb:rgba:rle:sgi:html:shtml:tga:ttf:uil:xcf:xwd:xbm:xpm:yuv
+formats=(jpg jpeg jp2 j2k jpc jpx jpf tiff miff ras bmp cgm dcx ps
eps fig fits fpx gif mpeg pbm pgm ppm pcd pcl pdf pcx png rad rgb rgba
rle sgi html shtml tga ttf uil xcf xwd xbm xpm yuv)
if (( $# )); then
- _files "$@" -g "*.(#i)(${~formats//:/|})(-.)"
+ _files "$@" -g "*.(#i)(${(j:|:)formats})(-.)"
return
fi
@@ -444,7 +444,7 @@ case "$service" in
'*-filter:filter type for resizing:(Point Box Triangle Hermite
Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell
Lanczos Bessel Sinc)' \
'*-flip[vertical mirror image]' \
'*-flop[horizontal mirror image]' \
- "*-format:output file format:(${formats//:/ })" \
+ "*-format:output file format:($formats)" \
'*-font:annotation font:_x_font' \
'*-frame:border dimensions (<width>x<height>+<out>+<in>)' \
'*-fuzz:maximum distance for equal colors' \
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author