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

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

On Sep 16, 10:47pm, Oliver Kiddle wrote:
} Subject: 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'
} 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.

Aha!  Indeed, this works:

  quote-this-word() { zle select-in-shell-word -w ; zle quote-region }

} For select-a-shell-word including the preceding space is intentional.

That should probably be documented, then.  Currently the doc says the
adjacent blanks are selected for -a-blank-word and -a-word, but does
not mention that for -a-shell-word.  I suppose it could be inferred
from name similarity, but that shouldn't be necessary.

} Looking at execzlefunc, I can't see an alternative way to get the
} actual widget being run. Have I missed anything?

Although it's not ideal to have a built-in widget that requires the
use of the -w flag when calling from a user-defined widget, it's also
probably OK if properly documented.

} Or it needs six small wrapper functions for the actual widgets.

This would be in line with the way similar widgets with a common
core have been implemented in the past.  However:

} Or a ZLE_ flag - actually two to cover
} select-in-word/select-in-blank-word.

I think one flag to force the equivalent of set_bindk = 1 would do?

I don't have a preference here, except:

It occurs to me that using this same sort of flag on the menu-complete
and reverse-menu-complete Thingys might have fixed the problem that
you addressed a different way in workers/38043.

It also occurs to me to wonder whether set_bindk = 0 *ever* makes sense
for builtin widgets.  Can somebody give me an example of a builtin that
would care about the widget name of its user-defined caller?

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