changeset 11761:d110042c1d95

(prepare_menu_bars): Save and restore the match data. (update_menu_bar): New arg save_match_data. Maybe save and restore match data here.
author Richard M. Stallman <rms@gnu.org>
date Tue, 09 May 1995 00:30:26 +0000
parents 898ec89f5379
children 329197fc1477
files src/xdisp.c
diffstat 1 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Mon May 08 23:53:13 1995 +0000
+++ b/src/xdisp.c	Tue May 09 00:30:26 1995 +0000
@@ -153,7 +153,6 @@
 void mark_window_display_accurate ();
 static void redisplay_windows ();
 static void redisplay_window ();
-static void update_menu_bars ();
 static void update_menu_bar ();
 static void try_window ();
 static int try_window_id ();
@@ -667,6 +666,9 @@
   if (all_windows)
     {
       Lisp_Object tail, frame;
+      int count = specpdl_ptr - specpdl;
+
+      record_unwind_protect (Fstore_match_data, Fmatch_data ());
 
       FOR_EACH_FRAME (tail, frame)
 	{
@@ -687,12 +689,14 @@
 	      UNGCPRO;
 	    }
 	  GCPRO1 (tail);
-	  update_menu_bar (XFRAME (frame));
+	  update_menu_bar (XFRAME (frame), 0);
 	  UNGCPRO;
 	}
+
+      unbind_to (count, Qnil);
     }
   else
-    update_menu_bar (selected_frame);
+    update_menu_bar (selected_frame, 1);
 
   /* Update all frame titles based on their buffer names, etc.
      We do this after the menu bars so that the frame will first
@@ -1181,15 +1185,19 @@
 
 /* Update the menu bar item list for frame F.
    This has to be done before we start to fill in any display lines,
-   because it can call eval.  */
+   because it can call eval.
+
+   If SAVE_MATCH_DATA is 1, we must save and restore it here.  */
 
 static void
-update_menu_bar (f)
+update_menu_bar (f, save_match_data)
      FRAME_PTR f;
+     int save_match_data;
 {
   struct buffer *old = current_buffer;
   Lisp_Object window;
   register struct window *w;
+
   window = FRAME_SELECTED_WINDOW (f);
   w = XWINDOW (window);
   
@@ -1218,6 +1226,11 @@
 		  <= BUF_SAVE_MODIFF (XBUFFER (w->buffer)))))
 	{
 	  struct buffer *prev = current_buffer;
+	  int count = specpdl_ptr - specpdl;
+
+	  if (!save_match_data)
+	    record_unwind_protect (Fstore_match_data, Fmatch_data ());
+
 	  call1 (Vrun_hooks, Qmenu_bar_update_hook);
 	  current_buffer = XBUFFER (w->buffer);
 	  FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
@@ -1225,6 +1238,8 @@
 #ifdef USE_X_TOOLKIT
 	  set_frame_menubar (f, 0);
 #endif /* USE_X_TOOLKIT */
+
+	  unbind_to (count, Qnil);
 	}
     }
 }