unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: sbaugh@catern.com
To: Po Lu <luangruo@yahoo.com>
Cc: Spencer Baugh <sbaugh@janestreet.com>, 64423@debbugs.gnu.org
Subject: bug#64423: 29.0.92; save-interprogram-paste-before-kill doesn't prevent streaming large selections
Date: Tue, 04 Jul 2023 14:46:36 +0000 (UTC)	[thread overview]
Message-ID: <87jzvfohtg.fsf@catern.com> (raw)
In-Reply-To: <87h6qjreyw.fsf@yahoo.com> (Po Lu's message of "Tue, 04 Jul 2023 21:19:51 +0800")

Po Lu <luangruo@yahoo.com> writes:
>> Such costs only need to be paid if there are indeed multiple conversions
>> happening at the same time.  In the common case there's just one, so
>> there's no extra cost of adding the ability to have multiple ongoing
>> conversions.
>
> Adding extra round trip cost to a part of Emacs that is already one of
> the slowest and most synchronous components of the X Windows support is
> unacceptable in my book.  Especially for such an uncommon situation: I
> can't remember the last time I quit a selection request to a working
> selection owner, and I use Emacs over wide area networks every day.

I think you might be misunderstanding me?  Just to say again, in the
normal case, this would not add extra cost.  This would only add extra
round trip cost in cases which, as you say below, currently just confuse
and break Emacs.

(Also, the entire point would be that this component would move from
being synchronous to being able to run in the background, concurrent
with other things.)

>> Actually, how does this work today?  If an Emacs user quits a conversion
>> and then immediately starts a new one, that seems to work fine.  We
>> don't do different properties in each request.  I realize the protocol
>> doesn't support it, but doesn't that suggest that it's fine in practice
>> to interrupt a conversion...?
>
> If Emacs quits while waiting for a property change to take place, and
> the property change event from the recipient of the request that was
> quit still arrives, Emacs will become confused and return outdated
> selection data.  Or even worse, a mixture of the selection data from
> both the new and old owners.
>
> Selection owners that are not implemented robustly may also freeze if
> Emacs quits before removing the selection transfer property from its
> window to acknowledge the selection data's arrival.

OK, interesting.  So it's basically broken already today to interrupt a
gui-get-selection... great.

>> (Quitting a conversion then running another would be one way to have
>> multiple conversions at the same time.  Another way would be (related to
>> my other thread about call-process) to allow running Lisp while an
>> incremental selection transfer is ongoing.  I know that seems useless
>> but I really am of the opinion that every blocking operation in Emacs
>> which can take more than a few milliseconds should support running Lisp
>> while it blocks...)
>
> No, it's only necessary for us to ensure that C-g works, so the user can
> always quit from the long-running operation.  Otherwise, your position
> cannot be consistent without insisting that constructs such as `while'
> also check for and run timers and selection converters.

This is becoming tangential, but, yes, I will bite that bullet.  "while"
should also check for and run timers and selection converters, when Lisp
code opts-in to that behavior.  I can think of several ways to implement
this without hurting performance.

IMO the major issue with the Emacs UI at the moment is that it blocks
too much, relative to "modern" applications.  Some of this blocking can
only be fixed by speeding up Lisp execution, but substantial parts of
this blocking can only be fixed by making Emacs more concurrent - that
is, making it possible for Lisp code to run concurrently with other Lisp
code, on an opt-in basis, instead of blocking all Lisp execution while
operations like gui-get-selection and call-process are running.

I am aware this is a major undertaking, but I think it's important for
Emacs to compare favorably with "modern" applications which don't
exhibit as much random UI blocking.  I regard this as basically
equivalent to the lexical-binding transition.

>> Yes.  Personally I'd like to have a lower value for that when a
>> save-interprogram-paste-before-kill is triggered.  So adding a separate
>> save-interprogram-paste-before-kill-timeout which can be lower, and
>> which let-binds x-selection-timeout, seems good.
>
> How is that different from setting `x-selection-timeout'?  IOW, what's
> your real-world use case for such an additional option?  Have you tried
> adjusting `x-selection-timeout' for all selection transfers?

Here is the real-world use case: When I yank I'm willing to wait for 2
or 10 seconds for the paste to complete, since the paste is what I
actually want.  But when I kill-new I want to wait less time, because
the save-interprogram-paste-before-kill behavior is just a nice-to-have,
which I want to happen if it's convenient and fast, not the actual thing
I want to do.

> Let's not overengineer the system independent interprogram code with
> X-specific options.  Thanks.

A gui-selection-timeout would be fine with me, too.  Maybe other systems
would benefit?  pgtk?





  reply	other threads:[~2023-07-04 14:46 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-02 14:13 bug#64423: 29.0.92; save-interprogram-paste-before-kill doesn't prevent streaming large selections sbaugh
2023-07-03  2:35 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-03 12:46   ` Spencer Baugh
2023-07-04  0:40     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-04  1:45       ` sbaugh
2023-07-04  3:58         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-04 11:46           ` sbaugh
2023-07-04 13:19             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-04 14:46               ` sbaugh [this message]
2023-07-04 16:18                 ` Eli Zaretskii
2023-07-04 16:32                   ` Ihor Radchenko
2023-07-04 16:41                     ` Eli Zaretskii
2023-07-04 16:48                   ` sbaugh
2023-07-04 17:02                     ` Eli Zaretskii
2023-07-04 17:14                       ` Ihor Radchenko
2023-07-04 17:30                         ` Eli Zaretskii
2023-07-04 17:35                           ` Ihor Radchenko
2023-07-05  0:30                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-05  2:29                             ` Eli Zaretskii
2023-07-05  3:51                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-05 11:27                                 ` Eli Zaretskii
2023-07-05  0:19                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-05 13:59                   ` Spencer Baugh
2023-07-06  0:12                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-06  0:50                       ` Spencer Baugh
2023-07-06  1:59                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-08 16:39             ` sbaugh
2023-07-08 16:48               ` Eli Zaretskii
2023-07-08 17:07                 ` Spencer Baugh
2023-07-08 17:49                   ` Eli Zaretskii
2023-07-09  0:39                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-09  6:10                       ` Eli Zaretskii
2023-07-09  6:12                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-09  6:46                           ` Eli Zaretskii
2023-07-12 19:18                             ` sbaugh
2023-07-13  0:32                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-13  4:48                               ` Eli Zaretskii
2023-07-13 16:17                                 ` sbaugh
2023-07-13 18:39                                   ` Eli Zaretskii
2023-07-13 22:39                                     ` sbaugh
2023-07-15  8:31                                       ` Eli Zaretskii
2023-07-15  8:33                                         ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-15  9:01                                           ` Eli Zaretskii
2023-07-15  9:35                                             ` Eli Zaretskii
2023-07-15 17:38                                               ` sbaugh
2023-07-15 19:12                                                 ` Eli Zaretskii
2023-07-15 21:00                                                   ` Spencer Baugh
2023-07-17 16:43 ` Mattias Engdegård
2023-08-03 15:53 ` Spencer Baugh

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87jzvfohtg.fsf@catern.com \
    --to=sbaugh@catern.com \
    --cc=64423@debbugs.gnu.org \
    --cc=luangruo@yahoo.com \
    --cc=sbaugh@janestreet.com \
    /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.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).