From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20807 invoked from network); 30 Nov 2005 14:11:16 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 30 Nov 2005 14:11:16 -0000 Received: (qmail 9503 invoked from network); 30 Nov 2005 14:11:10 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 Nov 2005 14:11:10 -0000 Received: (qmail 14121 invoked by alias); 30 Nov 2005 14:11:01 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9719 Received: (qmail 14109 invoked from network); 30 Nov 2005 14:11:00 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 30 Nov 2005 14:11:00 -0000 Received: (qmail 8374 invoked from network); 30 Nov 2005 14:11:00 -0000 Received: from cluster-c.mailcontrol.com (HELO rly06c.srv.mailcontrol.com) (168.143.177.190) by a.mx.sunsite.dk with SMTP; 30 Nov 2005 14:10:59 -0000 Received: from exchange03.csr.com ([62.189.241.194]) by rly06c.srv.mailcontrol.com (MailControl) with ESMTP id jAUEAuTT016331 for ; Wed, 30 Nov 2005 14:10:56 GMT Received: from news01 ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 30 Nov 2005 14:13:47 +0000 Date: Wed, 30 Nov 2005 14:10:54 +0000 From: Peter Stephenson To: zsh-users@sunsite.dk Subject: Re: zsh completion help sought Message-Id: <20051130141054.6afa2cd9.pws@csr.com> In-Reply-To: <20051130125237.GA30693@parhelion.globnix.org> References: <20051130125237.GA30693@parhelion.globnix.org> Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 30 Nov 2005 14:13:47.0037 (UTC) FILETIME=[4762C4D0:01C5F5B8] X-Scanned-By: MailControl A-05-40-01 (www.mailcontrol.com) on 10.67.0.116 Phil Pennock wrote: > (1) I use $_ frequently, rather than history expansion, when I'm > doing multiple operations on one file; I do want it expanded before > I press return, both as a sanity check and so that I can repeat a > command using command history. How do I set a style/function so > that if the current word is $_ and the cursor is at the end, to > ignore all those evil no-namespace-workaround-hack functions and > just expand the $_ variable itself? You do know about the non-completion binding ESC-. (widget insert-last-word) to recover the last word of the previous line (repeat to go to earlier lines; there's a contributed widget to allow previous words on the line you've landed on, too)? In general, it *ought* to be something like this: # Ensure is using expansion through compsys bindkey '^i' complete-word # Put the expand completer before the complete completer zstyle ':completion:*' completer _expand _complete # Force expand to expand exactly typed parameters. zstyle ':completion:*:expand:*' accept-exact true Unfortunately, though you (well, I, with a rather more complicated set of settings) get $_ expanded this way, you still run into a namespace problem and get whatever $_ was set to inside the completion function, which isn't what you want. If you're wedded to an idea of this kind, you could use an accept-line hack to get the last thing on the line assigned to a different parameter, say a: accept-line() { # for the execution of this line, $a is what we remembered from the old one typeset -g a=$newa # split the line we're about to execute into shell words local -a line line=(${(z)BUFFER}) # remember the last shell word for next time typeset -g newa=$line[-1] # do normal end-of-line processing zle .accept-line } zle -N accept-line Putting this all together, your trick ought to work with $a instead of $_. (I did get this to work, but I can't be sure you have all the same ingredients I do. You don't want to see my entire set of styles, believe me.) > (2) As a similar sanity check before pressing return, I like to > tab-expand a glob to cast an eye over the list and catch my more > egregrious mistakes. How do I keep menu-completion turned on for > tab expansions of a bare suffix but move straight to glob expansion > if the end of the current word is a '*' ? (ie, the item you get in > the new system when tab cycles far enough through the options to > show you all the options, just before showing you the bare '*')? I'm not sure I follow all of that, but the key step in getting expansion to insert all expansions is: zstyle ':completion:*:expand:*' tag-order all-expansions This says that the choice from the result of the expand completer which is tagged as all-expansions is to be preferred over others. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com