From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11119 invoked by alias); 29 Apr 2013 05:39: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: 31354 Received: (qmail 4917 invoked from network); 29 Apr 2013 05:39:18 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.217.174 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=e/JhWM6qQt2pW8Et/G4hSrUWG8975h+2I6nFQ9m0arQ=; b=AijF7OuWfVWPhNMrIunKIm5uwapp6jIlZSEUxa9ghJ1JIu3630+BzLZu7+iQr2vBYx TZw6ltrF1+yd6SJPKzrQwi9r1gMvgIuhTE10Hrfnjdz/5NAyjO+hmWZKwXBmFmz3Otvq LiFRDI7rYNJRiiM2WlVhtPI82m/3Y9npPl1td0AnfK+HYc1YbHT559Qeg1yAaFaPH8xY EWMEOqUYqcn68A1LxGeb13y444TjKArDXsUj+bD977aeTrhZcmsBlNcG8wBSzcPEzX+f k+B1kQCKiQZF8UqwOyiQq3GkTFwgJbZgrpU8xJKQJRJrud8qidJ+IoCJs8rykuAl1yD2 lPWQ== MIME-Version: 1.0 X-Received: by 10.112.139.226 with SMTP id rb2mr25458855lbb.12.1367213951808; Sun, 28 Apr 2013 22:39:11 -0700 (PDT) In-Reply-To: <20130428191240.34181099@pws-pc.ntlworld.com> References: <20130428191240.34181099@pws-pc.ntlworld.com> Date: Mon, 29 Apr 2013 00:39:11 -0500 Message-ID: Subject: Re: No way to properly complete specific set of files From: Felipe Contreras To: Peter Stephenson Cc: zsh-workers@zsh.org, Felipe Contreras Garza Content-Type: text/plain; charset=UTF-8 On Sun, Apr 28, 2013 at 1:12 PM, Peter Stephenson wrote: > On Sat, 27 Apr 2013 05:12:27 -0500 > Felipe Contreras wrote: >> I have an array, let's say: >> >> files=('Documents' 'Downloads' 'Downloads/test' 'Videos') >> >> And I want to complete those files, with all the niceties that _file has. >>... >> Am I missing something? > > I don't think you're missing anything in the sense that there's anything > really designed for this, no... to follow up on something Bart noted > earlier, the completion system is written in such a way that it doesn't > provide a lot of support for things that aren't done the way the > original author thought of. It would be great to refactor it to be > both more general and more maintainable, but alas there are way too few > volunteers for that sort of exercise. > > However, you can trick it to some extent: > > _path_files -g "(${(j.|.)~files})" > > relying on an extended_glob pattern to match any of the files. That's > not perfect --- in particular if there are metacharacters in the > file names they'll confuse it. Further, I think you're going to have > trouble with directories; you'd need to decide what the files were > within the current directory path, so you can't do stuff like complete > Downloads/test directly that way. It's probably possible to work around > --- factor out the path that's already been completed --- but a bit > fiddly and not gaining a lot over what you're already doing. Yeah, but the next question is; why didn't the author think of that? It seems like fairly obvious to me that somebody eventually would come up with that need, and it seems many have done so, and they are using _multi_parts for that (e.g. _git and _hg), but doesn't work nicely either. Too bad. Cheers. -- Felipe Contreras