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

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



On Oct 12, 10:57am, DervishD wrote:
}
}  * 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.  It also doesn't clearly explain what it means to "kill" vs.
"delete" a part of the buffer.  That was OK when those parts of the
docs were written several years ago, but is not the best thing now.

Incidentally, a wrapper function to delete the word under the cursor
is a little tricky to write.  You can't just do

	zle backward-word
	zle delete-word

because if the cursor is on the very first letter this is equivalent
to backward-delete-word.  You either need to examine $LBUFFER[-1] to
determine if it is [not] a word boundary, or do something like

	local cursor=$CURSOR
	zle backward-word
	zle forward-word
	if ((cursor >= CURSOR))
	then
	    zle delete-word
	else
	    zle backward-delete-word
	fi



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