zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH 3/5: _imagemagick: complete all files if image files didn't match
Date: Fri, 14 Aug 2015 17:05:56 -0700	[thread overview]
Message-ID: <150814170556.ZM15448@torch.brasslantern.com> (raw)
In-Reply-To: <CAHYJk3QbYvuXXRDxafQFSb5ZuYRyEjfETu3J-HDUTF92HcaMBQ@mail.gmail.com>

On Aug 15, 12:31am, Mikael Magnusson wrote:
} Subject: Re: PATCH 3/5: _imagemagick: complete all files if image files di
}
} > -  _files "$@" -g "*.(#i)(${~formats//:/|})(-.)"
} > +  _files "$@" -g "*.(#i)(${~formats//:/|})(-.)" || _files "$@"
} 
} 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.

The ~ there is in fact useless, because the expansion is quoted, so
converting characters within the elements of $format into patterns
doesn't do anything.

In fact it's more likely that ${(b)formats} is wanted so that pattern
charactes in each of the format strings would be quoted, if there were
any.  (That *will* persist because it's a textual change inserting
backslashes.)  Then they'd remain non-special when the positional
paramter is expanded later by _files.

} 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})(-.)"

Same thing.

} 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})(-.)"

When you have an array, "${(j:|:)array}" generates the set consisting of
each of the quoted array elements, and then joins them.  The vertical
bar is not part of the quoted regions, but it's also not interpreted as
a pattern character.

"${(~j:|:)array}" generates the quoted elements and then joins them
with the pattern character represented by vertical bar, so you get the
expansion immediately as you noted.

} -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 you're going to do that, you should also declare formats as an array
instead of a string, just for completeness.


  reply	other threads:[~2015-08-15  0:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-12  3:04 PATCH 1/5: _git: various fixes Mikael Magnusson
2015-08-12  3:05 ` PATCH 2/5: _wget: complete headers for --header and add --no-use-server-timestamps Mikael Magnusson
2015-08-12  3:05 ` PATCH 3/5: _imagemagick: complete all files if image files didn't match Mikael Magnusson
2015-08-12 17:20   ` Oliver Kiddle
2015-08-12 18:12     ` Mikael Magnusson
2015-08-12 18:59       ` Bart Schaefer
2015-08-12 19:35         ` Mikael Magnusson
2015-08-12 19:42           ` Bart Schaefer
2015-08-12 20:05         ` Mikael Magnusson
2015-08-12 20:57           ` Bart Schaefer
2015-08-12 21:15             ` Mikael Magnusson
2015-08-12 21:44               ` Bart Schaefer
2015-08-12 22:34                 ` Mikael Magnusson
2015-08-12 22:46                   ` Bart Schaefer
2015-08-12 23:37                     ` Mikael Magnusson
2015-08-13 10:12                     ` Oliver Kiddle
2015-08-13 20:27                       ` Bart Schaefer
2015-08-14  8:44                         ` Oliver Kiddle
2015-08-14 16:18                           ` Mikael Magnusson
2015-08-14 16:24                             ` Bart Schaefer
2015-08-14 22:31   ` Mikael Magnusson
2015-08-15  0:05     ` Bart Schaefer [this message]
2015-08-15  0:52       ` Mikael Magnusson
2015-08-12  3:05 ` PATCH 4/5: _sort: Fix syntax error Mikael Magnusson
2015-08-12  3:05 ` PATCH 5/5: _strftime: Add completion for zsh/datetime's strftime builtin Mikael Magnusson

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=150814170556.ZM15448@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).