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: Sun, 19 Nov 2017 16:19:43 +0000 Message-ID: <20171119161943.GA9922@ACM> References: <83shdjn3ju.fsf@gnu.org> <83mv3rn02t.fsf@gnu.org> <20171114205449.GA8025@ACM> <83r2svg72w.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 1511108600 17933 195.159.176.226 (19 Nov 2017 16:23:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 19 Nov 2017 16:23:20 +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 Sun Nov 19 17:23:15 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 1eGSNA-0003xc-6s for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 Nov 2017 17:23:08 +0100 Original-Received: from localhost ([::1]:53553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGSNH-0000Lg-J2 for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 Nov 2017 11:23:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGSN8-0000La-6B for bug-gnu-emacs@gnu.org; Sun, 19 Nov 2017 11:23:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGSN4-000347-QW for bug-gnu-emacs@gnu.org; Sun, 19 Nov 2017 11:23:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39025) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eGSN4-00033v-CA for bug-gnu-emacs@gnu.org; Sun, 19 Nov 2017 11:23:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eGSN4-00044s-5a for bug-gnu-emacs@gnu.org; Sun, 19 Nov 2017 11:23: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: Sun, 19 Nov 2017 16:23: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.151110856815639 (code B ref 29272); Sun, 19 Nov 2017 16:23:02 +0000 Original-Received: (at 29272) by debbugs.gnu.org; 19 Nov 2017 16:22:48 +0000 Original-Received: from localhost ([127.0.0.1]:47706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eGSMo-000449-6B for submit@debbugs.gnu.org; Sun, 19 Nov 2017 11:22:48 -0500 Original-Received: from ocolin.muc.de ([193.149.48.4]:15858 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1eGSMm-000441-S5 for 29272@debbugs.gnu.org; Sun, 19 Nov 2017 11:22:45 -0500 Original-Received: (qmail 67421 invoked by uid 3782); 19 Nov 2017 16:22:41 -0000 Original-Received: from acm.muc.de (p548C7514.dip0.t-ipconnect.de [84.140.117.20]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 19 Nov 2017 17:22:40 +0100 Original-Received: (qmail 10004 invoked by uid 1000); 19 Nov 2017 16:19:43 -0000 Content-Disposition: inline In-Reply-To: <83r2svg72w.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:140098 Archived-At: Hello, Eli. On Sat, Nov 18, 2017 at 13:27:35 +0200, Eli Zaretskii wrote: > > Date: Tue, 14 Nov 2017 20:54:49 +0000 > > Cc: 29272@debbugs.gnu.org > > From: Alan Mackenzie > > 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: > Thanks, this seems to fix the problem. I take it that you've verified > it doesn't re-introduce the original bug? > > 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 only see this in a text-mode frame (in my case it's " > "). On GUI frame, there's no "translation". Not on an X-Windows frame - X seems to handle all the mouse-movement and intermediate click events itself. On a linux tty with GPM, you do indeed see these intermediate events. > > . 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. > I think you are right, as I see the same problem in Emacs 24.5. > In any case, this is a much more minor bug than the one I reported, so > please install your changes on the release branch. Bonus points if > you can find where does the "translation" come from. I claim my prize. :-) The following patch (which absolutely requires the patch to bug #29349 "read_key_sequence is only partially recursive. This is a bug." to work) fixes the above glitch on Linux tty (and possibly on other platforms). It works by disregarding the "intermediate" events in UNTRANSLATED when comparing the processed key sequence with the UNTRANSLATED string of events: diff --git a/lisp/help.el b/lisp/help.el index 212e3679da..f5192e1902 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -583,14 +583,66 @@ where-is (princ string))))) nil) +(defun help--equivalent-sequence-p (key untranslated) + "Is KEY a (possibly translated) version of UNTRANSLATED? +If so return t, otherwise return nil. + +KEY is a key sequence, either a string or a vector. UNTRANSLATED +is a vector of events which gave rise to KEY, typically the output from +`this-single-command-raw-keys'. + +The idea here is that for menu structure key sequences, +UNTRANSLATED in certain environments contains things like + and intermediate mouse button presses. These +will be disregarded in the comparison between KEY and +UNTRANSLATED." + (let* ((len-key (length key)) + (len-unt (length untranslated)) + (key-idx 0) + (unt-idx 0) + key-elt unt-elt mods) + (cond + ((and (stringp key) + (eq len-key len-unt)) + (while (and (< key-idx len-key) + (eq (aref key key-idx) + (aref untranslated key-idx))) + (setq key-idx (1+ key-idx))) + (eq key-idx len-key)) + ((vectorp key) + ;; In this while go round one elt of `key' each time round + (while + (and (< key-idx len-key) + (< unt-idx len-unt) + (progn + (setq key-elt (aref key key-idx)) + ;; In this while, skip an intermediate mouse click, etc. + ;; from `untranslated' each time round. + (while + (and + (< unt-idx len-unt) + (progn + (setq unt-elt (aref untranslated unt-idx)) + (not (eq unt-elt key-elt))) + (progn + (setq mods (event-modifiers unt-elt)) + (or (eq (car-safe unt-elt) 'mouse-movement) + (cl-intersection '(click double triple drag down) + mods)))) + (setq unt-idx (1+ unt-idx))) + (eq unt-elt key-elt))) + (setq key-idx (1+ key-idx) + unt-idx (1+ unt-idx))) + (eq key-idx len-key))))) + (defun help-key-description (key untranslated) (let ((string (key-description key))) (if (or (not untranslated) (and (eq (aref untranslated 0) ?\e) (not (eq (aref key 0) ?\e)))) string - (let ((otherstring (key-description untranslated))) - (if (equal string otherstring) - string + (if (help--equivalent-sequence-p key untranslated) + string + (let ((otherstring (key-description untranslated))) (format "%s (translated from %s)" string otherstring)))))) (defun help--analyze-key (key untranslated) > Thanks. -- Alan Mackenzie (Nuremberg, Germany).