From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10306 invoked from network); 12 Oct 2003 18:29:43 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 12 Oct 2003 18:29:43 -0000 Received: (qmail 8642 invoked by alias); 12 Oct 2003 18:29:23 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6694 Received: (qmail 8599 invoked from network); 12 Oct 2003 18:29:22 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 12 Oct 2003 18:29:22 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [195.92.195.173] by sunsite.dk (MessageWall 1.0.8) with SMTP; 12 Oct 2003 18:29:22 -0000 Received: from modem-170.heniochus.dialup.pol.co.uk ([62.137.26.170] helo=pwstephenson.fsnet.co.uk) by cmailg3.svr.pol.co.uk with esmtp (Exim 4.14) id 1A8ky1-0006hG-AN for zsh-users@sunsite.dk; Sun, 12 Oct 2003 19:29:21 +0100 Received: by pwstephenson.fsnet.co.uk (Postfix, from userid 501) id 795968542; Sun, 12 Oct 2003 14:31:11 -0400 (EDT) Received: from pwstephenson.fsnet.co.uk (localhost [127.0.0.1]) by pwstephenson.fsnet.co.uk (Postfix) with ESMTP id 6BBC68511 for ; Sun, 12 Oct 2003 19:31:11 +0100 (BST) To: Zsh Users Subject: Re: delete-word does not delete the entire word... In-reply-to: "DervishD"'s message of "Sun, 12 Oct 2003 19:05:56 +0200." <20031012170556.GG23106@DervishD> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <11504.1065983327.0@pwstephenson.fsnet.co.uk> Date: Sun, 12 Oct 2003 19:31:10 +0100 From: Peter Stephenson Message-Id: <20031012183111.795968542@pwstephenson.fsnet.co.uk> ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11504.1065983327.1@pwstephenson.fsnet.co.uk> DervishD wrote: > > Incidentally, a wrapper function to delete the word under the cursor > > is a little tricky to write. > > Writing zle widgets is tricky. If you have 4.1, much of the work is done for you; see the description of match-words-by-style in the zshcontrib manual. Here's a function using it (which consequently won't work in 4.0) which can go into the distribution when the glitches have been ironed out. A side effect is that you can decide using styles what constitutes a word, as described in the same section of the manual. ------- =_aaaaaaaaaa0 Content-Type: text/plain; name="delete-whole-word"; charset="us-ascii" Content-ID: <11504.1065983327.2@pwstephenson.fsnet.co.uk> Content-Description: delete-whole-word emulate -L zsh setopt extendedglob local curcontext=:zle:delete-whole-word local -a matched_words # Start and end of range of characters to remove. integer pos1 pos2 match-words-by-style if [[ -n "${matched_words[3]}" ]]; then # There's whitespace before the cursor, so the word we are deleting # starts at the cursor position. pos1=$CURSOR else # No whitespace before us, so delete any wordcharacters there. pos1="${#matched_words[1]}" fi if [[ -n "${matched_words[4]}" ]]; then # There's whitespace at the cursor position, so only delete # up to the cursor position. pos2=$CURSOR else # No whitespace at the cursor position, so delete the # current character and any following wordcharacters. (( pos2 = CURSOR + ${#matched_words[5]} + 1 )) fi # Move the cursor and delete the block in one go for the # purpose of yanking. (( CURSOR = pos1 )) BUFFER="${BUFFER[1,pos1]}${BUFFER[pos2,-1]}" ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11504.1065983327.3@pwstephenson.fsnet.co.uk> -- Peter Stephenson Work: pws@csr.com Web: http://www.pwstephenson.fsnet.co.uk ------- =_aaaaaaaaaa0--