Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: delete-word does not delete the entire word...

    Hi Bart :)

 * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> } > What you're missing is that the documentation nearly always is
> } > expressed in terms of character positions, not semantic buffer
> } > contents.
> } [Zsh doc] doesn't say explicitly (I think, I haven't read the entire
> } documentation) that a word is not a semantic entity but just the
> } buffer contents from the cursor position to the next word boundary.
> You're right, it doesn't. Most of the functions emulate behavior of
> emacs or vi, so the doc assumes the reader is familiar with one of
> those.

    I assume that, at the moment of writing, 99% of UNIX users used
vi or emacs (or both...), so this behaviour was the expected
behaviour. In fact, since I haven't used word commands, this
behaviour is good for me, I can live with it, without writing
wrappers, and I should live with it, since my editor does exactly the
same, and it's very comfortable to have the same keybindings in the
shell and the editor (at least for me, I spend most of my time coding
or doing things in the shell). The problem, IMHO, is not the
behaviour, is the documentation, that should be more precise.

> That was OK when those parts of the docs were written several years
> ago, but is not the best thing now.

    And updating the documentation is several times harder than
updating the code, I have that problem when coding ;)) Anyway, zsh
docs are pretty good on the average. I like them ;)

> Incidentally, a wrapper function to delete the word under the cursor
> is a little tricky to write.

    Writing zle widgets is tricky. I've written a couple of them
lately, just for learning, and it has been a bit tricky. I've written
wrappers for up-line-or-search and down-line-or-search which searchs
$LBUFFER, not the first word. Like up/down-line-or-beginning-search,
that comes with zsh 4.1.x, but without bells and whistles: no NUMERIC
support, no zstyles, and an easy handling of PREBUFFER.

    I have a problem with it, not easy to solve since it has to do
with carrying information from the current execution of the widget to
the next execution of the widget, etc...

> You either need to examine $LBUFFER[-1] to
> determine if it is [not] a word boundary

    But that means dealing with WORDCHARS. I prefer your suggestion
of doing a double movement and testing where the cursor is
afterwards. BTW, thanks ;)))

    Raúl Núñez de Arenas Coronado

Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/

Messages sorted by: Reverse Date, Date, Thread, Author