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

Re: Magic URL quoting and bracketed paste gets "disabled" randomly



On 2022-07-10 19:44, Bart Schaefer wrote:

I am using autosuggest, so I get:

zle -N bracketed-paste _zsh_autosuggest_bound_1_bracketed-paste

I can't think of any reason autosuggest would need to rebind that widget.

I am adding it to ZSH_AUTOSUGGEST_CLEAR_WIDGETS. I suppose I didn't want the last suggestion to be kept after pasting.

It seems the condition if [[ "$words[-1]" == (#b)([^:]##):* ]] does not
match. I am using "disable -p #" which seems to be the cause. Using
"emulate -L zsh" at the top of the function instead of "setopt
localoptions" fixes the issue. I though functions should use "emulate -L
zsh" when using these options, but in Zsh codebase, "setopt
localoptions" seems used often. Should any of this considered as a bug?

"emulate -L" potentially resets a lot of things.  The decision for
each function has to be whether the scope requires all those elements
to be reset, or whether to make minimal changes so as to behave as
much as possible like the rest of the user's environment >
In the case of url-quote-magic I can't presently think of any reason
not to use "emulate -L".

Meantime, I am just wrapping it:

autoload -Uz url-quote-magic
function _vbe-url-quote-magic() {
  emulate -L zsh
  url-quote-magic "$@"
}
zle -N self-insert _vbe-url-quote-magic

That said, I also can't think of any
contributed function that intentionally defends itself against pattern
disables.

It's a wonder I am not running into such issues more often. I'll just disable extendedglob as I am only interested into the negative pattern and I don't use it that often.




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