[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: buffer.c/buffer.h: How to add new buffer-local variables?
From: |
Michael Welsh Duggan |
Subject: |
Re: buffer.c/buffer.h: How to add new buffer-local variables? |
Date: |
Mon, 08 Apr 2019 18:19:06 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
I would suggest that there be a
#define BUFFER_STRUCT_LAST_LISP_OBJECT cursor_in_non_selected_windows_
which would be properly commented and used in BUFFER_LISP_SIZE. This
would, I think, make it easier to notice that this needs to change when
more items get added to the list. I would also add a comment after the
cursor_in_non_selected_windows_ entry to the effect that the define
needs to be updated if more are added afterward.
Paul Eggert <address@hidden> writes:
> diff --git a/src/buffer.h b/src/buffer.h
> index 63b162161c..f42c3e97b9 100644
> --- a/src/buffer.h
> +++ b/src/buffer.h
> @@ -741,8 +741,8 @@ struct buffer
> See `cursor-type' for other values. */
> Lisp_Object cursor_in_non_selected_windows_;
>
> - /* No more Lisp_Object beyond this point. Except undo_list,
> - which is handled specially in Fgarbage_collect. */
> + /* No more Lisp_Object beyond cursor_in_non_selected_windows_.
> + Except undo_list, which is handled specially in Fgarbage_collect. */
>
> /* This structure holds the coordinates of the buffer contents
> in ordinary buffers. In indirect buffers, this is not used. */
> @@ -1019,14 +1019,12 @@ bset_width_table (struct buffer *b, Lisp_Object val)
> structure, make sure that this is still correct. */
>
> #define BUFFER_LISP_SIZE \
> - ((offsetof (struct buffer, own_text) - header_size) / word_size)
> + PSEUDOVECSIZE (struct buffer, cursor_in_non_selected_windows_)
>
> -/* Size of the struct buffer part beyond leading Lisp_Objects, in word_size
> - units. Rounding is needed for --with-wide-int configuration. */
> +/* Allocated size of the struct buffer part beyond leading
> + Lisp_Objects, in word_size units. */
>
> -#define BUFFER_REST_SIZE \
> - ((((sizeof (struct buffer) - offsetof (struct buffer, own_text)) \
> - + (word_size - 1)) & ~(word_size - 1)) / word_size)
> +#define BUFFER_REST_SIZE (VECSIZE (struct buffer) - BUFFER_LISP_SIZE)
>
> /* Initialize the pseudovector header of buffer object. BUFFER_LISP_SIZE
> is required for GC, but BUFFER_REST_SIZE is set up just to be consistent
--
Michael Welsh Duggan
(address@hidden)
- Re: buffer.c/buffer.h: How to add new buffer-local variables?, Keith David Bershatsky, 2019/04/08
- Re: buffer.c/buffer.h: How to add new buffer-local variables?, Eli Zaretskii, 2019/04/08
- Re: buffer.c/buffer.h: How to add new buffer-local variables?, Eli Zaretskii, 2019/04/08
- Re: buffer.c/buffer.h: How to add new buffer-local variables?, Andreas Schwab, 2019/04/08
- Re: buffer.c/buffer.h: How to add new buffer-local variables?, Eli Zaretskii, 2019/04/08
- Re: buffer.c/buffer.h: How to add new buffer-local variables?, Stefan Monnier, 2019/04/08
- Re: buffer.c/buffer.h: How to add new buffer-local variables?, Paul Eggert, 2019/04/08
- Re: buffer.c/buffer.h: How to add new buffer-local variables?,
Michael Welsh Duggan <=
- Re: buffer.c/buffer.h: How to add new buffer-local variables?, Paul Eggert, 2019/04/08
- Re: buffer.c/buffer.h: How to add new buffer-local variables?, Eli Zaretskii, 2019/04/09