From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25341 invoked from network); 26 Jan 2009 06:11:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 26 Jan 2009 06:11:36 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 31625 invoked from network); 26 Jan 2009 06:11:31 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 26 Jan 2009 06:11:31 -0000 Received: (qmail 15006 invoked by alias); 26 Jan 2009 06:11:25 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26442 Received: (qmail 14994 invoked from network); 26 Jan 2009 06:11:24 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 26 Jan 2009 06:11:24 -0000 Received: from mx.spodhuis.org (redoubt.spodhuis.org [193.202.115.177]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 699B480271F0 for ; Mon, 26 Jan 2009 07:11:21 +0100 (CET) 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=; Received: by smtp.spodhuis.org with local id 1LRKgo-000E73-Bk; Mon, 26 Jan 2009 06:11:18 +0000 Date: Sun, 25 Jan 2009 22:11:18 -0800 From: Phil Pennock To: Greg Klanderman Cc: zsh-workers@sunsite.dk Subject: Re: completing automounts with fake-files setting hangs zsh Message-ID: <20090126061118.GA54012@redoubt.spodhuis.org> Mail-Followup-To: Greg Klanderman , zsh-workers@sunsite.dk References: <18811.39531.84244.341828@gargle.gargle.HOWL> <090125042005.ZM25079@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: ClamAV 0.92.1/8902/Mon Jan 26 05:21:29 2009 on bifrost X-Virus-Status: Clean On 2009-01-25 at 13:56 -0500, Greg Klanderman wrote: > > >>>>> Greg Klanderman 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 ~ 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------------------------------