From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Shane Mulligan Newsgroups: gmane.emacs.bugs Subject: bug#48500: 28.0.50; url-retrieve-synchronously exits abnormally due to pending keyboard input from terminal Date: Wed, 19 May 2021 23:46:04 +1200 Message-ID: References: <87pmxo4kiu.wl-mullikine@gmail.com> <8335ukrsj3.fsf@gnu.org> <83sg2kq8yc.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000cea50405c2ad5fcc" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27390"; mail-complaints-to="usenet@ciao.gmane.io" To: 48500@debbugs.gnu.org, Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 19 13:47:16 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ljKfT-0006z0-OA for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 May 2021 13:47:15 +0200 Original-Received: from localhost ([::1]:45274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljKfS-0004b5-Rc for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 May 2021 07:47:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljKfG-0004WQ-4j for bug-gnu-emacs@gnu.org; Wed, 19 May 2021 07:47:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46702) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljKfF-0003qE-O7 for bug-gnu-emacs@gnu.org; Wed, 19 May 2021 07:47:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ljKfF-0004c9-Kt for bug-gnu-emacs@gnu.org; Wed, 19 May 2021 07:47:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Shane Mulligan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 May 2021 11:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48500 X-GNU-PR-Package: emacs Original-Received: via spool by 48500-submit@debbugs.gnu.org id=B48500.162142478517681 (code B ref 48500); Wed, 19 May 2021 11:47:01 +0000 Original-Received: (at 48500) by debbugs.gnu.org; 19 May 2021 11:46:25 +0000 Original-Received: from localhost ([127.0.0.1]:58248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljKee-0004b6-9K for submit@debbugs.gnu.org; Wed, 19 May 2021 07:46:24 -0400 Original-Received: from mail-yb1-f169.google.com ([209.85.219.169]:39675) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ljKeb-0004ar-Qs for 48500@debbugs.gnu.org; Wed, 19 May 2021 07:46:22 -0400 Original-Received: by mail-yb1-f169.google.com with SMTP id f9so17669620ybo.6 for <48500@debbugs.gnu.org>; Wed, 19 May 2021 04:46:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=3vV8kSRcxt1MQ/UruLhYYeK4Wi3AsyXFaEvJde/Lw80=; b=dZcvTZwyBCWcajQM3GNCA7nZn5pAXHm9OYKgisNU573aqSJkaP3qh8iLLoI7KNuPM9 RihkpaksNWKCxhIV3kLkEh+KjZMMmmG6RSMCNpBI7SF5AIM7JdIMdFJyXMbRAeXdbdFV Arzc2qkplkxrv463Q89KqTARlzBYJIYvEYGLPVWxA25nz6LoL0HvWQi2+pSpDpi5ZpvC yqXPYnKL+ykAYe6lbAnVIZ6c9crNjuVRMzq8oO/kvjGQogXB3YlW91nQbkwL3ZhhTLhS +qgT2MmeiESAa6e+5pSSGaJWgfjAU4MZn2WN2/YAKaetW1jlosKEC4nLCXLh2kDTA9IB bWvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=3vV8kSRcxt1MQ/UruLhYYeK4Wi3AsyXFaEvJde/Lw80=; b=d1uF5CdsTKabl6cFwS1IhbfDi3BbtRuLANaSaESC2DTE02gDk2TOfmlgUNmSqsxGj0 Jmi1kRylY2DpzQ57HRWoLdTjPxFXN3ob1FCdvbcDCDhNIYnhTj4Vy/PoF+bI5kqDuoWW VhcUdxIJyLoHxNuiBN1AGalv4waaoAWR3QFcvoC+oqIzKZUQ7EsTKj95v+smrQHfM3vZ FZTYvBizC6DNWvwKeV4f1b4GsqD4KREK8CyehHImRhifc6ftPstXdXX68CdejOZSkQXL /nmjrnpZxKm550Qv+5BHDTT20F83VJGLtQT4TiE8Lx2JFmloanhMukRMhlfStPbBdNXW r4yg== X-Gm-Message-State: AOAM531WmXVFa5NTN7ks73tkyaLoXPKueUgkrQBNVNa3Es8Kn6yVss5k dtIRACoQ54rNlevp8NKacJXFjPRCaHJHgh4eMdpXdkEugmRA X-Google-Smtp-Source: ABdhPJztXDwmjn5DN71r+IEQn9Ln37lSY3XjWiMESMcjPddVBYKUo2x2GQoD2UAqxNH135nMqbrHZbf+RbGcrtCcPi0= X-Received: by 2002:a25:585:: with SMTP id 127mr13567205ybf.299.1621424776060; Wed, 19 May 2021 04:46:16 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:206873 Archived-At: --000000000000cea50405c2ad5fcc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I have done a write-up on this issue to clarify everything. https://mullikine.github.io/posts/fixing-googling-tooling-in-emacs/ Shane Mulligan How to contact me: =F0=9F=87=A6=F0=9F=87=BA 00 61 421 641 250 =F0=9F=87=B3=F0=9F=87=BF 00 64 21 1462 759 <+64-21-1462-759> mullikine@gmail.com On Wed, May 19, 2021 at 6:49 PM Shane Mulligan wrote: > Hi Eli, > > I tagged you back in this conversation because I may have fixed the issue > :). > > Shane Mulligan > > How to contact me: > =F0=9F=87=A6=F0=9F=87=BA 00 61 421 641 250 > =F0=9F=87=B3=F0=9F=87=BF 00 64 21 1462 759 <+64-21-1462-759> > mullikine@gmail.com > > > On Wed, May 19, 2021 at 6:48 PM Shane Mulligan > wrote: > >> I may have resolved this issue with the following patch to >> `url-retrieve-synchronously`. >> What this achieves is to trigger a `quit` in a controlled environment >> rather than allowing it to occur when `accept-process-output` is run. >> It's not always wanted to trigger a quit when `(input-pending-p)` is `t`= . >> But I noticed from placing `while-no-input` around `accept-process-outpu= t` >> to avoid the `quit` that `url-retrieve-synchronously` would then hang bu= t >> with the controlled `quit` happening beforehand, `accept-process-output`= no >> longer needs `while-no-input` around it. The end result is buttery smoot= h >> helm with no accidental `quit` from typing too fast. I think this may ha= ve >> resulted in GUI helm faster too. >> >> ``` >> 29c29,30 >> < (let ((proc (get-buffer-process asynch-buffer))) >> --- >> > (let ((proc (get-buffer-process asynch-buffer)) >> > (counter 0)) >> 71a73,78 >> > (with-local-quit >> > (if (input-pending-p) >> > (progn >> > (setq counter (1+ counter)) >> > (if (> counter 20) >> > (keyboard-quit))))) >> ``` >> Shane Mulligan >> >> How to contact me: >> =F0=9F=87=A6=F0=9F=87=BA 00 61 421 641 250 >> =F0=9F=87=B3=F0=9F=87=BF 00 64 21 1462 759 <+64-21-1462-759> >> mullikine@gmail.com >> >> >> On Wed, May 19, 2021 at 11:32 AM Shane Mulligan >> wrote: >> >>> My apologies. It was literally 5am when I wrote that. I think I have >>> misunderstood `C-g` being generated with `quit-flag`. The bad behaviour= is >>> very clearly still happening. I will try to clarify this problem furthe= r by >>> experimenting with it. I need to figure out why `while-no-input` suppre= sses >>> the `quit` but merely setting `quit-flag` does not. Something indirect = may >>> be happening. >>> >>> Thank you all, >>> Shane Mulligan >>> >>> How to contact me: >>> =F0=9F=87=A6=F0=9F=87=BA 00 61 421 641 250 >>> =F0=9F=87=B3=F0=9F=87=BF 00 64 21 1462 759 <+64-21-1462-759> >>> mullikine@gmail.com >>> >>> >>> On Wed, May 19, 2021 at 4:54 AM Eli Zaretskii wrote: >>> >>>> > From: Shane Mulligan >>>> > Date: Wed, 19 May 2021 04:32:16 +1200 >>>> > >>>> > Thanks for looking into this so quickly. First some background on th= e >>>> problem. I managed to work through >>>> > this issue (https://github.com/emacs-helm/helm/issues/2417) with the >>>> `emacs-helm` maintainer and we >>>> > found what appears to be that the call to `accept-process-output` >>>> inside of `url-retrieve-synchronously` will >>>> > generate a `C-g` when there is pending input of any char. As far as = I >>>> can tell this is an issue only with >>>> > terminal emacs. As I understand it, `inhibit-quit`, as used in >>>> `accept-process-output` allows a `C-g` to be >>>> > propagated outwards and handled and from what I can see by the >>>> comments surrounding, >>>> > >>>> > ``` >>>> > ;; accept-process-output returned nil, maybe because >>>> the process >>>> > ;; exited (and may have been replaced with another). >>>> If we got >>>> > ;; a quit, just stop. >>>> > ``` >>>> > >>>> > the `C-g` in this case is expected. >>>> > >>>> > But I wonder if `C-g` was meant to be generated if the user was >>>> simply mashing keys on the keyboard. In >>>> > this case, the `C-g` emanating from `accept-process-output` was >>>> bubbling up into `helm` and `helm` was >>>> > treating it like an error. >>>> > >>>> > Here, you can see a quit being generated from the visual cue in the >>>> minibuffer. >>>> > https://asciinema.org/a/nAIB8Z1lGgZJqJg9Mt8YiNEM9 >>>> > >>>> > Here, I have added `while-no-input` and I no longer get the `quit`. >>>> > https://asciinema.org/a/x9ELZhwDP1IUtmOz0M1cly42H >>>> > >>>> > However, as I test the addition of `while-no-input` with >>>> `helm-google-suggest` (as above), though Quit is no >>>> > longer being generated from mashing keys, the key input which would >>>> have generated the `quit` is not >>>> > immediately shown in `helm`. Instead, it only appears on the next ke= y >>>> press. So my implementation may not >>>> > be perfect or complete. >>>> > >>>> > Finding the solution would make the minibuffer far less interrupted >>>> while typing when >>>> > `url-retrieve-synchronously` is used in the background. >>>> > >>>> > Thank you. >>>> > >>>> > Shane Mulligan >>>> >>>> Please in the future send your responses with the bug address, >>>> 48500@debbugs.gnu.org, on the CC list, so that others will see your >>>> detailed descriptions. I won't have time to take a good look into >>>> that in the next few days, so it's good to make others aware of your >>>> findings, because they might look into it meanwhile. >>>> >>>> Personally, I find it very strange that typing on the keyboard >>>> produces C-g, it shouldn't happen, neither on a TTY nor on a GUI >>>> display. >>>> >>> --000000000000cea50405c2ad5fcc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I have done a write-up on this issue to clarify every= thing.

