Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: completing automounts with fake-files setting hangs zsh
- X-seq: zsh-workers 26442
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: Greg Klanderman <gak@xxxxxxxxxxxxxx>
- Subject: Re: completing automounts with fake-files setting hangs zsh
- Date: Sun, 25 Jan 2009 22:11:18 -0800
- Cc: zsh-workers@xxxxxxxxxx
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=d200807; d=spodhuis.org; h=Received:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; b=jY83FxfCQGnx/SgsfaV17WIoOFDZg9JBKQPgSb4Dd9dHG+FzBQPbPWw6odn0SJVfoKAptGZlBG3N3zsxRhPEU8v8MaASqoK4okCIpf4XIL7F0aEN51AZzpyKl8LTWhxCTBQ137TMW81B1oYMMsVBQKUwT/1m94mfg1DL9rjYY5k=;
- In-reply-to: <m3k58jjjud.fsf@xxxxxxxxxxxxxx>
- Mail-followup-to: Greg Klanderman <gak@xxxxxxxxxxxxxx>, zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <18811.39531.84244.341828@xxxxxxxxxxxxxxxxxx> <m3r62sjbfj.fsf@xxxxxxxxxxxxxx> <090125042005.ZM25079@xxxxxxxxxxxxxxxxxxxxxx> <m3ocxvjq4c.fsf@xxxxxxxxxxxxxx> <m3k58jjjud.fsf@xxxxxxxxxxxxxx>
On 2009-01-25 at 13:56 -0500, Greg Klanderman wrote:
>
> >>>>> Greg Klanderman <gak@xxxxxxxxxxxxxx> writes:
>
> > 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..
>
> Well, I now see that the problem is not in compfiles.. it handles the
> fake files, and returns them in the result array back to _path_files.
> I'm gonna move on to something else for a bit..
Bear in mind that tab-completion often looks for spelling mistakes in
previous components of the path. Some knobs I have tuned at work:
----------------------------8< cut here >8------------------------------
# Prevent reading in parent directories for tab-expansion:
zstyle ':completion:*' preserve-prefix '(/home/*|/auto/*)/'
# Or: zstyle ':completion:*' preserve-prefix '*/'
# Post-4.3.6 flag which does things 'properly'; any prefix component
# which matches an existing dir should be directly accepted, instead of
# being subject to expansion:
zstyle ':completion:*' accept-exact-dirs true
----------------------------8< cut here >8------------------------------
We also have /home/ as an automount for some number of thousands of
users (>10); for me, I only see those entries for which I've already
populated the directory, so readdir() only returns items which have been
pulled into the local host. Mind, /etc/auto.home is a flat-file being
distributed, rather than LDAP or NIS or whatever.
The other part is that the userdirs variable, for ~<user> expansion,
will by default walk getpwent(), which can get rather tiresome when the
network is congested; userdirs is exposed by zsh/parameter but as a
read-only variable.
Here's how I get around it; zfilter_comments is another function, which
is just a "cat without comment lines, internal to shell" which I'll
include at the botton, since it's not relevant to the core
functionality.
----------------------------8< cut here >8------------------------------
function reset_userdirs {
# There is a zsh internal map, userdirs, exposed by zsh/parameter;
# it's read-only though.
[[ -f ~/.userdirs ]] || return
local _u
local -a _ud
_ud=( $(zfilter_comments ~/.userdirs) )
for _u in $_ud; do hash -d $_u="/home/$_u"; done
hash -d desktop="$HOME/Desktop"
#...
}
Hack to turn off userdirs completion by overriding userdirs.
# This overrides userdirs as a local variable inside the completion
# system, not touching the global variable. We don't need to load
# zsh/parameter to achieve this.
#zmodload -i zsh/parameter
_comp_setup+=$'\ntypeset -a userdirs\nreset_userdirs'
reset_userdirs
----------------------------8< cut here >8------------------------------
Other completion system tags you can look at defining include:
accounts my-accounts other-accounts users
There is in zsh room for improvement in a few areas to deal with large
maps loaded in by the OS slowly in large user environments or slow
filesystems; a way to explore might be adding a couple of zstyle tags
which activate more cautious lookup and adjust the relevant completion
functions to use those, as needed. After all, that's what 'users',
'accounts', etc do already. Perhaps with setting those and
preserve-prefix or accept-exact-dirs, you'll be okay; for me, the above
has made things work cleanly and smoothly enough that I haven't been
motivated to come up with decent improvements to feed back into zsh
(since it's only a problem at work and I have higher priorities when
there).
Regards,
-Phil
----------------------------8< cut here >8------------------------------
function zfilter_comments {
local f infile="$1"
while read f; do
[[ -n ${f%%[$' \t']*\#*} && ${f#[#;]} == $f ]] || continue
print -r -- ${f%%[$' \t']*\#*}
done < "$infile"
}
----------------------------8< cut here >8------------------------------
Messages sorted by:
Reverse Date,
Date,
Thread,
Author