unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Welsh Duggan <mwd@md5i.com>
To: emacs-devel@gnu.org
Subject: Re: buffer.c/buffer.h: How to add new buffer-local variables?
Date: Mon, 08 Apr 2019 18:19:06 -0400	[thread overview]
Message-ID: <87ef6cywbp.fsf@md5i.com> (raw)
In-Reply-To: <5d4bef90-0fdc-31e2-0543-a322cdc4eea4@cs.ucla.edu> (Paul Eggert's message of "Mon, 8 Apr 2019 13:07:22 -0700")

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 <eggert@cs.ucla.edu> 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
(md5i@md5i.com)



  reply	other threads:[~2019-04-08 22:19 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-08  8:03 buffer.c/buffer.h: How to add new buffer-local variables? Keith David Bershatsky
2019-04-08  9:37 ` Eli Zaretskii
2019-04-08 15:04   ` Eli Zaretskii
2019-04-08 17:31   ` Andreas Schwab
2019-04-08 17:43     ` Eli Zaretskii
2019-04-08 18:33       ` Stefan Monnier
2019-04-08 20:07         ` Paul Eggert
2019-04-08 22:19           ` Michael Welsh Duggan [this message]
2019-04-08 23:06             ` Paul Eggert
2019-04-09  6:13               ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2019-04-09  3:49 Keith David Bershatsky
2019-04-09  0:48 Keith David Bershatsky
2019-04-09  0:40 Keith David Bershatsky
2019-04-08  4:34 Keith David Bershatsky
2019-04-07  2:50 Keith David Bershatsky
2019-04-07 15:48 ` Eli Zaretskii
2019-04-08  5:23 ` Paul Eggert
2019-04-04 18:57 Keith David Bershatsky
2019-04-04 19:29 ` Eli Zaretskii
2019-04-01  7:43 Keith David Bershatsky
2019-03-31 16:32 Keith David Bershatsky
2019-03-31 20:02 ` Stefan Monnier
2019-03-31  9:03 Keith David Bershatsky
2019-03-30 23:19 Keith David Bershatsky
2019-03-31  2:37 ` Eli Zaretskii
2019-03-31  3:49   ` Eli Zaretskii
2019-03-31  9:42 ` Andreas Schwab
2019-03-31 10:06   ` Eli Zaretskii
2019-03-31 11:41     ` Andreas Schwab
2019-03-31 15:10       ` Eli Zaretskii
2019-04-02 16:18       ` Eli Zaretskii
2019-04-02 18:46         ` Daniel Colascione
2019-04-03 17:43           ` Eli Zaretskii
2019-03-31 12:22 ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ef6cywbp.fsf@md5i.com \
    --to=mwd@md5i.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).