From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh Users <zsh-users@sunsite.dk>
Subject: Re: compsys issues
Date: Wed, 27 Oct 2004 16:08:26 +0200 [thread overview]
Message-ID: <15603.1098886106@trentino.logica.co.uk> (raw)
In-Reply-To: <20041027132610.GA9928@DervishD>
DervishD wrote:
> # expand-or-complete is currently bound to <TAB>
> zle -C expand-or-complete expand-or-complete _completer
>
> function _completer () {
>
> compstate[insert]=${compstate[insert]//tab /}
>
> compadd -f - $PREFIX*(/)
I realise that it is there to get any preceding directory portion but
you're overriding the internal matching by starting the pattern match
with $PREFIX. I'd use something like ${(M)PREFIX##*/} instead.
> Let's say I pick 'Projects' and hit tab again. Now I'm presented
> with this:
>
> $ cd Projects/<TAB>
>
> Projects/mta/ Projects/zsh-things/ Projects/more/
>
> But what I want is to be presented with:
>
> $ cd Projects/<TAB>
>
> mta/ zsh-things/ more/
For that, you need to use compset -P '*/' to move the initial directory
portions to $IPREFIX so they are not part of matching.
> I've tried tweaking IPREFIX and PREFIX (with and without the help
> from compset), I've tried generating the list of matches before
You need to tweak the compadd command too. After compset, any initial
directory portion will be in $IPREFIX instead of $PREFIX. That will
include a trailing slash so you can do $IPREFIX*(/) to get the files.
That will now try to add stuff like `Projects/more' as a match when
`Projects/' is in IPREFIX. You don't want to include the stuff in
$IPREFIX in the possible matches so you can use the :t modifier to get
just the filenames as matches: $IPREFIX*(/:t)
Next, you need to use compadd's -W option so that the -f option can find
the right directory. Try something like the following to begin with:
compadd -W $PWD/$IPREFIX -f - $IPREFIX*(/:t)
That won't work with paths starting with variable expansions or
non-relative directories. You'll need more logic to work out the
argument to -W. Using $~IPREFIX will help resolve any expansions on the
command line.
Hope that helps
Oliver
next prev parent reply other threads:[~2004-10-27 14:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-27 13:26 DervishD
2004-10-27 14:08 ` Oliver Kiddle [this message]
2004-10-27 14:54 ` DervishD
2004-10-27 15:43 ` Oliver Kiddle
2004-10-27 16:07 ` DervishD
2004-10-27 16:44 ` DervishD
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=15603.1098886106@trentino.logica.co.uk \
--to=okiddle@yahoo.co.uk \
--cc=zsh-users@sunsite.dk \
/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).