From ed08365b9e2756208b0cd2724715b47df6bf5320 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Fri, 7 Dec 2012 11:16:32 +0400 Subject: Convenient macro to check whether the buffer is hidden. * buffer.h (BUFFER_HIDDEN_P): New macro. * frame.c (make_frame): Use it. Adjust comment. * buffer.c (candidate_buffer): New function. (Fother_buffer, other_buffer_safely): Use it. --- src/buffer.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index fbbbf1b8434..1129840bd47 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -982,6 +982,11 @@ bset_width_table (struct buffer *b, Lisp_Object val) #define BUFFER_LIVE_P(b) (!NILP (BVAR (b, name))) +/* Convenient check whether buffer B is hidden (i.e. its name + starts with a space). Caller must ensure that B is live. */ + +#define BUFFER_HIDDEN_P(b) (SREF (BVAR (b, name), 0) == ' ') + /* Verify indirection counters. */ #define BUFFER_CHECK_INDIRECTION(b) \ -- cgit v1.2.1 From 98a07056558be8c13945a3a99b4801996af685a4 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Mon, 10 Dec 2012 21:34:47 +0400 Subject: 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. --- src/buffer.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/buffer.h') 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. */ -- cgit v1.2.1 From f9e7c67e4ccdaf160c0506748f776d628a38eeba Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Mon, 24 Dec 2012 15:41:28 +0400 Subject: * buffer.h (BUF_COMPACT): New macro to follow the common style. * buffer.c (Fget_buffer_create): Use it to set compact field of struct buffer_text to avoid accessing an uninitialized value when compact_buffer is called for the first time. (compact_buffer): Use convenient BUF_COMPACT and BUF_MODIFF. --- src/buffer.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index d838d3767ef..a8769fd3397 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -193,6 +193,9 @@ INLINE_HEADER_BEGIN /* FIXME: should we move this into ->text->auto_save_modiff? */ #define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified) +/* Compaction count. */ +#define BUF_COMPACT(buf) ((buf)->text->compact) + /* Marker chain of buffer. */ #define BUF_MARKERS(buf) ((buf)->text->markers) -- cgit v1.2.1 From ab422c4d6899b1442cb6954c1829c1fb656b006c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 1 Jan 2013 09:11:05 +0000 Subject: Update copyright notices for 2013. --- src/buffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index 9e0e9eef0b1..f4c8a8cc839 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -1,7 +1,7 @@ /* Header file for the buffer manipulation primitives. -Copyright (C) 1985-1986, 1993-1995, 1997-2012 - Free Software Foundation, Inc. +Copyright (C) 1985-1986, 1993-1995, 1997-2013 Free Software Foundation, +Inc. This file is part of GNU Emacs. -- cgit v1.2.1 From eefd727851555237c7bc205b7ad255c50ba3fff9 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Wed, 9 Jan 2013 17:50:22 +0400 Subject: * lisp.h (make_gap_1): New prototype. * buffer.h (GAP_BYTES_DFL, GAP_BYTES_MIN): New macros for the special gap size values. * editfns.c (Fbuffer_size): Rename from Fbufsize to fit the common naming convention. (syms_of_editfns): Adjust defsubr. Drop commented-out obsolete code. * insdel.c (make_gap_larger): Use GAP_BYTES_DFL. (make_gap_smaller): Use GAP_BYTES_MIN. Adjust comment. (make_gap_1): New function to adjust the gap of any buffer. * coding.c (coding_alloc_by_making_gap): Use it. * buffer.c (compact_buffer): Likewise. Use BUF_Z_BYTE, BUF_GAP_SIZE, GAP_BYTES_DFL and GAP_BYTES_MIN. Adjust comment. --- src/buffer.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index eb6a9d4d3e1..ec9c34b3eb3 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -320,6 +320,16 @@ while (0) #define BUF_BYTES_MAX \ (ptrdiff_t) min (MOST_POSITIVE_FIXNUM - 1, min (SIZE_MAX, PTRDIFF_MAX)) +/* Maximum gap size after compact_buffer, in bytes. Also + used in make_gap_larger to get some extra reserved space. */ + +#define GAP_BYTES_DFL 2000 + +/* Minimum gap size after compact_buffer, in bytes. Also + used in make_gap_smaller to avoid too small gap size. */ + +#define GAP_BYTES_MIN 20 + /* Return the address of byte position N in current buffer. */ #define BYTE_POS_ADDR(n) \ -- cgit v1.2.1 From 58cc0a010b7e16dfcf03d7e858ea27eba5dece65 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 10 Jan 2013 14:30:16 +0400 Subject: Omit buffer_slot_type_mismatch and use generic predicates to enforce the type of per-buffer values where appropriate. * src/lisp.h (struct Lisp_Buffer_Objfwd): Rename slottype member to predicate, which is how it's really used now. Adjust comment. * src/buffer.h (buffer_slot_type_mismatch): Remove prototype. * src/buffer.c (buffer_slot_type_mismatch): Remove. (DEFVAR_PER_BUFFER, defvar_per_buffer): Rename type argument to predicate. Adjust comment. (syms_of_buffer): Use Qsymbolp for major-mode. Use Qintegerp for fill-column, left-margin, tab-width, buffer-saved-size, left-margin-width, right-margin-width, left-fringe-width, right-fringe-width, scroll-bar-width and buffer-display-count. Use Qstringp for default-directory, buffer-file-name, buffer-file-truename and buffer-auto-save-file-name. Use Qfloatp for scroll-up-aggressively and scroll-down-aggressively. Use Qnumberp for line-spacing. * src/data.c (store_symval_forwarding): Adjust to call the predicate. * lisp/cus-start.el (toplevel): Only allow float values for scroll-up-aggressively and scroll-down-aggressively. Allow any number for line-spacing. --- src/buffer.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index ec9c34b3eb3..b4cc21d675d 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -1078,7 +1078,6 @@ extern void set_buffer_internal_1 (struct buffer *); extern void set_buffer_temp (struct buffer *); extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object); extern void record_buffer (Lisp_Object); -extern _Noreturn void buffer_slot_type_mismatch (Lisp_Object, int); extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); extern void mmap_set_vars (bool); -- cgit v1.2.1 From 0e70695aa48cb34d8c3df6e4d4173b6adb474b23 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 17 Jan 2013 09:52:13 +0400 Subject: * buffer.h (NARROWED, BUF_NARROWED): Drop unused macros. (DECODE_POSITION, BUFFER_CHECK_INDIRECTION): Fix indentation. * buffer.c (toplevel, syms_of_buffer): Drop old commented-out debugging stubs. --- src/buffer.h | 61 +++++++++++++++++++++++++++--------------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) (limited to 'src/buffer.h') diff --git a/src/buffer.h b/src/buffer.h index b4cc21d675d..276cca32e48 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -82,9 +82,6 @@ INLINE_HEADER_BEGIN /* Size of gap. */ #define GAP_SIZE (current_buffer->text->gap_size) -/* Is the current buffer narrowed? */ -#define NARROWED ((BEGV != BEG) || (ZV != Z)) - /* Modification count. */ #define MODIFF (current_buffer->text->modiff) @@ -173,10 +170,6 @@ INLINE_HEADER_BEGIN /* Size of gap. */ #define BUF_GAP_SIZE(buf) ((buf)->text->gap_size) -/* Is this buffer narrowed? */ -#define BUF_NARROWED(buf) ((BUF_BEGV (buf) != BUF_BEG (buf)) \ - || (BUF_ZV (buf) != BUF_Z (buf))) - /* Modification count. */ #define BUF_MODIFF(buf) ((buf)->text->modiff) @@ -294,24 +287,24 @@ extern void enlarge_buffer_text (struct buffer *, ptrdiff_t); /* Access a Lisp position value in POS, and store the charpos in CHARPOS and the bytepos in BYTEPOS. */ -#define DECODE_POSITION(charpos, bytepos, pos) \ -do \ - { \ - Lisp_Object __pos = (pos); \ - if (NUMBERP (__pos)) \ - { \ - charpos = __pos; \ - bytepos = buf_charpos_to_bytepos (current_buffer, __pos); \ - } \ - else if (MARKERP (__pos)) \ - { \ - charpos = marker_position (__pos); \ - bytepos = marker_byte_position (__pos); \ - } \ - else \ - wrong_type_argument (Qinteger_or_marker_p, __pos); \ - } \ -while (0) +#define DECODE_POSITION(charpos, bytepos, pos) \ + do \ + { \ + Lisp_Object __pos = (pos); \ + if (NUMBERP (__pos)) \ + { \ + charpos = __pos; \ + bytepos = buf_charpos_to_bytepos (current_buffer, __pos); \ + } \ + else if (MARKERP (__pos)) \ + { \ + charpos = marker_position (__pos); \ + bytepos = marker_byte_position (__pos); \ + } \ + else \ + wrong_type_argument (Qinteger_or_marker_p, __pos); \ + } \ + while (0) /* Maximum number of bytes in a buffer. A buffer cannot contain more bytes than a 1-origin fixnum can represent, @@ -1009,15 +1002,15 @@ bset_width_table (struct buffer *b, Lisp_Object val) #define BUFFER_CHECK_INDIRECTION(b) \ do { \ if (BUFFER_LIVE_P (b)) \ - { \ - if (b->base_buffer) \ - { \ - eassert (b->indirections == -1); \ - eassert (b->base_buffer->indirections > 0); \ - } \ - else \ - eassert (b->indirections >= 0); \ - } \ + { \ + if (b->base_buffer) \ + { \ + eassert (b->indirections == -1); \ + eassert (b->base_buffer->indirections > 0); \ + } \ + else \ + eassert (b->indirections >= 0); \ + } \ } while (0) /* Chain of all buffers, including killed ones. */ -- cgit v1.2.1