GNU bug report logs - #39687
26.3; Add customize-variable option for not locking keyboards

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Logan Perkins <logan@HIDDEN>; Keywords: patch; dated Thu, 20 Feb 2020 06:30:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 39687 <at> debbugs.gnu.org:


Received: (at 39687) by debbugs.gnu.org; 1 Oct 2020 18:44:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 01 14:44:46 2020
Received: from localhost ([127.0.0.1]:38309 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kO3ZO-0008Bc-7T
	for submit <at> debbugs.gnu.org; Thu, 01 Oct 2020 14:44:46 -0400
Received: from quimby.gnus.org ([95.216.78.240]:34246)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1kO3ZL-0008BO-Sc
 for 39687 <at> debbugs.gnu.org; Thu, 01 Oct 2020 14:44:44 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=XmtKUATy3Et3Gi4O0EQsdLajpVkOowSvp2EeNpb3tgA=; b=OVhifEU/Q+WIpC/dHG3LLvYqSk
 VbDxka8G1UjuwV5GPu+Q383i9LyY//cnH0fm8PQAVQvTTzJZHgiyWy/SW3rrJqDQV9+54wHYckabk
 GAyCbt6o2+tbhYamLXaBGP7HclkhKfRLI6NU4rofRPlfpJuSofLgLG6+jhfQ72inxz4U=;
Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo)
 by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1kO3ZA-00029l-04; Thu, 01 Oct 2020 20:44:36 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Logan Perkins <logan@HIDDEN>
Subject: Re: bug#39687: 26.3; Add customize-variable option for not locking
 keyboards
References: <3a518d18-cc99-195b-42a9-adc8ef764d67@HIDDEN>
 <83mu9cjqml.fsf@HIDDEN>
 <32ea14fb-1ab8-186e-2534-4d3d2a56d6d8@HIDDEN>
 <83pne7hsyp.fsf@HIDDEN>
 <6a23af03-d597-6e3e-ceb4-5fb1305a496a@HIDDEN>
