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

Re: Off-by-one with select-*-shell-word text object?



Bart wrote:
> Noticed during recent zsh-users thread:
>
> torch% quote-this-word() { zle select-in-shell-word; zle quote-region }
> torch% zle -N quote-this-word
> torch% bindkey "''" quote-this-word
> torch% echo foo''
> torch% echo' foo'
>
> Note the left-quote has now included the space preceding the word.  I at
> first suspected another vi-mode vs. emacs-mode difference, but:
>
> torch% bindkey -v "''" quote-this-word

You'd need to do vicmd bindings to identify a vi-mode vs. emacs-mode
difference: bindkey -a. However, it is neither that nor an off-by-one
error.

The problem is that both select-in-shell-word and select-a-shell-word
are handled by a single function that tests the value of bindk to
see which widget it is running. bindk apparently points to the
quote-this-word shell widget so that isn't doing what was intended.
In this case you're getting select-a-shell-word behaviour as a result.
For select-a-shell-word including the preceding space is intentional.

Looking at execzlefunc, I can't see an alternative way to get the
actual widget being run. Have I missed anything? I could add another
global variable for that. Or a ZLE_ flag - actually two to cover
select-in-word/select-in-blank-word. Or it needs six small wrapper
functions for the actual widgets. Have you got any preference in
the choice between those or alternative ideas?

Oliver



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