From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28248 invoked from network); 10 Dec 2006 17:56:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) 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.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Dec 2006 17:56:43 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 38920 invoked from network); 10 Dec 2006 17:56:36 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Dec 2006 17:56:36 -0000 Received: (qmail 14832 invoked by alias); 10 Dec 2006 17:56:28 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11075 Received: (qmail 14822 invoked from network); 10 Dec 2006 17:56:28 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 Dec 2006 17:56:28 -0000 Received: (qmail 37851 invoked from network); 10 Dec 2006 17:56:27 -0000 Received: from mtaout02-winn.ispmail.ntl.com (81.103.221.48) by a.mx.sunsite.dk with SMTP; 10 Dec 2006 17:56:24 -0000 Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com with ESMTP id <20061210175708.QQUJ27023.mtaout02-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com> for ; Sun, 10 Dec 2006 17:57:08 +0000 Received: from pwslaptop.csr.com ([81.107.41.185]) by aamtaout03-winn.ispmail.ntl.com with ESMTP id <20061210175759.XNNZ26699.aamtaout03-winn.ispmail.ntl.com@pwslaptop.csr.com> for ; Sun, 10 Dec 2006 17:57:59 +0000 Received: from pwslaptop.csr.com (pwslaptop.csr.com [127.0.0.1]) by pwslaptop.csr.com (8.13.8/8.13.7) with ESMTP id kBAHuDLN003968 for ; Sun, 10 Dec 2006 17:56:16 GMT Message-Id: <200612101756.kBAHuDLN003968@pwslaptop.csr.com> From: Peter Stephenson To: zsh-users@sunsite.dk Subject: Re: zsh widget to resolve symlinks In-Reply-To: Message from Mikel Ward of "Sun, 10 Dec 2006 11:33:23 +1100." <457B55D3.9030003@mikelward.com> Date: Sun, 10 Dec 2006 17:56:13 +0000 Mikel Ward wrote: > It turns out copy-region-as-kill doesn't use killring but rather > CUTBUFFER. This is a little confusing! Right, CUTBUFFER is the most recently killed, killring holds the entries before that. This is something of a historical curiosity. The manual needs to be more explicit about the link between the two. > I'm also surprised that CUTBUFFER persists invocations of zle, yet it > isn't set in the top-level interactive shell. This reflects how zle works. If you use "yank" when editing, it will insert the last string cut or copied even if it wasn't in the current command line, and even though zle wasn't active in the intervening period. In recent zsh, you can hook in code to be run at the start of the line by defining zle-line-init as a widget; however, you probably don't want to reset CUTBUFFER because of its unexpected effect on yanking. You can avoid using CUTBUFFER at all with something like (note I haven't actually tried this but it shouldn't be too far out): zle backward-word integer pos1=$((CURSOR+1)) zle forward-word # this will grab any whitespace at the end, too... integer pos2=$((CURSOR)) local word="$BUFFER[$pos1,$pos2]" and to replace the word, leaving the cursor after it, LBUFFER="${LBUFFER[1,$pos-1]}$realpath" If I were writing the widget, I'd probably use raw access to $BUFFER etc. to find the start and end of the word (hence avoiding the use of $CURSOR apart from finding out where to start), and ${(z)...} trickery to access shell words as done in match-words-by-style (which might give you some other ideas). It occurred to me recently that a generic widget to split the line into shell words and whitespace would be extremely useful, making this sort of task much easier. However, I haven't got around to it yet. -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/