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

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



On 7/9/22 05:10, Bart Schaefer wrote:
On Wed, Jul 6, 2022 at 11:13 PM Vincent Bernat <bernat@xxxxxxxx> wrote:

zle -N self-insert url-quote-magic
zle -N bracketed-paste bracketed-paste-magic

It works fine, but after some time, [url-quote-magic] stops working.
Bracketed paste never stops working.

First thing to check is whether any of your widgets have become
re-bound somehow.
   zle -l -L bracketed-paste self-insert
should return
   zle -N bracketed-paste bracketed-paste-magic
   zle -N self-insert url-quote-magic

I am using autosuggest, so I get:

 07:22 ❱ zle -l -L bracketed-paste self-insert
zle -N bracketed-paste _zsh_autosuggest_bound_1_bracketed-paste
zle -N self-insert _zsh_autosuggest_bound_1_self-insert

If that hasn't changed, does url-quote-magic work when just typing in
a URL without pasting?

It does not work either.

If so, next I'd try
   exec 2>/tmp/zshuqmtrace
   functions -t url-quote-magic
and then paste a URL.  See if you get anything in that trace file.

 url-quote-magic ❱ setopt localoptions noksharrays extendedglob
 url-quote-magic ❱ local qkey='\?'
 url-quote-magic ❱ local -a reply match mbegin mend
 url-quote-magic ❱ [[ '?' != \\\? ]]
 url-quote-magic ❱ local lbuf='http://kjfkjkgjf/fgkfjgkf\?'
url-quote-magic ❱ [[ 'http://kjfkjkgjf/fgkfjgkf?' == http://kjfkjkgjf/fgkfjgkf\? ]]
 url-quote-magic ❱ local -a words
 url-quote-magic ❱ words=( 'http://kjfkjkgjf/fgkfjgkf?' )
url-quote-magic ❱ local urlseps urlmetas urlglobbers localschema otherschema
 url-quote-magic ❱ [[ 'http://kjfkjkgjf/fgkfjgkf?' == (#b)([^:]##):* ]]
 url-quote-magic ❱ zstyle -s :url-quote-magic url-globbers urlglobbers '|'
 url-quote-magic ❱ zmodload -i zsh/parameter
 url-quote-magic ❱ reply=( noglob '=' globurl )
 url-quote-magic ❱ zstyle -s :urlglobber url-other-schema otherschema '|'
 url-quote-magic ❱ [[ 'http://kjfkjkgjf/fgkfjgkf?' == noglob|=|globurl ]]
 url-quote-magic ❱ localschema=' '
 url-quote-magic ❱ case http://kjfkjkgjf/fgkfjgkf? (*['"]*)
 url-quote-magic ❱ case http://kjfkjkgjf/fgkfjgkf? ((\ ):/(|/localhost)/*)
 url-quote-magic ❱ case http://kjfkjkgjf/fgkfjgkf? ((http|https|ftp):*)
 url-quote-magic ❱ [[ '' == *\?* ]]
 url-quote-magic ❱ zle .self-insert

For some reason, typing manually an URL always failed, but not copy/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?




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