unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: hw <hw@adminart.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: psainty@orcon.net.nz, gazally@runbox.com, rms@gnu.org,
	emacs-devel-bounces+psainty=orcon.net.nz@gnu.org,
	emacs-devel@gnu.org
Subject: Re: User interaction from multiple threads
Date: Mon, 27 Aug 2018 06:33:39 +0200	[thread overview]
Message-ID: <871sakl97g.fsf@himinbjorg.adminart.net> (raw)
In-Reply-To: <83va7x5guc.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 26 Aug 2018 17:43:07 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>> From: hw <hw@adminart.net>
>> Cc: rms@gnu.org, psainty@orcon.net.nz, emacs-devel@gnu.org,
>> emacs-devel-bounces+psainty=orcon.net.nz@gnu.org, gazally@runbox.com
>> Date: Sun, 26 Aug 2018 14:52:41 +0200
>> 
>> > I don't see how this would solve the problem, since thread IDs will
>> > always be quite short.
>> 
>> I don´t understand this.  I thought requests for input would be queued
>> in such a way that the users can look at the queue when ever they see
>> fit, and the information in the queue along with the prompts would make
>> it obvious to the users what each request is about.
>> 
>> Wouldn't that be much better than having requests for input and the
>> threads that created them fight over the mini-buffer and interrupt the
>> user once they can hijack the mini-buffer?
>
> You need to catch up with the discussion ;-)

I read it as far as it has come.  Maybe I'm missing something, or am
just misunderstanding.

> We all but agreed that threads should not "fight" one another.

When you don't want threads to have to fight over the mini-buffer, each
thread needs its own.  I thought that is not really wanted because it is
so difficult to do?

If that would be done, each mini-buffer would need its own history so
users can look at it to remember what they were doing --- I think that
was mentioned.

Do you want to do that?

> Still, when Emacs decides that a certain thread is granted access to
> the minibuffer and can interact with the user, how will the user know
> which of the N threads asks them the question, and for what purpose?

How about: Emacs does not make this decision and does not let threads
interact with users in this manner.  It puts all requests for input onto
the queue unless it can clearly determine that the request is directly
related to what the user is doing or working with.

Since threads are not spawned out of nothing for no reason and with no
purpose and nothing they work with --- at least I imagine so --- and
since Emacs creates and manages the threads, it should be able to put
information into the queue along with the request that tells the user
what the request is about.

> The correct answer could well depend on that.  As a trivial example,
> consider 2 threads, one copying files, the other removing files.  How
> do you know whether to confirm or not when the prompt says just "FOO
> (y or n)?"

Simple: Either both threads are in the background because meanwhile, I'm
doing something else, or one of the threads is in the background and the
other one is in the foreground.

The one in the foreground is the one Emacs would direct my input to if I
were to make any.  What that is must not change by itself.  In case
Emacs can not determine where to direct input to (because there are
multiple simultaneous inputs [1]), all requests must be queued.

Threads working in the background must not interrupt me, hence their
requests for input are put onto the queue and do not appear in the
mini-buffer before I attend to them. --- Only threads that execute in
the foreground are allowed to interrupt me (unless I disable that).

In any case I know that requests appearing in the mini-buffer always
refer to what is in the foreground, so in all cases, I know what the
prompt is about[2], unless I can't remember what I was doing in the
foreground.


What you seem to think you must do --- grant an arbitrary thread access
to the mini-buffer --- is what you *must not* do.  And I think you don't
want to do that.  A queue would cover it, that's why I don't understand
what the problem is.

However, a situation like in [1] requires multiple foregrounds.  What
would that bring about?


[1]: I can ssh into a machine running an Emacs server from many remote
     machines as the same user and have a person at each remote machine
     who uses emacsclient with the same server to edit each a different
     file.  How does Emacs figure out which input goes where and what to
     display in which mini-buffer?

[2]: What happens when I press C-g before a prompt appears, or when one
     has appeared?  How do I interrupt a particular operation a thread
     is or multiple threads are performing, possibly in the background,
     or partly in the background, when there is no list of operations I
     can turn to and interrupt the operation from there?  If there is
     such a list, use it to queue the requests related to each
     operation.  (Who says that one operation is done by only one thread
     each?  Does that require a mini-buffer or queue for each operation,
     for each thread or for both?)



  reply	other threads:[~2018-08-27  4:33 UTC|newest]