X-Now-Playing: Nanang Tatang's _Muki_: "Last Train Out"
Date: Thu, 01 Oct 2020 20:44:30 +0200
In-Reply-To: <6a23af03-d597-6e3e-ceb4-5fb1305a496a@HIDDEN> (Logan
 Perkins's message of "Mon, 18 May 2020 18:15:15 -0700")
Message-ID: <877ds93hwx.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Logan Perkins <logan@HIDDEN> writes: > I *think*
 I have a patch that still fixes the current behavior,
 and > does not reintroduce
 those two bugs, I've included it below. > Basically, the fix for Bug#5095
 should only be applied if we are [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 39687
Cc: Eli Zaretskii <eliz@HIDDEN>, 39687 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Logan Perkins <logan@HIDDEN> writes:

> I *think* I have a patch that still fixes the current behavior, and
> does not reintroduce those two bugs, I've included it below.
> Basically, the fix for Bug#5095 should only be applied if we are in
> the right context.  If we're not, the if block above puts a
> Qswitch_frame at the head of the side queue and triggers
> replay_entire_sequence, so we just skip the second check.  It'll get
> run again and catch the interruption on the next pass, but in the
> right context.

Eli, did you have a chance to take a look at the proposed patch here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#39687; Package emacs. Full text available.
Added tag(s) patch. Request was from Stefan Kangas <stefan@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 39687 <at> debbugs.gnu.org:


Received: (at 39687) by debbugs.gnu.org; 19 May 2020 01:15:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 18 21:15:43 2020
Received: from localhost ([127.0.0.1]:48658 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jaqr8-0006un-Or
	for submit <at> debbugs.gnu.org; Mon, 18 May 2020 21:15:43 -0400
Received: from mr15.netdorm.com ([64.182.101.205]:46642 helo=gw2.litvpn.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <logan@HIDDEN>) id 1jaqr4-0006uW-La
 for 39687 <at> debbugs.gnu.org; Mon, 18 May 2020 21:15:41 -0400
Received: from [192.168.1.43] (unknown [63.227.187.208])
 (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits))
 (No client certificate requested)
 by gw2.litvpn.com (Postfix) with ESMTPSA id EFFDEE05BC;
 Mon, 18 May 2020 21:15:46 -0400 (EDT)
Subject: Re: bug#39687: 26.3; Add customize-variable option for not locking
 keyboards
To: Eli Zaretskii <eliz@HIDDEN>
References: <3a518d18-cc99-195b-42a9-adc8ef764d67@HIDDEN>
 <83mu9cjqml.fsf@HIDDEN>
 <32ea14fb-1ab8-186e-2534-4d3d2a56d6d8@HIDDEN>
 <83pne7hsyp.fsf@HIDDEN>
From: Logan Perkins <logan@HIDDEN>
Message-ID: <6a23af03-d597-6e3e-ceb4-5fb1305a496a@HIDDEN>
Date: Mon, 18 May 2020 18:15:15 -0700
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.8.0
MIME-Version: 1.0
In-Reply-To: <83pne7hsyp.fsf@HIDDEN>
Content-Type: multipart/alternative;
 boundary="------------17DD87586F2F79AE4ECEE762"
Content-Language: en-US
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 39687
Cc: 39687 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This is a multi-part message in MIME format.
--------------17DD87586F2F79AE4ECEE762
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit

On 2/22/20 1:27 AM, Eli Zaretskii wrote:

> > Also, are you implicitly saying that several persons work
>>   > simultaneously vis-à-vis the same Emacs server? Because if not, I'm
>>   > not sure I understand how simultaneous need to input from different
>>   > clients could even happen.
>>
>> That's exactly the use-case where it matters most. If you're familiar
>> with Ludum Dare and similar code-sprints, it's pretty common to
>> have multiple people working on the same files at the same time. Having
>> a shared editor makes it faster and easier to draw attention to exactly
>> where one person needs help. It's also great for teaching (when you
>> aren't physically in front of the same computer), or for onboarding new
>> team members. Screen (the terminal multiplexer) can be used to similar
>> effect, but the ability to simultaneously edit the *same* file is
>> specific to emacs.
> I don't understand what you expect Emacs to do in these use cases.  If
> we process inputs from several clients as they arrive, we could
> produce results that are unexpected and even disastrous.  For example,
> suppose we receive C-x from one client followed by C-u from another
> followed by C-s from the first one -- if we process these in the order
> they were received, the result will be none of what the two clients
> intended.
>
> Maybe you thought that our input code will process input in chunks of
> complete sequences, and thus avoid the above-mentioned disasters, but
> then (a) I think we will need a very thorough restructuring of the
> current code in keyboard.c, as it currently decides on this
> dynamically; and (b) you will still have the same problem if the user
> of one client types C-x and then pauses for some reason.
>
> So I'm afraid I don't see what kind of solution is sought for here,
> please clarify.

Alright, I finally had time to dig in to what commit broke the split input.
The commit was e3cebbb839fc94f314659bf667c6790edebf4297, from 19 October 2019.
It was to fix Bug#37782, and improve the fix for Bug#5095.

Reverting that commit resolves the issue, but obviously reintroduces Bug#37782.
I *think* I have a patch that still fixes the current behavior, and does not
reintroduce those two bugs, I've included it below.  Basically, the fix for
Bug#5095 should only be applied if we are in the right context.  If we're not,
the if block above puts a Qswitch_frame at the head of the side queue and
triggers replay_entire_sequence, so we just skip the second check.  It'll get
run again and catch the interruption on the next pass, but in the right context.

diff --git a/src/keyboard.c b/src/keyboard.c
index f9b9399d50..90ed1d3e9a 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -9599,17 +9599,23 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt,
                       (interrupted_kboard,
                        Fcons (make_lispy_switch_frame (frame),
                               KVAR (interrupted_kboard, kbd_queue)));
+                   mock_input = 0;
+                 }
+               else
+                 {
+                   if (FIXNUMP (key) && XFIXNUM (key) != -2)
+                     {
+                       /* If interrupted while initializing terminal, we
+                          need to replay the interrupting key.  See
+                          Bug#5095 and Bug#37782.  */
+                       mock_input = 1;
+                       keybuf[0] = key;
+                     }
+                   else
+                     {
+                       mock_input = 0;
+                     }
                   }
-                if (FIXNUMP (key) && XFIXNUM (key) != -2)
-                  {
-                    /* If interrupted while initializing terminal, we
-                       need to replay the interrupting key.  See
-                       Bug#5095 and Bug#37782.  */
-                    mock_input = 1;
-                    keybuf[0] = key;
-                  }
-                else
-                  mock_input = 0;
                 goto replay_entire_sequence;
               }
           }




