zsh-workers
 help / color / mirror / code / Atom feed
From: Greg Klanderman <gak@klanderman.net>
To: zsh-workers@sunsite.dk
Subject: Re: completing automounts with fake-files setting hangs zsh
Date: Sun, 25 Jan 2009 11:40:35 -0500	[thread overview]
Message-ID: <m3ocxvjq4c.fsf@klanderman.net> (raw)
In-Reply-To: <090125042005.ZM25079@torch.brasslantern.com> (Bart Schaefer's message of "Sun, 25 Jan 2009 04:20:05 -0800")

>>>>> Bart Schaefer <schaefer@brasslantern.com> writes:

> So if you are able to push some of that filtering into the functions
> by use of hooks like "zstyle -e", you can optimize much better than
> the generic internal filters are able.

I don't think that's going to be a workable solution; if I or one of
my users ever have the misfortune to hit <tab> after an automount
point with not enough text to narrow the match list, then their shell
is just done.  I've waited up to half an hour - it doesn't come back.

Here's what I have done for over 10 years in compctl, based on the
compctl-examples file:

function _comp_autonet  () { ... } # parse etc/auto.net and return all completions
function _comp_autohome () { ... } # parse etc/auto.home and return all completions

compctl -T -x 's[/net/] C[0,^/net/[^/]#/*]'   -K _comp_autonet  -S/ -tn \
            - 's[/home/] C[0,^/home/[^/]#/*]' -K _comp_autohome -S/ -tn

So compctl could deal with the full set of completions without
pre-filtering against the user text.

Under the new completion system, I have something like:

zstyle ':completion:*' fake-files \
       '/net:foo bar baz ..' \
       '/home:user1 user2 user3 ..'

The completion system is smart enough that this doesn't cause any
problem with several hundred fake files defined per automount point,
until I actually try to complete on those fake files.  In fact it's
even fine if the set of completions is reasonably small, so it appears
to be filtering against the user input before stat'ing all the
completions.  It's only when there are a large number of matches that
it gets completely wedged stat'ing them all.

I traced the code from the _path_files function into the compfiles
builtin in the zsh/computil module but then I'm getting pretty lost.
It seems that the compctl mechanism worked because it treated the
completions simply as strings rather than files, and set the -S/
suffix argument so they would behave as directory completions.

If I append a '/' to each file in the fake-files style setting, then
everything is fast, but it appends a space after the completion is
inserted (after the '/').

So maybe the right thing is to modify the compfiles builtin to treat
fake files ending in '/' as directories without stat'ing them?  I'll
poke at that some more if you agree it's reasonable..

thanks,
Greg


  reply	other threads:[~2009-01-25 16:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-24 22:47 Greg Klanderman
2009-01-25  3:45 ` Greg Klanderman
2009-01-25 12:20   ` Bart Schaefer
2009-01-25 16:40     ` Greg Klanderman [this message]
2009-01-25 18:56       ` Greg Klanderman
2009-01-26  6:11         ` Phil Pennock

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=m3ocxvjq4c.fsf@klanderman.net \
    --to=gak@klanderman.net \
    --cc=zsh-workers@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).