From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19437 invoked by alias); 7 Mar 2012 13:46:41 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16861 Received: (qmail 23293 invoked from network); 7 Mar 2012 13:46:39 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Wed, 7 Mar 2012 13:40:33 +0000 From: Peter Stephenson To: Subject: Re: Ordering of alternatives for menu completion Message-ID: <20120307134033.32325549@pwslap01u.europe.root.pri> In-Reply-To: References: Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.101.10.170] X-Scanned-By: MailControl 7.6.6 (www.mailcontrol.com) on 10.68.0.134 On Wed, 7 Mar 2012 14:24:43 +0100 Jesper Nyg=C3=A5rds wrote: > _up() { > local myarray myindex revarray > myarray=3D( ${(s:/:)PWD} ) > revarray=3D() > for myindex in {2..$(( $#myarray - 1 ))}; do > revarray=3D( $myarray[$myindex] $revarray[@] ) > done > compadd - $revarray > } > This works fine, but when I use the completion like this: "up ", > the alternatives are cycled in alphabetical order. I want them to be > suggested in the order of $revarray, i.e. with the closest parent > first and the progressively higher up in the hierarchy, but some > mechanism sorts the alternatives alphabetically. You need to tell compadd by passing -V plus the name of a group of matches. I think compadd -V unsorted - $revarray ought to be good enough. While I'm at it, compadd -V unsorted -a revarray is a little more efficient if the array is big. (It's not too hard to make this use the usual tags mechanism to mix with other completions but it doesn't sound like you actually need that.) --=20 Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, = UK Member of the CSR plc group of companies. CSR plc registered in England and= Wales, registered number 4187346, registered office Churchill House, Cambr= idge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http= ://twitter.com/CSR_PLC and read our blog at www.csr.com/blog