From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2851 invoked from network); 29 Sep 2008 17:38:39 -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.6 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; 29 Sep 2008 17:38:39 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 21074 invoked from network); 29 Sep 2008 17:38:30 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 29 Sep 2008 17:38:30 -0000 Received: (qmail 7628 invoked by alias); 29 Sep 2008 17:38:25 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25773 Received: (qmail 7618 invoked from network); 29 Sep 2008 17:38:24 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 29 Sep 2008 17:38:24 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [217.69.20.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 848FB80308BA for ; Mon, 29 Sep 2008 19:38:21 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly50d.srv.mailcontrol.com (MailControl) with ESMTP id m8THcKE2022220 for ; Mon, 29 Sep 2008 18:38:20 +0100 Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Mon, 29 Sep 2008 18:38:20 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.14.2/8.13.4) with ESMTP id m8THcKP7011771 for ; Mon, 29 Sep 2008 18:38:20 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.14.2/8.14.2/Submit) with ESMTP id m8THcKM0011768 for ; Mon, 29 Sep 2008 18:38:20 +0100 X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: stub for dynamic directory name completion X-Mailer: MH-E 8.0.3; nmh 1.3; GNU Emacs 22.1.1 Date: Mon, 29 Sep 2008 18:38:20 +0100 Message-ID: <11767.1222709900@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 29 Sep 2008 17:38:20.0105 (UTC) FILETIME=[29D5D390:01C9225A] X-Scanned-By: MailControl A-08-50-15 (www.mailcontrol.com) on 10.68.0.160 X-Virus-Scanned: ClamAV 0.92.1/8353/Mon Sep 29 11:57:09 2008 on bifrost X-Virus-Status: Clean This provides a hook for you to complete dynamic directory names by redefining _dynamic_directory_name. As it's entirely up to you there's no point in providing any code, although we could agree a useful format: I'm using colon-separated name parts where the context for later parts depends on earlier parts. It's still quite hard to define completion generically, even with styles, because of the tree structure. Maybe someone from computer-science-land has some bright ideas. Index: Completion/Zsh/Context/.distfiles =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Context/.distfiles,v retrieving revision 1.4 diff -u -r1.4 .distfiles --- Completion/Zsh/Context/.distfiles 13 Jun 2008 13:57:04 -0000 1.4 +++ Completion/Zsh/Context/.distfiles 29 Sep 2008 17:32:27 -0000 @@ -5,6 +5,7 @@ _brace_parameter _condition _default +_dynamic_directory_name _equal _first _in_vared Index: Completion/Zsh/Context/_dynamic_directory_name =================================================================== RCS file: Completion/Zsh/Context/_dynamic_directory_name diff -N Completion/Zsh/Context/_dynamic_directory_name --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Completion/Zsh/Context/_dynamic_directory_name 29 Sep 2008 17:32:27 -0000 @@ -0,0 +1,7 @@ +#autoload + +# The core libraries don't check for dynamic directory name expansion; +# this gets called from _subscript. This is a placeholder for +# people to overload. + +_message 'dynamic directory name: redefine _dynamic_directory_name to use' Index: Completion/Zsh/Context/_subscript =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Context/_subscript,v retrieving revision 1.14 diff -u -r1.14 _subscript --- Completion/Zsh/Context/_subscript 9 Apr 2008 13:06:55 -0000 1.14 +++ Completion/Zsh/Context/_subscript 29 Sep 2008 17:32:27 -0000 @@ -10,7 +10,16 @@ compset -P '\(([^\(\)]|\(*\))##\)' # remove subscript flags -if [[ "$PREFIX" = :* ]]; then +# Look for a dynamic name expansion. Completion only gives us +# the stuff inside the square brackets; we need to find out what's +# outside. We ought to check for quoting, really, but given we've +# got to the subscript code " ~[" is pretty likely to be a dynamic +# name expansion. +integer pos=$((CURSOR+1)) +while [[ pos > 1 && $BUFFER[pos-1] != '[' ]]; do (( pos-- )); done +if [[ $BUFFER[1,pos] = *[[:space:]]##\~\[ ]]; then + _dynamic_directory_name +elif [[ "$PREFIX" = :* ]]; then _wanted characters expl 'character class' \ compadd -p: -S ':]' alnum alpha ascii blank cntrl digit graph \ lower print punct space upper xdigit -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070