From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail
From: Michael Welsh Duggan <mwd@md5i.com>
Newsgroups: gmane.emacs.devel
Subject: Re: buffer.c/buffer.h: How to add new buffer-local variables?
Date: Mon, 08 Apr 2019 18:19:06 -0400
Message-ID: <87ef6cywbp.fsf@md5i.com>
References: <m2r2ac9b5m.wl%esq@lawlist.com>
	<3C6817C0-1CDB-4F83-805E-BF6B93C77F44@gnu.org>
	<87y34kl7y5.fsf@igel.home> <831s2c8kav.fsf@gnu.org>
	<jwv8swkxsal.fsf-monnier+emacs@gnu.org>
	<5d4bef90-0fdc-31e2-0543-a322cdc4eea4@cs.ucla.edu>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226";
	logging-data="195366"; mail-complaints-to="usenet@blaine.gmane.org"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
To: emacs-devel@gnu.org
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 09 00:20:07 2019
Return-path: <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>
Envelope-to: ged-emacs-devel@m.gmane.org
Original-Received: from lists.gnu.org ([209.51.188.17])
	by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256)
	(Exim 4.89)
	(envelope-from <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>)
	id 1hDccX-000oet-LN
	for ged-emacs-devel@m.gmane.org; Tue, 09 Apr 2019 00:20:06 +0200
Original-Received: from localhost ([127.0.0.1]:59742 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>)
	id 1hDccW-0001Ib-Do
	for ged-emacs-devel@m.gmane.org; Mon, 08 Apr 2019 18:20:04 -0400
Original-Received: from eggs.gnu.org ([209.51.188.92]:53114)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <mwd@md5i.com>) id 1hDcbc-0001IS-VB
	for emacs-devel@gnu.org; Mon, 08 Apr 2019 18:19:10 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <mwd@md5i.com>) id 1hDcbb-0003nT-TG
	for emacs-devel@gnu.org; Mon, 08 Apr 2019 18:19:08 -0400
Original-Received: from md5i.com ([75.151.244.229]:36210)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from <mwd@md5i.com>) id 1hDcbb-0003lX-D2
	for emacs-devel@gnu.org; Mon, 08 Apr 2019 18:19:07 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=md5i.com;
	s=dkim;
	h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References:
	Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:
	Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
	:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
	List-Post:List-Owner:List-Archive;
	bh=cV3ChULj+TdiVsHwdLRPgHRNO90s/84DJ7/UXR0Jzs4=;
	b=lFsvJ3aTVzQv1dLE2WUh0OPVLE
	EzSUGcEsU0JIdGkFtQRNHxyFujy+uKOVozjx+NztgaEuDDiey4Gdvq8FXkQU2Thujppw5WBRlaah9
	P7xUy8/8VpBGiVnsjyPek+dNC;
Original-Received: from md5i by md5i.com with local (Exim 4.92)
	(envelope-from <mwd@md5i.com>) id 1hDcba-0004p0-7R
	for emacs-devel@gnu.org; Mon, 08 Apr 2019 18:19:06 -0400
In-Reply-To: <5d4bef90-0fdc-31e2-0543-a322cdc4eea4@cs.ucla.edu> (Paul Eggert's
	message of "Mon, 8 Apr 2019 13:07:22 -0700")
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 75.151.244.229
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-devel/>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-devel>,
	<mailto:emacs-devel-request@gnu.org?subject=subscribe>
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org
Original-Sender: "Emacs-devel" <emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org>
Xref: news.gmane.org gmane.emacs.devel:235137
Archived-At: <http://permalink.gmane.org/gmane.emacs.devel/235137>

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)