--------------17DD87586F2F79AE4ECEE762
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>On 2/22/20 1:27 AM, Eli Zaretskii wrote:<br>
    </p>
    <blockquote type="cite" cite="mid:83pne7hsyp.fsf@HIDDEN"> &gt;
      Also, are you implicitly saying that several persons work
      <blockquote type="cite">
        <pre class="moz-quote-pre" wrap=""> &gt; simultaneously vis-à-vis the same Emacs server? Because if not, I'm
 &gt; not sure I understand how simultaneous need to input from different
 &gt; clients could even happen.

That's exactly the use-case where it matters most. If you're familiar
with Ludum Dare and similar code-sprints, it's pretty common to
have multiple people working on the same files at the same time. Having
a shared editor makes it faster and easier to draw attention to exactly
where one person needs help. It's also great for teaching (when you
aren't physically in front of the same computer), or for onboarding new
team members. Screen (the terminal multiplexer) can be used to similar
effect, but the ability to simultaneously edit the *same* file is
specific to emacs.
</pre>
      </blockquote>
      <pre class="moz-quote-pre" wrap="">
I don't understand what you expect Emacs to do in these use cases.  If
we process inputs from several clients as they arrive, we could
produce results that are unexpected and even disastrous.  For example,
suppose we receive C-x from one client followed by C-u from another
followed by C-s from the first one -- if we process these in the order
they were received, the result will be none of what the two clients
intended.

Maybe you thought that our input code will process input in chunks of
complete sequences, and thus avoid the above-mentioned disasters, but
then (a) I think we will need a very thorough restructuring of the
current code in keyboard.c, as it currently decides on this
dynamically; and (b) you will still have the same problem if the user
of one client types C-x and then pauses for some reason.

So I'm afraid I don't see what kind of solution is sought for here,
please clarify.
</pre>
    </blockquote>
    <pre>Alright, I finally had time to dig in to what commit broke the split input.  
The commit was e3cebbb839fc94f314659bf667c6790edebf4297, from 19 October 2019.
It was to fix Bug#37782, and improve the fix for Bug#5095.  

Reverting that commit resolves the issue, but obviously reintroduces Bug#37782.
I *think* I have a patch that still fixes the current behavior, and does not 
reintroduce those two bugs, I've included it below.  Basically, the fix for 
Bug#5095 should only be applied if we are in the right context.  If we're not, 
the if block above puts a Qswitch_frame at the head of the side queue and 
triggers replay_entire_sequence, so we just skip the second check.  It'll get
run again and catch the interruption on the next pass, but in the right context.

diff --git a/src/keyboard.c b/src/keyboard.c
index f9b9399d50..90ed1d3e9a 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -9599,17 +9599,23 @@ read_key_sequence (Lisp_Object *keybuf, Lisp_Object prompt,
                      (interrupted_kboard,
                       Fcons (make_lispy_switch_frame (frame),
                              KVAR (interrupted_kboard, kbd_queue)));
+                   mock_input = 0;
+                 }
+               else
+                 {
+                   if (FIXNUMP (key) &amp;&amp; XFIXNUM (key) != -2)
+                     {
+                       /* If interrupted while initializing terminal, we
+                          need to replay the interrupting key.  See
+                          Bug#5095 and Bug#37782.  */
+                       mock_input = 1;
+                       keybuf[0] = key;
+                     }
+                   else
+                     {
+                       mock_input = 0;
+                     }
                  }
