aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorEli Zaretskii2015-10-24 10:03:07 +0300
committerEli Zaretskii2015-10-24 10:03:07 +0300
commitbc0b340d5532bc13988b8cc637690764f1d6c6f0 (patch)
tree8faaab99fe027d4ecb22e961e74b5f744318d611 /src/buffer.c
parent972493658b13265a8d2dd59aa55cad59f05e5d77 (diff)
downloademacs-bc0b340d5532bc13988b8cc637690764f1d6c6f0.tar.gz
emacs-bc0b340d5532bc13988b8cc637690764f1d6c6f0.zip
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.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c52
1 files changed, 41 insertions, 11 deletions
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)
1611 } 1611 }
1612} 1612}
1613 1613
1614/* Set the global update_mode_lines variable non-zero if the buffer
1615 was displayed in some window. This is needed to catch the
1616 attention of redisplay to changes that might require redisplay of
1617 the frame title (which uses the same variables as mode lines) when
1618 the buffer object cannot be used for recording that fact, e.g. if
1619 the buffer is killed. */
1620static void
1621set_update_modelines_for_buf (bool disp)
1622{
1623 if (disp)
1624 update_mode_lines = 42;
1625}
1626
1614DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ", 1627DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ",
1615 doc: /* Kill the buffer specified by BUFFER-OR-NAME. 1628 doc: /* Kill the buffer specified by BUFFER-OR-NAME.
1616The argument may be a buffer or the name of an existing buffer. 1629The 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. */)
1633 struct buffer *b; 1646 struct buffer *b;
1634 Lisp_Object tem; 1647 Lisp_Object tem;
1635 struct Lisp_Marker *m; 1648 struct Lisp_Marker *m;
1649 bool buffer_was_displayed = false;
1636 1650
1637 if (NILP (buffer_or_name)) 1651 if (NILP (buffer_or_name))
1638 buffer = Fcurrent_buffer (); 1652 buffer = Fcurrent_buffer ();
@@ -1647,6 +1661,8 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1647 if (!BUFFER_LIVE_P (b)) 1661 if (!BUFFER_LIVE_P (b))
1648 return Qnil; 1662 return Qnil;
1649 1663
1664 buffer_was_displayed = buffer_window_count (b);
1665
1650 /* Run hooks with the buffer to be killed the current buffer. */ 1666 /* Run hooks with the buffer to be killed the current buffer. */
1651 { 1667 {
1652 ptrdiff_t count = SPECPDL_INDEX (); 1668 ptrdiff_t count = SPECPDL_INDEX ();
@@ -1673,7 +1689,10 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1673 1689
1674 /* If the hooks have killed the buffer, exit now. */ 1690 /* If the hooks have killed the buffer, exit now. */
1675 if (!BUFFER_LIVE_P (b)) 1691 if (!BUFFER_LIVE_P (b))
1676 return unbind_to (count, Qt); 1692 {
1693 set_update_modelines_for_buf (buffer_was_displayed);
1694 return unbind_to (count, Qt);
1695 }
1677 1696
1678 /* Then run the hooks. */ 1697 /* Then run the hooks. */
1679 run_hook (Qkill_buffer_hook); 1698 run_hook (Qkill_buffer_hook);
@@ -1682,7 +1701,10 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1682 1701
1683 /* If the hooks have killed the buffer, exit now. */ 1702 /* If the hooks have killed the buffer, exit now. */
1684 if (!BUFFER_LIVE_P (b)) 1703 if (!BUFFER_LIVE_P (b))
1685 return Qt; 1704 {
1705 set_update_modelines_for_buf (buffer_was_displayed);
1706 return Qt;
1707 }
1686 1708
1687 /* We have no more questions to ask. Verify that it is valid 1709 /* We have no more questions to ask. Verify that it is valid
1688 to kill the buffer. This must be done after the questions 1710 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. */)
1710 1732
1711 /* Exit if we now have killed the base buffer (Bug#11665). */ 1733 /* Exit if we now have killed the base buffer (Bug#11665). */
1712 if (!BUFFER_LIVE_P (b)) 1734 if (!BUFFER_LIVE_P (b))
1713 return Qt; 1735 {
1736 set_update_modelines_for_buf (buffer_was_displayed);
1737 return Qt;
1738 }
1714 } 1739 }
1715 1740
1716 /* Run replace_buffer_in_windows before making another buffer current 1741 /* 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. */)
1721 1746
1722 /* Exit if replacing the buffer in windows has killed our buffer. */ 1747 /* Exit if replacing the buffer in windows has killed our buffer. */
1723 if (!BUFFER_LIVE_P (b)) 1748 if (!BUFFER_LIVE_P (b))
1724 return Qt; 1749 {
1750 set_update_modelines_for_buf (buffer_was_displayed);
1751 return Qt;
1752 }
1725 1753
1726 /* Make this buffer not be current. Exit if it is the sole visible 1754 /* Make this buffer not be current. Exit if it is the sole visible
1727 buffer. */ 1755 buffer. */
@@ -1747,15 +1775,13 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1747 1775
1748 kill_buffer_processes (buffer); 1776 kill_buffer_processes (buffer);
1749 1777
1750 /* Killing a buffer might have global effects which require
1751 redisplaying frames. For example, if the buffer's name appears
1752 in the frame title. */
1753 windows_or_buffers_changed = 11;
1754
1755 /* Killing buffer processes may run sentinels which may have killed 1778 /* Killing buffer processes may run sentinels which may have killed
1756 our buffer. */ 1779 our buffer. */
1757 if (!BUFFER_LIVE_P (b)) 1780 if (!BUFFER_LIVE_P (b))
1758 return Qt; 1781 {
1782 set_update_modelines_for_buf (buffer_was_displayed);
1783 return Qt;
1784 }
1759 1785
1760 /* These may run Lisp code and into infinite loops (if someone 1786 /* These may run Lisp code and into infinite loops (if someone
1761 insisted on circular lists) so allow quitting here. */ 1787 insisted on circular lists) so allow quitting here. */
@@ -1787,7 +1813,10 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1787 1813
1788 /* Deleting an auto-save file could have killed our buffer. */ 1814 /* Deleting an auto-save file could have killed our buffer. */
1789 if (!BUFFER_LIVE_P (b)) 1815 if (!BUFFER_LIVE_P (b))
1790 return Qt; 1816 {
1817 set_update_modelines_for_buf (buffer_was_displayed);
1818 return Qt;
1819 }
1791 1820
1792 if (b->base_buffer) 1821 if (b->base_buffer)
1793 { 1822 {
@@ -1886,6 +1915,7 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1886 if (!NILP (Vrun_hooks)) 1915 if (!NILP (Vrun_hooks))
1887 call1 (Vrun_hooks, Qbuffer_list_update_hook); 1916 call1 (Vrun_hooks, Qbuffer_list_update_hook);
1888 1917
1918 set_update_modelines_for_buf (buffer_was_displayed);
1889 return Qt; 1919 return Qt;
1890} 1920}
1891 1921