From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27060 invoked from network); 5 Oct 2008 20:39:07 -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; 5 Oct 2008 20:39:07 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 56798 invoked from network); 5 Oct 2008 20:39:01 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 5 Oct 2008 20:39:01 -0000 Received: (qmail 2202 invoked by alias); 5 Oct 2008 20:38:53 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25815 Received: (qmail 2185 invoked from network); 5 Oct 2008 20:38:51 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 5 Oct 2008 20:38:51 -0000 Received: from ik-out-1112.google.com (ik-out-1112.google.com [66.249.90.177]) by bifrost.dotsrc.org (Postfix) with ESMTP id 6152180308BD for ; Sun, 5 Oct 2008 22:38:46 +0200 (CEST) Received: by ik-out-1112.google.com with SMTP id c30so1507036ika.5 for ; Sun, 05 Oct 2008 13:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=BIyaxAMirYvl1HZJz8HCTNvjdq16XSP2qreNtDVi/WA=; b=MbLavuAT8qFtIR90vpeZSuNmXr8vm8/KXUew2DF8IafzmWhZ6kz7jK7kllp1VQ2nLm 3X+tKA/cLyg2remp0qadMygKz2rtXV0ohiasF0WMZsaWdLOmJ28QB+2Zraiw0woz3sLZ G5J//hOtxWva8wN9H0e8AEsWPmtPcLa7VpdCw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=pS1iWCeu/5PKNUUH3H+euZNfDClBj4Yl/YYpgQARaOcFT7u0ZzYQNKPJ2wXVolYBmN or+plW9mVBPf9WnR2Sx/Kj78FEViuAnDBNmDEY7+4bsU7tZeD2awoLZCO7n5QDlmv+Xc m/6f1C3FicPkjA2VjK11AQntmWgLCXbW0+IxQ= Received: by 10.210.46.12 with SMTP id t12mr1040734ebt.170.1223239126780; Sun, 05 Oct 2008 13:38:46 -0700 (PDT) Received: by 10.210.19.20 with HTTP; Sun, 5 Oct 2008 13:38:46 -0700 (PDT) Message-ID: <237967ef0810051338r1637e4abld12fbab29d1f1b91@mail.gmail.com> Date: Sun, 5 Oct 2008 22:38:46 +0200 From: "Mikael Magnusson" To: "Bart Schaefer" Subject: Re: [rfc + bad patch] Allow to get the current cursor command from zle, for doing a nicer run-help. Cc: zsh-workers In-Reply-To: <081005120817.ZM15224@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <237967ef0810050640n7c536bafl9255e870f83d15f8@mail.gmail.com> <081005120817.ZM15224@torch.brasslantern.com> X-Virus-Scanned: ClamAV 0.92.1/8376/Sun Oct 5 21:09:44 2008 on bifrost X-Virus-Status: Clean 2008/10/5 Bart Schaefer : > On Oct 5, 3:40pm, Mikael Magnusson wrote: > } > } Let's say you have the command line > } git add -u; git commit - # hmm, was it -m or -M for message? *press alt-h* > } Now, also assume you have the run-help-git stuff set up, but it will still > } show you the manpage for git-add instead of git-commit. > > This points out a more generalized bug in Functions/Misc/run-help as it > currently is implemented. If you have, for example > > zsh% run-help-less() { print $* } > zsh% print this is not less but the next is; less /etc/termcap > > If you now hit ESC-h to invoke run-help, you get: > > but the next is > > and then the command "less /etc/termcap" is *executed*. The "eval" in > Functions/Misc/run-help needs a (q) parameter expansion flag added, at > the very least. > > } Since the run-help widget does a push-line, we can't use $CURSOR to > } find out which is the actual command, this is how i solved it. > > It should be possible to solve this without resorting to hacking the C > source. All you need is a user-defined ZLE widget that runs as a wrapper > around the run-help widget to save the value of CURSOR. E.g.: > > run_help_cursor () { > typeset -g HELPCURSOR=$CURSOR > zle .run-help "$@" > } > zle -N run-help run_help_cursor > > Except that you're using CURSOR in your _runhelp function, so it must > already be a widget? You didn't show a usage example. Yeah it's a widget to use instead of run-help. > It might be nice if the .run-help widget saved the cursor position itself, > or behaved more like a completion widget and passed an array containing > only the command words "around" the cursor, stripping from separators on > either side. *That* would require C hacking. > > In any case I think your function will still do the wrong thing for > something like "git commit git", though that's admittedly not a very > likely scenario. Hm yeah, the only way to really solve it would be if the C code also gave us the index into $BUFFER where the word is, I think? -- Mikael Magnusson