-                if (FIXNUMP (key) &amp;&amp; XFIXNUM (key) != -2)
-                  {
-                    /* If interrupted while initializing terminal, we
-                       need to replay the interrupting key.  See
-                       Bug#5095 and Bug#37782.  */
-                    mock_input = 1;
-                    keybuf[0] = key;
-                  }
-                else
-                  mock_input = 0;
                goto replay_entire_sequence;
              }
          }



</pre>
  </body>
</html>

--------------17DD87586F2F79AE4ECEE762--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#39687; Package emacs. Full text available.

Message received at 39687 <at> debbugs.gnu.org:


Received: (at 39687) by debbugs.gnu.org; 22 Feb 2020 18:48:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 22 13:48:19 2020
Received: from localhost ([127.0.0.1]:49991 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1j5Zp2-0005fX-QO
	for submit <at> debbugs.gnu.org; Sat, 22 Feb 2020 13:48:19 -0500
Received: from mr16.netdorm.com ([64.182.101.206]:44274 helo=gw1.litvpn.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <logan@HIDDEN>) id 1j5Z5S-0004O0-JY
 for 39687 <at> debbugs.gnu.org; Sat, 22 Feb 2020 13:01:11 -0500
Received: from [192.168.1.43] (unknown [63.227.187.208])
 (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits))
 (No client certificate requested)
 by gw1.litvpn.com (Postfix) with ESMTPSA id C160C408C3;
 Sat, 22 Feb 2020 13:01:15 -0500 (EST)
Subject: Re: bug#39687: 26.3; Add customize-variable option for not locking
 keyboards
To: Eli Zaretskii <eliz@HIDDEN>
References: <3a518d18-cc99-195b-42a9-adc8ef764d67@HIDDEN>
 <83mu9cjqml.fsf@HIDDEN>
 <32ea14fb-1ab8-186e-2534-4d3d2a56d6d8@HIDDEN>
 <83pne7hsyp.fsf@HIDDEN>
From: Logan Perkins <logan@HIDDEN>
Message-ID: <5bc16edc-a02d-f9ef-ba68-e0d7b94628e4@HIDDEN>
Date: Sat, 22 Feb 2020 10:00:42 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.3.0
MIME-Version: 1.0
In-Reply-To: <83pne7hsyp.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Content-Language: en-US
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 39687
X-Mailman-Approved-At: Sat, 22 Feb 2020 13:48:15 -0500
Cc: 39687 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)




On 2/22/20 1:27 AM, Eli Zaretskii wrote:
 > [Please keep the bug address on the CC list, so this whole discussion
 > is recorded by the Emacs issue tracker.]

Oops! I hit reply instead of reply-all, not sure why Thunderbird
doesn't make that the default, but I'll be more mindful of that in the 
future.

 >
 >> From: Logan Perkins <logan@HIDDEN>
 >> Date: Fri, 21 Feb 2020 10:37:39 -0800
 >>
 >> On 2/21/20 12:23 AM, Eli Zaretskii wrote:
 >> >> From: Logan Perkins <logan@HIDDEN>
 >> >> Date: Wed, 19 Feb 2020 21:01:30 -0800
 >> >>
 >> >> Is there some further reason to lock the keyboard that I haven't
 >> >> considered?
 >> >
 >> > Can we back up a little, and discuss the use cases where the current
 >> > behavior presents a limitation? Is quitting in the other clients the
 >> > only one, or are there more?
 >>
 >> Quitting in other clients is one, but fairly minor (C-z; kill %1 will
 >> get you out of it). Switching clients generally is another minor case.
 >> If you walk away with the minibuffer open by accident, and then try to
 >> use a remote client (via SSH or similar) later, it's locked (you can
 >> work around this by registering a SIGUSR handler to close the
 >> minibuffer, but that's not ideal).
 >
 > These seem to be valid use cases, so I tend to agree we should have an
 > easier way of breaking out of the minibuffer input in another client.
 >
 >> > Also, are you implicitly saying that several persons work
 >> > simultaneously vis-�-vis the same Emacs server? Because if not, I'm
 >> > not sure I understand how simultaneous need to input from different
 >> > clients could even happen.
 >>
 >> That's exactly the use-case where it matters most. If you're familiar
 >> with Ludum Dare and similar code-sprints, it's pretty common to
 >> have multiple people working on the same files at the same time. Having
 >> a shared editor makes it faster and easier to draw attention to exactly
 >> where one person needs help. It's also great for teaching (when you
 >> aren't physically in front of the same computer), or for onboarding new
 >> team members. Screen (the terminal multiplexer) can be used to similar
 >> effect, but the ability to simultaneously edit the *same* file is
 >> specific to emacs.
 >
 > I don't understand what you expect Emacs to do in these use cases. If
 > we process inputs from several clients as they arrive, we could
 > produce results that are unexpected and even disastrous. For example,
 > suppose we receive C-x from one client followed by C-u from another
 > followed by C-s from the first one -- if we process these in the order
 > they were received, the result will be none of what the two clients
 > intended.
 >
 > Maybe you thought that our input code will process input in chunks of
 > complete sequences, and thus avoid the above-mentioned disasters, but
 > then (a) I think we will need a very thorough restructuring of the
 > current code in keyboard.c, as it currently decides on this
 > dynamically; and (b) you will still have the same problem if the user
 > of one client types C-x and then pauses for some reason.
 >
 > So I'm afraid I don't see what kind of solution is sought for here,
 > please clarify.


