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#29349: read_key_sequence is only partially recursive. This is a bug. Date: Sat, 18 Nov 2017 09:38:43 +0000 Message-ID: <20171118093843.GA3819@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1510998137 32199 195.159.176.226 (18 Nov 2017 09:42:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 18 Nov 2017 09:42:17 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) To: 29349@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 18 10:42:13 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 1eFzda-0007uO-A6 for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Nov 2017 10:42:10 +0100 Original-Received: from localhost ([::1]:49299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFzdh-0000BL-I6 for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Nov 2017 04:42:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFzdX-0000Au-Gl for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2017 04:42:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eFzdS-0004PL-GC for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2017 04:42:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36863) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eFzdS-0004PF-C2 for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2017 04:42:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eFzdS-00083Y-0e for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2017 04:42: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: Sat, 18 Nov 2017 09:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 29349 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.151099811430952 (code B ref -1); Sat, 18 Nov 2017 09:42:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Nov 2017 09:41:54 +0000 Original-Received: from localhost ([127.0.0.1]:45544 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFzdJ-00083A-Mm for submit@debbugs.gnu.org; Sat, 18 Nov 2017 04:41:53 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33151) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFzdI-00082y-Jv for submit@debbugs.gnu.org; Sat, 18 Nov 2017 04:41:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eFzdC-0004AN-8A for submit@debbugs.gnu.org; Sat, 18 Nov 2017 04:41:47 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:49273) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eFzdC-0004A5-4t for submit@debbugs.gnu.org; Sat, 18 Nov 2017 04:41:46 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFzdB-00008C-2G for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2017 04:41:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eFzd6-0003zC-51 for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2017 04:41:45 -0500 Original-Received: from ocolin.muc.de ([193.149.48.4]:22973 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1eFzd5-0003ui-Ps for bug-gnu-emacs@gnu.org; Sat, 18 Nov 2017 04:41:40 -0500 Original-Received: (qmail 50993 invoked by uid 3782); 18 Nov 2017 09:41:34 -0000 Original-Received: from acm.muc.de (p548C78EA.dip0.t-ipconnect.de [84.140.120.234]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 18 Nov 2017 10:41:32 +0100 Original-Received: (qmail 4504 invoked by uid 1000); 18 Nov 2017 09:38:43 -0000 Content-Disposition: inline X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:140044 Archived-At: Hello, Emacs. In branch emacs-26. I came across this bug whilst working on bug #29272 ("C-h k C-mouse-3" followed by menu selection asks for more keys). In a Linux tty using the GPM mouse package, doing read_key_sequence (the C function in keyboard.c), when a menu action is activated, read_key_sequence calls itself recursively to handle all the mouse manipulation. Unfortunately, the variable raw_keybuf_count is initialised to 0 in r_k_s. This includes in the recursive call. This variable indexes the global buffer raw_keybuf, which accumulates the raw events which make up the key sequence. The result of this is that the events in the recursive call overwrite the stored events of the outer r_k_s call, leaving a mess. r_k_s is static in keyboard.c and is called from three functions: command_loop_1, read_menu_command (the one that gives the trouble), and read_key_sequence_vs. So I propose as a solution that raw_keybuf_count be initialised to zero in two of these three functions, but not in read_menu_command (and no longer in read_key_sequence). I've tried this, and it seems to work. It has the disadvantage of being ugly, and it makes read_menu_command only callable as a subfunction of r_k_s. Has anybody any thoughts on this? ######################################################################### As a second problem, is there any way, preferably at the Lisp level, to determine that a key sequence is a menu key sequence? -- Alan Mackenzie (Nuremberg, Germany).