Thread overview: 119+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-14 15:12 User interaction from multiple threads Eli Zaretskii
2018-08-14 16:42 ` Michael Welsh Duggan
2018-08-15  8:02   ` Michael Albinus
2018-08-16 14:25   ` Eli Zaretskii
2018-08-17  2:59     ` Michael Welsh Duggan
2018-08-17  8:56       ` Eli Zaretskii
2018-08-15  8:06 ` martin rudalics
2018-08-15  8:22   ` Michael Albinus
2018-08-15  9:08     ` martin rudalics
2018-08-15 10:30       ` Michael Albinus
2018-08-15 12:27         ` martin rudalics
2018-08-15 12:59           ` Michael Albinus
2018-08-15 16:27             ` Elias Mårtenson
2018-08-15 18:04               ` Michael Albinus
2018-08-17  4:26                 ` Elias Mårtenson
2018-08-17  4:32                   ` Elias Mårtenson
2018-08-17  7:33                   ` Michael Albinus
2018-08-17  7:48                     ` Elias Mårtenson
2018-08-17  8:11                       ` Michael Albinus
2018-08-17  9:02                       ` Eli Zaretskii
2018-08-15 16:55           ` Eli Zaretskii
2018-08-16 12:21             ` martin rudalics
2018-08-16 13:46               ` Eli Zaretskii
2018-08-17  7:24                 ` martin rudalics
2018-08-17  7:48                   ` Eli Zaretskii
2018-08-17  8:34                     ` martin rudalics
2018-08-17  8:52                       ` Eric Abrahamsen
2018-08-17  9:06                       ` Michael Albinus
2018-08-17  9:12                       ` Eli Zaretskii
2018-08-18  8:31                         ` martin rudalics
2018-08-18  9:32                           ` Eli Zaretskii
2018-08-19  9:17                             ` martin rudalics
2018-08-15 16:47   ` Eli Zaretskii
2018-08-16 12:20     ` martin rudalics
2018-08-16 13:45       ` Eli Zaretskii
2018-08-16 15:19         ` Michael Albinus
2018-08-20 14:36     ` Gemini Lasswell
2018-08-20 15:06       ` Eli Zaretskii
2018-08-19 23:08 ` Gemini Lasswell
2018-08-20  1:18   ` Phil Sainty
2018-08-20 14:15     ` Gemini Lasswell
2018-08-20 17:07       ` Eli Zaretskii
2018-08-29 17:36         ` John Shahid
2018-08-30  0:18           ` Phil Sainty
2018-08-30  2:34             ` John Shahid
2018-08-30 13:10               ` Eli Zaretskii
2018-08-30 16:08                 ` John Shahid
2018-08-30 17:38                   ` Eli Zaretskii
2018-08-30 20:15                     ` John Shahid
2018-08-31 18:06                       ` Eli Zaretskii
2018-08-31 21:37                       ` Gemini Lasswell
2018-09-01  7:00                         ` Eli Zaretskii
2018-08-20 17:03   ` Eli Zaretskii
2018-08-20 22:38     ` Phil Sainty
2018-08-21 15:09       ` Eli Zaretskii
2018-08-22  4:05         ` Richard Stallman
2018-08-22 14:28           ` Eli Zaretskii
2018-08-22 15:48             ` hw
2018-08-22 17:33               ` Eli Zaretskii
2018-08-22 19:34                 ` hw
2018-08-22 23:58               ` Richard Stallman
2018-08-23  0:22                 ` John Wiegley
2018-08-24  1:59                   ` Richard Stallman
2018-08-23 14:08                 ` Eli Zaretskii
2018-08-23 22:34                   ` Phil Sainty
2018-08-24  8:51                     ` Eli Zaretskii
2018-08-24 12:59                       ` Phil Sainty
2018-08-25  0:21                       ` Richard Stallman
2018-08-25  0:16                     ` Richard Stallman
2018-08-24  2:00                   ` Richard Stallman
2018-08-24  3:57                     ` Elias Mårtenson
2018-08-24  9:20                     ` Eli Zaretskii
2018-08-24 11:44                       ` Michael Albinus
2018-08-24 15:41                         ` Elias Mårtenson
2018-08-25 11:58                           ` Michael Albinus
2018-08-27 10:53                             ` Elias Mårtenson
2018-08-25  0:20                       ` Richard Stallman
2018-08-25  7:51                         ` Eli Zaretskii
2018-08-25 10:32                           ` Phil Sainty
2018-08-25 19:11                           ` Richard Stallman
2018-08-25 19:51                             ` Eli Zaretskii
2018-08-26 12:52                               ` hw
2018-08-26 14:43                                 ` Eli Zaretskii
2018-08-27  4:33                                   ` hw [this message]
2018-08-27  7:32                                     ` Michael Albinus
2018-08-27 14:35                                       ` hw
2018-08-27 15:29                                         ` Eli Zaretskii
2018-08-27 18:43                                           ` hw
2018-08-28  5:39                                             ` Eli Zaretskii
2018-08-28 20:47                                               ` hw
2018-08-27 15:06                                     ` Eli Zaretskii
2018-08-27 19:46                                       ` hw
2018-08-28  5:38                                         ` Eli Zaretskii
2018-08-28 13:05                                           ` Phil Sainty
2018-08-28 16:50                                             ` Eli Zaretskii
2018-08-28 22:05                                           ` hw
2018-08-29 15:20                                             ` Eli Zaretskii
2018-08-29 20:00                                               ` hw
2018-08-30 13:48                                                 ` Eli Zaretskii
2018-09-01 17:32                                                   ` hw
2018-09-01 18:55                                                     ` Eli Zaretskii
2018-09-02 16:37                                                       ` hw
2018-09-02 17:20                                                         ` Eli Zaretskii
2018-09-01 22:30                                                     ` Drew Adams
2018-09-02 16:43                                                       ` hw
2018-08-30  1:16                                   ` Uday S Reddy
2018-08-30 13:05                                     ` Eli Zaretskii
2018-08-30 21:12                                       ` Uday Reddy
2018-08-31 18:17                                         ` Eli Zaretskii
2018-09-01 17:33                                     ` hw
2018-08-26 20:43                               ` Richard Stallman
2018-08-22 16:24           ` Tom Tromey
2018-08-22 17:40             ` Eli Zaretskii
2018-08-25 16:16               ` Tom Tromey
2018-08-22  7:18         ` martin rudalics
2018-08-22 14:32           ` Eli Zaretskii
2018-08-21 16:17     ` Gemini Lasswell
2018-08-30  0:21 ` Uday Reddy
2018-08-30 13:01   ` Eli Zaretskii

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=871sakl97g.fsf@himinbjorg.adminart.net \
    --to=hw@adminart.net \
    --cc=eliz@gnu.org \
    --cc=emacs-devel-bounces+psainty=orcon.net.nz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=gazally@runbox.com \
    --cc=psainty@orcon.net.nz \
    --cc=rms@gnu.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.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).