Commit a2725ab2 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(prepare_menu_bars): Save and restore the match data.

(update_menu_bar): New arg save_match_data.
Maybe save and restore match data here.
parent d8e54b47
...@@ -153,7 +153,6 @@ static void echo_area_display (); ...@@ -153,7 +153,6 @@ static void echo_area_display ();
void mark_window_display_accurate (); void mark_window_display_accurate ();
static void redisplay_windows (); static void redisplay_windows ();
static void redisplay_window (); static void redisplay_window ();
static void update_menu_bars ();
static void update_menu_bar (); static void update_menu_bar ();
static void try_window (); static void try_window ();
static int try_window_id (); static int try_window_id ();
...@@ -667,6 +666,9 @@ prepare_menu_bars () ...@@ -667,6 +666,9 @@ prepare_menu_bars ()
if (all_windows) if (all_windows)
{ {
Lisp_Object tail, frame; Lisp_Object tail, frame;
int count = specpdl_ptr - specpdl;
record_unwind_protect (Fstore_match_data, Fmatch_data ());
FOR_EACH_FRAME (tail, frame) FOR_EACH_FRAME (tail, frame)
{ {
...@@ -687,12 +689,14 @@ prepare_menu_bars () ...@@ -687,12 +689,14 @@ prepare_menu_bars ()
UNGCPRO; UNGCPRO;
} }
GCPRO1 (tail); GCPRO1 (tail);
update_menu_bar (XFRAME (frame)); update_menu_bar (XFRAME (frame), 0);
UNGCPRO; UNGCPRO;
} }
unbind_to (count, Qnil);
} }
else else
update_menu_bar (selected_frame); update_menu_bar (selected_frame, 1);
/* Update all frame titles based on their buffer names, etc. /* Update all frame titles based on their buffer names, etc.
We do this after the menu bars so that the frame will first We do this after the menu bars so that the frame will first
...@@ -1181,15 +1185,19 @@ mark_window_display_accurate (window, flag) ...@@ -1181,15 +1185,19 @@ mark_window_display_accurate (window, flag)
/* Update the menu bar item list for frame F. /* Update the menu bar item list for frame F.
This has to be done before we start to fill in any display lines, 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 static void
update_menu_bar (f) update_menu_bar (f, save_match_data)
FRAME_PTR f; FRAME_PTR f;
int save_match_data;
{ {
struct buffer *old = current_buffer; struct buffer *old = current_buffer;
Lisp_Object window; Lisp_Object window;
register struct window *w; register struct window *w;
window = FRAME_SELECTED_WINDOW (f); window = FRAME_SELECTED_WINDOW (f);
w = XWINDOW (window); w = XWINDOW (window);
...@@ -1218,6 +1226,11 @@ update_menu_bar (f) ...@@ -1218,6 +1226,11 @@ update_menu_bar (f)
<= BUF_SAVE_MODIFF (XBUFFER (w->buffer))))) <= BUF_SAVE_MODIFF (XBUFFER (w->buffer)))))
{ {
struct buffer *prev = current_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); call1 (Vrun_hooks, Qmenu_bar_update_hook);
current_buffer = XBUFFER (w->buffer); current_buffer = XBUFFER (w->buffer);
FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
...@@ -1225,6 +1238,8 @@ update_menu_bar (f) ...@@ -1225,6 +1238,8 @@ update_menu_bar (f)
#ifdef USE_X_TOOLKIT #ifdef USE_X_TOOLKIT
set_frame_menubar (f, 0); set_frame_menubar (f, 0);
#endif /* USE_X_TOOLKIT */ #endif /* USE_X_TOOLKIT */
unbind_to (count, Qnil);
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment