zsh-users
 help / color / mirror / code / Atom feed
* Is there a delete-to-previous-slash key?
@ 2005-11-04 17:27 Ian Langworth
  2005-11-04 18:00 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Langworth @ 2005-11-04 17:27 UTC (permalink / raw)
  To: zsh-users

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?

--
Ian Langworth


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is there a delete-to-previous-slash key?
  2005-11-04 17:27 Is there a delete-to-previous-slash key? Ian Langworth
@ 2005-11-04 18:00 ` Peter Stephenson
  2005-11-04 18:11   ` Ian Langworth
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2005-11-04 18:00 UTC (permalink / raw)
  To: Ian Langworth; +Cc: zsh-users

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is there a delete-to-previous-slash key?
  2005-11-04 18:00 ` Peter Stephenson
@ 2005-11-04 18:11   ` Ian Langworth
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Langworth @ 2005-11-04 18:11 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users

Thank you, Peter. I believe that your simplest example will suit me just fine.

On 11/4/05, Peter Stephenson <pws@csr.com> wrote:
> 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

--
Ian Langworth


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-11-04 18:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-04 17:27 Is there a delete-to-previous-slash key? Ian Langworth
2005-11-04 18:00 ` Peter Stephenson
2005-11-04 18:11   ` Ian Langworth

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).