zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: Ian Langworth <ian.langworth@gmail.com>
Cc: zsh-users@sunsite.dk
Subject: Re: Is there a delete-to-previous-slash key?
Date: Fri, 4 Nov 2005 18:00:24 +0000	[thread overview]
Message-ID: <20051104180024.5db02beb.pws@csr.com> (raw)
In-Reply-To: <b6c719b90511040927q5d0bbf44h2ad06a3925b7a45c@mail.gmail.com>

Ian Langworth <ian.langworth@gmail.com> wrote:
> I'd like to have a key that deletes leftwards from the cursor to the
> previous occurrence of '/'. Does anyone have a snippet that does this
> sort of thing, or shall I dig deeper into zle?

The easiest way is temporarily not to allow / to be part of a word and
use backward-delete-word:

backward-delete-to-slash () {
  local WORDCHARS=${WORDCHARS//\//}
  zle .backward-delete-word
}
zle -N backward-delete-to-slash

but if you really want to delete anything else in the way you can
use something like:

backward-delete-to-slash() {
  integer pos=$CURSOR
  while (( pos > 1 )); do
    if [[ $LBUFFER[--pos] = / ]]; then
      LBUFFER=${LBUFFER[1,pos]}
      return 0
    fi
  done
  return 1
}
zle -N backward-delete-to-slash

That doesn't save it on the kill ring; I had hoped there would be some
shorthand for "delete this and put it on the kill ring" but the only ways I
can see are either to set the mark, or do it longhand with CUTBUFFER and
killring, and I couldn't be bothered.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com


  reply	other threads:[~2005-11-04 18:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-04 17:27 Ian Langworth
2005-11-04 18:00 ` Peter Stephenson [this message]
2005-11-04 18:11   ` Ian Langworth

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=20051104180024.5db02beb.pws@csr.com \
    --to=pws@csr.com \
    --cc=ian.langworth@gmail.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).