diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2012-12-10 21:34:47 +0400 |
---|---|---|
committer | Dmitry Antipov <dmantipov@yandex.ru> | 2012-12-10 21:34:47 +0400 |
commit | 98a07056558be8c13945a3a99b4801996af685a4 (patch) | |
tree | 657c931f7e1cb73ef5158beda8a429013e3a23cf /src/buffer.h | |
parent | 2b8c906403908a5037b52bfecb72b65d0ce0cd1e (diff) | |
download | emacs-98a07056558be8c13945a3a99b4801996af685a4.tar.gz |
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.h')
-rw-r--r-- | src/buffer.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/buffer.h b/src/buffer.h index 1129840bd47..d838d3767ef 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -770,11 +770,15 @@ struct buffer In an ordinary buffer, it is 0. */ struct buffer *base_buffer; - /* In an indirect buffer, this is -1. In an ordinary buffer, + /* In an indirect buffer, this is -1. In an ordinary buffer, it's the number of indirect buffers that share our text; zero means that we're the only owner of this text. */ int indirections; + /* Number of windows showing this buffer. Always -1 for + an indirect buffer since it counts as its base buffer. */ + int window_count; + /* A non-zero value in slot IDX means that per-buffer variable with index IDX has a local value in this buffer. The index IDX for a buffer-local variable is stored in that variable's slot @@ -1173,7 +1177,18 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos) + pos + BUF_BEG_ADDR (buf) - BEG_BYTE); return STRING_CHAR (p); } - + +/* Return number of windows showing B. */ + +BUFFER_INLINE int +buffer_window_count (struct buffer *b) +{ + if (b->base_buffer) + b = b->base_buffer; + eassert (b->window_count >= 0); + return b->window_count; +} + /* Overlays */ /* Return the marker that stands for where OV starts in the buffer. */ |