aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 6e2191dc22f..748422df73a 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -547,6 +547,8 @@ even if it is dead. The return value is never nil. */)
547 b->base_buffer = NULL; 547 b->base_buffer = NULL;
548 /* No one shares the text with us now. */ 548 /* No one shares the text with us now. */
549 b->indirections = 0; 549 b->indirections = 0;
550 /* No one shows us now. */
551 b->window_count = 0;
550 552
551 BUF_GAP_SIZE (b) = 20; 553 BUF_GAP_SIZE (b) = 20;
552 block_input (); 554 block_input ();
@@ -794,6 +796,8 @@ CLONE nil means the indirect buffer's state is reset to default values. */)
794 b->indirections = -1; 796 b->indirections = -1;
795 /* Notify base buffer that we share the text now. */ 797 /* Notify base buffer that we share the text now. */
796 b->base_buffer->indirections++; 798 b->base_buffer->indirections++;
799 /* Always -1 for an indirect buffer. */
800 b->window_count = -1;
797 801
798 b->pt = b->base_buffer->pt; 802 b->pt = b->base_buffer->pt;
799 b->begv = b->base_buffer->begv; 803 b->begv = b->base_buffer->begv;
@@ -1929,10 +1933,16 @@ cleaning up all windows currently displaying the buffer to be killed. */)
1929 eassert (b->indirections == -1); 1933 eassert (b->indirections == -1);
1930 b->base_buffer->indirections--; 1934 b->base_buffer->indirections--;
1931 eassert (b->base_buffer->indirections >= 0); 1935 eassert (b->base_buffer->indirections >= 0);
1936 /* Make sure that we wasn't confused. */
1937 eassert (b->window_count == -1);
1932 } 1938 }
1933 else 1939 else
1934 /* No one shares our buffer text, can free it. */ 1940 {
1935 free_buffer_text (b); 1941 /* Make sure that no one shows us. */
1942 eassert (b->window_count == 0);
1943 /* No one shares our buffer text, can free it. */
1944 free_buffer_text (b);
1945 }
1936 1946
1937 if (b->newline_cache) 1947 if (b->newline_cache)
1938 { 1948 {
@@ -2681,10 +2691,11 @@ current buffer is cleared. */)
2681 2691
2682 UNGCPRO; 2692 UNGCPRO;
2683 2693
2684 /* Changing the multibyteness of a buffer means that all windows
2685 showing that buffer must be updated thoroughly. */
2686 current_buffer->prevent_redisplay_optimizations_p = 1; 2694 current_buffer->prevent_redisplay_optimizations_p = 1;
2687 ++windows_or_buffers_changed; 2695
2696 /* If buffer is shown in a window, let redisplay consider other windows. */
2697 if (buffer_window_count (current_buffer))
2698 ++windows_or_buffers_changed;
2688 2699
2689 /* Copy this buffer's new multibyte status 2700 /* Copy this buffer's new multibyte status
2690 into all of its indirect buffers. */ 2701 into all of its indirect buffers. */
@@ -3880,17 +3891,17 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
3880 3891
3881 BUF_COMPUTE_UNCHANGED (buf, start, end); 3892 BUF_COMPUTE_UNCHANGED (buf, start, end);
3882 3893
3883 /* If this is a buffer not in the selected window, 3894 /* If BUF is visible, consider updating the display if ... */
3884 we must do other windows. */ 3895 if (buffer_window_count (buf) > 0)
3885 if (buf != XBUFFER (XWINDOW (selected_window)->buffer)) 3896 {
3886 windows_or_buffers_changed = 1; 3897 /* ... it's visible in other window than selected, */
3887 /* If multiple windows show this buffer, we must do other windows. */ 3898 if (buf != XBUFFER (XWINDOW (selected_window)->buffer))
3888 else if (buffer_shared > 1) 3899 windows_or_buffers_changed = 1;
3889 windows_or_buffers_changed = 1; 3900 /* ... or if we modify an overlay at the end of the buffer
3890 /* If we modify an overlay at the end of the buffer, we cannot 3901 and so we cannot be sure that window end is still valid. */
3891 be sure that window end is still valid. */ 3902 else if (end >= ZV && start <= ZV)
3892 else if (end >= ZV && start <= ZV) 3903 windows_or_buffers_changed = 1;
3893 windows_or_buffers_changed = 1; 3904 }
3894 3905
3895 ++BUF_OVERLAY_MODIFF (buf); 3906 ++BUF_OVERLAY_MODIFF (buf);
3896} 3907}
@@ -5125,6 +5136,9 @@ init_buffer_once (void)
5125 /* No one will share the text with these buffers, but let's play it safe. */ 5136 /* No one will share the text with these buffers, but let's play it safe. */
5126 buffer_defaults.indirections = 0; 5137 buffer_defaults.indirections = 0;
5127 buffer_local_symbols.indirections = 0; 5138 buffer_local_symbols.indirections = 0;
5139 /* Likewise no one will display them. */
5140 buffer_defaults.window_count = 0;
5141 buffer_local_symbols.window_count = 0;
5128 set_buffer_intervals (&buffer_defaults, NULL); 5142 set_buffer_intervals (&buffer_defaults, NULL);
5129 set_buffer_intervals (&buffer_local_symbols, NULL); 5143 set_buffer_intervals (&buffer_local_symbols, NULL);
5130 /* This is not strictly necessary, but let's make them initialized. */ 5144 /* This is not strictly necessary, but let's make them initialized. */