From 7a6968b45f2b93d984c5c3fcd5fce68d6e5b6ea9 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 24 Oct 2015 17:58:34 +0300 Subject: [PATCH] An even better fix for bug#21739 * src/window.c (set_window_buffer): If the window is the frame's selected window, set update_mode_lines, not the window's update_mode_line flag. (Bug#21739) * src/buffer.c (Fkill_buffer): Undo last change. (set_update_modelines_for_buf): Function deleted. --- src/buffer.c | 47 ++++++----------------------------------------- src/window.c | 9 ++++++++- 2 files changed, 14 insertions(+), 42 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 84768767c6b..380a7af33c1 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1611,19 +1611,6 @@ compact_buffer (struct buffer *buffer) } } -/* Set the global update_mode_lines variable non-zero if the buffer - was displayed in some window. This is needed to catch the - attention of redisplay to changes that might require redisplay of - the frame title (which uses the same variables as mode lines) when - the buffer object cannot be used for recording that fact, e.g. if - the buffer is killed. */ -static void -set_update_modelines_for_buf (bool disp) -{ - if (disp) - update_mode_lines = 42; -} - DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ", doc: /* Kill the buffer specified by BUFFER-OR-NAME. The argument may be a buffer or the name of an existing buffer. @@ -1646,7 +1633,6 @@ cleaning up all windows currently displaying the buffer to be killed. */) struct buffer *b; Lisp_Object tem; struct Lisp_Marker *m; - bool buffer_was_displayed = false; if (NILP (buffer_or_name)) buffer = Fcurrent_buffer (); @@ -1661,8 +1647,6 @@ cleaning up all windows currently displaying the buffer to be killed. */) if (!BUFFER_LIVE_P (b)) return Qnil; - buffer_was_displayed = buffer_window_count (b); - /* Run hooks with the buffer to be killed the current buffer. */ { ptrdiff_t count = SPECPDL_INDEX (); @@ -1689,10 +1673,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) /* If the hooks have killed the buffer, exit now. */ if (!BUFFER_LIVE_P (b)) - { - set_update_modelines_for_buf (buffer_was_displayed); - return unbind_to (count, Qt); - } + return unbind_to (count, Qt); /* Then run the hooks. */ run_hook (Qkill_buffer_hook); @@ -1701,10 +1682,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) /* If the hooks have killed the buffer, exit now. */ if (!BUFFER_LIVE_P (b)) - { - set_update_modelines_for_buf (buffer_was_displayed); - return Qt; - } + return Qt; /* We have no more questions to ask. Verify that it is valid to kill the buffer. This must be done after the questions @@ -1732,10 +1710,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) /* Exit if we now have killed the base buffer (Bug#11665). */ if (!BUFFER_LIVE_P (b)) - { - set_update_modelines_for_buf (buffer_was_displayed); - return Qt; - } + return Qt; } /* Run replace_buffer_in_windows before making another buffer current @@ -1746,10 +1721,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) /* Exit if replacing the buffer in windows has killed our buffer. */ if (!BUFFER_LIVE_P (b)) - { - set_update_modelines_for_buf (buffer_was_displayed); - return Qt; - } + return Qt; /* Make this buffer not be current. Exit if it is the sole visible buffer. */ @@ -1778,10 +1750,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) /* Killing buffer processes may run sentinels which may have killed our buffer. */ if (!BUFFER_LIVE_P (b)) - { - set_update_modelines_for_buf (buffer_was_displayed); - return Qt; - } + return Qt; /* These may run Lisp code and into infinite loops (if someone insisted on circular lists) so allow quitting here. */ @@ -1813,10 +1782,7 @@ cleaning up all windows currently displaying the buffer to be killed. */) /* Deleting an auto-save file could have killed our buffer. */ if (!BUFFER_LIVE_P (b)) - { - set_update_modelines_for_buf (buffer_was_displayed); - return Qt; - } + return Qt; if (b->base_buffer) { @@ -1915,7 +1881,6 @@ cleaning up all windows currently displaying the buffer to be killed. */) if (!NILP (Vrun_hooks)) call1 (Vrun_hooks, Qbuffer_list_update_hook); - set_update_modelines_for_buf (buffer_was_displayed); return Qt; } diff --git a/src/window.c b/src/window.c index 8ed0f32a694..a8605ee628c 100644 --- a/src/window.c +++ b/src/window.c @@ -3271,7 +3271,14 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, /* Maybe we could move this into the `if' but it's not obviously safe and I doubt it's worth the trouble. */ wset_redisplay (w); - w->update_mode_line = true; + /* If this window is the selected window on its frame, set the + global variable update_mode_lines, so that x_consider_frame_title + will consider this frame's title for rtedisplay. */ + Lisp_Object fselected_window = XFRAME (WINDOW_FRAME (w))->selected_window; + if (WINDOWP (fselected_window) && XWINDOW (fselected_window) == w) + update_mode_lines = 42; + else + w->update_mode_line = true; /* We must select BUFFER to run the window-scroll-functions and to look up the buffer-local value of Vwindow_point_insertion_type. */ -- 2.39.5