From 2ec9db5d1e97275a2a4c27e04ed6f3e8c3382cab Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Wed, 6 Nov 2013 13:41:31 -0500 Subject: [PATCH] * src/xdisp.c (syms_of_xdisp): New vars redisplay--all-windows-cause and redisplay--mode-lines-cause. (redisplay_internal): Keep them uptodate. Remove redundant check of buffer_shared_and_changed. * *.[chm]: Number every assignment to update_mode_lines so we can track why it is set. --- src/ChangeLog | 9 ++++++++ src/buffer.c | 6 +++--- src/commands.h | 4 ++-- src/dosfns.c | 2 +- src/fileio.c | 2 +- src/frame.c | 4 ++-- src/keyboard.c | 4 ++-- src/macros.c | 6 +++--- src/nsfns.m | 12 +++++------ src/process.c | 4 ++-- src/w32fns.c | 4 ++-- src/window.c | 6 +++--- src/xdisp.c | 68 ++++++++++++++++++++++++++++++++++++++++++---------------- src/xfns.c | 4 ++-- 14 files changed, 87 insertions(+), 48 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 19186ea3bbf..07e27ac820c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2013-11-06 Stefan Monnier + + * xdisp.c (syms_of_xdisp): New vars redisplay--all-windows-cause and + redisplay--mode-lines-cause. + (redisplay_internal): Keep them uptodate. Remove redundant check of + buffer_shared_and_changed. + * *.[chm]: Number every assignment to update_mode_lines so we + can track why it is set. + 2013-11-06 Eli Zaretskii * editfns.c (Fformat_time_string): Doc fix. (Bug#15816) diff --git a/src/buffer.c b/src/buffer.c index 9aed1909bbd..d3288ad0429 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1393,7 +1393,7 @@ A non-nil FLAG means mark the buffer modified. */) smarter about updating the `*' in mode lines. --gerd */ if (buffer_window_count (current_buffer)) { - ++update_mode_lines; + update_mode_lines = 10; current_buffer->prevent_redisplay_optimizations_p = 1; } @@ -1513,7 +1513,7 @@ This does not change the name of the visited file (if any). */) /* Catch redisplay's attention. Unless we do this, the mode lines for any windows displaying current_buffer will stay unchanged. */ - update_mode_lines++; + update_mode_lines = 11; XSETBUFFER (buf, current_buffer); Fsetcar (Frassq (buf, Vbuffer_alist), newname); @@ -2765,7 +2765,7 @@ the normal hook `change-major-mode-hook'. */) /* Force mode-line redisplay. Useful here because all major mode commands call this function. */ - update_mode_lines++; + update_mode_lines = 12; return Qnil; } diff --git a/src/commands.h b/src/commands.h index 35c2c05fe72..b7f0049515d 100644 --- a/src/commands.h +++ b/src/commands.h @@ -36,10 +36,10 @@ extern Lisp_Object control_x_map; events until a non-ASCII event is acceptable as input. */ extern Lisp_Object unread_switch_frame; -/* Nonzero if input is coming from the keyboard */ +/* Nonzero if input is coming from the keyboard. */ #define INTERACTIVE (NILP (Vexecuting_kbd_macro) && !noninteractive) -/* Set this nonzero to force reconsideration of mode line. */ +/* Set this nonzero to force reconsideration of mode line. */ extern int update_mode_lines; diff --git a/src/dosfns.c b/src/dosfns.c index 37d3998b5ee..426da1fb41a 100644 --- a/src/dosfns.c +++ b/src/dosfns.c @@ -472,7 +472,7 @@ x_set_title (struct frame *f, Lisp_Object name) if (EQ (name, f->title)) return; - update_mode_lines = 1; + update_mode_lines = 13; fset_title (f, name); diff --git a/src/fileio.c b/src/fileio.c index d54c43c4635..d42b3811d76 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4997,7 +4997,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename, SAVE_MODIFF = MODIFF; XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG); bset_filename (current_buffer, visit_file); - update_mode_lines++; + update_mode_lines = 14; } else if (quietly) { diff --git a/src/frame.c b/src/frame.c index 05f74e4b621..4494edda5d7 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1489,7 +1489,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force) /* Cause frame titles to update--necessary if we now have just one frame. */ if (!is_tooltip_frame) - update_mode_lines = 1; + update_mode_lines = 15; return Qnil; } @@ -2025,7 +2025,7 @@ set_term_frame_name (struct frame *f, Lisp_Object name) } fset_name (f, name); - update_mode_lines = 1; + update_mode_lines = 16; } void diff --git a/src/keyboard.c b/src/keyboard.c index 81713dc5115..1231b4ca30d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -821,7 +821,7 @@ This function is called by the editor initialization to begin editing. */) return Qnil; command_loop_level++; - update_mode_lines = 1; + update_mode_lines = 17; if (command_loop_level && current_buffer != XBUFFER (XWINDOW (selected_window)->contents)) @@ -848,7 +848,7 @@ recursive_edit_unwind (Lisp_Object buffer) Fset_buffer (buffer); command_loop_level--; - update_mode_lines = 1; + update_mode_lines = 18; } diff --git a/src/macros.c b/src/macros.c index 0c11efcdc9a..232188a408b 100644 --- a/src/macros.c +++ b/src/macros.c @@ -55,7 +55,7 @@ Use \\[name-last-kbd-macro] to give it a permanent name. Non-nil arg (prefix arg) means append to last macro defined; this begins by re-executing that macro as if you typed it again. If optional second arg, NO-EXEC, is non-nil, do not re-execute last -macro before appending to it. */) +macro before appending to it. */) (Lisp_Object append, Lisp_Object no_exec) { if (!NILP (KVAR (current_kboard, defining_kbd_macro))) @@ -66,7 +66,7 @@ macro before appending to it. */) current_kboard->kbd_macro_buffer = xmalloc (30 * word_size); current_kboard->kbd_macro_bufsize = 30; } - update_mode_lines++; + update_mode_lines = 19; if (NILP (append)) { if (current_kboard->kbd_macro_bufsize > 200) @@ -138,7 +138,7 @@ void end_kbd_macro (void) { kset_defining_kbd_macro (current_kboard, Qnil); - update_mode_lines++; + update_mode_lines = 20; kset_last_kbd_macro (current_kboard, make_event_array ((current_kboard->kbd_macro_end diff --git a/src/nsfns.m b/src/nsfns.m index 7dea868e341..ee6020f2b43 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -451,8 +451,8 @@ ns_set_name_internal (struct frame *f, Lisp_Object name) str = [NSString stringWithUTF8String: SSDATA (encoded_icon_name)]; - if ([[view window] miniwindowTitle] && - ! [[[view window] miniwindowTitle] isEqualToString: str]) + if ([[view window] miniwindowTitle] + && ! [[[view window] miniwindowTitle] isEqualToString: str]) [[view window] setMiniwindowTitle: str]; } @@ -469,7 +469,7 @@ ns_set_name (struct frame *f, Lisp_Object name, int explicit) /* If we're switching from explicit to implicit, we had better update the mode lines and thereby update the title. */ if (f->explicit_name && NILP (name)) - update_mode_lines = 1; + update_mode_lines = 21; f->explicit_name = ! NILP (name); } @@ -477,7 +477,7 @@ ns_set_name (struct frame *f, Lisp_Object name, int explicit) return; if (NILP (name)) - name = build_string([ns_app_name UTF8String]); + name = build_string ([ns_app_name UTF8String]); else CHECK_STRING (name); @@ -487,7 +487,7 @@ ns_set_name (struct frame *f, Lisp_Object name, int explicit) fset_name (f, name); - /* title overrides explicit name */ + /* Title overrides explicit name. */ if (! NILP (f->title)) name = f->title; @@ -534,7 +534,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) if (EQ (name, f->title)) return; - update_mode_lines = 1; + update_mode_lines = 22; fset_title (f, name); diff --git a/src/process.c b/src/process.c index c0c522a1403..307eab3ab30 100644 --- a/src/process.c +++ b/src/process.c @@ -5246,7 +5246,7 @@ DEFUN ("internal-default-process-filter", Finternal_default_process_filter, else set_marker_both (p->mark, p->buffer, PT, PT_BYTE); - update_mode_lines++; + update_mode_lines = 23; /* Make sure opoint and the old restrictions float ahead of any new text just as point would. */ @@ -6390,7 +6390,7 @@ status_notify (struct Lisp_Process *deleting_process) } } /* end for */ - update_mode_lines++; /* In case buffers use %s in mode-line-format. */ + update_mode_lines = 24; /* In case buffers use %s in mode-line-format. */ UNGCPRO; } diff --git a/src/w32fns.c b/src/w32fns.c index 84a504e84c2..403a7ba0d6a 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -1740,7 +1740,7 @@ x_set_name (struct frame *f, Lisp_Object name, int explicit) /* If we're switching from explicit to implicit, we had better update the mode lines and thereby update the title. */ if (f->explicit_name && NILP (name)) - update_mode_lines = 1; + update_mode_lines = 25; f->explicit_name = ! NILP (name); } @@ -1808,7 +1808,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) if (EQ (name, f->title)) return; - update_mode_lines = 1; + update_mode_lines = 26; fset_title (f, name); diff --git a/src/window.c b/src/window.c index ac6bac42800..bc0adaf459f 100644 --- a/src/window.c +++ b/src/window.c @@ -2639,7 +2639,7 @@ window_loop (enum window_loop type, Lisp_Object obj, int mini, Lisp_Object frame mark_window_display_accurate (window, 0); w->update_mode_line = 1; XBUFFER (obj)->prevent_redisplay_optimizations_p = 1; - ++update_mode_lines; + update_mode_lines = 27; best_window = window; } break; @@ -3279,7 +3279,7 @@ displaying that buffer. */) if (NILP (object)) { windows_or_buffers_changed = 29; - update_mode_lines++; + update_mode_lines = 28; return Qt; } @@ -3290,7 +3290,7 @@ displaying that buffer. */) w->update_mode_line = 1; if (BUFFERP (w->contents)) XBUFFER (w->contents)->prevent_redisplay_optimizations_p = 1; - ++update_mode_lines; + update_mode_lines = 29; return Qt; } diff --git a/src/xdisp.c b/src/xdisp.c index 0ec1bd2cea9..b1251aad511 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -10337,7 +10337,7 @@ resize_echo_area_exactly (void) if (resized_p) { windows_or_buffers_changed = 42; - ++update_mode_lines; + update_mode_lines = 30; redisplay_internal (); } } @@ -12886,12 +12886,12 @@ redisplay_internal (void) int polling_stopped_here = 0; Lisp_Object tail, frame; - /* Non-zero means redisplay has to consider all windows on all - frames. Zero means, only selected_window is considered. */ - int consider_all_windows_p; + /* True means redisplay has to consider all windows on all + frames. False, only selected_window is considered. */ + bool consider_all_windows_p; - /* Non-zero means redisplay has to redisplay the miniwindow. */ - int update_miniwindow_p = 0; + /* True means redisplay has to redisplay the miniwindow. */ + bool update_miniwindow_p = false; TRACE ((stderr, "redisplay_internal %d\n", redisplaying_p)); @@ -12984,7 +12984,7 @@ redisplay_internal (void) /* If cursor type has been changed on the frame other than selected, consider all frames. */ if (f != sf && f->cursor_type_changed) - update_mode_lines++; + update_mode_lines = 31; } clear_desired_matrices (f); } @@ -13004,8 +13004,8 @@ redisplay_internal (void) if (NILP (Vmemory_full)) prepare_menu_bars (); - if (windows_or_buffers_changed) - update_mode_lines++; + if (windows_or_buffers_changed & !update_mode_lines) + update_mode_lines = 32; reconsider_clip_changes (w); @@ -13018,7 +13018,7 @@ redisplay_internal (void) { w->update_mode_line = 1; if (buffer_shared_and_changed ()) - update_mode_lines++; + update_mode_lines = 33; } if (mode_line_update_needed (w)) @@ -13031,7 +13031,10 @@ redisplay_internal (void) /* If specs for an arrow have changed, do thorough redisplay to ensure we remove any arrow that should no longer exist. */ if (overlay_arrows_changed_p ()) - consider_all_windows_p = windows_or_buffers_changed = 49; + { + consider_all_windows_p = true; + windows_or_buffers_changed = 49; + } /* Normally the message* functions will have already displayed and updated the echo area, but the frame may have been trashed, or @@ -13049,7 +13052,7 @@ redisplay_internal (void) int window_height_changed_p = echo_area_display (0); if (message_cleared_p) - update_miniwindow_p = 1; + update_miniwindow_p = true; must_finish = 1; @@ -13062,8 +13065,8 @@ redisplay_internal (void) if (window_height_changed_p) { - consider_all_windows_p = 1; - ++update_mode_lines; + consider_all_windows_p = true; + update_mode_lines = 34; windows_or_buffers_changed = 50; /* If window configuration was changed, frames may have been @@ -13083,9 +13086,9 @@ redisplay_internal (void) since only the current frame needs to be considered. This function needs to be rewritten with two variables, consider_all_windows and consider_all_frames. */ - consider_all_windows_p = 1; + consider_all_windows_p = true; windows_or_buffers_changed = 51; - ++update_mode_lines; + update_mode_lines = 35; /* If window configuration was changed, frames may have been marked garbaged. Clear them or we will experience @@ -13093,6 +13096,24 @@ redisplay_internal (void) clear_garbaged_frames (); } + if (VECTORP (Vredisplay__all_windows_cause) + && windows_or_buffers_changed >= 0 + && windows_or_buffers_changed < ASIZE (Vredisplay__all_windows_cause) + && INTEGERP (AREF (Vredisplay__all_windows_cause, + windows_or_buffers_changed))) + ASET (Vredisplay__all_windows_cause, windows_or_buffers_changed, + make_number (1 + XINT (AREF (Vredisplay__all_windows_cause, + windows_or_buffers_changed)))); + + if (VECTORP (Vredisplay__mode_lines_cause) + && update_mode_lines >= 0 + && update_mode_lines < ASIZE (Vredisplay__mode_lines_cause) + && INTEGERP (AREF (Vredisplay__mode_lines_cause, + update_mode_lines))) + ASET (Vredisplay__mode_lines_cause, update_mode_lines, + make_number (1 + XINT (AREF (Vredisplay__mode_lines_cause, + update_mode_lines)))); + /* Optimize the case that only the line containing the cursor in the selected window has changed. Variables starting with this_ are set in display_line and record information about the line @@ -13294,7 +13315,6 @@ redisplay_internal (void) } CHARPOS (this_line_start_pos) = 0; - consider_all_windows_p |= buffer_shared_and_changed (); ++clear_face_cache_count; #ifdef HAVE_WINDOW_SYSTEM ++clear_image_cache_count; @@ -13473,7 +13493,7 @@ redisplay_internal (void) matrices of some windows are not valid. */ if (!WINDOW_FULL_WIDTH_P (w) && !FRAME_WINDOW_P (XFRAME (w->frame))) - update_mode_lines = 1; + update_mode_lines = 36; } else { @@ -15337,7 +15357,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) } else if ((w != XWINDOW (minibuf_window) || minibuf_level == 0) - /* When buffer is nonempty, redisplay window normally. */ + /* When buffer is nonempty, redisplay window normally. */ && BUF_Z (XBUFFER (w->contents)) == BUF_BEG (XBUFFER (w->contents)) /* Quail displays non-mini buffers in minibuffer window. In that case, redisplay the window normally. */ @@ -29735,6 +29755,16 @@ display table takes effect; in this case, Emacs does not consult DEFVAR_LISP ("debug-on-message", Vdebug_on_message, doc: /* If non-nil, debug if a message matching this regexp is displayed. */); Vdebug_on_message = Qnil; + + DEFVAR_LISP ("redisplay--all-windows-cause", Vredisplay__all_windows_cause, + doc: /* */); + Vredisplay__all_windows_cause + = Fmake_vector (make_number (100), make_number (0)); + + DEFVAR_LISP ("redisplay--mode-lines-cause", Vredisplay__mode_lines_cause, + doc: /* */); + Vredisplay__mode_lines_cause + = Fmake_vector (make_number (100), make_number (0)); } diff --git a/src/xfns.c b/src/xfns.c index 624c16fe0fb..42e7c2eeec5 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -1383,7 +1383,7 @@ x_set_name (struct frame *f, Lisp_Object name, int explicit) /* If we're switching from explicit to implicit, we had better update the mode lines and thereby update the title. */ if (f->explicit_name && NILP (name)) - update_mode_lines = 1; + update_mode_lines = 37; f->explicit_name = ! NILP (name); } @@ -1445,7 +1445,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name) if (EQ (name, f->title)) return; - update_mode_lines = 1; + update_mode_lines = 38; fset_title (f, name); -- 2.11.4.GIT