From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15719 invoked by alias); 14 Aug 2015 22:31:20 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36172 Received: (qmail 21434 invoked from network); 14 Aug 2015 22:31:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.0 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== MIME-Version: 1.0 X-Received: by 10.50.88.8 with SMTP id bc8mr5474722igb.46.1439591475499; Fri, 14 Aug 2015 15:31:15 -0700 (PDT) In-Reply-To: <1439348703-8268-3-git-send-email-mikachu@gmail.com> References: <1439348703-8268-1-git-send-email-mikachu@gmail.com> <1439348703-8268-3-git-send-email-mikachu@gmail.com> Date: Sat, 15 Aug 2015 00:31:15 +0200 Message-ID: Subject: Re: PATCH 3/5: _imagemagick: complete all files if image files didn't match From: Mikael Magnusson To: zsh workers Content-Type: text/plain; charset=UTF-8 On Wed, Aug 12, 2015 at 5:05 AM, Mikael Magnusson 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 (x++)' \ '*-fuzz:maximum distance for equal colors' \ -- Mikael Magnusson