From: Eli Zaretskii Date: Sat, 24 Oct 2015 07:03:07 +0000 (+0300) Subject: A better fix for bug#21739 X-Git-Tag: emacs-25.0.90~1044 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bc0b340d5532bc13988b8cc637690764f1d6c6f0;p=emacs.git A better fix for bug#21739 * src/buffer.c (set_update_modelines_for_buf): New function. (Fkill_buffer): Use it to set the global variable update_mode_lines if the killed buffer was displayed in some window. Don't set windows_or_buffers_changed. This is a better fix for bug#21739 than the previous fix, since it will cause only redisplay of mode lines, not of entire windows, but will still catch attention of x_consider_frame_title in xdisp.c, which redraws the frame title. --- diff --git a/src/buffer.c b/src/buffer.c index aff80bce4c9..84768767c6b 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1611,6 +1611,19 @@ 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. @@ -1633,6 +1646,7 @@ 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 (); @@ -1647,6 +1661,8 @@ 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 (); @@ -1673,7 +1689,10 @@ 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)) - return unbind_to (count, Qt); + { + set_update_modelines_for_buf (buffer_was_displayed); + return unbind_to (count, Qt); + } /* Then run the hooks. */ run_hook (Qkill_buffer_hook); @@ -1682,7 +1701,10 @@ 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)) - return Qt; + { + set_update_modelines_for_buf (buffer_was_displayed); + 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 @@ -1710,7 +1732,10 @@ 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)) - return Qt; + { + set_update_modelines_for_buf (buffer_was_displayed); + return Qt; + } } /* Run replace_buffer_in_windows before making another buffer current @@ -1721,7 +1746,10 @@ 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)) - return Qt; + { + set_update_modelines_for_buf (buffer_was_displayed); + return Qt; + } /* Make this buffer not be current. Exit if it is the sole visible buffer. */ @@ -1747,15 +1775,13 @@ cleaning up all windows currently displaying the buffer to be killed. */) kill_buffer_processes (buffer); - /* Killing a buffer might have global effects which require - redisplaying frames. For example, if the buffer's name appears - in the frame title. */ - windows_or_buffers_changed = 11; - /* Killing buffer processes may run sentinels which may have killed our buffer. */ if (!BUFFER_LIVE_P (b)) - return Qt; + { + set_update_modelines_for_buf (buffer_was_displayed); + return Qt; + } /* These may run Lisp code and into infinite loops (if someone insisted on circular lists) so allow quitting here. */ @@ -1787,7 +1813,10 @@ 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)) - return Qt; + { + set_update_modelines_for_buf (buffer_was_displayed); + return Qt; + } if (b->base_buffer) { @@ -1886,6 +1915,7 @@ 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; }