aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorDmitry Antipov2012-12-10 21:34:47 +0400
committerDmitry Antipov2012-12-10 21:34:47 +0400
commit98a07056558be8c13945a3a99b4801996af685a4 (patch)
tree657c931f7e1cb73ef5158beda8a429013e3a23cf /src/buffer.c
parent2b8c906403908a5037b52bfecb72b65d0ce0cd1e (diff)
downloademacs-98a07056558be8c13945a3a99b4801996af685a4.tar.gz
emacs-98a07056558be8c13945a3a99b4801996af685a4.zip
Per-buffer window counters.
* buffer.h (struct buffer): New member window_count. (buffer_window_count): New function. * buffer.c (Fget_buffer_create, Fmake_indirect_buffer): Initialize window_count. (Fkill_buffer): Verify window_count for the buffer being killed. (modify_overlay): Do not force redisplay if buffer is not shown in any window. (init_buffer_once): Initialize window_count for buffer_defaults and buffer_local_symbols. * window.h (buffer_shared): Remove declaration. (wset_buffer): Convert from inline ... * window.c (wset_buffer): ... to an ordinary function. (adjust_window_count): New function. (make_parent_window): Use it. * xdisp.c (buffer_shared): Remove. (redisplay_internal, redisplay_window): Adjust users. (buffer_shared_and_changed): Use per-buffer window counter.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 6e2191dc22f..1194431841a 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 {
@@ -3880,17 +3890,17 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, ptrdiff_t end)
3880 3890
3881 BUF_COMPUTE_UNCHANGED (buf, start, end); 3891 BUF_COMPUTE_UNCHANGED (buf, start, end);
3882 3892
3883 /* If this is a buffer not in the selected window, 3893 /* If BUF is visible, consider updating the display if ... */
3884 we must do other windows. */ 3894 if (buffer_window_count (buf) > 0)
3885 if (buf != XBUFFER (XWINDOW (selected_window)->buffer)) 3895 {
3886 windows_or_buffers_changed = 1; 3896 /* ... it's visible in other window than selected, */
3887 /* If multiple windows show this buffer, we must do other windows. */ 3897 if (buf != XBUFFER (XWINDOW (selected_window)->buffer))
3888 else if (buffer_shared > 1) 3898 windows_or_buffers_changed = 1;
3889 windows_or_buffers_changed = 1; 3899 /* ... 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 3900 and so we cannot be sure that window end is still valid. */
3891 be sure that window end is still valid. */ 3901 else if (end >= ZV && start <= ZV)
3892 else if (end >= ZV && start <= ZV) 3902 windows_or_buffers_changed = 1;
3893 windows_or_buffers_changed = 1; 3903 }
3894 3904
3895 ++BUF_OVERLAY_MODIFF (buf); 3905 ++BUF_OVERLAY_MODIFF (buf);
3896} 3906}
@@ -5125,6 +5135,9 @@ init_buffer_once (void)
5125 /* No one will share the text with these buffers, but let's play it safe. */ 5135 /* No one will share the text with these buffers, but let's play it safe. */
5126 buffer_defaults.indirections = 0; 5136 buffer_defaults.indirections = 0;
5127 buffer_local_symbols.indirections = 0; 5137 buffer_local_symbols.indirections = 0;
5138 /* Likewise no one will display them. */
5139 buffer_defaults.window_count = 0;
5140 buffer_local_symbols.window_count = 0;
5128 set_buffer_intervals (&buffer_defaults, NULL); 5141 set_buffer_intervals (&buffer_defaults, NULL);
5129 set_buffer_intervals (&buffer_local_symbols, NULL); 5142 set_buffer_intervals (&buffer_local_symbols, NULL);
5130 /* This is not strictly necessary, but let's make them initialized. */ 5143 /* This is not strictly necessary, but let's make them initialized. */