https://mullikine.github.io/posts/fixing-go= ogling-tooling-in-emacs/

Shane Mulligan

=
How to contact me:
3D""
=F0=9F=87=A6=F0=9F=87=BA00 61 421 641 250
=F0=9F= =87=B3=F0=9F=87=BF00 6= 4 21 1462 759
mullikine@gmail.com



On Wed, May 19, 2021 at 6:49 = PM Shane Mulligan <mullikine@gmai= l.com> wrote:
Hi Eli,

I tagged you back in this = conversation because I may have fixed the issue :).

Shane Mulligan

How to contact me:
3D""
=F0=9F=87=A6=F0=9F=87=BA00 61 421 641 250
=F0=9F=87=B3=F0=9F=87=BF00 64 21 1462 759
mullikine@gmail= .com



On Wed, May 19, 2021 at= 6:48 PM Shane Mulligan <mullikine@gmail.com> wrote:
I m= ay have resolved this issue with the following patch to `url-retrieve-synch= ronously`.
What this achieves is to trigger a `quit` in a control= led environment rather than allowing it to occur when `accept-process-outpu= t` is run.
It's not always wanted to trigger a quit when = `(input-pending-p)` is `t`. But I noticed from placing `while-no-input` aro= und `accept-process-output` to avoid the `quit` that `url-retrieve-synchron= ously` would then hang but with the controlled `quit` happening beforehand,= `accept-process-output` no longer needs `while-no-input` around it. The en= d result is buttery smooth helm with no accidental `quit` from typing too f= ast. I think this may have resulted in GUI helm faster too.

