zsh-users
 help / color / mirror / code / Atom feed
From: Vincent Bernat <bernat@luffy.cx>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Magic URL quoting and bracketed paste gets "disabled" randomly
Date: Sat, 9 Jul 2022 07:40:19 +0200	[thread overview]
Message-ID: <fee50c49-721d-fdb0-c3dc-8ff95514f334@luffy.cx> (raw)
In-Reply-To: <CAH+w=7YcH=rBzOF42a3vmZJBfD1PU=ToJuCiNbcSL5XWg0kOyA@mail.gmail.com>

On 7/9/22 05:10, Bart Schaefer wrote:
> On Wed, Jul 6, 2022 at 11:13 PM Vincent Bernat <bernat@luffy.cx> 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?


  reply	other threads:[~2022-07-09  5:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07  6:13 Vincent Bernat
2022-07-09  3:10 ` Bart Schaefer
2022-07-09  5:40   ` Vincent Bernat [this message]
2022-07-10 17:44     ` Bart Schaefer
2022-07-10 19:12       ` Vincent Bernat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fee50c49-721d-fdb0-c3dc-8ff95514f334@luffy.cx \
    --to=bernat@luffy.cx \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).