From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#29272: 26.0.90; "C-h k C-mouse-3" followed by menu selection asks for more keys Date: Tue, 14 Nov 2017 20:54:49 +0000 Message-ID: <20171114205449.GA8025@ACM> References: <83shdjn3ju.fsf@gnu.org> <83mv3rn02t.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1510693156 12347 195.159.176.226 (14 Nov 2017 20:59:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 14 Nov 2017 20:59:16 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: 29272@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 14 21:59:11 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eEiIX-0002p5-Vr for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 Nov 2017 21:59:10 +0100 Original-Received: from localhost ([::1]:33549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEiIf-0000P1-5u for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 Nov 2017 15:59:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eEiGV-0007mL-Mk for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2017 15:57:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eEiGU-0002VY-L8 for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2017 15:57:03 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60171) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eEiGU-0002VI-GQ for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2017 15:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eEiGU-00030u-7H for bug-gnu-emacs@gnu.org; Tue, 14 Nov 2017 15:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Nov 2017 20:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29272 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29272-submit@debbugs.gnu.org id=B29272.151069301711573 (code B ref 29272); Tue, 14 Nov 2017 20:57:02 +0000 Original-Received: (at 29272) by debbugs.gnu.org; 14 Nov 2017 20:56:57 +0000 Original-Received: from localhost ([127.0.0.1]:40619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eEiGP-00030b-Cl for submit@debbugs.gnu.org; Tue, 14 Nov 2017 15:56:57 -0500 Original-Received: from ocolin.muc.de ([193.149.48.4]:14615 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1eEiGO-00030T-8q for 29272@debbugs.gnu.org; Tue, 14 Nov 2017 15:56:57 -0500 Original-Received: (qmail 9709 invoked by uid 3782); 14 Nov 2017 20:56:52 -0000 Original-Received: from acm.muc.de (p548C6DFA.dip0.t-ipconnect.de [84.140.109.250]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 14 Nov 2017 21:56:51 +0100 Original-Received: (qmail 8132 invoked by uid 1000); 14 Nov 2017 20:54:49 -0000 Content-Disposition: inline In-Reply-To: <83mv3rn02t.fsf@gnu.org> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:139902 Archived-At: Hello, Eli. On Sun, Nov 12, 2017 at 14:38:50 +0200, Eli Zaretskii wrote: > > Date: Sun, 12 Nov 2017 13:23:49 +0200 > > From: Eli Zaretskii > > To reproduce: > > emacs -Q > > C-h k C-mouse-3 > > This pops up a Lisp Interaction Mode menu. Select some item from the > > menu. The expected result is to show in *Help* the description of the > > command selected from the menu. Instead, you are prompted again for a > > key or a mouse click. > > "C-h l" shows this: > > C-h k [describe-key] > > > > (I'm guessing help-echo comes from the menu items traversed by the > > mouse while selecting the item.) I would think so, too. > I think those help-echo events are the reason. We have this in > help-read-key-sequence: > (while > (pcase (setq key (read-key-sequence "\ > Describe the following key, mouse click, or menu item: ")) > ((and (pred vectorp) (let `(,key0 . ,_) (aref key 0)) > (guard (symbolp key0)) (let keyname (symbol-name key0))) > (if no-mouse-movement > (string-match "mouse-movement" keyname) > (and (string-match "\\(mouse\\|down\\|click\\|drag\\)" > keyname) > (not (sit-for (/ double-click-time 1000.0) t))))))) > What I think happens is that after the mouse-click event we get a > help-echo event, which causes sit-for to exit with nil value, and we > keep looping, because the loop expects only mouse events. Yes. > Alan, could you please take a look? I think this was introduced by > your changes in 10c0e1c (which you, no doubt, will have hard time > recognizing among the code that meanwhile was completely refactored), > which I think was an attempt to fix bug#22731 (not mentioned in the > log message). I think the changes failed to consider mouse clicks > that invoke menu items. You're not kidding about the refactoring. ;-) The following patch attempts to catch and filter out obtrusive events. Could you try it out, please, even though it's not perfect (see below). It's based on the emacs-26 branch: diff --git a/lisp/help.el b/lisp/help.el index fbb9fc8cbe..d119615180 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -728,11 +728,17 @@ help-read-key-sequence Describe the following key, mouse click, or menu item: ")) ((and (pred vectorp) (let `(,key0 . ,_) (aref key 0)) (guard (symbolp key0)) (let keyname (symbol-name key0))) - (if no-mouse-movement - (string-match "mouse-movement" keyname) - (and (string-match "\\(mouse\\|down\\|click\\|drag\\)" - keyname) - (not (sit-for (/ double-click-time 1000.0) t))))))) + (or + (and no-mouse-movement + (string-match "mouse-movement" keyname)) + (and (string-match "\\(mouse\\|down\\|click\\|drag\\)" + keyname) + (progn + ;; Discard events (e.g. ) which might + ;; spuriously trigger the `sit-for'. + (sleep-for 0.001) + (while (read-event nil nil 0.001)) + (not (sit-for (/ double-click-time 1000.0) t)))))))) (list key ;; If KEY is a down-event, read and include the I think I've corrected what looks like a bug, there; even when `no-mouse-movement' is non-nil (i.e. in C-h c), it should still check for double clicks. However, the problem is that in C-h k C-mouse-3 , we get a spurious "translation" message in *Help*, looking something like: (translated from ) at that spot runs the command find-file (found in global-map), which is an interactive compiled Lisp function in `files.el'. That was from a Linux tty session using gpm. In X, I got the message .... (translated from ....) . I don't believe this glitch has to do with my patch - I think it's been there for some while, but this bug has prevented it being seen before. -- Alan Mackenzie (Nuremberg, Germany).