<= /div>
```
29c29,30
< =C2=A0 =C2=A0 =C2=A0 (let ((proc (get-b= uffer-process asynch-buffer)))
---
> =C2=A0 =C2=A0 =C2=A0 (let ((p= roc (get-buffer-process asynch-buffer))
> =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 (counter 0))
71a73,78
> =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 (with-local-quit
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 (if (input-pending-p)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (progn
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq counter (1+ counter))
&g= t; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (i= f (> counter 20)
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (keyboard-quit)))))
```
Shane Mulligan

How to contact me:
3D""=F0=9F=87=A6=F0=9F=87=BA<= td style=3D"display:inline-block;padding:0.1em 0.35em 0.2em 0.3em;backgroun= d:linear-gradient(135deg,rgb(255,255,255) 0%,rgba(255,255,255,0) 100%)">00 64 21 1462 759
00 61 421 641 250
=F0=9F=87=B3=F0=9F=87=BF
mullikine@gmail.com
<= /td>



On Wed, May 19, 2021 at 11:32= AM Shane Mulligan <mullikine@gmail.com> wrote:
My apologies. It was literally 5am= when I wrote that. I think I have misunderstood `C-g` being generated with= `quit-flag`. The bad behaviour is very clearly still happening. I will try= to clarify this problem further by experimenting with it. I need to figure= out why `while-no-input` suppresses the `quit` but merely setting `quit-fl= ag` does not. Something indirect may be happening.=C2=A0