So I've just done some more testing, with emacs 26.3-r1 (the latest
stable version in Gentoo), and emacs 27.0.50_pre20191223, the latest
snapshot, both compiled with and without the gutted
switch_to_single_kboard... (I'll see about getting the latest
development version from the repo probably this evening).

Looks like keyboard handling got changed sometime between the two
versions. I ran the following sequence in all 4 copies.

1. ./emacs -nw #on seat0
2. M-x start-server
3. ./emacsclient -t #on seat1
4. Switch both to the scratch buffer
5. Put each seat's cursor on its own line
6. On seat0, type abcde
7. On seat1, type 12345
8. On seat0, type C-x
9. On seat1, type u
10. On seat1, type C-x
11. On seat0, type C-c

Note that this sequence doesn't try to put emacs into single keyboard
mode, so the gutted function has no impact on the results.

In emacs-26, step 9 inserts a literal u on seat1's line, step 11 closes
emacs. Before step 11, both seat and seat1 display C-x as "breadcrumbs"
in the minibuffer.

In emacs-27, step 9 undoes seat0's last action (removes abcde), step 11
closes seat1's emacsclient.

Obviously, the behaviour in emacs-27 precludes simultanuous input. I
also think it's poor behavior, even if we don't unlock the keyboard when
the minibuffer is in use, since someone walking away after hitting C-x
(or some other partial command) and then connecting later will get
unexpected (and probably unseen) results with their first keypress.

I'll see if I can figure out which changes in keyboard.c account for the
changed behavior, and what the reason for them was.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#39687; Package emacs. Full text available.

Message received at 39687 <at> debbugs.gnu.org:


Received: (at 39687) by debbugs.gnu.org; 22 Feb 2020 09:28:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 22 04:28:18 2020
Received: from localhost ([127.0.0.1]:48559 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1j5R58-0001JP-EI
	for submit <at> debbugs.gnu.org; Sat, 22 Feb 2020 04:28:18 -0500
Received: from eggs.gnu.org ([209.51.188.92]:57272)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1j5R56-0001JA-6z
 for 39687 <at> debbugs.gnu.org; Sat, 22 Feb 2020 04:28:16 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:50748)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1j5R4x-0001Rq-DK; Sat, 22 Feb 2020 04:28:07 -0500
