From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6596 invoked from network); 17 May 2005 15:55:58 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 17 May 2005 15:55:58 -0000 Received: (qmail 65465 invoked from network); 17 May 2005 15:55:52 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 May 2005 15:55:52 -0000 Received: (qmail 21326 invoked by alias); 17 May 2005 15:55:45 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8853 Received: (qmail 21317 invoked from network); 17 May 2005 15:55:44 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 17 May 2005 15:55:44 -0000 Received: (qmail 64386 invoked from network); 17 May 2005 15:55:44 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 17 May 2005 15:55:33 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id ; Tue, 17 May 2005 16:53:46 +0100 Received: from news01.csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 17 May 2005 16:56:55 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.1/8.12.11) with ESMTP id j4HFtVqV012965; Tue, 17 May 2005 16:55:31 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.13.1/8.13.1/Submit) with ESMTP id j4HFtUOb012962; Tue, 17 May 2005 16:55:31 +0100 Message-Id: <200505171555.j4HFtUOb012962@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: Bart Schaefer cc: Zsh User Subject: Re: which-command help In-reply-to: <1050517153211.ZM27474@candle.brasslantern.com> References: <20050517132000.GB9627@let.rug.nl> <200505171447.j4HElTUj011344@news01.csr.com> <1050517153211.ZM27474@candle.brasslantern.com> Date: Tue, 17 May 2005 16:55:30 +0100 From: Peter Stephenson X-OriginalArrivalTime: 17 May 2005 15:56:55.0180 (UTC) FILETIME=[0C6DB4C0:01C55AF9] X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 Bart Schaefer wrote: > On May 17, 3:47pm, Peter Stephenson wrote: > } Subject: Re: which-command help > } > } > # but if I use "^[?" (is which-command) I get: > } > > } > ~ % which-command /bin/ls > } > /bin/ls > } > } The problem is that the processing of which-command within the editor > } expands the alias, so that the command line that which-command sees > } already has the /bin/ls expanded. > } > } I think this is a bug, fixed below: we don't want to expand aliases when > } getting the name of the command. > > Compare zsh-workers/20895 and surrounding thread. Are we breaking one > thing to fix another? Well, your reply in that message was: > Suppose you have > > alias LL='ls -lL' > > Do you want run-help to display the man page for "ls", or do you want it > to simply fail because there is no LL command? Actually, it *doesn't* fail after the patch: % alias LL='ls -lL' % which-command LL ls -lL I would have said that's more useful, because it's clearer about what's going on (even more so if which-command is aliased to something more verbose). However, I'm certainly not set on the patch. I would be happy to suggest using the editor widget instead. That could even be modified to expand the alias and lookup the first word as a command, noting that aliases work recursively: which-command() { zmodload -i zsh/parameter zle -I local -a wds wds=(${(z)LBUFFER}) local wd=${wds[1]} local rawwd=${(Q)wd} local -A seen while true; do wd=${wds[1]} rawwd=${(Q)wd} # replace "whence -c" with your favourite function # (but NOT which-command!) if [[ $rawwd != $wd || -n $seen[$rawwd] ]]; then # quoted or already expanded, don't expand alias (unalias -- $rawwd 2>/dev/null; whence -c $rawwd) else # turn on globsubst for =ls etc. whence -c ${~rawwd} if [[ -n $aliases[$rawwd] && -z $seen[$rawwd] ]]; then # Recursively expand aliases seen[$rawwd]=1 wds=(${(z)aliases[$rawwd]}) continue fi fi break done } This might be worth sticking in Functions/Zle. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. **********************************************************************