Thank you all,
=
Shane Mulligan

How to contact me:
=
=F0=9F=87=A6=F0=9F=87=BA00 61 421 641 250
=F0=9F=87=B3=F0=9F=87= =BF00 64 21 1462 759
mullikine@gmail.com



On Wed, May 19, 2021 at= 4:54 AM Eli Zaretskii <eliz@gnu.org> wrote:
> From: Shane Mulligan <mullikine@gmail.com>
> Date: Wed, 19 May 2021 04:32:16 +1200
>
> Thanks for looking into this so quickly. First some background on the = problem. I managed to work through
> this issue (https://github.com/emacs-helm/helm/is= sues/2417) with the `emacs-helm` maintainer and we
> found what appears to be that the call to `accept-process-output` insi= de of `url-retrieve-synchronously` will
> generate a `C-g` when there is pending input of any char. As far as I = can tell this is an issue only with
> terminal emacs. As I understand it, `inhibit-quit`, as used in `accept= -process-output` allows a `C-g` to be
> propagated outwards and handled and from what I can see by the comment= s surrounding,
>
> ```
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; accept-proces= s-output returned nil, maybe because the process
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; exited (and m= ay have been replaced with another).=C2=A0 If we got
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; a quit, just = stop.
> ```
>
> the `C-g` in this case is expected.
>
> But I wonder if `C-g` was meant to be generated if the user was simply= mashing keys on the keyboard.=C2=A0 In
> this case, the `C-g` emanating from `accept-process-output` was bubbli= ng up into `helm` and `helm` was
> treating it like an error.
>
> Here, you can see a quit being generated from the visual cue in the mi= nibuffer.
> https://asciinema.org/a/nAIB8Z1lGgZJqJg9Mt8YiN= EM9
>
> Here, I have added `while-no-input` and I no longer get the `quit`. > https://asciinema.org/a/x9ELZhwDP1IUtmOz0M1cly= 42H
>
> However, as I test the addition of `while-no-input` with `helm-google-= suggest` (as above), though Quit is no
> longer being generated from mashing keys, the key input which would ha= ve generated the `quit` is not
> immediately shown in `helm`. Instead, it only appears on the next key = press. So my implementation may not
> be perfect or complete.
>
> Finding the solution would make the minibuffer far less interrupted wh= ile typing when
> `url-retrieve-synchronously` is used in the background.
>
> Thank you.
>
> Shane Mulligan

Please in the future send your responses with the bug address,
48500@debbugs.gn= u.org, on the CC list, so that others will see your
detailed descriptions.=C2=A0 I won't have time to take a good look into=
that in the next few days, so it's good to make others aware of your findings, because they might look into it meanwhile.

Personally, I find it very strange that typing on the keyboard
produces C-g, it shouldn't happen, neither on a TTY nor on a GUI
display.
--000000000000cea50405c2ad5fcc--