From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10177 invoked from network); 31 Dec 2007 16:20:00 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) 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.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 31 Dec 2007 16:20:00 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 84666 invoked from network); 31 Dec 2007 16:19:53 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 31 Dec 2007 16:19:53 -0000 Received: (qmail 17905 invoked by alias); 31 Dec 2007 16:19:49 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24332 Received: (qmail 17892 invoked from network); 31 Dec 2007 16:19:49 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 31 Dec 2007 16:19:49 -0000 Received: from virusfilter.dotsrc.org (bifrost [127.0.0.1]) by spamfilter.dotsrc.org (Postfix) with ESMTP id BACD78058FA9 for ; Mon, 31 Dec 2007 17:19:45 +0100 (CET) Received: from vms173001pub.verizon.net (vms173001pub.verizon.net [206.46.173.1]) by bifrost.dotsrc.org (Postfix) with ESMTP for ; Mon, 31 Dec 2007 17:19:45 +0100 (CET) Received: from torch.brasslantern.com ([71.121.18.67]) by vms173001.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JTX008D18XP5L8A@vms173001.mailsrvcs.net> for zsh-workers@sunsite.dk; Mon, 31 Dec 2007 10:10:38 -0600 (CST) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id lBVGJF7V000838; Mon, 31 Dec 2007 08:19:16 -0800 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id lBVGJE2s000837; Mon, 31 Dec 2007 08:19:14 -0800 Date: Mon, 31 Dec 2007 08:19:12 -0800 From: Bart Schaefer Subject: Re: run-help: Support for svn and git In-reply-to: To: , zsh-workers@sunsite.dk Message-id: <071231081914.ZM836@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <071230200204.ZM32486@torch.brasslantern.com> Comments: In reply to ( Text in unknown character set UTF-8 not shown ) Sommer "Re: run-help: Support for svn and git" (Dec 31, 12:10pm) X-Virus-Scanned: ClamAV using ClamSMTP On Dec 31, 12:10pm, joerg@alea.gnuu.de wrote: } Subject: Re: run-help: Support for svn and git } } > run-help-svn () { } > local cmd_args } > cmd_args=( ${@:#-*} ) } > svn help $cmd_args[1] } } I'm not very familiar with zsh programming. So this question might sound } stupid, but why do you create a new variable? Why don't you use } ${${@:#-*}[1]} ? No particular reason except that the above evolved from a couple of earlier attempts that had the "getln" part in the helper instead of in run-help. } Is it possible to get the point where run-help was called? Maybe for } } ssh -option <1> host cmd <2> Not from within the run-help shell function. For that one would need information that's only available inside the ZLE widget. In fact, that's probably why nobody has bothered with improving run-help much before: Most people just hit TAB at those places and rely on the help strings from the completion function to tell them what they can do. One could replace the run-help widget itself with something that takes the line apart with $LBUFFER and $RBUFFER and analyzes it in more detail, and if run-help had been invented after user-defined widgets were, it would probably never have been designed the way it is. } > + if whence -w "run-help-$1" >/dev/null } } Why do you use -w, while you throw the output away. Evolution again. At one point I thought I cared what type of command it was. } > + cmd_args=( ${${(z)cmd_args}[2,-1]} ) } > + eval "run-help-$1 $cmd_args[@]" } } Where do you remove the part before $1, e.g. LANG=bla? Ah, I missed that bit. I wondered why you were doing ${full_cmd#*$1}. Yours doesn't quite work, either; consider something like PATH=/opt/cvs/bin:$PATH cvs commit ... (which admittedly is contrived, but demonstrative). } Why do you have to use eval? Doesn't run-help-$1 work? Aliases would not be expanded without the eval, and I wanted one to be able to do e.g.: alias run-help-perl=perldoc Here's a new patch. Index: run-help =================================================================== RCS file: /extra/cvsroot/zsh/zsh-4.0/Functions/Misc/run-help,v retrieving revision 1.3 diff -c -r1.3 run-help --- run-help 30 May 2007 03:36:56 -0000 1.3 +++ run-help 31 Dec 2007 16:13:25 -0000 @@ -85,7 +85,24 @@ man zshmisc ;; (*) - ((! didman++)) && man $@ + if ((! didman++)) + then + if whence "run-help-$1:t" >/dev/null + then + local cmd_args + builtin getln cmd_args + builtin print -z "$cmd_args" + cmd_args=( ${(z)cmd_args} ) + # Discard environment assignments, etc. + while [[ $cmd_args[1] != $1 ]] + do + shift cmd_args + done + eval "run-help-$1:t ${(@)cmd_args[2,-1]}" + else + man $@:t + fi + fi ;; esac if ((i < $#places && ! didman)) --