]> git.eshelyaron.com Git - emacs.git/commitdiff
* macmenu.c (cleanup_popup_menu): New function.
authorJan Djärv <jan.h.d@swipnet.se>
Sat, 4 Jun 2005 08:06:57 +0000 (08:06 +0000)
committerJan Djärv <jan.h.d@swipnet.se>
Sat, 4 Jun 2005 08:06:57 +0000 (08:06 +0000)
(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).

src/ChangeLog
src/macmenu.c

index 5f724fe8450ef9eb57a3ebe04a2452965c1252cc..36650215350cc18d9021120364689d8f56755e9e 100644 (file)
@@ -1,3 +1,11 @@
+2005-06-04  Jan Dj\e,Ad\e(Brv  <jan.h.d@swipnet.se>
+
+       * 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  <storm@cua.dk>
 
        * coding.c (decode_coding_string): Handle CODING_FINISH_INTERRUPT.
index 54393bca59497e39e511383e7a077a3cc7a228f8..e97a968d92ddedd761b9255ec93d7a7ca09e9e18 100644 (file)
@@ -602,6 +602,13 @@ list_of_items (pane)
     }
 }
 \f
+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 @@ cached information about equivalent key sequences.  */)
   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 @@ cached information about equivalent key sequences.  */)
 
 #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 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
            }
        }
     }
+  else if (!for_click)
+    /* Make "Cancel" equivalent to C-g.  */
+    Fsignal (Qquit, Qnil);
 
   return Qnil;
 }