Received: from [176.228.60.248] (port=3881 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1j5R4w-0000OU-7o; Sat, 22 Feb 2020 04:28:06 -0500
Date: Sat, 22 Feb 2020 11:27:58 +0200
Message-Id: <83pne7hsyp.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Logan Perkins <logan@HIDDEN>
In-reply-to: <32ea14fb-1ab8-186e-2534-4d3d2a56d6d8@HIDDEN>
 (message from Logan Perkins on Fri, 21 Feb 2020 10:37:39 -0800)
Subject: Re: bug#39687: 26.3; Add customize-variable option for not locking
 keyboards
References: <3a518d18-cc99-195b-42a9-adc8ef764d67@HIDDEN>
 <83mu9cjqml.fsf@HIDDEN>
 <32ea14fb-1ab8-186e-2534-4d3d2a56d6d8@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: 1.6 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  [Please keep the bug address on the CC list, so this whole
 discussion is recorded by the Emacs issue tracker.] > From: Logan Perkins
 <logan@HIDDEN> > Date: Fri, 21 Feb 2020 10:37:39 -0800 > > On
 2/21/20 12:23 AM,
 Eli Zaretskii wrote: > >> From: Logan Perkins <logan@HIDDEN>
 > >> Date: We [...] 
 Content analysis details:   (1.6 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in
 bl.spamcop.net
 [Blocked - see <https://www.spamcop.net/bl.shtml?176.228.60.248>]
 -0.7 RCVD_IN_DNSWL_LOW      RBL: Sender listed at https://www.dnswl.org/,
 low trust [209.51.188.92 listed in list.dnswl.org]
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 0.0 URIBL_BLOCKED          ADMINISTRATOR NOTICE: The query to URIBL was
 blocked.  See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block
 for more information. [URIs: lp-programming.com]
 0.3 URIBL_RHS_DOB          Contains an URI of a new domain (Day Old Bread)
 [URIs: lp-programming.com]
 0.1 URIBL_SBL_A Contains URL's A record listed in the Spamhaus SBL
 blocklist [URIs: lp-programming.com]
 0.6 URIBL_SBL Contains an URL's NS IP listed in the Spamhaus SBL
 blocklist [URIs: lp-programming.com]
X-Debbugs-Envelope-To: 39687
Cc: 39687 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.6 (/)

[Please keep the bug address on the CC list, so this whole discussion
is recorded by the Emacs issue tracker.]

> From: Logan Perkins <logan@HIDDEN>
> Date: Fri, 21 Feb 2020 10:37:39 -0800
> 
> On 2/21/20 12:23 AM, Eli Zaretskii wrote:
>  >> From: Logan Perkins <logan@HIDDEN>
>  >> Date: Wed, 19 Feb 2020 21:01:30 -0800
>  >>
>  >> Is there some further reason to lock the keyboard that I haven't
>  >> considered?
>  >
>  > Can we back up a little, and discuss the use cases where the current
>  > behavior presents a limitation? Is quitting in the other clients the
>  > only one, or are there more?
> 
> Quitting in other clients is one, but fairly minor (C-z; kill %1 will
> get you out of it). Switching clients generally is another minor case.
> If you walk away with the minibuffer open by accident, and then try to
> use a remote client (via SSH or similar) later, it's locked (you can
> work around this by registering a SIGUSR handler to close the
> minibuffer, but that's not ideal).

These seem to be valid use cases, so I tend to agree we should have an
easier way of breaking out of the minibuffer input in another client.

>  > Also, are you implicitly saying that several persons work
>  > simultaneously vis-à-vis the same Emacs server? Because if not, I'm
>  > not sure I understand how simultaneous need to input from different
>  > clients could even happen.
> 
> That's exactly the use-case where it matters most. If you're familiar
> with Ludum Dare and similar code-sprints, it's pretty common to
> have multiple people working on the same files at the same time. Having
> a shared editor makes it faster and easier to draw attention to exactly
> where one person needs help. It's also great for teaching (when you
> aren't physically in front of the same computer), or for onboarding new
> team members. Screen (the terminal multiplexer) can be used to similar
> effect, but the ability to simultaneously edit the *same* file is
> specific to emacs.

I don't understand what you expect Emacs to do in these use cases.  If
we process inputs from several clients as they arrive, we could
produce results that are unexpected and even disastrous.  For example,
suppose we receive C-x from one client followed by C-u from another
followed by C-s from the first one -- if we process these in the order
they were received, the result will be none of what the two clients
intended.

Maybe you thought that our input code will process input in chunks of
complete sequences, and thus avoid the above-mentioned disasters, but
then (a) I think we will need a very thorough restructuring of the
current code in keyboard.c, as it currently decides on this
dynamically; and (b) you will still have the same problem if the user
of one client types C-x and then pauses for some reason.

So I'm afraid I don't see what kind of solution is sought for here,
please clarify.

>  > In any case, we thank you for your interest in Emacs and look forward
>  > to seeing your contributions, but I suggest to start your legal
>  > paperwork rolling now, because changes you are talking about will
>  > probably be non-trivial in length, so we will need a copyright
>  > assignment from you in order to accept the changes. If you agree, I
>  > can send you the form to fill and the instructions to go with it.
> 
> I have no problem assigning copyright for my work on FSF projects to the
> FSF. I live in Eastern Washington, and am self employed, so getting
> the paperwork done should be about as trivial as it can be.

Thanks, I will send the form off-list.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#39687; Package emacs. Full text available.

Message received at 39687 <at> debbugs.gnu.org:


Received: (at 39687) by debbugs.gnu.org; 21 Feb 2020 08:23:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 21 03:23:33 2020
Received: from localhost ([127.0.0.1]:46325 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1j53au-00035z-U2
	for submit <at> debbugs.gnu.org; Fri, 21 Feb 2020 03:23:33 -0500
Received: from eggs.gnu.org ([209.51.188.92]:35292)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1j53at-00035k-Ky
 for 39687 <at> debbugs.gnu.org; Fri, 21 Feb 2020 03:23:32 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:44844)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1j53an-0004mo-Fn; Fri, 21 Feb 2020 03:23:25 -0500
Received: from [176.228.60.248] (port=2544 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1j53am-0004la-U5; Fri, 21 Feb 2020 03:23:25 -0500
Date: Fri, 21 Feb 2020 10:23:14 +0200
Message-Id: <83mu9cjqml.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Logan Perkins <logan@HIDDEN>
In-reply-to: <3a518d18-cc99-195b-42a9-adc8ef764d67@HIDDEN>
 (message from Logan Perkins on Wed, 19 Feb 2020 21:01:30 -0800)
Subject: Re: bug#39687: 26.3;
 Add customize-variable option for not locking keyboards
References: <3a518d18-cc99-195b-42a9-adc8ef764d67@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 39687
Cc: 39687 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> From: Logan Perkins <logan@HIDDEN>
> Date: Wed, 19 Feb 2020 21:01:30 -0800
> 
> Is there some further reason to lock the keyboard that I haven't
> considered?

Can we back up a little, and discuss the use cases where the current
behavior presents a limitation?  Is quitting in the other clients the
only one, or are there more?

Also, are you implicitly saying that several persons work
simultaneously vis-à-vis the same Emacs server?  Because if not, I'm
not sure I understand how simultaneous need to input from different
clients could even happen.

> Should I make the behavior depend on some elisp function? I think that
> might be the easiest way to support the "minibuffer in use" message and
> the like, but I'm not sure what the downside would be.
> 
> Is it a waste of time for me to submit patches related to this feature?
> If there's zero interest in adding this, or it would be less work for
> someone else to write it than review my patches, I won't waste your time
> sending them.

Speaking for myself, I think the interest depends on the relevant use
cases where the current behavior implies restrictions.  Thus my
questions above.

In any case, we thank you for your interest in Emacs and look forward
to seeing your contributions, but I suggest to start your legal
paperwork rolling now, because changes you are talking about will
probably be non-trivial in length, so we will need a copyright
assignment from you in order to accept the changes.  If you agree, I
can send you the form to fill and the instructions to go with it.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#39687; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Feb 2020 06:29:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 20 01:29:47 2020
Received: from localhost ([127.0.0.1]:43741 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1j4fLF-0000VB-Pa
	for submit <at> debbugs.gnu.org; Thu, 20 Feb 2020 01:29:47 -0500
Received: from lists.gnu.org ([209.51.188.17]:59232)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <logan@HIDDEN>) id 1j4dy3-0004gn-GA
 for submit <at> debbugs.gnu.org; Thu, 20 Feb 2020 00:01:43 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:49177)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <logan@HIDDEN>) id 1j4dy2-0000F6-3t
 for bug-gnu-emacs@HIDDEN; Thu, 20 Feb 2020 00:01:43 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: *
X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_50,KHOP_HELO_FCRDNS,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <logan@HIDDEN>) id 1j4dy0-0004Y2-Pw
 for bug-gnu-emacs@HIDDEN; Thu, 20 Feb 2020 00:01:41 -0500
Received: from host29.netdorm.com ([64.182.105.29]:36626 helo=gw1.litvpn.com)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <logan@HIDDEN>)
 id 1j4dy0-0004Wx-Iw
 for bug-gnu-emacs@HIDDEN; Thu, 20 Feb 2020 00:01:40 -0500
