# HG changeset patch # User Jan Dj¸«£rv # Date 1117872417 0 # Node ID 3ca414a251030a0eb52b4b8452958a69387796dc # Parent 5378f1ac43f4279dfbd36cf1071968d493810aac * macmenu.c (cleanup_popup_menu): New function. (Fx_popup_menu): unwind protect cleanup_popup_menu in case mac_menu_show Quit:s. (mac_menu_show): Quit on cancel if not popped up on click (i.e. a dialog). diff -r 5378f1ac43f4 -r 3ca414a25103 src/ChangeLog --- a/src/ChangeLog Fri Jun 03 23:48:21 2005 +0000 +++ b/src/ChangeLog Sat Jun 04 08:06:57 2005 +0000 @@ -1,3 +1,11 @@ +2005-06-04 Jan Dj,Ad(Brv + + * macmenu.c (cleanup_popup_menu): New function. + (Fx_popup_menu): unwind protect cleanup_popup_menu in case + mac_menu_show Quit:s. + (mac_menu_show): Quit on cancel if not popped up on click (i.e. + a dialog). + 2005-06-04 Kim F. Storm * coding.c (decode_coding_string): Handle CODING_FINISH_INTERRUPT. diff -r 5378f1ac43f4 -r 3ca414a25103 src/macmenu.c --- a/src/macmenu.c Fri Jun 03 23:48:21 2005 +0000 +++ b/src/macmenu.c Sat Jun 04 08:06:57 2005 +0000 @@ -602,6 +602,13 @@ } } +static Lisp_Object +cleanup_popup_menu (arg) + Lisp_Object arg; +{ + discard_menu_items (); +} + DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, doc: /* Pop up a deck-of-cards menu and return user's selection. POSITION is a position specification. This is either a mouse button @@ -647,6 +654,8 @@ int keymaps = 0; int for_click = 0; struct gcpro gcpro1; + int specpdl_count = SPECPDL_INDEX (); + #ifdef HAVE_MENUS if (! NILP (position)) @@ -806,13 +815,13 @@ #ifdef HAVE_MENUS /* Display them in a menu. */ + record_unwind_protect (cleanup_popup_menu, Qnil); BLOCK_INPUT; selection = mac_menu_show (f, xpos, ypos, for_click, keymaps, title, &error_name); UNBLOCK_INPUT; - - discard_menu_items (); + unbind_to (specpdl_count, Qnil); UNGCPRO; #endif /* HAVE_MENUS */ @@ -1931,6 +1940,9 @@ } } } + else if (!for_click) + /* Make "Cancel" equivalent to C-g. */ + Fsignal (Qquit, Qnil); return Qnil; }