zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.dk
Subject: Re: Readline-like ^W behavior
Date: Thu, 03 Jul 2003 14:21:28 +0100	[thread overview]
Message-ID: <2170.1057238488@csr.com> (raw)
In-Reply-To: "Haakon Riiser"'s message of "Thu, 03 Jul 2003 14:50:04 +0200." <20030703125004.GA1792@s.chello.no>

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 <pws@csr.com>                  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.
**********************************************************************


  reply	other threads:[~2003-07-03 13:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-03 12:50 Haakon Riiser
2003-07-03 13:21 ` Peter Stephenson [this message]
2003-07-03 14:40   ` Haakon Riiser
2003-07-03 14:48     ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2170.1057238488@csr.com \
    --to=pws@csr.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).