bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#29349: [Patch] Bug 29349: read_key_sequence is only partially recurs


From: Alan Mackenzie
Subject: bug#29349: [Patch] Bug 29349: read_key_sequence is only partially recursive. This is a bug.
Date: Sun, 19 Nov 2017 17:45:22 +0000
User-agent: Mutt/1.7.2 (2016-11-26)

Hello, Eli.

On Sun, Nov 19, 2017 at 19:01:09 +0200, Eli Zaretskii wrote:
> > Date: Sun, 19 Nov 2017 15:59:08 +0000
> > From: Alan Mackenzie <acm@muc.de>

> > > > 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?

> > > Here is how I propose to solve this:

> Can you please show a recipe where the current code misbehaves?  I've
> re-read the thread, and found myself confused wrt the practical
> implications of the problem you describe.

In the emacs-26 branch, in a Linux tty with GPM configured and working,
type:

    C-h c  C-mouse-3 mouse-1 mouse-1

, without moving the mouse.  This will end up clicking on
"emacs-tutorial".  The message printed in the message area is then:

    <C-down-mouse-3> <help-menu> <emacs-tutorial> (translated from
    <mouse-1> <emacs-tutorial>) at that spot runs the command
    help-with-tutorial

.  In the "translated from <mouse-1> <emacs-tutorial>", the first event,
C-mouse-3 has been overwritten by mouse-1.  This mouse-1 is a mouse-click
from the menu processing.  `describe-key-briefly' can then do nothing
other than printing a spurious "translated from" message.

With the patch applied, the C-down-mouse-3 survives in the raw key
buffer, enabling `describe-key-briefly' to do the Right Thing.  It does
this by collecting the menu processing's mouse events in a separate
buffer, then copying that buffer to the main one afterwards.

> Thanks.

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]