From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7124 invoked from network); 3 Jul 2003 13:22:00 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 3 Jul 2003 13:22:00 -0000 Received: (qmail 3532 invoked by alias); 3 Jul 2003 13:21:37 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6367 Received: (qmail 3520 invoked from network); 3 Jul 2003 13:21:37 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 3 Jul 2003 13:21:37 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [62.189.183.235] by sunsite.dk (MessageWall 1.0.8) with SMTP; 3 Jul 2003 13:21:37 -0000 Received: from EXCHANGE02.csr.com (unverified) by MAILSWEEPER01.cambridgesiliconradio.com (Content Technologies SMTPRS 4.3.10) with ESMTP id for ; Wed, 2 Jul 2003 14:21:04 +0100 Received: from csr.com ([192.168.144.127]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.5329); Thu, 3 Jul 2003 14:20:46 +0100 To: zsh-users@sunsite.dk Subject: Re: Readline-like ^W behavior In-reply-to: "Haakon Riiser"'s message of "Thu, 03 Jul 2003 14:50:04 +0200." <20030703125004.GA1792@s.chello.no> Date: Thu, 03 Jul 2003 14:21:28 +0100 Message-ID: <2170.1057238488@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 03 Jul 2003 13:20:46.0463 (UTC) FILETIME=[E9AFF0F0:01C34165] Haakon Riiser wrote: > Is it possible to make ^W delete the word to the left of the cursor > with the same word-boundary rules as in readline/bash? Here's what > I'm looking for: > > bash$ ls foo-bar | wc^W > => bash$ ls foo-bar | ^W > => bash$ ls foo-bar ^W > => bash$ ls ^W > => bash$ So you're assuming unix-word-rubout in bash? (The usual bash/readline rules for words are to use alphanumerics only, but the default ^w binding does what you show.) As you're using zsh 4.1.1, you have an easy solution: redefine backward-kill-word to the Swiss-army-knife function variant with `-match' appended, and set the style to use whitespace word boundaries: bindkey '^w' backward-kill-word # as before autoload -U backward-kill-word-match zle -N backward-kill-word backward-kill-word-match zstyle ':zle:backward-kill-word' word-style whitespace See the zshcontrib manual for more on these functions, implemented by match-words-by-style (and not match-word-by-style, hence the following patch). If you want all functions to use this behaviour, you can use select-word-style (which you can bind to a keystroke for instant control) instead of setting the style yourself. Index: Doc/Zsh/contrib.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v retrieving revision 1.26 diff -u -r1.26 contrib.yo --- Doc/Zsh/contrib.yo 28 Mar 2003 11:34:07 -0000 1.26 +++ Doc/Zsh/contrib.yo 3 Jul 2003 13:16:50 -0000 @@ -381,12 +381,12 @@ tindex(up-case-word-match) tindex(down-case-word-match) tindex(select-word-style) -tindex(match-word-by-style) +tindex(match-words-by-style) xitem(tt(forward-word-match), tt(backward-word-match)) xitem(tt(kill-word-match), tt(backward-kill-word-match)) xitem(tt(transpose-words-match), tt(capitalize-word-match)) xitem(tt(up-case-word-match), tt(down-case-word-match)) -item(tt(select-word-style), tt(match-word-by-style))( +item(tt(select-word-style), tt(match-words-by-style))( The eight `tt(-match)' functions are drop-in replacements for the builtin widgets without the suffix. By default they behave in a similar way. However, by the use of styles and the function tt(select-word-style), @@ -484,10 +484,10 @@ the resulting expression is tt(bar)var(X)tt(foo). The word matching and all the handling of tt(zstyle) settings is actually -implemented by the function tt(match-word-by-style). This can be used to +implemented by the function tt(match-words-by-style). This can be used to create new user-defined widgets. The calling function should set the local parameter tt(curcontext) to tt(:zle:)var(widget), create the local -parameter tt(matched_words) and call tt(match-word-by-style) with no +parameter tt(matched_words) and call tt(match-words-by-style) with no arguments. On return, tt(matched_words) will be set to an array with the elements: (1) the start of the line (2) the word before the cursor (3) any non-word characters between that word and the cursor (4) any non-word -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. **********************************************************************