zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Felipe Contreras <felipe.contreras@gmail.com>, zsh-workers@zsh.org
Subject: Re: No way to properly complete specific set of files
Date: Sun, 28 Apr 2013 19:12:40 +0100	[thread overview]
Message-ID: <20130428191240.34181099@pws-pc.ntlworld.com> (raw)
In-Reply-To: <CAMP44s1hjM94+o_xwaw=gsiwx1Y1rd12sqhunWywiTkWaJvTEQ@mail.gmail.com>

On Sat, 27 Apr 2013 05:12:27 -0500
Felipe Contreras <felipe.contreras@gmail.com> 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.
 
-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2013-04-28 18:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-27 10:12 Felipe Contreras
2013-04-28 18:12 ` Peter Stephenson [this message]
2013-04-28 23:42   ` Bart Schaefer
2013-04-29  5:39   ` Felipe Contreras

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=20130428191240.34181099@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=felipe.contreras@gmail.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).