Received: from [192.168.1.43] (unknown [63.227.187.208])
 (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits))
 (No client certificate requested)
 by gw1.litvpn.com (Postfix) with ESMTPSA id 5CF114079C
 for <bug-gnu-emacs@HIDDEN>; Thu, 20 Feb 2020 00:01:48 -0500 (EST)
To: bug-gnu-emacs@HIDDEN
Subject: 26.3; Add customize-variable option for not locking keyboards
From: Logan Perkins <logan@HIDDEN>
Message-ID: <3a518d18-cc99-195b-42a9-adc8ef764d67@HIDDEN>
Date: Wed, 19 Feb 2020 21:01:30 -0800
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.3.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From: 64.182.105.29
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Thu, 20 Feb 2020 01:29:44 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)


In GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.11)
of 2020-01-28 built on gentoo-server
Windowing system distributor 'The X.Org Foundation', version 11.0.12005000
System Description: Gentoo Base System release 2.6

This is a feature request more than a bug report. When using the
built-in server (either via `emacs --daemon` or `server-start`) +
emacsclient, use of the minibuffer from one client completely blocks
other clients (they can't even quit until the mini buffer finishes).
This is governed by calls to
`temporarily_switch_to_single_kboard(struct frame *f)` in `keyboard.c`.

If I understand correctly, there are two reasons for locking other
clients while the minibuffer is in use. First, the input for the
minibuffer is stored in a single global variable; while enabling
recursive minibuffers is possible, bottom line is there can only be *one*
active mini buffer at a time. Locking secondary inputs reduces the
potential for confusion with fighting over the minibuffer.

Additionally, sometimes there is something which requires a user
response (such as confirmation on killing a modified buffer), and
resolving that is simpler if the state isn't changing in the background.

On the other hand, even with a confirmation box open, a user can switch
away from the minibuffer and continue changing state (potentially even
opening a recursive minibuffer), so I don't think the second case is
sufficient cause to disallow multi-keyboard mode when the minibuffer is
in use.

As for the first issue, I don't think the present behavior is clearly
best, as it doesn't *ignore* secondary keyboard input, it *queues*
it, executing it in one block when the minibuffer ends. This can cause
unexpected issues for novice users. Also, the inability to even close
the client (short of SIGTERMing it) is not ideal.

I've gutted the
`temporarily_switch_to_single_kboard(struct frame *f)` in `keyboard.c`
on a test system, and successfully used it with multiple people sharing
a single server instance (on a joint project), and it works reasonably
well. I'd like to propose adding a customizeable variable in the
`minibuffer` group which disables locking the other keyboards. Ideally,
the other clients should get a "minibuffer in use" message in their
minibuffers so users can see when someone is using the minibuffer.

I am happy to work on this, and submit patches for it, but would
appreciate some advice before I start.

Is there some further reason to lock the keyboard that I haven't
considered?

I think it's better to use the customizeable variable to prevent the 
call to
temporarily_switch_to_single_kboard, rather than have that function not
do what it's name implies it does. Should I intercept all calls to it
based on one new variable? Or should I split general minibuffer use
from confirmation uses, and so on? (Looks like 3-4 different places
it's called in the source).

Should I make the behavior depend on some elisp function? I think that
might be the easiest way to support the "minibuffer in use" message and
the like, but I'm not sure what the downside would be.

Is it a waste of time for me to submit patches related to this feature?
If there's zero interest in adding this, or it would be less work for
someone else to write it than review my patches, I won't waste your time
sending them.

Regards,
Logan Perkins





Acknowledgement sent to Logan Perkins <logan@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#39687; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 1 Oct 2020 18:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.