From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5899 invoked from network); 22 Apr 2006 21:39:07 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.1 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 22 Apr 2006 21:39:07 -0000 Received: (qmail 92120 invoked from network); 22 Apr 2006 21:38:59 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 22 Apr 2006 21:38:59 -0000 Received: (qmail 23631 invoked by alias); 22 Apr 2006 21:38:52 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10167 Received: (qmail 23621 invoked from network); 22 Apr 2006 21:38:51 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 22 Apr 2006 21:38:51 -0000 Received: (qmail 90985 invoked from network); 22 Apr 2006 21:38:51 -0000 Received: from wproxy.gmail.com (64.233.184.227) by a.mx.sunsite.dk with SMTP; 22 Apr 2006 21:38:50 -0000 Received: by wproxy.gmail.com with SMTP id 69so503182wra for ; Sat, 22 Apr 2006 14:38:48 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=K3s95qHXX1+uIQmkGPN298jskg9kIcbfgqTtGiExUIj5uhMSHJBXas/ekvHb1O7yAbGbsJ5nlJcfcrRgFhLvyzS9RNoqp02TqqMg/tThch9cK3JUHC9z3kB1rHRCvTtrTXuLmVbtA6NXitvRVX3xUP0Q7KZvGX6jcVnL/nWgjtQ= Received: by 10.64.151.2 with SMTP id y2mr1955256qbd; Sat, 22 Apr 2006 14:38:48 -0700 (PDT) Received: by 10.64.142.16 with HTTP; Sat, 22 Apr 2006 14:38:48 -0700 (PDT) Message-ID: Date: Sat, 22 Apr 2006 23:38:48 +0200 From: "Nikolai Weibull" Sender: nikolai.weibull@gmail.com To: "Bart Schaefer" Subject: Re: Problem with motion commands defined using match-word-by-style used with vi-delete Cc: "Zsh Users" In-Reply-To: <060422113544.ZM9246@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <060421220035.ZM7625@torch.brasslantern.com> <060422113544.ZM9246@torch.brasslantern.com> On 4/22/06, Bart Schaefer wrote: > On Apr 22, 1:04pm, Nikolai Weibull wrote: > } > } Until then I'm going to use my own vi-delete > } > > } > Creating a vi-delete-match function seems like the next best thing. > } > } That's what I meant (I think) :-). > > Yes, I was agreeing with you. Ah, :-). > On further checking, however, the value of $WIDGETFUNC within the widget > called by vi-delete appears to be ".internal" which means that although > it's possible to determine *when* one of these functions has been called > from vi-delete, it's not possible to determine under which name it was > called. So a custom vi-delete replacement appears to be required, and > perhaps we should consider adding one to the distribution. The same is > going to be true of vi-change and any other widget that combines with a > motion widget in this way. I've begun writing one, but it won't work. What I do is roughly the follow= ing: vi-delete-match () { integer begin end local motion integer count=3D0 read -k 1 motion while [[ $motion =3D=3D [[:digit:]] ]]; do (( count =3D count * 10 + motion )) read -k 1 motion done (( count =3D (count =3D=3D 0) ? 1 : count )) case $motion in (*) local motion_command=3D"${${:-$(bindkey -a $motion)}##* }" if [[ -n $motion_command ]]; then (( begin =3D CURSOR )) zle $motion_command -n $count (( end =3D CURSOR + 1 )) (( CURSOR =3D begin )) BUFFER=3D"${BUFFER[1,begin]}${BUFFER[end,-1]}" fi ;; esac } zle -N vi-delete-match bindkey -a "d" vi-delete-match The convoluted handling of $motion is for future expansion with what Vim refers to as text objects, i.e., "aw" for "a word", which selects the current word you're in. This, however, doesn't work. $WIDGET is set to vi-delete-match, which is the top-level widget, not the widget run by the zle command in zle $motion_command -n $count I guess this makes sense in almost all cases, but not here. $WIDGETFUNC is set to vi-delete-match, which is correct, given the value of $WIDGET. I'm positive that there's a way to do this, but I can't see it, so any help is welcome. I'm sure it'll break all kinds of stuff, but one solution would be to have getvirange() set bindk to k2 once it has been read and checked. Also, it would be great if we had a switch for bindkey that made it print the widgets name, nothing else. nikolai