Subject: bug#16565: 24.3.50; x-popup-menu just returns nil

From: Eli Zaretskii <[email-masked]>
Date: Tue, 28 Jan 2014 05:47:25 +0200

> From: Michael Heerdegen <[email-masked]>
> Cc: [email-masked]
> Date: Tue, 28 Jan 2014 04:11:42 +0100
> 
> Ok, I tried to do my best to understand the C code and GUD.
> 
> If I understand correctly, this is executed for me:
> 
>     selection = xmenu_show (f, xpos, ypos, for_click,
> 			    keymaps, title, &error_name);
> 
> In the good case, SELECTION is bound to different integers, in the bad
> case, it is always the same integer, which seems to mean "nil".

If you start GDB in the src directory, or let it otherwise read the
file src/.gdbinit, you can know for sure: the "xtype" command will
tell you what kind of Lisp data is in 'selection':

  (gdb) p selection
  (gdb) xtype

If "xtype" says it's a Lisp symbol, another command "xsymbol" will
tell you what symbol is that, it will say "nil" if it is nil.

> But there is a difference in the arguments of the xmenu_show call.  In
> the bad case calling with an event:
> 
>   (x-popup-menu event (mouse-menu-bar-map))
> 
> FOR_CLICK is bound to true.  In the good case with
> 
>   (x-popup-menu t (mouse-menu-bar-map))
> 
> FOR_CLICK is bound to false.
> 
> That made me wonder what happened when I bind `foo' to a mouse-down
> event.  Then the bug doesn't happen, `foo' doesn't return nil.

In general, as long as the menu pops up, you should see the selection
made by the user.  The binding should only determine whether the menu
pops up or not, AFAIK.