GNU logs - #48264, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: 28.0.50; Changing the default for DEFVAR_PER_BUFFER variables takes O(#buffers) time
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 20:25:01 +0000
Resent-Message-ID: <handler.48264.B.162033268029396 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.162033268029396
          (code B ref -1); Thu, 06 May 2021 20:25:01 +0000
Received: (at submit) by debbugs.gnu.org; 6 May 2021 20:24:40 +0000
Received: from localhost ([127.0.0.1]:39483 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lekY4-0007e4-83
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 16:24:40 -0400
Received: from lists.gnu.org ([209.51.188.17]:34010)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lekY0-0007dw-Qa
 for submit <at> debbugs.gnu.org; Thu, 06 May 2021 16:24:38 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:57528)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sbaugh@HIDDEN>) id 1lekY0-00057T-E3
 for bug-gnu-emacs@HIDDEN; Thu, 06 May 2021 16:24:36 -0400
Received: from venus.catern.com ([68.183.49.163]:44274)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sbaugh@HIDDEN>) id 1lekXy-0003Cj-Qn
 for bug-gnu-emacs@HIDDEN; Thu, 06 May 2021 16:24:36 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620332673; bh=3fAEMzbzxSwFkt3W89kKSkiLPUZ/+wnzYXok8jv3bXg=;
 h=From:To:Subject:Date;
 b=Rcp5RKs5qMKx9Fe5/gL3g19FOeWfkzHXcS0hRACc3SrvhjAd2uThp+SXcaUbP3UuM
 qHkMIS5dYuLtAgXm5Y+VqiXzSUGlWmZyz/VoZh9I3CtGK1r6jihaHBQPWaz1iA082g
 DqlUAsfWS/9GWCHptmj/Ro6WlYrU8RnN56TQtoAI=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 8575E2E907E
 for <bug-gnu-emacs@HIDDEN>; Thu,  6 May 2021 20:24:31 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu, 06 May 2021 16:24:30 -0400
Message-ID: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=68.183.49.163; envelope-from=sbaugh@HIDDEN;
 helo=venus.catern.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)


When changing the default for a Lisp variable defined in the C source
with the DEFVAR_PER_BUFFER macro, whether by let or by set-default, it
takes time proportional to the number of currently live buffers.

Note, DEFVAR_PER_BUFFER variables are stored as Lisp_Object fields in
struct buffer.

The cause of the pathological performance is that setting a default for
a DEFVAR_PER_BUFFER variable iterates over every struct buffer (that
doesn't already have a binding) to set the field corresponding to the
variable.

This is because accessing a DEFVAR_PER_BUFFER variable is done purely by
looking at the current buffer, even if the buffer doesn't have a local
binding for the variable.

This issue was previously reported in bug#41029 and noticed as part of
several other bugs.

I have a patch series which fixes this issue by making DEFVAR_PER_BUFFER
variable accesses fall back to the default if there's no local binding
for the variable, which I'll send shortly as a followup.





Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Spencer Baugh <sbaugh@HIDDEN>
Subject: bug#48264: Acknowledgement (28.0.50; Changing the default for
 DEFVAR_PER_BUFFER variables takes O(#buffers) time)
Message-ID: <handler.48264.B.162033268029396.ack <at> debbugs.gnu.org>
References: <877dkbsj9d.fsf@HIDDEN>
X-Gnu-PR-Message: ack 48264
X-Gnu-PR-Package: emacs
Reply-To: 48264 <at> debbugs.gnu.org
Date: Thu, 06 May 2021 20:25:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 48264 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
48264: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D48264
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 01/15] Stop checking the constant default for enable_multibyte_characters
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:34:02 +0000
Resent-Message-ID: <handler.48264.B48264.1620336839616 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336839616
          (code B ref 48264); Thu, 06 May 2021 21:34:02 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:33:59 +0000
Received: from localhost ([127.0.0.1]:39844 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leld8-00009h-At
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:33:58 -0400
Received: from venus.catern.com ([68.183.49.163]:41460)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leld6-00009O-Qw
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:33:57 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336836; bh=pG8gD8Z+vVpc+s6B604cjVRQFaIdqTIfXOc8y3+//dg=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=YCcATPD83RPbyOqtyk7RwgzeDLVVLW0Xr/xab4rWTU/C74QXzvcdG6Ui99aiZQ4iC
 xBARtpyJIzGqwTAipNWtX8bagpZcTC6CVYv4/mFjT3UK526R8F0V1hx+u/B8vE1gSZ
 O7CFmp2zNeLk3b9ws//5lMkIgT8woa0N/+aCU8jo=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 7D8ED2E9655;
 Thu,  6 May 2021 21:33:56 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:32 -0400
Message-Id: <20210506213346.9730-2-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

The default is a constant "t", and can't be changed. So we don't need
to check it. This makes enable_multibyte_characters like every other
permanently buffer-local variable defined with DEFVAR_PER_BUFFER.

* src/buffer.c (reset_buffer, init_buffer):
* src/print.c (print_string, temp_output_buffer_setup):
* src/process.c (Fmake_pipe_process, Fmake_serial_process)
(set_network_socket_coding_system):
Don't check buffer_defaults for enable_multibyte_characters
---
 src/buffer.c  |  5 +----
 src/print.c   |  6 ++----
 src/process.c | 15 ++++-----------
 3 files changed, 7 insertions(+), 19 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 8e33162989..8b3e15bc81 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -988,8 +988,7 @@ reset_buffer (register struct buffer *b)
   bset_last_selected_window (b, Qnil);
   bset_display_count (b, make_fixnum (0));
   bset_display_time (b, Qnil);
-  bset_enable_multibyte_characters
-    (b, BVAR (&buffer_defaults, enable_multibyte_characters));
+  bset_enable_multibyte_characters (b, Qt);
   bset_cursor_type (b, BVAR (&buffer_defaults, cursor_type));
   bset_extra_line_spacing (b, BVAR (&buffer_defaults, extra_line_spacing));
 
@@ -5406,8 +5405,6 @@ init_buffer (void)
 
   AUTO_STRING (scratch, "*scratch*");
   Fset_buffer (Fget_buffer_create (scratch, Qnil));
-  if (NILP (BVAR (&buffer_defaults, enable_multibyte_characters)))
-    Fset_buffer_multibyte (Qnil);
 
   char const *pwd = emacs_wd;
 
diff --git a/src/print.c b/src/print.c
index d4301fd7b6..653f17aa1d 100644
--- a/src/print.c
+++ b/src/print.c
@@ -453,8 +453,7 @@ print_string (Lisp_Object string, Lisp_Object printcharfun)
 	chars = SCHARS (string);
       else if (! print_escape_nonascii
 	       && (EQ (printcharfun, Qt)
-		   ? ! NILP (BVAR (&buffer_defaults, enable_multibyte_characters))
-		   : ! NILP (BVAR (current_buffer, enable_multibyte_characters))))
+		   || ! NILP (BVAR (current_buffer, enable_multibyte_characters))))
 	{
 	  /* If unibyte string STRING contains 8-bit codes, we must
 	     convert STRING to a multibyte string containing the same
@@ -572,8 +571,7 @@ temp_output_buffer_setup (const char *bufname)
   bset_undo_list (current_buffer, Qt);
   eassert (current_buffer->overlays_before == NULL);
   eassert (current_buffer->overlays_after == NULL);
-  bset_enable_multibyte_characters
-    (current_buffer, BVAR (&buffer_defaults, enable_multibyte_characters));
+  bset_enable_multibyte_characters (current_buffer, Qt);
   specbind (Qinhibit_read_only, Qt);
   specbind (Qinhibit_modification_hooks, Qt);
   Ferase_buffer ();
diff --git a/src/process.c b/src/process.c
index 84e301a87a..44ba6c578e 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2399,8 +2399,7 @@ usage:  (make-pipe-process &rest ARGS)  */)
       }
     else if (!NILP (Vcoding_system_for_read))
       val = Vcoding_system_for_read;
-    else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
-	     || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
+    else if (!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
       /* We dare not decode end-of-line format by setting VAL to
 	 Qraw_text, because the existing Emacs Lisp libraries
 	 assume that they receive bare code including a sequence of
@@ -2425,8 +2424,6 @@ usage:  (make-pipe-process &rest ARGS)  */)
       }
     else if (!NILP (Vcoding_system_for_write))
       val = Vcoding_system_for_write;
-    else if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
-      val = Qnil;
     else
       {
 	if (CONSP (coding_systems))
@@ -3124,8 +3121,7 @@ usage:  (make-serial-process &rest ARGS)  */)
     }
   else if (!NILP (Vcoding_system_for_read))
     val = Vcoding_system_for_read;
-  else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
-	   || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
+  else if (!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
     val = Qnil;
   pset_decode_coding_system (p, val);
 
@@ -3138,8 +3134,7 @@ usage:  (make-serial-process &rest ARGS)  */)
     }
   else if (!NILP (Vcoding_system_for_write))
     val = Vcoding_system_for_write;
-  else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
-	   || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
+  else if (!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
     val = Qnil;
   pset_encode_coding_system (p, val);
 
@@ -3181,9 +3176,7 @@ set_network_socket_coding_system (Lisp_Object proc, Lisp_Object host,
   else if (!NILP (Vcoding_system_for_read))
     val = Vcoding_system_for_read;
   else if ((!NILP (p->buffer)
-	    && NILP (BVAR (XBUFFER (p->buffer), enable_multibyte_characters)))
-	   || (NILP (p->buffer)
-	       && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
+	    && NILP (BVAR (XBUFFER (p->buffer), enable_multibyte_characters))))
     /* We dare not decode end-of-line format by setting VAL to
        Qraw_text, because the existing Emacs Lisp libraries
        assume that they receive bare code including a sequence of
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 00/15] Speeding up setting the default for DEFVAR_PER_BUFFER vars
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:34:04 +0000
Resent-Message-ID: <handler.48264.B48264.1620336842650 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336842650
          (code B ref 48264); Thu, 06 May 2021 21:34:04 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:02 +0000
Received: from localhost ([127.0.0.1]:39850 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldA-0000AI-VL
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:01 -0400
Received: from venus.catern.com ([68.183.49.163]:41454)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leld5-00009N-0m
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:33:57 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336834; bh=q2skZYdZV73MIKMCr2rG4O3reurWTJHhN13gT2u0huc=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=ZmvvVgIZ/IFjqcjUjrTljR593d2+/EKp1MQfILMEo93RiRsKstgmyo+CDRHyKlO9B
 I9uYoTzeylSwB0kIczeQ0zkRDZ4zrLU19XBSV7B4Z+1fFobTQxs5YHr8rbjMb5SG7m
 xm3MIvh4KYptNJM7eRpUvzPLRe8RdUg1zQKjxk/4=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 5F9092E9360;
 Thu,  6 May 2021 21:33:52 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:31 -0400
Message-Id: <20210506213346.9730-1-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This patch series fixes bug#48264 by speeding up changes to the
default value for DEFVAR_PER_BUFFER vars, whether by let or
set-default.  Such changes are now constant time, and run as fast as
changes to non-default values.

This change optimizes setting the default in exchange for a small
slowdown on every access to a DEFVAR_PER_BUFFER var that has a
default.  I've benchmarked this change (results posted in other
threads on emacs-devel) and found minimal slowdown in pure Lisp code,
and a 1-2% slowdown in the display engine.

=== Background on DEFVAR_PER_BUFFER variables ===

DEFVAR_PER_BUFFER is a C macro which sets up a correspondence between a
Lisp symbol and a field of type Lisp_Object in the C `struct buffer'
struct.  There are a finite number of such fields, and DEFVAR_PER_BUFFER
is called for a subset of them.

Each DEFVAR_PER_BUFFER variable appears to Lisp code as a buffer-local
variable, and should behave like pure Lisp buffer-local variables.  Each
DEFVAR_PER_BUFFER variable is either permanently buffer-local, or has a
default value which is used by buffers that don't currently have a
buffer-local binding.

If a buffer has a buffer-local binding for one of these variables, then
the per-buffer value is stored in the corresponding field in that
buffer's `struct buffer'.

Default values for these variables are stored in a global `struct
buffer' C variable, `buffer_defaults'.  This struct does not correspond
to a real buffer, and its non-DEFVAR_PER_BUFFER fields are unused.  When
a variable's default value is changed, the corresponding field is
changed in (at least) buffer_defaults.  When `default-value' is used to
read a DEFVAR_PER_BUFFER variable's default value, it's read from
buffer_defaults.

The underlying fields in `struct buffer' used with DEFVAR_PER_BUFFER are
also read and written directly from C, through the BVAR macro.  The BVAR
macro takes a pointer to a `struct buffer' and the name of a field in
`struct buffer', and evaluates to the value for that field.

The variables must behave the same both when used through the symbol in
Lisp, and used through BVAR in C.  For example, if BVAR reads a field
from a buffer that does not have a buffer-local binding for that field,
it should evaluate to the default value for that field.

=== Old implementation ===

In the old implementation, both the permanently buffer-local
DEFVAR_PER_BUFFER variables and the variables with defaults values
were accessed in the same way: Through the BVAR macro.

The BVAR macro is essentially a no-op.  It turns into a simple field
dereference, essentially:

  #define BVAR(buf, field) (buf)->field

We simply read the field directly out of the specific `struct buffer'
we're working with.  Neither BVAR nor surrounding C code checks whether
a buffer has a buffer-local binding for a variable before using this
field, and at no point does most code check what value is in
buffer_defaults.

This is fine for permanently buffer-local DEFVAR_PER_BUFFER variables,
which have no default value.

For variables which are not permanently buffer-local, though, this means
we need to ensure that the C Lisp_Object field always contains the
"correct" value for the variable, whether that's a currently
buffer-local value, or the global default value.

If there is a buffer-local binding, then the field contains the
per-buffer value, and all is well.

If there is no buffer-local binding, then we need to ensure that the
field contains the global default value.

To do this, whenever the global default value changes, we iterate over
all buffers, and if there's no buffer-local binding, set the field to
the new default value. This is O(n) in the number of buffers open in
Emacs - quite slow.

= Old implementation: local_flags and buffer_local_flags =

Also, we frequently need to know whether a variable has a buffer-local
binding.  We maintain this information with the `local_flags' field in
`struct buffer', which is a char array with an entry for each
DEFVAR_PER_BUFFER variable.

When we create or kill a buffer-local binding for a DEFVAR_PER_BUFFER
variable, we update local_flags.

To support local_flags, we need even further metadata;
buffer_local_flags is a global, initialized at startup and constant
after that, which maps the offsets of the DEFVAR_PER_BUFFER C fields to
indices in local_flags.  We perform a lookup in buffer_local_flags
whenever we need to change local_flags for a variable.

=== New implementation ===

In the new implementation, we use separate macros for permanently
buffer-local variables and for variables with defaults.

Permanently buffer-local variables use BVAR, which stays the same.

Variables with defaults now use BVAR_OR_DEFAULT, which does a bit more
work.
Simplifying a bit:

  #define BVAR_OR_DEFAULT(buf, field) \
    EQ ((buf)->field, Qunbound) ? buffer_defaults.field : (buf)->field

We now use Qunbound as a sentinel to tell us whether the buffer has a
buffer-local binding for this field or not.  If the field contains
Qunbound, we should use the default value out of buffer_defaults; if
not, there's a buffer-local binding, and we should use the per-buffer
value.

We no longer need to iterate over all buffers whenever we change the
default value.  So setting the default value is now fast.

= New implementation: No more local_flags and buffer_local_flags =

Both of these are now useless and can be deleted.

When we create a buffer-local binding for a DEFVAR_PER_BUFFER variable,
we simply set the field.  When we kill a buffer-local binding, we set
the field to Qunbound.  There's no additional metadata.

=== Individual commits ===

See the individual commit messages for more.

  Stop checking the constant default for enable_multibyte_characters

This removes a defunct default that still existed for
enable_multibyte_characters, making it work like all the other
permanently buffer-local variables, which simplifies the rest of our
changes.

  Take offset not idx in PER_BUFFER_VALUE_P
  Add and use BUFFER_DEFAULT_VALUE_P
  Combine unnecessarily separate loops in buffer.c
  Add and use KILL_PER_BUFFER_VALUE
  Rearrange set_internal for buffer forwarded symbols

These change or add abstractions for accessing buffer Lisp_Object
fields, to remove dependencies on implementation details which will
change.

  Add BVAR_OR_DEFAULT macro as a stub

This adds the BVAR_OR_DEFAULT macro without actually changing behavior
yet. This is the largest patch, since it needs to change code using
BVAR everywhere in Emacs.

  Set non-buffer-local BVARs to Qunbound

This is the heart of the patch series; it changes the behavior of
BVAR_OR_DEFAULT to match what was described above.

  Remove unnecessary Qunbound check
  Get rid of buffer_permanent_local_flags array
  Delete SET_PER_BUFFER_VALUE_P and buffer local_flags field
  Set buffer_defaults fields without a default to Qunbound
  Assert that PER_BUFFER_IDX for Lisp variables is not 0
  Remove PER_BUFFER_IDX and buffer_local_flags

These remove various forms of metadata maintained in buffer.c which
are no longer necessary after our change.

  Add and use BVAR_FIELD macros

This enforces statically that BVAR_OR_DEFAULT is only used for fields
with defaults, and that BVAR is only used for fields without defaults.

Spencer Baugh (15):
  Stop checking the constant default for enable_multibyte_characters
  Take offset not idx in PER_BUFFER_VALUE_P
  Add and use BUFFER_DEFAULT_VALUE_P
  Combine unnecessarily separate loops in buffer.c
  Add and use KILL_PER_BUFFER_VALUE
  Rearrange set_internal for buffer forwarded symbols
  Add BVAR_OR_DEFAULT macro as a stub
  Set non-buffer-local BVARs to Qunbound
  Remove unnecessary Qunbound check
  Get rid of buffer_permanent_local_flags array
  Delete SET_PER_BUFFER_VALUE_P and buffer local_flags field
  Set buffer_defaults fields without a default to Qunbound
  Assert that PER_BUFFER_IDX for Lisp variables is not 0
  Remove PER_BUFFER_IDX and buffer_local_flags
  Add and use BVAR_FIELD macros

 lisp/bindings.el       |   3 +-
 src/alloc.c            |   3 +-
 src/bidi.c             |  19 +-
 src/buffer.c           | 430 +++++++++++++----------------------------
 src/buffer.h           | 302 +++++++++++++----------------
 src/category.c         |  12 +-
 src/cmds.c             |   6 +-
 src/data.c             |  82 ++------
 src/editfns.c          |   4 +-
 src/fileio.c           |   9 +-
 src/fns.c              |   8 +-
 src/fringe.c           |  21 +-
 src/hbfont.c           |   2 +-
 src/indent.c           |  34 ++--
 src/msdos.c            |   6 +-
 src/pdumper.c          |   3 -
 src/print.c            |   6 +-
 src/process.c          |  15 +-
 src/search.c           |  21 +-
 src/syntax.c           |  13 +-
 src/syntax.h           |   5 +-
 src/window.c           |  29 +--
 src/xdisp.c            | 130 +++++++------
 test/src/data-tests.el |   1 -
 24 files changed, 448 insertions(+), 716 deletions(-)

-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 02/15] Take offset not idx in PER_BUFFER_VALUE_P
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:34:05 +0000
Resent-Message-ID: <handler.48264.B48264.1620336844678 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336844678
          (code B ref 48264); Thu, 06 May 2021 21:34:05 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:04 +0000
Received: from localhost ([127.0.0.1]:39853 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldB-0000AR-Ud
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:03 -0400
Received: from venus.catern.com ([68.183.49.163]:41466)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leld7-00009U-I2
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:33:57 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336837; bh=Qma0rUKzeh7JnjVA+FpsVJYp5tSJoSCqw7sDFOwzNE8=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=fpG70AG+DW9ZcVkGTDxIBE5SZjrTJGOW12ZsNDCmZCYY8NuwE1IIVfk58pbBDkVyp
 Mea6YeD4wHqhyoYJ0eoDDQhjoTTGFWAMrQKJZmCWoOgzBl7zapiM4aoyPllyPb4kNn
 z4sdQyt96kyDuB+dRvKUq1hv9w8PRhCE/KiSnFyQ=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 3797F2E9655;
 Thu,  6 May 2021 21:33:57 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:33 -0400
Message-Id: <20210506213346.9730-3-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This improves clarity and allows us to more easily change how
PER_BUFFER_VALUE_P works.

* src/buffer.h (PER_BUFFER_VALUE_P): Move to be in scope of
PER_BUFFER_IDX.  Take offset instead of idx, and perform the common
"idx == -1" check internally.
* src/data.c (store_symval_forwarding, set_internal)
(set_default_internal, Flocal_variable_p):
* src/buffer.c (buffer_local_variables_1): Pass offset not idx to
PER_BUFFER_VALUE_P, and remove idx == -1 checks.
---
 src/buffer.c |  3 +--
 src/buffer.h | 21 +++++++++++----------
 src/data.c   | 11 +++++------
 3 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 8b3e15bc81..c395c6ec98 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1319,8 +1319,7 @@ buffer_lisp_local_variables (struct buffer *buf, bool clone)
 static Lisp_Object
 buffer_local_variables_1 (struct buffer *buf, int offset, Lisp_Object sym)
 {
-  int idx = PER_BUFFER_IDX (offset);
-  if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx))
+  if (PER_BUFFER_VALUE_P (buf, offset)
       && SYMBOLP (PER_BUFFER_SYMBOL (offset)))
     {
       sym = NILP (sym) ? PER_BUFFER_SYMBOL (offset) : sym;
diff --git a/src/buffer.h b/src/buffer.h
index 24e9c3fcbc..7367c2cb2b 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1415,16 +1415,6 @@ OVERLAY_POSITION (Lisp_Object p)
 
 extern bool valid_per_buffer_idx (int);
 
-/* Value is true if the variable with index IDX has a local value
-   in buffer B.  */
-
-INLINE bool
-PER_BUFFER_VALUE_P (struct buffer *b, int idx)
-{
-  eassert (valid_per_buffer_idx (idx));
-  return b->local_flags[idx];
-}
-
 /* Set whether per-buffer variable with index IDX has a buffer-local
    value in buffer B.  VAL zero means it hasn't.  */
 
@@ -1491,6 +1481,17 @@ set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
   *(Lisp_Object *)(offset + (char *) b) = value;
 }
 
+/* Value is true if the variable with offset OFFSET has a local value
+   in buffer B.  */
+
+INLINE bool
+PER_BUFFER_VALUE_P (struct buffer *b, int offset)
+{
+  int idx = PER_BUFFER_IDX (offset);
+  eassert (idx == -1 || valid_per_buffer_idx (idx));
+  return idx == -1 || b->local_flags[idx];
+}
+
 /* Downcase a character C, or make no change if that cannot be done.  */
 INLINE int
 downcase (int c)
diff --git a/src/data.c b/src/data.c
index d547f5da5e..bd399e0439 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1280,7 +1280,7 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval,
 	    {
 	      struct buffer *b = XBUFFER (buf);
 
-	      if (! PER_BUFFER_VALUE_P (b, idx))
+	      if (! PER_BUFFER_VALUE_P (b, offset))
 		set_per_buffer_value (b, offset, newval);
 	    }
 	}
@@ -1597,8 +1597,8 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
 	  {
 	    int offset = XBUFFER_OBJFWD (innercontents)->offset;
 	    int idx = PER_BUFFER_IDX (offset);
-	    if (idx > 0 && bindflag == SET_INTERNAL_SET
-	        && !PER_BUFFER_VALUE_P (buf, idx))
+	    if (bindflag == SET_INTERNAL_SET
+	        && !PER_BUFFER_VALUE_P (buf, offset))
 	      {
 		if (let_shadows_buffer_binding_p (sym))
 		  set_default_internal (symbol, newval, bindflag);
@@ -1899,7 +1899,7 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value,
 		  {
 		    struct buffer *b = XBUFFER (buf);
 
-		    if (!PER_BUFFER_VALUE_P (b, idx))
+		    if (!PER_BUFFER_VALUE_P (b, offset))
 		      set_per_buffer_value (b, offset, value);
 		  }
 	      }
@@ -2238,8 +2238,7 @@ BUFFER defaults to the current buffer.  */)
 	if (BUFFER_OBJFWDP (valcontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
-	    int idx = PER_BUFFER_IDX (offset);
-	    if (idx == -1 || PER_BUFFER_VALUE_P (buf, idx))
+	    if (PER_BUFFER_VALUE_P (buf, offset))
 	      return Qt;
 	  }
 	return Qnil;
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:34:07 +0000
Resent-Message-ID: <handler.48264.B48264.1620336845705 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336845705
          (code B ref 48264); Thu, 06 May 2021 21:34:07 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:05 +0000
Received: from localhost ([127.0.0.1]:39859 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldD-0000As-Kw
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:04 -0400
Received: from venus.catern.com ([68.183.49.163]:41472)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leld8-00009f-1u
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:33:58 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336837; bh=XwEDQVsjfII4Okws8PbC6as5G+tUq2DML38Eb0EzaRc=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=kca3TMk8RZLNg3mONNOqR/tIwM/laFaAgvQ0ogLhdrdmig1b0h7dwkPBqJzWoDGai
 9KkycLI/O0J/gJJOt1YZD0WTg1CHRz2+hwB4GuccURUQjWCX5qOnrMRg3BUwdUkBnc
 NCZ5b60+PeJc7a8pyh0V9eaL49RuAZGHl4XxOyqI=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id BACF52E87C0;
 Thu,  6 May 2021 21:33:57 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:34 -0400
Message-Id: <20210506213346.9730-4-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This makes the code more clear and allows us to more easily change how
this property is determined.

* src/buffer.h (BUFFER_DEFAULT_VALUE_P):
New function.
* src/buffer.c (reset_buffer_local_variables):
* src/data.c (set_default_internal, Fkill_local_variable):
Use BUFFER_DEFAULT_VALUE_P
---
 src/buffer.c |  2 +-
 src/buffer.h | 10 ++++++++++
 src/data.c   |  5 ++---
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index c395c6ec98..3427022ace 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1108,7 +1108,7 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
   FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
     {
       int idx = PER_BUFFER_IDX (offset);
-      if ((idx > 0
+      if ((BUFFER_DEFAULT_VALUE_P (offset)
 	   && (permanent_too
 	       || buffer_permanent_local_flags[idx] == 0)))
 	set_per_buffer_value (b, offset, per_buffer_default (offset));
diff --git a/src/buffer.h b/src/buffer.h
index 7367c2cb2b..2125d1b907 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1481,6 +1481,16 @@ set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
   *(Lisp_Object *)(offset + (char *) b) = value;
 }
 
+/* Value is true if the variable with offset OFFSET has a default
+   value; false if the variable has no default, and is therefore
+   always local. */
+
+INLINE bool
+BUFFER_DEFAULT_VALUE_P (int offset)
+{
+  return PER_BUFFER_IDX (offset) > 0;
+}
+
 /* Value is true if the variable with offset OFFSET has a local value
    in buffer B.  */
 
diff --git a/src/data.c b/src/data.c
index bd399e0439..9bd935fe09 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1879,13 +1879,12 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value,
 	if (BUFFER_OBJFWDP (valcontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
-	    int idx = PER_BUFFER_IDX (offset);
 
 	    set_per_buffer_default (offset, value);
 
 	    /* If this variable is not always local in all buffers,
 	       set it in the buffers that don't nominally have a local value.  */
-	    if (idx > 0)
+	    if (BUFFER_DEFAULT_VALUE_P (offset))
 	      {
 		Lisp_Object buf, tail;
 
@@ -2157,7 +2156,7 @@ From now on the default value will apply in this buffer.  Return VARIABLE.  */)
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
 	    int idx = PER_BUFFER_IDX (offset);
 
-	    if (idx > 0)
+	    if (BUFFER_DEFAULT_VALUE_P (offset))
 	      {
 		SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0);
 		set_per_buffer_value (current_buffer, offset,
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 04/15] Combine unnecessarily separate loops in buffer.c
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:34:08 +0000
Resent-Message-ID: <handler.48264.B48264.1620336846735 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336846735
          (code B ref 48264); Thu, 06 May 2021 21:34:08 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:06 +0000
Received: from localhost ([127.0.0.1]:39864 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldE-0000BK-VF
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:05 -0400
Received: from venus.catern.com ([68.183.49.163]:41478)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leld8-00009s-PB
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:33:59 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336838; bh=4A7sFotf1TfnIWghFuSNPhK+ZeczRfZ8+fI2fo7WkV0=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=EWFop7mjD287Erz4LLYphGe5p/jRfq8M5g3s0K4F3i1a/MHC8vDtYWTny0WopeJr5
 F2QkuCMqAbhJN0igRCgH6Pl4SWH4BwMMNloQzv21tpdd9MCGqHLG9XV9OLYX8tgJt5
 zdheuGBjCX1J9kDKnIzRzBSS4us4MrN5cOCcr0dQ=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 613C12E87C0;
 Thu,  6 May 2021 21:33:58 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:35 -0400
Message-Id: <20210506213346.9730-5-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

These loops iterate over the same things with the same check.

* src/buffer.c (reset_buffer_local_variables): Combine loops
---
 src/buffer.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 3427022ace..c2a268adec 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1006,7 +1006,7 @@ reset_buffer (register struct buffer *b)
 static void
 reset_buffer_local_variables (struct buffer *b, bool permanent_too)
 {
-  int offset, i;
+  int offset;
 
   /* Reset the major mode to Fundamental, together with all the
      things that depend on the major mode.
@@ -1100,10 +1100,6 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
         }
     }
 
-  for (i = 0; i < last_per_buffer_idx; ++i)
-    if (permanent_too || buffer_permanent_local_flags[i] == 0)
-      SET_PER_BUFFER_VALUE_P (b, i, 0);
-
   /* For each slot that has a default value, copy that into the slot.  */
   FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
     {
@@ -1111,7 +1107,10 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
       if ((BUFFER_DEFAULT_VALUE_P (offset)
 	   && (permanent_too
 	       || buffer_permanent_local_flags[idx] == 0)))
-	set_per_buffer_value (b, offset, per_buffer_default (offset));
+        {
+          SET_PER_BUFFER_VALUE_P (b, idx, 0);
+          set_per_buffer_value (b, offset, per_buffer_default (offset));
+        }
     }
 }
 
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 05/15] Add and use KILL_PER_BUFFER_VALUE
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:34:08 +0000
Resent-Message-ID: <handler.48264.B48264.1620336847742 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336847742
          (code B ref 48264); Thu, 06 May 2021 21:34:08 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:07 +0000
Received: from localhost ([127.0.0.1]:39868 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldG-0000Bj-0x
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:06 -0400
Received: from venus.catern.com ([68.183.49.163]:41484)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leld9-0000A5-Ed
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:33:59 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336839; bh=vmnkif9/rZF+ZdexRziKCgrUoZJvh/Kad9BfutRrerE=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=Ld5zOvKcShCSr0iWj8/85KJXYbh6YuI0M0uXDAxCW0NqZKshP6PbnA1s12F+jXUiX
 Jn/SYxqAYKE/WakyOSsZtgfZ7e1GcNtmRXbk/GigbuYcusreGdZsXztshR614BpfJe
 b+Z8pl4RDPS6dzYk1xErFJiGz8a+GBhci4qUP7V8=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 24FBB2E87C0;
 Thu,  6 May 2021 21:33:59 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:36 -0400
Message-Id: <20210506213346.9730-6-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This makes the code more clear and allows us to more easily change how
this function is implemented.

* src/buffer.h (KILL_PER_BUFFER_VALUE):
New function.
* src/buffer.c (reset_buffer_local_variables):
* src/data.c (Fkill_local_variable):
Use KILL_PER_BUFFER_VALUE.
---
 src/buffer.c |  5 +----
 src/buffer.h | 10 ++++++++++
 src/data.c   |  8 +-------
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index c2a268adec..c75dcbcffb 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1107,10 +1107,7 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
       if ((BUFFER_DEFAULT_VALUE_P (offset)
 	   && (permanent_too
 	       || buffer_permanent_local_flags[idx] == 0)))
-        {
-          SET_PER_BUFFER_VALUE_P (b, idx, 0);
-          set_per_buffer_value (b, offset, per_buffer_default (offset));
-        }
+        KILL_PER_BUFFER_VALUE (b, offset);
     }
 }
 
diff --git a/src/buffer.h b/src/buffer.h
index 2125d1b907..fff2d27ea0 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1502,6 +1502,16 @@ PER_BUFFER_VALUE_P (struct buffer *b, int offset)
   return idx == -1 || b->local_flags[idx];
 }
 
+/* Kill the per-buffer binding for this value, if there is one. */
+
+INLINE void
+KILL_PER_BUFFER_VALUE (struct buffer *b, int offset)
+{
+  int idx = PER_BUFFER_IDX (offset);
+  SET_PER_BUFFER_VALUE_P (b, idx, 0);
+  set_per_buffer_value (b, offset, per_buffer_default (offset));
+}
+
 /* Downcase a character C, or make no change if that cannot be done.  */
 INLINE int
 downcase (int c)
diff --git a/src/data.c b/src/data.c
index 9bd935fe09..75ebcceb93 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2154,14 +2154,8 @@ From now on the default value will apply in this buffer.  Return VARIABLE.  */)
 	if (BUFFER_OBJFWDP (valcontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
-	    int idx = PER_BUFFER_IDX (offset);
-
 	    if (BUFFER_DEFAULT_VALUE_P (offset))
-	      {
-		SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0);
-		set_per_buffer_value (current_buffer, offset,
-				      per_buffer_default (offset));
-	      }
+              KILL_PER_BUFFER_VALUE (current_buffer, offset);
 	  }
 	return variable;
       }
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 06/15] Rearrange set_internal for buffer forwarded symbols
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:35:02 +0000
Resent-Message-ID: <handler.48264.B48264.1620336852797 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336852797
          (code B ref 48264); Thu, 06 May 2021 21:35:02 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:12 +0000
Received: from localhost ([127.0.0.1]:39875 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldL-0000Cm-Ug
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:12 -0400
Received: from venus.catern.com ([68.183.49.163]:41490)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leldA-0000AB-4s
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:00 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336839; bh=emBC0E+2QvvjUe0hxh/nhSjDuaJx4AjtCpBtoAJslzw=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=Sg1JWg/AH0T5FzN0mUxy8Sdz2myCUIWEhlHgXwKhywLE+jsCbDhT86U/yiE4gqnSF
 6Qq672ta5ody9EvtLih8afM62e39wB/fgVK5lGRM36b6pKGnt6VqquZOaw4xKnyPPK
 yP0fK8PnE8qOentypKNBp+N02RTAZks600rW62cc=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id CFD202E87C0;
 Thu,  6 May 2021 21:33:59 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:37 -0400
Message-Id: <20210506213346.9730-7-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Previously, when setting buffer-local values for DEFVAR_PER_BUFFER
variables, the call to SET_PER_BUFFER_VALUE_P was far from the call to
set_per_buffer_value, even though they're conceptually tied together.

Now, the two calls are in the same place in store_symval_forwarding,
and we can delete the old call to SET_PER_BUFFER_VALUE_P in
set_internal.

Since we did this, we need to also avoid calling
store_symval_forwarding in set_internal when setting the default value
for a DEFVAR_PER_BUFFER variable.

This improves clarity quite a bit; it also makes it easier to later
merge set_per_buffer_value and SET_PER_BUFFER_VALUE_P together.

* src/data.c (store_symval_forwarding):
Call SET_PER_BUFFER_VALUE_P directly for buffer-forwarded symbols.
(set_internal):
Don't call SET_PER_BUFFER_VALUE_P for buffer-forwarded symbols.  Also
don't call store_symval_forwarding when we're setting the default
value for a buffer-forwarded symbol.
---
 src/data.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/data.c b/src/data.c
index 75ebcceb93..b3d3111eaa 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1320,6 +1320,9 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval,
 	if (buf == NULL)
 	  buf = current_buffer;
 	set_per_buffer_value (buf, offset, newval);
+        int idx = PER_BUFFER_IDX (offset);
+        if (idx > 0)
+          SET_PER_BUFFER_VALUE_P (buf, idx, 1);
       }
       break;
 
@@ -1593,17 +1596,16 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
 	struct buffer *buf
 	  = BUFFERP (where) ? XBUFFER (where) : current_buffer;
 	lispfwd innercontents = SYMBOL_FWD (sym);
+        bool should_store = true;
 	if (BUFFER_OBJFWDP (innercontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (innercontents)->offset;
-	    int idx = PER_BUFFER_IDX (offset);
 	    if (bindflag == SET_INTERNAL_SET
-	        && !PER_BUFFER_VALUE_P (buf, offset))
+	        && !PER_BUFFER_VALUE_P (buf, offset)
+                && let_shadows_buffer_binding_p (sym))
 	      {
-		if (let_shadows_buffer_binding_p (sym))
-		  set_default_internal (symbol, newval, bindflag);
-		else
-		  SET_PER_BUFFER_VALUE_P (buf, idx, 1);
+                set_default_internal (symbol, newval, bindflag);
+		should_store = false;
 	      }
 	  }
 
@@ -1613,7 +1615,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
 	    sym->u.s.redirect = SYMBOL_PLAINVAL;
 	    SET_SYMBOL_VAL (sym, newval);
 	  }
-	else
+	else if (should_store)
 	  store_symval_forwarding (/* sym, */ innercontents, newval, buf);
 	break;
       }
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 09/15] Remove unnecessary Qunbound check
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:35:02 +0000
Resent-Message-ID: <handler.48264.B48264.1620336852804 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336852804
          (code B ref 48264); Thu, 06 May 2021 21:35:02 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:12 +0000
Received: from localhost ([127.0.0.1]:39877 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldM-0000Co-7A
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:12 -0400
Received: from venus.catern.com ([68.183.49.163]:41510)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leldC-0000AX-8q
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:03 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336842; bh=VMUbgpmgJBqIoiyXmqe74txHAVWmakeISG7aKGfUX/k=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=IYkoj5kUAYCGRZMBuVxgtuo47cjFEE3p86KSigKP3km7LU3aDR3avJSZSG6ydSjum
 kSCuFrE5avKmyxGcAyJoFXNt0vq6zkWamFcUJTZ7eJTqdC3joE4+g+QVDN489O7QOk
 TdqejNNJoA13mnHBNXSVtMuzEP065UTwpuNBDcVA=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id E4EA42E966A;
 Thu,  6 May 2021 21:34:01 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:40 -0400
Message-Id: <20210506213346.9730-10-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

DEFVAR_PER_BUFFER variables (which this function deals with) cannot be
Qunbound anymore.

* src/buffer.c (buffer_local_variables_1): Remove Qunbound check
---
 src/buffer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index b9ac93c5e8..e6b7cd9aa8 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1316,8 +1316,7 @@ buffer_local_variables_1 (struct buffer *buf, int offset, Lisp_Object sym)
       && SYMBOLP (PER_BUFFER_SYMBOL (offset)))
     {
       sym = NILP (sym) ? PER_BUFFER_SYMBOL (offset) : sym;
-      Lisp_Object val = per_buffer_value (buf, offset);
-      return EQ (val, Qunbound) ? sym : Fcons (sym, val);
+      return Fcons (sym, per_buffer_value (buf, offset));
     }
   return Qnil;
 }
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 08/15] Set non-buffer-local BVARs to Qunbound
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:35:03 +0000
Resent-Message-ID: <handler.48264.B48264.1620336853811 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336853811
          (code B ref 48264); Thu, 06 May 2021 21:35:03 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:13 +0000
Received: from localhost ([127.0.0.1]:39879 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldM-0000Cv-EA
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:12 -0400
Received: from venus.catern.com ([68.183.49.163]:41504)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leldB-0000AJ-Ep
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:03 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336841; bh=dSNJJAepnr9Zuqd+TxBmr4Mvny94ss+YKnXud518MmU=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=E6j7fwr2hVzA6b7euEfzseb+tkzGAsDLmO/4NGOD6ZgVuip49B7oOpf9f65NpmXle
 uWGH6gxglnwXAsNmiw1EWeiMicLc7nCg2tQ/O/zSuSzuKH3E41xny9n4mjTgC6aBMM
 /kTaZ03QknMcxErCOVvUIh+QeHjuzCV6gbPtr8+4=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 25E0A2E9669;
 Thu,  6 May 2021 21:34:01 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:39 -0400
Message-Id: <20210506213346.9730-9-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Previously, we used the local_flags array in each struct buffer
to know which field was buffer-local.

Now, we set the field to Qunbound if it's not buffer-local, and use
that to determine if the variable is local.  We'll delete local_flags
in a followup commit.

* src/buffer.h (BVAR_OR_DEFAULT): Update implementation to
(bvar_get): Add an offset-based function version of BVAR_OR_DEFAULT.
(PER_BUFFER_VALUE_P): Check if value is Qunbound instead of checking
local_flags.
(KILL_PER_BUFFER_VALUE): Set killed buffer-local vars to Qunbound, not
the default value.
* src/buffer.c (reset_buffer): Set killed buffer-local vars to
Qunbound, not the default value.
(buffer_local_value): Use bvar_get so we look up defaults.
(init_buffer_once): Don't call reset_buffer_local_variables on
pseudobuffers, so we don't set all their values to Qunbound.
* src/data.c (do_symval_forwarding): Use bvar_get so we look up
defaults.
(store_symval_forwarding, set_default_internal): Don't loop all over
buffers when setting buffer defaults; this fixes bug#41029.
* test/src/data-tests.el (data-tests--set-default-per-buffer): Enable,
this is fixed now.
---
 src/buffer.c           |  9 ++------
 src/buffer.h           | 22 +++++++++++++------
 src/data.c             | 50 ++----------------------------------------
 test/src/data-tests.el |  1 -
 4 files changed, 19 insertions(+), 63 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index cc2df67f6c..b9ac93c5e8 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -54,8 +54,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    defined with DEFVAR_PER_BUFFER, that have special slots in each buffer.
    The default value occupies the same slot in this structure
    as an individual buffer's value occupies in that buffer.
-   Setting the default value also goes through the alist of buffers
-   and stores into each buffer that does not say it has a local value.  */
+*/
 
 struct buffer buffer_defaults;
 
@@ -989,8 +988,6 @@ reset_buffer (register struct buffer *b)
   bset_display_count (b, make_fixnum (0));
   bset_display_time (b, Qnil);
   bset_enable_multibyte_characters (b, Qt);
-  bset_cursor_type (b, BVAR (&buffer_defaults, cursor_type));
-  bset_extra_line_spacing (b, BVAR (&buffer_defaults, extra_line_spacing));
 
   b->display_error_modiff = 0;
 }
@@ -1260,7 +1257,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object buffer)
       {
 	lispfwd fwd = SYMBOL_FWD (sym);
 	if (BUFFER_OBJFWDP (fwd))
-	  result = per_buffer_value (buf, XBUFFER_OBJFWD (fwd)->offset);
+          result = bvar_get (buf, XBUFFER_OBJFWD (fwd)->offset);
 	else
 	  result = Fdefault_value (variable);
 	break;
@@ -5251,10 +5248,8 @@ init_buffer_once (void)
      are initialized reasonably, so mark_buffer won't choke.  */
   reset_buffer (&buffer_defaults);
   eassert (NILP (BVAR (&buffer_defaults, name)));
-  reset_buffer_local_variables (&buffer_defaults, 1);
   eassert (NILP (BVAR (&buffer_local_symbols, name)));
   reset_buffer (&buffer_local_symbols);
-  reset_buffer_local_variables (&buffer_local_symbols, 1);
   /* Prevent GC from getting confused.  */
   buffer_defaults.text = &buffer_defaults.own_text;
   buffer_local_symbols.text = &buffer_local_symbols.own_text;
diff --git a/src/buffer.h b/src/buffer.h
index 0af51d3348..ee5924dad8 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -284,7 +284,9 @@ struct buffer_text
 
 #define BVAR(buf, field) ((buf)->field ## _)
 
-#define BVAR_OR_DEFAULT(buf, field) BVAR (buf, field)
+#define BVAR_OR_DEFAULT(buf, field) (EQ (BVAR ((buf), field), Qunbound) \
+				     ? BVAR (&buffer_defaults, field) \
+				     : BVAR ((buf), field))
 
 /* Max number of builtin per-buffer variables.  */
 enum { MAX_PER_BUFFER_VARS = 50 };
@@ -1107,8 +1109,7 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
    that have special slots in each buffer.
    The default value occupies the same slot in this structure
    as an individual buffer's value occupies in that buffer.
-   Setting the default value also goes through the alist of buffers
-   and stores into each buffer that does not say it has a local value.  */
+*/
 
 extern struct buffer buffer_defaults;
 
@@ -1499,9 +1500,16 @@ BUFFER_DEFAULT_VALUE_P (int offset)
 INLINE bool
 PER_BUFFER_VALUE_P (struct buffer *b, int offset)
 {
-  int idx = PER_BUFFER_IDX (offset);
-  eassert (idx == -1 || valid_per_buffer_idx (idx));
-  return idx == -1 || b->local_flags[idx];
+  return !EQ (per_buffer_value (b, offset), Qunbound);
+}
+
+INLINE Lisp_Object
+bvar_get (struct buffer *b, ptrdiff_t offset)
+{
+  Lisp_Object val = per_buffer_value (b, offset);
+  return EQ (val, Qunbound)
+    ? per_buffer_default (offset)
+    : val;
 }
 
 /* Kill the per-buffer binding for this value, if there is one. */
@@ -1511,7 +1519,7 @@ KILL_PER_BUFFER_VALUE (struct buffer *b, int offset)
 {
   int idx = PER_BUFFER_IDX (offset);
   SET_PER_BUFFER_VALUE_P (b, idx, 0);
-  set_per_buffer_value (b, offset, per_buffer_default (offset));
+  set_per_buffer_value (b, offset, Qunbound);
 }
 
 /* Downcase a character C, or make no change if that cannot be done.  */
diff --git a/src/data.c b/src/data.c
index b3d3111eaa..04c27b4940 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1161,8 +1161,8 @@ do_symval_forwarding (lispfwd valcontents)
       return *XOBJFWD (valcontents)->objvar;
 
     case Lisp_Fwd_Buffer_Obj:
-      return per_buffer_value (current_buffer,
-			       XBUFFER_OBJFWD (valcontents)->offset);
+      return bvar_get (current_buffer,
+                       XBUFFER_OBJFWD (valcontents)->offset);
 
     case Lisp_Fwd_Kboard_Obj:
       /* We used to simply use current_kboard here, but from Lisp
@@ -1259,31 +1259,6 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval,
 
     case Lisp_Fwd_Obj:
       *XOBJFWD (valcontents)->objvar = newval;
-
-      /* If this variable is a default for something stored
-	 in the buffer itself, such as default-fill-column,
-	 find the buffers that don't have local values for it
-	 and update them.  */
-      if (XOBJFWD (valcontents)->objvar > (Lisp_Object *) &buffer_defaults
-	  && XOBJFWD (valcontents)->objvar < (Lisp_Object *) (&buffer_defaults + 1))
-	{
-	  int offset = ((char *) XOBJFWD (valcontents)->objvar
-			- (char *) &buffer_defaults);
-	  int idx = PER_BUFFER_IDX (offset);
-
-	  Lisp_Object tail, buf;
-
-	  if (idx <= 0)
-	    break;
-
-	  FOR_EACH_LIVE_BUFFER (tail, buf)
-	    {
-	      struct buffer *b = XBUFFER (buf);
-
-	      if (! PER_BUFFER_VALUE_P (b, offset))
-		set_per_buffer_value (b, offset, newval);
-	    }
-	}
       break;
 
     case Lisp_Fwd_Buffer_Obj:
@@ -1883,27 +1858,6 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value,
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
 
 	    set_per_buffer_default (offset, value);
-
-	    /* If this variable is not always local in all buffers,
-	       set it in the buffers that don't nominally have a local value.  */
-	    if (BUFFER_DEFAULT_VALUE_P (offset))
-	      {
-		Lisp_Object buf, tail;
-
-		/* Do this only in live buffers, so that if there are
-		   a lot of buffers which are dead, that doesn't slow
-		   down let-binding of variables that are
-		   automatically local when set, like
-		   case-fold-search.  This is for Lisp programs that
-		   let-bind such variables in their inner loops.  */
-		FOR_EACH_LIVE_BUFFER (tail, buf)
-		  {
-		    struct buffer *b = XBUFFER (buf);
-
-		    if (!PER_BUFFER_VALUE_P (b, offset))
-		      set_per_buffer_value (b, offset, value);
-		  }
-	      }
 	  }
 	else
           set_internal (symbol, value, Qnil, bindflag);
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index b1e5fa0767..eae2109fe6 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -424,7 +424,6 @@ comparing the subr with a much slower lisp implementation."
   (with-no-warnings (should (setq :keyword :keyword))))
 
 (ert-deftest data-tests--set-default-per-buffer ()
-  :expected-result t ;; Not fixed yet!
   ;; FIXME: Performance tests are inherently unreliable.
   ;; Using wall-clock time makes it even worse, so don't bother unless
   ;; we have the primitive to measure cpu-time.
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 10/15] Get rid of buffer_permanent_local_flags array
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:35:03 +0000
Resent-Message-ID: <handler.48264.B48264.1620336853818 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336853818
          (code B ref 48264); Thu, 06 May 2021 21:35:03 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:13 +0000
Received: from localhost ([127.0.0.1]:39881 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldN-0000D2-06
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:13 -0400
Received: from venus.catern.com ([68.183.49.163]:41516)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leldC-0000Ad-Oq
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:04 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336842; bh=M+vy07Lb39N/NbzPDCfUdA5/oM9l+uV3O870CGRrA64=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=CK3tInc70us3Tjlarjqq0F1IBJpEjgEZn+pXXyIDfVxOegOTlqx0/HtlwS/+iFOm2
 Lmqo6Ap/1VPoAFenYKmLxbiqQKzUx4WhdVfgMDB6KouJK/nd6p+pAuE5pOLWhliWEB
 MEuWrEuxgZpSgnlpKN2mmeCOfj3c+W6z4oMPYWoI=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 69B812E966E;
 Thu,  6 May 2021 21:34:02 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:41 -0400
Message-Id: <20210506213346.9730-11-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* lisp/bindings.el: Update comment to point to
reset_buffer_local_variables for information about
pseudo-permanent-locals.
* src/buffer.c (buffer_permanent_local_flags): Delete.
(reset_buffer_local_variables): Special case two
pseudo-permanent-locals for backwards-compatibility.
(init_buffer_once): Remove use of buffer_permanent_local_flags.
---
 lisp/bindings.el |  3 ++-
 src/buffer.c     | 28 +++++++++-------------------
 2 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/lisp/bindings.el b/lisp/bindings.el
index 6eac528eb6..902528a9ca 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -766,7 +766,8 @@ okay.  See `mode-line-format'.")
 ;; `kill-all-local-variables', because they have no default value.
 ;; For consistency, we give them the `permanent-local' property, even
 ;; though `kill-all-local-variables' does not actually consult it.
-;; See init_buffer_once in buffer.c for the origins of this list.
+;; See init_buffer_once and reset_buffer_local_variables in buffer.c
+;; for the origins of this list.
 
 (mapc (lambda (sym) (put sym 'permanent-local t))
       '(buffer-file-name default-directory buffer-backed-up
diff --git a/src/buffer.c b/src/buffer.c
index e6b7cd9aa8..9363aabddc 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -93,10 +93,6 @@ struct buffer buffer_local_symbols;
   ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM,				\
 		    min (PTRDIFF_MAX, SIZE_MAX) / word_size))
 
-/* Flags indicating which built-in buffer-local variables
-   are permanent locals.  */
-static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS];
-
 /* Number of per-buffer variables used.  */
 
 static int last_per_buffer_idx;
@@ -1100,10 +1096,14 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
   /* For each slot that has a default value, copy that into the slot.  */
   FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
     {
-      int idx = PER_BUFFER_IDX (offset);
       if ((BUFFER_DEFAULT_VALUE_P (offset)
-	   && (permanent_too
-	       || buffer_permanent_local_flags[idx] == 0)))
+           && (permanent_too
+               /* Special case these two for backwards-compat; they're
+                  flagged as permanent-locals in bindings.el, even
+                  though they do have default values. */
+               || (offset != PER_BUFFER_VAR_OFFSET (truncate_lines)
+                   && offset !=
+                   PER_BUFFER_VAR_OFFSET (buffer_file_coding_system)))))
         KILL_PER_BUFFER_VALUE (b, offset);
     }
 }
@@ -5133,7 +5133,6 @@ init_buffer_once (void)
 
      buffer_defaults: default values of buffer-locals
      buffer_local_flags: metadata
-     buffer_permanent_local_flags: metadata
      buffer_local_symbols: metadata
 
      There must be a simpler way to store the metadata.
@@ -5141,11 +5140,6 @@ init_buffer_once (void)
 
   int idx;
 
-  /* Items flagged permanent get an explicit permanent-local property
-     added in bindings.el, for clarity.  */
-  PDUMPER_REMEMBER_SCALAR (buffer_permanent_local_flags);
-  memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags);
-
   /* 0 means not a lisp var, -1 means always local, else mask.  */
   memset (&buffer_local_flags, 0, sizeof buffer_local_flags);
   bset_filename (&buffer_local_flags, make_fixnum (-1));
@@ -5193,9 +5187,7 @@ init_buffer_once (void)
   XSETFASTINT (BVAR (&buffer_local_flags, selective_display), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, selective_display_ellipses), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, tab_width), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, truncate_lines), idx);
-  /* Make this one a permanent local.  */
-  buffer_permanent_local_flags[idx++] = 1;
+  XSETFASTINT (BVAR (&buffer_local_flags, truncate_lines), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, word_wrap), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, ctl_arrow), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, fill_column), idx); ++idx;
@@ -5209,9 +5201,7 @@ init_buffer_once (void)
   XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_direction), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_separate_re), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_start_re), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, buffer_file_coding_system), idx);
-  /* Make this one a permanent local.  */
-  buffer_permanent_local_flags[idx++] = 1;
+  XSETFASTINT (BVAR (&buffer_local_flags, buffer_file_coding_system), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, left_margin_cols), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, right_margin_cols), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, left_fringe_width), idx); ++idx;
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 11/15] Delete SET_PER_BUFFER_VALUE_P and buffer local_flags field
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:35:04 +0000
Resent-Message-ID: <handler.48264.B48264.1620336854826 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336854826
          (code B ref 48264); Thu, 06 May 2021 21:35:04 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:14 +0000
Received: from localhost ([127.0.0.1]:39883 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldN-0000D9-DW
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:13 -0400
Received: from venus.catern.com ([68.183.49.163]:41522)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leldD-0000Ak-8g
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:05 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336843; bh=aMYcgthmqsZDfqWljPXYjCtIPmD2P+87QTorX3jCEII=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=ZcCIZVa/9fjS7QE8AVxkVbpLTs5NmKnNLccknUgf7ipnfD7OABmROnTJTaR/vkUlh
 oSUAOQtJSfOfymjuPc3eYYqWj2MELFHu0oELYQNM2wAzeZjk+yUJCOm6K1Tl4Pxmwc
 CTHLFYD86zP01+1cfVoeL7mn2GI4Tnid1NXLZJXo=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 0A45F2E966D;
 Thu,  6 May 2021 21:34:02 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:42 -0400
Message-Id: <20210506213346.9730-12-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* src/buffer.h (struct buffer): Remove local_flags field.
(SET_PER_BUFFER_VALUE_P): Remove.
(KILL_PER_BUFFER_VALUE): Stop using SET_PER_BUFFER_VALUE_P.
* src/buffer.c (Fget_buffer_create, clone_per_buffer_values)
(Fmake_indirect_buffer): Stop initializing local_flags.
* src/category.c (Fset_category_table):
* src/data.c (store_symval_forwarding):
* src/syntax.c (Fset_syntax_table):
Stop using SET_PER_BUFFER_VALUE_P.
* src/pdumper.c (dump_buffer):
Stop dumping local_flags field.
---
 src/buffer.c   |  6 ------
 src/buffer.h   | 19 -------------------
 src/category.c |  4 ----
 src/data.c     |  3 ---
 src/pdumper.c  |  3 ---
 src/syntax.c   |  4 ----
 6 files changed, 39 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 9363aabddc..3ece2f5b15 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -561,8 +561,6 @@ even if it is dead.  The return value is never nil.  */)
   /* No one shows us now.  */
   b->window_count = 0;
 
-  memset (&b->local_flags, 0, sizeof (b->local_flags));
-
   BUF_GAP_SIZE (b) = 20;
   block_input ();
   /* We allocate extra 1-byte at the tail and keep it always '\0' for
@@ -718,8 +716,6 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to)
       set_per_buffer_value (to, offset, obj);
     }
 
-  memcpy (to->local_flags, from->local_flags, sizeof to->local_flags);
-
   set_buffer_overlays_before (to, copy_overlays (to, from->overlays_before));
   set_buffer_overlays_after (to, copy_overlays (to, from->overlays_after));
 
@@ -821,8 +817,6 @@ CLONE nil means the indirect buffer's state is reset to default values.  */)
   /* Always -1 for an indirect buffer.  */
   b->window_count = -1;
 
-  memset (&b->local_flags, 0, sizeof (b->local_flags));
-
   b->pt = b->base_buffer->pt;
   b->begv = b->base_buffer->begv;
   b->zv = b->base_buffer->zv;
diff --git a/src/buffer.h b/src/buffer.h
index ee5924dad8..e55cbcdd94 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -605,13 +605,6 @@ struct buffer
      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
-     in buffer_local_flags as a Lisp integer.  If the index is -1,
-     this means the variable is always local in all buffers.  */
-  char local_flags[MAX_PER_BUFFER_VARS];
-
   /* Set to the modtime of the visited file when read or written.
      modtime.tv_nsec == NONEXISTENT_MODTIME_NSECS means
      visited file was nonexistent.  modtime.tv_nsec ==
@@ -1418,16 +1411,6 @@ OVERLAY_POSITION (Lisp_Object p)
 
 extern bool valid_per_buffer_idx (int);
 
-/* Set whether per-buffer variable with index IDX has a buffer-local
-   value in buffer B.  VAL zero means it hasn't.  */
-
-INLINE void
-SET_PER_BUFFER_VALUE_P (struct buffer *b, int idx, bool val)
-{
-  eassert (valid_per_buffer_idx (idx));
-  b->local_flags[idx] = val;
-}
-
 /* Return the index value of the per-buffer variable at offset OFFSET
    in the buffer structure.
 
@@ -1517,8 +1500,6 @@ bvar_get (struct buffer *b, ptrdiff_t offset)
 INLINE void
 KILL_PER_BUFFER_VALUE (struct buffer *b, int offset)
 {
-  int idx = PER_BUFFER_IDX (offset);
-  SET_PER_BUFFER_VALUE_P (b, idx, 0);
   set_per_buffer_value (b, offset, Qunbound);
 }
 
diff --git a/src/category.c b/src/category.c
index 522f4da697..a9f5225df8 100644
--- a/src/category.c
+++ b/src/category.c
@@ -268,12 +268,8 @@ DEFUN ("set-category-table", Fset_category_table, Sset_category_table, 1, 1, 0,
 Return TABLE.  */)
   (Lisp_Object table)
 {
-  int idx;
   table = check_category_table (table);
   bset_category_table (current_buffer, table);
-  /* Indicate that this buffer now has a specified category table.  */
-  idx = PER_BUFFER_VAR_IDX (category_table);
-  SET_PER_BUFFER_VALUE_P (current_buffer, idx, 1);
   return table;
 }
 
diff --git a/src/data.c b/src/data.c
index 04c27b4940..49a4bc3bea 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1295,9 +1295,6 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval,
 	if (buf == NULL)
 	  buf = current_buffer;
 	set_per_buffer_value (buf, offset, newval);
-        int idx = PER_BUFFER_IDX (offset);
-        if (idx > 0)
-          SET_PER_BUFFER_VALUE_P (buf, idx, 1);
       }
       break;
 
diff --git a/src/pdumper.c b/src/pdumper.c
index dfc7388b63..1e2e5238c7 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2802,9 +2802,6 @@ dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer)
   DUMP_FIELD_COPY (out, buffer, indirections);
   DUMP_FIELD_COPY (out, buffer, window_count);
 
-  memcpy (out->local_flags,
-          &buffer->local_flags,
-          sizeof (out->local_flags));
   DUMP_FIELD_COPY (out, buffer, modtime);
   DUMP_FIELD_COPY (out, buffer, modtime_size);
   DUMP_FIELD_COPY (out, buffer, auto_save_modified);
diff --git a/src/syntax.c b/src/syntax.c
index 6ea92beb7c..4724b39097 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1042,12 +1042,8 @@ DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0,
 One argument, a syntax table.  */)
   (Lisp_Object table)
 {
-  int idx;
   check_syntax_table (table);
   bset_syntax_table (current_buffer, table);
-  /* Indicate that this buffer now has a specified syntax table.  */
-  idx = PER_BUFFER_VAR_IDX (syntax_table);
-  SET_PER_BUFFER_VALUE_P (current_buffer, idx, 1);
   return table;
 }
 
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 13/15] Assert that PER_BUFFER_IDX for Lisp variables is not 0
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:35:04 +0000
Resent-Message-ID: <handler.48264.B48264.1620336854833 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336854833
          (code B ref 48264); Thu, 06 May 2021 21:35:04 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:14 +0000
Received: from localhost ([127.0.0.1]:39885 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldN-0000DH-TL
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:14 -0400
Received: from venus.catern.com ([68.183.49.163]:41534)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leldE-0000B5-BL
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:05 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336844; bh=rVvbw9Uob92bI+iHJCKOqBT/MzgHOqHU60lVfVGdSwk=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=Fy57ZqkjM6YikGszjlNElHyyS2K2KXdfDoglgBFo/wOyuSJ4t5WITh8VJphmXvcT2
 6yymJZhjjMZqL5QP08Tpnworw5YquoKDDV6QnDUo1dgKO2bkUtzMsEAp+pwCoLRUpw
 SM8fA1CwwPFaJ+5dFwfyJaVWw/elU7nyYtEdgfJY=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 0A30A2E9669;
 Thu,  6 May 2021 21:34:04 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:44 -0400
Message-Id: <20210506213346.9730-14-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

PER_BUFFER_IDX can't be 0 for Lisp variables - so this if-check was
always pointless.

* src/data.c (default_value): Change if to eassert
---
 src/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/data.c b/src/data.c
index 49a4bc3bea..4e58c6c815 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1758,8 +1758,8 @@ default_value (Lisp_Object symbol)
 	if (BUFFER_OBJFWDP (valcontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
-	    if (PER_BUFFER_IDX (offset) != 0)
-	      return per_buffer_default (offset);
+	    eassert (PER_BUFFER_IDX (offset) != 0);
+            return per_buffer_default (offset);
 	  }
 
 	/* For other variables, get the current value.  */
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:35:04 +0000
Resent-Message-ID: <handler.48264.B48264.1620336855840 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336855840
          (code B ref 48264); Thu, 06 May 2021 21:35:04 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:15 +0000
Received: from localhost ([127.0.0.1]:39887 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldO-0000DO-6C
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:15 -0400
Received: from venus.catern.com ([68.183.49.163]:41528)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leldD-0000Ay-Q6
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:05 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336843; bh=MUB7y+imm4F0C+1WEU3CVF15/0Vnzos4iYfXAoBQ6hk=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=ZwdMxDpJx8g6oZtKCraKxRF4CMKGmKFsn0gmXmBy6GuZY0sqSJF+QWJzsvMGyyhaw
 W33kDyEMTaIoR4EA3xM1OWeKXledACsdMwBLVO0VgGLav7gdD/w8vUj9Gcpn2VUcgh
 9HExNKVMyVTRB6NeJ0L525d/YbUoPN3GSB6w3JiI=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 7AE442E966A;
 Thu,  6 May 2021 21:34:03 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:43 -0400
Message-Id: <20210506213346.9730-13-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

In this way, we can be more sure that we aren't accidentally using
these fields.  We can also use the fact that fields without a default
are set to Qunbound to implement BUFFER_DEFAULT_VALUE_P.

* src/buffer.c (init_buffer_once): Set unused buffer_defaults fields
to Qunbound.
* src/buffer.h (BUFFER_DEFAULT_VALUE_P):
Check if field is Qunbound to determine if there's a default.
---
 src/buffer.c | 43 +++++++++++++++++++++++++++++++------------
 src/buffer.h |  5 +++--
 2 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 3ece2f5b15..097d03690a 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -54,7 +54,8 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    defined with DEFVAR_PER_BUFFER, that have special slots in each buffer.
    The default value occupies the same slot in this structure
    as an individual buffer's value occupies in that buffer.
-*/
+   Slots in this structure which are set to Qunbound are permanently
+   buffer-local. */
 
 struct buffer buffer_defaults;
 
@@ -5252,6 +5253,15 @@ init_buffer_once (void)
 
   /* Set up the default values of various buffer slots.  */
   /* Must do these before making the first buffer! */
+  int offset;
+  FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
+    {
+      /* These are initialized before us. */
+      if (!(offset == PER_BUFFER_VAR_OFFSET (syntax_table)
+            || offset == PER_BUFFER_VAR_OFFSET (category_table)))
+        set_per_buffer_default (offset, Qunbound);
+    }
+  set_per_buffer_default (PER_BUFFER_VAR_OFFSET (undo_list), Qunbound);
 
   /* real setup is done in bindings.el */
   bset_mode_line_format (&buffer_defaults, build_pure_c_string ("%-"));
@@ -5265,13 +5275,6 @@ init_buffer_once (void)
   bset_selective_display_ellipses (&buffer_defaults, Qt);
   bset_abbrev_table (&buffer_defaults, Qnil);
   bset_display_table (&buffer_defaults, Qnil);
-  bset_undo_list (&buffer_defaults, Qnil);
-  bset_mark_active (&buffer_defaults, Qnil);
-  bset_file_format (&buffer_defaults, Qnil);
-  bset_auto_save_file_format (&buffer_defaults, Qt);
-  set_buffer_overlays_before (&buffer_defaults, NULL);
-  set_buffer_overlays_after (&buffer_defaults, NULL);
-  buffer_defaults.overlay_center = BEG;
 
   XSETFASTINT (BVAR (&buffer_defaults, tab_width), 8);
   bset_truncate_lines (&buffer_defaults, Qnil);
@@ -5285,13 +5288,10 @@ init_buffer_once (void)
   bset_extra_line_spacing (&buffer_defaults, Qnil);
   bset_cursor_in_non_selected_windows (&buffer_defaults, Qt);
 
-  bset_enable_multibyte_characters (&buffer_defaults, Qt);
   bset_buffer_file_coding_system (&buffer_defaults, Qnil);
   XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70);
   XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0);
   bset_cache_long_scans (&buffer_defaults, Qt);
-  bset_file_truename (&buffer_defaults, Qnil);
-  XSETFASTINT (BVAR (&buffer_defaults, display_count), 0);
   XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0);
   XSETFASTINT (BVAR (&buffer_defaults, right_margin_cols), 0);
   bset_left_fringe_width (&buffer_defaults, Qnil);
@@ -5307,7 +5307,6 @@ init_buffer_once (void)
   bset_fringe_cursor_alist (&buffer_defaults, Qnil);
   bset_scroll_up_aggressively (&buffer_defaults, Qnil);
   bset_scroll_down_aggressively (&buffer_defaults, Qnil);
-  bset_display_time (&buffer_defaults, Qnil);
 
   /* Assign the local-flags to the slots that have default values.
      The local flag is a bit that is used in the buffer
@@ -5333,6 +5332,26 @@ init_buffer_once (void)
   DEFSYM (Qkill_buffer_hook, "kill-buffer-hook");
   Fput (Qkill_buffer_hook, Qpermanent_local, Qt);
 
+  /* Sanity check that we didn't set the default for slots which
+     are permanent-buffer-locals. */
+  eassert (EQ (BVAR (&buffer_defaults, filename), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, directory), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, backed_up), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, save_length), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, auto_save_file_name), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, read_only), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, mode_name), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, undo_list), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, mark_active), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, point_before_scroll), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, file_truename), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, invisibility_spec), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, file_format), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, auto_save_file_format), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, display_count), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, display_time), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, enable_multibyte_characters), Qunbound));
+
   /* Super-magic invisible buffer.  */
   Vprin1_to_string_buffer =
     Fget_buffer_create (build_pure_c_string (" prin1"), Qt);
diff --git a/src/buffer.h b/src/buffer.h
index e55cbcdd94..fc67b220e4 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1102,7 +1102,8 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
    that have special slots in each buffer.
    The default value occupies the same slot in this structure
    as an individual buffer's value occupies in that buffer.
-*/
+   Slots in this structure which are set to Qunbound are permanently
+   buffer-local. */
 
 extern struct buffer buffer_defaults;
 
@@ -1474,7 +1475,7 @@ set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
 INLINE bool
 BUFFER_DEFAULT_VALUE_P (int offset)
 {
-  return PER_BUFFER_IDX (offset) > 0;
+  return !EQ (per_buffer_default (offset), Qunbound);
 }
 
 /* Value is true if the variable with offset OFFSET has a local value
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 07/15] Add BVAR_OR_DEFAULT macro as a stub
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:35:05 +0000
Resent-Message-ID: <handler.48264.B48264.1620336857848 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336857848
          (code B ref 48264); Thu, 06 May 2021 21:35:05 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:17 +0000
Received: from localhost ([127.0.0.1]:39889 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldP-0000DV-4U
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:17 -0400
Received: from venus.catern.com ([68.183.49.163]:41498)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leldA-0000AH-QC
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:07 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336840; bh=p5i9zRFl1K7pYaU4T6tGtw2vMBpqQbAmkY5OTMdT4nE=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=kZwjY2ysNY0Z4X3NoUAlMcDeoyGk96f2UShqiA6AOvl9dz1wYZuBm0YYwS43V7vcV
 NJXWXNjoaMbPvoeDmwCSwIybIahVyRq2qKgaxeb93OBZSnM3XlZhmo5P0HLZd0xpU6
 Y3lQzA6VetO0DGmH2UFpQTkzTsG0kIaBylAlHlxE=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 72EAF2E87C0;
 Thu,  6 May 2021 21:34:00 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:38 -0400
Message-Id: <20210506213346.9730-8-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

For buffer variables without a default, we still use BVAR.  For any
buffer variable with a default, we use BVAR_OR_DEFAULT.  A later
commit will statically enforce this.

This has no functional change in this commit, but syntactically
differentiating between buffer variables with and without defaults
allows us to have different behavior for each kind in later commits.

* src/buffer.h (BVAR_OR_DEFAULT):
Add.
* src/bidi.c (bidi_at_paragraph_end, bidi_paragraph_cache_on_off)
(bidi_find_paragraph_start):
* src/buffer.c (swapfield_defaulted, Fbuffer_swap_text):
* src/buffer.h (SANE_TAB_WIDTH, CHARACTER_WIDTH):
* src/category.c (check_category_table, Fcategory_table)
(char_category_set):
* src/cmds.c (internal_self_insert):
* src/editfns.c (Fcompare_buffer_substrings)
(Fchar_equal):
* src/fileio.c (choose_write_coding_system):
* src/fns.c (extract_data_from_object):
* src/fringe.c (get_logical_cursor_bitmap, get_logical_fringe_bitmap)
(update_window_fringes):
* src/hbfont.c (hbfont_shape):
* src/indent.c (buffer_display_table, width_run_cache_on_off, current_column)
(scan_for_column, compute_motion, vmotion):
* src/msdos.c (IT_frame_up_to_date):
* src/search.c (compile_pattern_1, compile_pattern, looking_at_1)
(string_match_1, newline_cache_on_off, search_command, Fnewline_cache_check):
* src/syntax.c
(update_syntax_table, Fsyntax_table, Fmodify_syntax_entry):
* src/syntax.h
(syntax_property_entry, SETUP_BUFFER_SYNTAX_TABLE):
* src/window.c
(window_display_table, set_window_buffer, window_wants_mode_line)
(window_wants_header_line, window_wants_tab_line):
* src/xdisp.c
(fill_column_indicator_column, default_line_pixel_height, pos_visible_p)
(init_iterator, reseat_to_string, set_message_1)
(text_outside_line_unchanged_p, try_scrolling, try_cursor_movement)
(redisplay_window, try_window_reusing_current_matrix, row_containing_pos)
(try_window_id, display_line, Fcurrent_bidi_paragraph_direction)
(Fbidi_find_overridden_directionality, display_mode_lines, decode_mode_spec)
(display_count_lines, get_window_cursor_type, note_mouse_highlight):
Use BVAR_OR_DEFAULT.
---
 src/bidi.c     |  19 ++++----
 src/buffer.c   |  14 ++++--
 src/buffer.h   |   6 ++-
 src/category.c |   6 +--
 src/cmds.c     |   6 +--
 src/editfns.c  |   4 +-
 src/fileio.c   |   9 ++--
 src/fns.c      |   8 +--
 src/fringe.c   |  21 ++++----
 src/hbfont.c   |   2 +-
 src/indent.c   |  34 ++++++-------
 src/msdos.c    |   6 +--
 src/search.c   |  21 ++++----
 src/syntax.c   |   7 +--
 src/syntax.h   |   5 +-
 src/window.c   |  29 +++++------
 src/xdisp.c    | 130 +++++++++++++++++++++++++------------------------
 17 files changed, 173 insertions(+), 154 deletions(-)

diff --git a/src/bidi.c b/src/bidi.c
index 1413ba6b88..0d0587f5f5 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -1451,12 +1451,12 @@ bidi_at_paragraph_end (ptrdiff_t charpos, ptrdiff_t bytepos)
   Lisp_Object start_re;
   ptrdiff_t val;
 
-  if (STRINGP (BVAR (current_buffer, bidi_paragraph_separate_re)))
-    sep_re = BVAR (current_buffer, bidi_paragraph_separate_re);
+  if (STRINGP (BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_separate_re)))
+    sep_re = BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_separate_re);
   else
     sep_re = paragraph_separate_re;
-  if (STRINGP (BVAR (current_buffer, bidi_paragraph_start_re)))
-    start_re = BVAR (current_buffer, bidi_paragraph_start_re);
+  if (STRINGP (BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_start_re)))
+    start_re = BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_start_re);
   else
     start_re = paragraph_start_re;
 
@@ -1500,10 +1500,10 @@ bidi_paragraph_cache_on_off (void)
      This is because doing so will just make the cache pure overhead,
      since if we turn it on via indirect buffer, it will be
      immediately turned off by its base buffer.  */
-  if (NILP (BVAR (current_buffer, cache_long_scans)))
+  if (NILP (BVAR_OR_DEFAULT (current_buffer, cache_long_scans)))
     {
       if (!indirect_p
-	  || NILP (BVAR (cache_buffer, cache_long_scans)))
+	  || NILP (BVAR_OR_DEFAULT (cache_buffer, cache_long_scans)))
 	{
 	  if (cache_buffer->bidi_paragraph_cache)
 	    {
@@ -1516,7 +1516,7 @@ bidi_paragraph_cache_on_off (void)
   else
     {
       if (!indirect_p
-	  || !NILP (BVAR (cache_buffer, cache_long_scans)))
+	  || !NILP (BVAR_OR_DEFAULT (cache_buffer, cache_long_scans)))
 	{
 	  if (!cache_buffer->bidi_paragraph_cache)
 	    cache_buffer->bidi_paragraph_cache = new_region_cache ();
@@ -1538,9 +1538,8 @@ bidi_paragraph_cache_on_off (void)
 static ptrdiff_t
 bidi_find_paragraph_start (ptrdiff_t pos, ptrdiff_t pos_byte)
 {
-  Lisp_Object re =
-    STRINGP (BVAR (current_buffer, bidi_paragraph_start_re))
-    ? BVAR (current_buffer, bidi_paragraph_start_re)
+  Lisp_Object re = STRINGP (BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_start_re))
+    ? BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_start_re)
     : paragraph_start_re;
   ptrdiff_t limit = ZV, limit_byte = ZV_BYTE;
   struct region_cache *bpc = bidi_paragraph_cache_on_off ();
diff --git a/src/buffer.c b/src/buffer.c
index c75dcbcffb..cc2df67f6c 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2382,6 +2382,12 @@ results, see Info node `(elisp)Swapping Text'.  */)
     bset_##field (other_buffer, BVAR (current_buffer, field));	\
     bset_##field (current_buffer, tmp##field);			\
   } while (0)
+#define swapfield_defaulted(field, type) \
+  do {							\
+    type tmp##field = BVAR_OR_DEFAULT (other_buffer, field);		\
+    bset_##field (other_buffer, BVAR_OR_DEFAULT (current_buffer, field));	\
+    bset_##field (current_buffer, tmp##field);			\
+  } while (0)
 
   swapfield (own_text, struct buffer_text);
   eassert (current_buffer->text == &current_buffer->own_text);
@@ -2415,10 +2421,10 @@ results, see Info node `(elisp)Swapping Text'.  */)
   swapfield_ (mark, Lisp_Object);
   swapfield_ (mark_active, Lisp_Object); /* Belongs with the `mark'.  */
   swapfield_ (enable_multibyte_characters, Lisp_Object);
-  swapfield_ (bidi_display_reordering, Lisp_Object);
-  swapfield_ (bidi_paragraph_direction, Lisp_Object);
-  swapfield_ (bidi_paragraph_separate_re, Lisp_Object);
-  swapfield_ (bidi_paragraph_start_re, Lisp_Object);
+  swapfield_defaulted (bidi_display_reordering, Lisp_Object);
+  swapfield_defaulted (bidi_paragraph_direction, Lisp_Object);
+  swapfield_defaulted (bidi_paragraph_separate_re, Lisp_Object);
+  swapfield_defaulted (bidi_paragraph_start_re, Lisp_Object);
   /* FIXME: Not sure what we should do with these *_marker fields.
      Hopefully they're just nil anyway.  */
   swapfield_ (pt_marker, Lisp_Object);
diff --git a/src/buffer.h b/src/buffer.h
index fff2d27ea0..0af51d3348 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -284,6 +284,8 @@ struct buffer_text
 
 #define BVAR(buf, field) ((buf)->field ## _)
 
+#define BVAR_OR_DEFAULT(buf, field) BVAR (buf, field)
+
 /* Max number of builtin per-buffer variables.  */
 enum { MAX_PER_BUFFER_VARS = 50 };
 
@@ -1556,7 +1558,7 @@ sanitize_tab_width (Lisp_Object width)
 INLINE int
 SANE_TAB_WIDTH (struct buffer *buf)
 {
-  return sanitize_tab_width (BVAR (buf, tab_width));
+  return sanitize_tab_width (BVAR_OR_DEFAULT (buf, tab_width));
 }
 
 /* Return a non-outlandish value for a character width.  */
@@ -1580,7 +1582,7 @@ CHARACTER_WIDTH (int c)
 			(XFIXNUM (CHAR_TABLE_REF (Vchar_width_table, c))))
 	  : c == '\t' ? SANE_TAB_WIDTH (current_buffer)
 	  : c == '\n' ? 0
-	  : !NILP (BVAR (current_buffer, ctl_arrow)) ? 2 : 4);
+	  : !NILP (BVAR_OR_DEFAULT (current_buffer, ctl_arrow)) ? 2 : 4);
 }
 
 
diff --git a/src/category.c b/src/category.c
index ec8f61f7f0..522f4da697 100644
--- a/src/category.c
+++ b/src/category.c
@@ -180,7 +180,7 @@ static Lisp_Object
 check_category_table (Lisp_Object table)
 {
   if (NILP (table))
-    return BVAR (current_buffer, category_table);
+    return BVAR_OR_DEFAULT (current_buffer, category_table);
   CHECK_TYPE (!NILP (Fcategory_table_p (table)), Qcategory_table_p, table);
   return table;
 }
@@ -190,7 +190,7 @@ DEFUN ("category-table", Fcategory_table, Scategory_table, 0, 0, 0,
 This is the one specified by the current buffer.  */)
   (void)
 {
-  return BVAR (current_buffer, category_table);
+  return BVAR_OR_DEFAULT (current_buffer, category_table);
 }
 
 DEFUN ("standard-category-table", Fstandard_category_table,
@@ -281,7 +281,7 @@ Return TABLE.  */)
 Lisp_Object
 char_category_set (int c)
 {
-  return CHAR_TABLE_REF (BVAR (current_buffer, category_table), c);
+  return CHAR_TABLE_REF (BVAR_OR_DEFAULT (current_buffer, category_table), c);
 }
 
 DEFUN ("char-category-set", Fchar_category_set, Schar_category_set, 1, 1, 0,
diff --git a/src/cmds.c b/src/cmds.c
index c8a96d918c..a355142480 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -320,7 +320,7 @@ internal_self_insert (int c, EMACS_INT n)
   ptrdiff_t chars_to_delete = 0;
   ptrdiff_t spaces_to_insert = 0;
 
-  overwrite = BVAR (current_buffer, overwrite_mode);
+  overwrite = BVAR_OR_DEFAULT (current_buffer, overwrite_mode);
   if (!NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions))
     hairy = 1;
 
@@ -406,7 +406,7 @@ internal_self_insert (int c, EMACS_INT n)
 
   synt = SYNTAX (c);
 
-  if (!NILP (BVAR (current_buffer, abbrev_mode))
+  if (!NILP (BVAR_OR_DEFAULT (current_buffer, abbrev_mode))
       && synt != Sword
       && NILP (BVAR (current_buffer, read_only))
       && PT > BEGV
@@ -474,7 +474,7 @@ internal_self_insert (int c, EMACS_INT n)
   if ((CHAR_TABLE_P (Vauto_fill_chars)
        ? !NILP (CHAR_TABLE_REF (Vauto_fill_chars, c))
        : (c == ' ' || c == '\n'))
-      && !NILP (BVAR (current_buffer, auto_fill_function)))
+      && !NILP (BVAR_OR_DEFAULT (current_buffer, auto_fill_function)))
     {
       Lisp_Object auto_fill_result;
 
diff --git a/src/editfns.c b/src/editfns.c
index 04b8e85d9c..01e56843a6 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1769,7 +1769,7 @@ determines whether case is significant or ignored.  */)
   register EMACS_INT begp1, endp1, begp2, endp2, temp;
   register struct buffer *bp1, *bp2;
   register Lisp_Object trt
-    = (!NILP (BVAR (current_buffer, case_fold_search))
+    = (!NILP (BVAR_OR_DEFAULT (current_buffer, case_fold_search))
        ? BVAR (current_buffer, case_canon_table) : Qnil);
   ptrdiff_t chars = 0;
   ptrdiff_t i1, i2, i1_byte, i2_byte;
@@ -4022,7 +4022,7 @@ Case is ignored if `case-fold-search' is non-nil in the current buffer.  */)
 
   if (XFIXNUM (c1) == XFIXNUM (c2))
     return Qt;
-  if (NILP (BVAR (current_buffer, case_fold_search)))
+  if (NILP (BVAR_OR_DEFAULT (current_buffer, case_fold_search)))
     return Qnil;
 
   i1 = XFIXNAT (c1);
diff --git a/src/fileio.c b/src/fileio.c
index 741e297d29..4ee3b293a1 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4919,7 +4919,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
       bool using_default_coding = 0;
       bool force_raw_text = 0;
 
-      val = BVAR (current_buffer, buffer_file_coding_system);
+      val = BVAR_OR_DEFAULT (current_buffer, buffer_file_coding_system);
       if (NILP (val)
 	  || NILP (Flocal_variable_p (Qbuffer_file_coding_system, Qnil)))
 	{
@@ -4942,7 +4942,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
 	{
 	  /* If we still have not decided a coding system, use the
 	     current buffer's value of buffer-file-coding-system.  */
-	  val = BVAR (current_buffer, buffer_file_coding_system);
+	  val = BVAR_OR_DEFAULT (current_buffer, buffer_file_coding_system);
 	  using_default_coding = 1;
 	}
 
@@ -4974,7 +4974,8 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
 	 format, we use that of `buffer-file-coding-system'.  */
       if (! using_default_coding)
 	{
-	  Lisp_Object dflt = BVAR (&buffer_defaults, buffer_file_coding_system);
+	  Lisp_Object dflt = BVAR_OR_DEFAULT (&buffer_defaults,
+                                             buffer_file_coding_system);
 
 	  if (! NILP (dflt))
 	    val = coding_inherit_eol_type (val, dflt);
@@ -4989,7 +4990,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
   val = coding_inherit_eol_type (val, eol_parent);
   setup_coding_system (val, coding);
 
-  if (!STRINGP (start) && EQ (Qt, BVAR (current_buffer, selective_display)))
+  if (!STRINGP (start) && EQ (Qt, BVAR_OR_DEFAULT (current_buffer, selective_display)))
     coding->mode |= CODING_MODE_SELECTIVE_DISPLAY;
   return val;
 }
diff --git a/src/fns.c b/src/fns.c
index 41429c8863..4ac9481325 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -5416,7 +5416,8 @@ extract_data_from_object (Lisp_Object spec,
 	    {
 	      bool force_raw_text = false;
 
-	      coding_system = BVAR (XBUFFER (object), buffer_file_coding_system);
+	      coding_system = BVAR_OR_DEFAULT (XBUFFER(object),
+                                              buffer_file_coding_system);
 	      if (NILP (coding_system)
 		  || NILP (Flocal_variable_p (Qbuffer_file_coding_system, Qnil)))
 		{
@@ -5437,11 +5438,12 @@ extract_data_from_object (Lisp_Object spec,
 		}
 
 	      if (NILP (coding_system)
-		  && !NILP (BVAR (XBUFFER (object), buffer_file_coding_system)))
+		  && !NILP (BVAR_OR_DEFAULT (XBUFFER(object), buffer_file_coding_system)))
 		{
 		  /* If we still have not decided a coding system, use the
 		     default value of buffer-file-coding-system.  */
-		  coding_system = BVAR (XBUFFER (object), buffer_file_coding_system);
+		  coding_system = BVAR_OR_DEFAULT (XBUFFER(object),
+                                                  buffer_file_coding_system);
 		}
 
 	      if (!force_raw_text
diff --git a/src/fringe.c b/src/fringe.c
index 65c9a84ac9..91f06a1291 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -697,7 +697,8 @@ get_logical_cursor_bitmap (struct window *w, Lisp_Object cursor)
 {
   Lisp_Object cmap, bm = Qnil;
 
-  if ((cmap = BVAR (XBUFFER (w->contents), fringe_cursor_alist)), !NILP (cmap))
+  if ((cmap = BVAR_OR_DEFAULT (XBUFFER(w->contents), fringe_cursor_alist)),
+      !NILP (cmap))
     {
       bm = Fassq (cursor, cmap);
       if (CONSP (bm))
@@ -707,9 +708,9 @@ get_logical_cursor_bitmap (struct window *w, Lisp_Object cursor)
 	  return lookup_fringe_bitmap (bm);
 	}
     }
-  if (EQ (cmap, BVAR (&buffer_defaults, fringe_cursor_alist)))
+  if (EQ (cmap, BVAR_OR_DEFAULT (&buffer_defaults, fringe_cursor_alist)))
     return NO_FRINGE_BITMAP;
-  bm = Fassq (cursor, BVAR (&buffer_defaults, fringe_cursor_alist));
+  bm = Fassq (cursor, BVAR_OR_DEFAULT (&buffer_defaults, fringe_cursor_alist));
   if (!CONSP (bm) || ((bm = XCDR (bm)), NILP (bm)))
     return NO_FRINGE_BITMAP;
   return lookup_fringe_bitmap (bm);
@@ -734,7 +735,8 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, in
      If partial, lookup partial bitmap in default value if not found here.
      If not partial, or no partial spec is present, use non-partial bitmap.  */
 
-  if ((cmap = BVAR (XBUFFER (w->contents), fringe_indicator_alist)), !NILP (cmap))
+  if ((cmap = BVAR_OR_DEFAULT (XBUFFER(w->contents), fringe_indicator_alist)),
+      !NILP (cmap))
     {
       bm1 = Fassq (bitmap, cmap);
       if (CONSP (bm1))
@@ -768,10 +770,11 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, in
 	}
     }
 
-  if (!EQ (cmap, BVAR (&buffer_defaults, fringe_indicator_alist))
-      && !NILP (BVAR (&buffer_defaults, fringe_indicator_alist)))
+  if (!EQ (cmap, BVAR_OR_DEFAULT (&buffer_defaults, fringe_indicator_alist))
+      && !NILP (BVAR_OR_DEFAULT (&buffer_defaults, fringe_indicator_alist)))
     {
-      bm2 = Fassq (bitmap, BVAR (&buffer_defaults, fringe_indicator_alist));
+      bm2 = Fassq (bitmap,
+                   BVAR_OR_DEFAULT (&buffer_defaults, fringe_indicator_alist));
       if (CONSP (bm2))
 	{
 	  if ((bm2 = XCDR (bm2)), !NILP (bm2))
@@ -970,7 +973,7 @@ update_window_fringes (struct window *w, bool keep_current_p)
     return 0;
 
   if (!MINI_WINDOW_P (w)
-      && (ind = BVAR (XBUFFER (w->contents), indicate_buffer_boundaries), !NILP (ind)))
+      && (ind = BVAR_OR_DEFAULT (XBUFFER (w->contents), indicate_buffer_boundaries), !NILP (ind)))
     {
       if (EQ (ind, Qleft) || EQ (ind, Qright))
 	boundary_top = boundary_bot = arrow_top = arrow_bot = ind;
@@ -1031,7 +1034,7 @@ update_window_fringes (struct window *w, bool keep_current_p)
 	}
     }
 
-  empty_pos = BVAR (XBUFFER (w->contents), indicate_empty_lines);
+  empty_pos = BVAR_OR_DEFAULT (XBUFFER (w->contents), indicate_empty_lines);
   if (!NILP (empty_pos) && !EQ (empty_pos, Qright))
     empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft;
 
diff --git a/src/hbfont.c b/src/hbfont.c
index e9f4085b1a..5f8f4d2445 100644
--- a/src/hbfont.c
+++ b/src/hbfont.c
@@ -443,7 +443,7 @@ hbfont_shape (Lisp_Object lgstring, Lisp_Object direction)
       /* If they bind bidi-display-reordering to nil, the DIRECTION
 	 they provide is meaningless, and we should let HarfBuzz guess
 	 the real direction.  */
-      && !NILP (BVAR (current_buffer, bidi_display_reordering)))
+      && !NILP (BVAR_OR_DEFAULT (current_buffer, bidi_display_reordering)))
     {
       hb_direction_t dir = HB_DIRECTION_LTR;
       if (EQ (direction, QL2R))
diff --git a/src/indent.c b/src/indent.c
index 6246b544fb..d30b5b3ad9 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -60,7 +60,7 @@ buffer_display_table (void)
 {
   Lisp_Object thisbuf;
 
-  thisbuf = BVAR (current_buffer, display_table);
+  thisbuf = BVAR_OR_DEFAULT (current_buffer, display_table);
   if (DISP_TABLE_P (thisbuf))
     return XCHAR_TABLE (thisbuf);
   if (DISP_TABLE_P (Vstandard_display_table))
@@ -153,13 +153,13 @@ width_run_cache_on_off (void)
       indirect_p = true;
     }
 
-  if (NILP (BVAR (current_buffer, cache_long_scans))
+  if (NILP (BVAR_OR_DEFAULT (current_buffer, cache_long_scans))
       /* And, for the moment, this feature doesn't work on multibyte
          characters.  */
       || !NILP (BVAR (current_buffer, enable_multibyte_characters)))
     {
       if (!indirect_p
-	  || NILP (BVAR (cache_buffer, cache_long_scans))
+	  || NILP (BVAR_OR_DEFAULT (cache_buffer, cache_long_scans))
 	  || !NILP (BVAR (cache_buffer, enable_multibyte_characters)))
 	{
 	  /* It should be off.  */
@@ -175,7 +175,7 @@ width_run_cache_on_off (void)
   else
     {
       if (!indirect_p
-	  || (!NILP (BVAR (cache_buffer, cache_long_scans))
+	  || (!NILP (BVAR_OR_DEFAULT (cache_buffer, cache_long_scans))
 	      && NILP (BVAR (cache_buffer, enable_multibyte_characters))))
 	{
 	  /* It should be on.  */
@@ -334,7 +334,7 @@ current_column (void)
   ptrdiff_t post_tab;
   int c;
   int tab_width = SANE_TAB_WIDTH (current_buffer);
-  bool ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
+  bool ctl_arrow = !NILP (BVAR_OR_DEFAULT (current_buffer, ctl_arrow));
   struct Lisp_Char_Table *dp = buffer_display_table ();
 
   if (PT == last_known_column_point
@@ -416,7 +416,7 @@ current_column (void)
 	    col++;
 	  else if (c == '\n'
 		   || (c == '\r'
-		       && EQ (BVAR (current_buffer, selective_display), Qt)))
+		       && EQ (BVAR_OR_DEFAULT (current_buffer, selective_display), Qt)))
 	    {
 	      ptr++;
 	      goto start_of_line_found;
@@ -531,7 +531,7 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol,
 		 ptrdiff_t *prevpos, ptrdiff_t *prevbpos, ptrdiff_t *prevcol)
 {
   int tab_width = SANE_TAB_WIDTH (current_buffer);
-  bool ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
+  bool ctl_arrow = !NILP (BVAR_OR_DEFAULT (current_buffer, ctl_arrow));
   struct Lisp_Char_Table *dp = buffer_display_table ();
   bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
   struct composition_it cmp_it;
@@ -652,7 +652,7 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol,
 
 	      if (c == '\n')
 		goto endloop;
-	      if (c == '\r' && EQ (BVAR (current_buffer, selective_display), Qt))
+	      if (c == '\r' && EQ (BVAR_OR_DEFAULT (current_buffer, selective_display), Qt))
 		goto endloop;
 	      if (c == '\t')
 		{
@@ -670,7 +670,7 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol,
 
 	  if (c == '\n')
 	    goto endloop;
-	  if (c == '\r' && EQ (BVAR (current_buffer, selective_display), Qt))
+	  if (c == '\r' && EQ (BVAR_OR_DEFAULT (current_buffer, selective_display), Qt))
 	    goto endloop;
 	  if (c == '\t')
 	    {
@@ -1131,12 +1131,12 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos,
   ptrdiff_t pos_byte;
   int c = 0;
   int tab_width = SANE_TAB_WIDTH (current_buffer);
-  bool ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
+  bool ctl_arrow = !NILP (BVAR_OR_DEFAULT (current_buffer, ctl_arrow));
   struct Lisp_Char_Table *dp = window_display_table (win);
   EMACS_INT selective
-    = (FIXNUMP (BVAR (current_buffer, selective_display))
-       ? XFIXNUM (BVAR (current_buffer, selective_display))
-       : !NILP (BVAR (current_buffer, selective_display)) ? -1 : 0);
+    = (FIXNUMP (BVAR_OR_DEFAULT (current_buffer, selective_display))
+       ? XFIXNUM (BVAR_OR_DEFAULT (current_buffer, selective_display))
+       : !NILP (BVAR_OR_DEFAULT (current_buffer, selective_display)) ? -1 : 0);
   ptrdiff_t selective_rlen
     = (selective && dp && VECTORP (DISP_INVIS_VECTOR (dp))
        ? ASIZE (DISP_INVIS_VECTOR (dp)) : 0);
@@ -1352,7 +1352,7 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos,
 	    }
 
 	  if (hscroll || truncate
-	      || !NILP (BVAR (current_buffer, truncate_lines)))
+	      || !NILP (BVAR_OR_DEFAULT (current_buffer, truncate_lines)))
 	    {
 	      /* Truncating: skip to newline, unless we are already past
                  TO (we need to go back below).  */
@@ -1837,10 +1837,10 @@ vmotion (ptrdiff_t from, ptrdiff_t from_byte,
   register ptrdiff_t first;
   ptrdiff_t lmargin = hscroll > 0 ? 1 - hscroll : 0;
   ptrdiff_t selective
-    = (FIXNUMP (BVAR (current_buffer, selective_display))
-       ? clip_to_bounds (-1, XFIXNUM (BVAR (current_buffer, selective_display)),
+    = (FIXNUMP (BVAR_OR_DEFAULT (current_buffer, selective_display))
+       ? clip_to_bounds (-1, XFIXNUM (BVAR_OR_DEFAULT (current_buffer, selective_display)),
 			 PTRDIFF_MAX)
-       : !NILP (BVAR (current_buffer, selective_display)) ? -1 : 0);
+       : !NILP (BVAR_OR_DEFAULT (current_buffer, selective_display)) ? -1 : 0);
   Lisp_Object window;
   bool did_motion;
   /* This is the object we use for fetching character properties.  */
diff --git a/src/msdos.c b/src/msdos.c
index 5da01c9e7c..e3426d9403 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -1321,12 +1321,12 @@ IT_frame_up_to_date (struct frame *f)
     {
       struct buffer *b = XBUFFER (sw->contents);
 
-      if (EQ (BVAR (b,cursor_type), Qt))
+      if (EQ (BVAR_OR_DEFAULT (b, cursor_type), Qt))
 	new_cursor = frame_desired_cursor;
-      else if (NILP (BVAR (b, cursor_type))) /* nil means no cursor */
+      else if (NILP (BVAR_OR_DEFAULT (b, cursor_type))) /* nil means no cursor */
 	new_cursor = Fcons (Qbar, make_fixnum (0));
       else
-	new_cursor = BVAR (b, cursor_type);
+	new_cursor = BVAR_OR_DEFAULT (b, cursor_type);
     }
 
   IT_set_cursor_type (f, new_cursor);
diff --git a/src/search.c b/src/search.c
index c757bf3d1f..f15059635c 100644
--- a/src/search.c
+++ b/src/search.c
@@ -125,7 +125,8 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern,
 
   /* If the compiled pattern hard codes some of the contents of the
      syntax-table, it can only be reused with *this* syntax table.  */
-  cp->syntax_table = cp->buf.used_syntax ? BVAR (current_buffer, syntax_table) : Qt;
+  cp->syntax_table = cp->buf.used_syntax ? BVAR_OR_DEFAULT (current_buffer,
+                                                           syntax_table) : Qt;
 
   if (val)
     xsignal1 (Qinvalid_regexp, build_string (val));
@@ -219,7 +220,7 @@ compile_pattern (Lisp_Object pattern, struct re_registers *regp,
 	  && EQ (cp->buf.translate, translate)
 	  && cp->posix == posix
 	  && (EQ (cp->syntax_table, Qt)
-	      || EQ (cp->syntax_table, BVAR (current_buffer, syntax_table)))
+	      || EQ (cp->syntax_table, BVAR_OR_DEFAULT (current_buffer, syntax_table)))
 	  && !NILP (Fequal (cp->f_whitespace_regexp, Vsearch_spaces_regexp))
 	  && cp->buf.charset_unibyte == charset_unibyte)
 	break;
@@ -282,7 +283,7 @@ looking_at_1 (Lisp_Object string, bool posix)
   struct regexp_cache *cache_entry = compile_pattern (
     string,
     preserve_match_data ? &search_regs : NULL,
-    (!NILP (BVAR (current_buffer, case_fold_search))
+    (!NILP (BVAR_OR_DEFAULT (current_buffer, case_fold_search))
      ? BVAR (current_buffer, case_canon_table) : Qnil),
     posix,
     !NILP (BVAR (current_buffer, enable_multibyte_characters)));
@@ -401,7 +402,7 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start,
   bufp = &compile_pattern (regexp,
                            (NILP (Vinhibit_changing_match_data)
                             ? &search_regs : NULL),
-                           (!NILP (BVAR (current_buffer, case_fold_search))
+                           (!NILP (BVAR_OR_DEFAULT (current_buffer, case_fold_search))
                             ? BVAR (current_buffer, case_canon_table) : Qnil),
                            posix,
                            STRING_MULTIBYTE (string))->buf;
@@ -592,10 +593,10 @@ newline_cache_on_off (struct buffer *buf)
      This is because doing so will just make the cache pure overhead,
      since if we turn it on via indirect buffer, it will be
      immediately turned off by its base buffer.  */
-  if (NILP (BVAR (buf, cache_long_scans)))
+  if (NILP (BVAR_OR_DEFAULT (buf, cache_long_scans)))
     {
       if (!indirect_p
-	  || NILP (BVAR (base_buf, cache_long_scans)))
+	  || NILP (BVAR_OR_DEFAULT (base_buf, cache_long_scans)))
 	{
 	  /* It should be off.  */
 	  if (base_buf->newline_cache)
@@ -609,7 +610,7 @@ newline_cache_on_off (struct buffer *buf)
   else
     {
       if (!indirect_p
-	  || !NILP (BVAR (base_buf, cache_long_scans)))
+	  || !NILP (BVAR_OR_DEFAULT (base_buf, cache_long_scans)))
 	{
 	  /* It should be on.  */
 	  if (base_buf->newline_cache == 0)
@@ -1048,10 +1049,10 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
 			 BVAR (current_buffer, case_eqv_table));
 
   np = search_buffer (string, PT, PT_BYTE, lim, lim_byte, n, RE,
-		      (!NILP (BVAR (current_buffer, case_fold_search))
+		      (!NILP (BVAR_OR_DEFAULT (current_buffer, case_fold_search))
 		       ? BVAR (current_buffer, case_canon_table)
 		       : Qnil),
-		      (!NILP (BVAR (current_buffer, case_fold_search))
+		      (!NILP (BVAR_OR_DEFAULT (current_buffer, case_fold_search))
 		       ? BVAR (current_buffer, case_eqv_table)
 		       : Qnil),
 		      posix);
@@ -3275,7 +3276,7 @@ the buffer.  If the buffer doesn't have a cache, the value is nil.  */)
     buf = buf->base_buffer;
 
   /* If the buffer doesn't have a newline cache, return nil.  */
-  if (NILP (BVAR (buf, cache_long_scans))
+  if (NILP (BVAR_OR_DEFAULT (buf, cache_long_scans))
       || buf->newline_cache == NULL)
     return Qnil;
 
diff --git a/src/syntax.c b/src/syntax.c
index 9fbf88535f..6ea92beb7c 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -416,7 +416,8 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, bool init,
       else
 	{
 	  gl_state.use_global = 0;
-	  gl_state.current_syntax_table = BVAR (current_buffer, syntax_table);
+	  gl_state.current_syntax_table = BVAR_OR_DEFAULT (current_buffer,
+                                                          syntax_table);
 	}
     }
 
@@ -998,7 +999,7 @@ DEFUN ("syntax-table", Fsyntax_table, Ssyntax_table, 0, 0, 0,
 This is the one specified by the current buffer.  */)
   (void)
 {
-  return BVAR (current_buffer, syntax_table);
+  return BVAR_OR_DEFAULT (current_buffer, syntax_table);
 }
 
 DEFUN ("standard-syntax-table", Fstandard_syntax_table,
@@ -1254,7 +1255,7 @@ usage: (modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE)  */)
     CHECK_CHARACTER (c);
 
   if (NILP (syntax_table))
-    syntax_table = BVAR (current_buffer, syntax_table);
+    syntax_table = BVAR_OR_DEFAULT (current_buffer, syntax_table);
   else
     check_syntax_table (syntax_table);
 
diff --git a/src/syntax.h b/src/syntax.h
index 66ee139a96..c89797ea13 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -103,7 +103,7 @@ syntax_property_entry (int c, bool via_property)
     return (gl_state.use_global
 	    ? gl_state.global_code
 	    : CHAR_TABLE_REF (gl_state.current_syntax_table, c));
-  return CHAR_TABLE_REF (BVAR (current_buffer, syntax_table), c);
+  return CHAR_TABLE_REF (BVAR_OR_DEFAULT (current_buffer, syntax_table), c);
 }
 INLINE Lisp_Object
 SYNTAX_ENTRY (int c)
@@ -212,7 +212,8 @@ SETUP_BUFFER_SYNTAX_TABLE (void)
 {
   gl_state.use_global = false;
   gl_state.e_property_truncated = false;
-  gl_state.current_syntax_table = BVAR (current_buffer, syntax_table);
+  gl_state.current_syntax_table = BVAR_OR_DEFAULT (current_buffer,
+                                                  syntax_table);
 }
 
 extern ptrdiff_t scan_words (ptrdiff_t, EMACS_INT);
diff --git a/src/window.c b/src/window.c
index 0a14eca58f..b85f758679 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2315,8 +2315,8 @@ window_display_table (struct window *w)
     {
       struct buffer *b = XBUFFER (w->contents);
 
-      if (DISP_TABLE_P (BVAR (b, display_table)))
-	dp = XCHAR_TABLE (BVAR (b, display_table));
+      if (DISP_TABLE_P (BVAR_OR_DEFAULT (b, display_table)))
+	dp = XCHAR_TABLE (BVAR_OR_DEFAULT (b, display_table));
       else if (DISP_TABLE_P (Vstandard_display_table))
 	dp = XCHAR_TABLE (Vstandard_display_table);
     }
@@ -4044,17 +4044,18 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
       /* Set fringes and scroll bars from buffer unless they have been
 	 declared as persistent.  */
       if (!w->fringes_persistent)
-	set_window_fringes (w, BVAR (b, left_fringe_width),
-			    BVAR (b, right_fringe_width),
-			    BVAR (b, fringes_outside_margins), Qnil);
+	set_window_fringes (w, BVAR_OR_DEFAULT (b, left_fringe_width),
+			    BVAR_OR_DEFAULT (b, right_fringe_width),
+			    BVAR_OR_DEFAULT (b, fringes_outside_margins), Qnil);
       if (!w->scroll_bars_persistent)
-	set_window_scroll_bars (w, BVAR (b, scroll_bar_width),
-				BVAR (b, vertical_scroll_bar_type),
-				BVAR (b, scroll_bar_height),
-				BVAR (b, horizontal_scroll_bar_type), Qnil);
+	set_window_scroll_bars (w, BVAR_OR_DEFAULT (b, scroll_bar_width),
+				BVAR_OR_DEFAULT (b, vertical_scroll_bar_type),
+				BVAR_OR_DEFAULT (b, scroll_bar_height),
+				BVAR_OR_DEFAULT (b, horizontal_scroll_bar_type),
+				Qnil);
       /* Set left and right marginal area width from buffer.  */
-      set_window_margins (w, BVAR (b, left_margin_cols),
-			  BVAR (b, right_margin_cols));
+      set_window_margins (w, BVAR_OR_DEFAULT (b, left_margin_cols),
+			  BVAR_OR_DEFAULT (b, right_margin_cols));
       apply_window_adjustment (w);
     }
 
@@ -5372,7 +5373,7 @@ window_wants_mode_line (struct window *w)
 	  && !WINDOW_PSEUDO_P (w)
 	  && !EQ (window_mode_line_format, Qnone)
 	  && (!NILP (window_mode_line_format)
-	      || !NILP (BVAR (XBUFFER (WINDOW_BUFFER (w)), mode_line_format)))
+	      || !NILP (BVAR_OR_DEFAULT (XBUFFER(WINDOW_BUFFER(w)), mode_line_format)))
 	  && WINDOW_PIXEL_HEIGHT (w) > WINDOW_FRAME_LINE_HEIGHT (w));
 }
 
@@ -5401,7 +5402,7 @@ window_wants_header_line (struct window *w)
 	  && !WINDOW_PSEUDO_P (w)
 	  && !EQ (window_header_line_format, Qnone)
 	  && (!NILP (window_header_line_format)
-	      || !NILP (BVAR (XBUFFER (WINDOW_BUFFER (w)), header_line_format)))
+	      || !NILP (BVAR_OR_DEFAULT (XBUFFER(WINDOW_BUFFER(w)), header_line_format)))
 	  && (WINDOW_PIXEL_HEIGHT (w)
 	      > (window_wants_mode_line (w)
 		 ? 2 * WINDOW_FRAME_LINE_HEIGHT (w)
@@ -5435,7 +5436,7 @@ window_wants_tab_line (struct window *w)
 	  && !WINDOW_PSEUDO_P (w)
 	  && !EQ (window_tab_line_format, Qnone)
 	  && (!NILP (window_tab_line_format)
-	      || !NILP (BVAR (XBUFFER (WINDOW_BUFFER (w)), tab_line_format)))
+	      || !NILP (BVAR_OR_DEFAULT (XBUFFER(WINDOW_BUFFER(w)), tab_line_format)))
 	  && (WINDOW_PIXEL_HEIGHT (w)
 	      > (((window_wants_mode_line (w) ? 1 : 0)
 		  + (window_wants_header_line (w) ? 1 : 0)
diff --git a/src/xdisp.c b/src/xdisp.c
index 23b4ba5c39..07f3939cbe 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -595,7 +595,7 @@ fill_column_indicator_column (struct it *it, int char_width)
       && CHARACTERP (Vdisplay_fill_column_indicator_character))
     {
       Lisp_Object col = (EQ (Vdisplay_fill_column_indicator_column, Qt)
-			 ? BVAR (current_buffer, fill_column)
+			 ? BVAR_OR_DEFAULT (current_buffer, fill_column)
 			 : Vdisplay_fill_column_indicator_column);
 
       /* The stretch width needs to consider the latter
@@ -1543,10 +1543,10 @@ default_line_pixel_height (struct window *w)
   if (!FRAME_INITIAL_P (f) && BUFFERP (w->contents))
     {
       struct buffer *b = XBUFFER (w->contents);
-      Lisp_Object val = BVAR (b, extra_line_spacing);
+      Lisp_Object val = BVAR_OR_DEFAULT (b, extra_line_spacing);
 
       if (NILP (val))
-	val = BVAR (&buffer_defaults, extra_line_spacing);
+	val = BVAR_OR_DEFAULT (&buffer_defaults, extra_line_spacing);
       if (!NILP (val))
 	{
 	  if (RANGED_FIXNUMP (0, val, INT_MAX))
@@ -1684,7 +1684,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
       w->mode_line_height
 	= display_mode_line (w, CURRENT_MODE_LINE_FACE_ID (w),
 			     NILP (window_mode_line_format)
-			     ? BVAR (current_buffer, mode_line_format)
+			     ? BVAR_OR_DEFAULT (current_buffer, mode_line_format)
 			     : window_mode_line_format);
     }
 
@@ -1696,7 +1696,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
       w->tab_line_height
 	= display_mode_line (w, TAB_LINE_FACE_ID,
 			     NILP (window_tab_line_format)
-			     ? BVAR (current_buffer, tab_line_format)
+			     ? BVAR_OR_DEFAULT (current_buffer, tab_line_format)
 			     : window_tab_line_format);
     }
 
@@ -1708,7 +1708,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
       w->header_line_height
 	= display_mode_line (w, HEADER_LINE_FACE_ID,
 			     NILP (window_header_line_format)
-			     ? BVAR (current_buffer, header_line_format)
+			     ? BVAR_OR_DEFAULT (current_buffer, header_line_format)
 			     : window_header_line_format);
     }
 
@@ -3205,10 +3205,10 @@ init_iterator (struct it *it, struct window *w,
   if (base_face_id == DEFAULT_FACE_ID
       && FRAME_WINDOW_P (it->f))
     {
-      if (FIXNATP (BVAR (current_buffer, extra_line_spacing)))
-	it->extra_line_spacing = XFIXNAT (BVAR (current_buffer, extra_line_spacing));
-      else if (FLOATP (BVAR (current_buffer, extra_line_spacing)))
-	it->extra_line_spacing = (XFLOAT_DATA (BVAR (current_buffer, extra_line_spacing))
+      if (FIXNATP (BVAR_OR_DEFAULT (current_buffer, extra_line_spacing)))
+	it->extra_line_spacing = XFIXNAT (BVAR_OR_DEFAULT (current_buffer, extra_line_spacing));
+      else if (FLOATP (BVAR_OR_DEFAULT (current_buffer, extra_line_spacing)))
+	it->extra_line_spacing = (XFLOAT_DATA (BVAR_OR_DEFAULT (current_buffer, extra_line_spacing))
 				  * FRAME_LINE_HEIGHT (it->f));
       else if (it->f->extra_line_spacing > 0)
 	it->extra_line_spacing = it->f->extra_line_spacing;
@@ -3226,19 +3226,19 @@ init_iterator (struct it *it, struct window *w,
   it->override_ascent = -1;
 
   /* Are control characters displayed as `^C'?  */
-  it->ctl_arrow_p = !NILP (BVAR (current_buffer, ctl_arrow));
+  it->ctl_arrow_p = !NILP (BVAR_OR_DEFAULT (current_buffer, ctl_arrow));
 
   /* -1 means everything between a CR and the following line end
      is invisible.  >0 means lines indented more than this value are
      invisible.  */
-  it->selective = (FIXNUMP (BVAR (current_buffer, selective_display))
+  it->selective = (FIXNUMP (BVAR_OR_DEFAULT (current_buffer, selective_display))
 		   ? (clip_to_bounds
-		      (-1, XFIXNUM (BVAR (current_buffer, selective_display)),
+		      (-1, XFIXNUM (BVAR_OR_DEFAULT (current_buffer, selective_display)),
 		       PTRDIFF_MAX))
-		   : (!NILP (BVAR (current_buffer, selective_display))
+		   : (!NILP (BVAR_OR_DEFAULT (current_buffer, selective_display))
 		      ? -1 : 0));
   it->selective_display_ellipsis_p
-    = !NILP (BVAR (current_buffer, selective_display_ellipses));
+    = !NILP (BVAR_OR_DEFAULT (current_buffer, selective_display_ellipses));
 
   /* Display table to use.  */
   it->dp = window_display_table (w);
@@ -3270,8 +3270,8 @@ init_iterator (struct it *it, struct window *w,
 	      /* PXW: Shall we do something about this?  */
 	      && (XFIXNUM (Vtruncate_partial_width_windows)
 		  <= WINDOW_TOTAL_COLS (it->w))))
-      && NILP (BVAR (current_buffer, truncate_lines)))
-    it->line_wrap = NILP (BVAR (current_buffer, word_wrap))
+      && NILP (BVAR_OR_DEFAULT (current_buffer, truncate_lines)))
+    it->line_wrap = NILP (BVAR_OR_DEFAULT (current_buffer, word_wrap))
       ? WINDOW_WRAP : WORD_WRAP;
 
   /* Get dimensions of truncation and continuation glyphs.  These are
@@ -3416,7 +3416,7 @@ init_iterator (struct it *it, struct window *w,
 	 available.  */
       it->bidi_p =
 	!redisplay__inhibit_bidi
-	&& !NILP (BVAR (current_buffer, bidi_display_reordering))
+	&& !NILP (BVAR_OR_DEFAULT (current_buffer, bidi_display_reordering))
 	&& it->multibyte_p;
 
       /* If we are to reorder bidirectional text, init the bidi
@@ -3438,10 +3438,10 @@ init_iterator (struct it *it, struct window *w,
 	    }
 	  /* Note the paragraph direction that this buffer wants to
 	     use.  */
-	  if (EQ (BVAR (current_buffer, bidi_paragraph_direction),
+	  if (EQ (BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_direction),
 		  Qleft_to_right))
 	    it->paragraph_embedding = L2R;
-	  else if (EQ (BVAR (current_buffer, bidi_paragraph_direction),
+	  else if (EQ (BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_direction),
 		       Qright_to_left))
 	    it->paragraph_embedding = R2L;
 	  else
@@ -7208,7 +7208,7 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
      not yet available.  */
   it->bidi_p =
     !redisplay__inhibit_bidi
-    && !NILP (BVAR (&buffer_defaults, bidi_display_reordering));
+    && !NILP (BVAR_OR_DEFAULT (&buffer_defaults, bidi_display_reordering));
 
   if (s == NULL)
     {
@@ -12140,7 +12140,7 @@ set_message_1 (void *a1, Lisp_Object string)
     Fset_buffer_multibyte (Qt);
 
   bset_truncate_lines (current_buffer, message_truncate_lines ? Qt : Qnil);
-  if (!NILP (BVAR (current_buffer, bidi_display_reordering)))
+  if (!NILP (BVAR_OR_DEFAULT (current_buffer, bidi_display_reordering)))
     bset_bidi_paragraph_direction (current_buffer, Qleft_to_right);
 
   /* Insert new message at BEG.  */
@@ -15187,8 +15187,8 @@ text_outside_line_unchanged_p (struct window *w,
       /* If selective display, can't optimize if changes start at the
 	 beginning of the line.  */
       if (unchanged_p
-	  && FIXNUMP (BVAR (current_buffer, selective_display))
-	  && XFIXNUM (BVAR (current_buffer, selective_display)) > 0
+	  && FIXNUMP (BVAR_OR_DEFAULT (current_buffer, selective_display))
+	  && XFIXNUM (BVAR_OR_DEFAULT (current_buffer, selective_display)) > 0
 	  && (BEG_UNCHANGED < start || GPT <= start))
 	unchanged_p = false;
 
@@ -15216,8 +15216,8 @@ text_outside_line_unchanged_p (struct window *w,
 	 require redisplaying the whole paragraph.  It might be worthwhile
 	 to find the paragraph limits and widen the range of redisplayed
 	 lines to that, but for now just give up this optimization.  */
-      if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))
-	  && NILP (BVAR (XBUFFER (w->contents), bidi_paragraph_direction)))
+      if (!NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_display_reordering))
+	  && NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_paragraph_direction)))
 	unchanged_p = false;
     }
 
@@ -17395,8 +17395,8 @@ try_scrolling (Lisp_Object window, bool just_this_one_p,
       int scroll_lines = clip_to_bounds (0, scroll_lines_max, 1000000);
       scroll_max = scroll_lines * frame_line_height;
     }
-  else if (NUMBERP (BVAR (current_buffer, scroll_down_aggressively))
-	   || NUMBERP (BVAR (current_buffer, scroll_up_aggressively)))
+  else if (NUMBERP (BVAR_OR_DEFAULT (current_buffer, scroll_down_aggressively))
+	   || NUMBERP (BVAR_OR_DEFAULT (current_buffer, scroll_up_aggressively)))
     /* We're trying to scroll because of aggressive scrolling but no
        scroll_step is set.  Choose an arbitrary one.  */
     scroll_max = 10 * frame_line_height;
@@ -17494,7 +17494,7 @@ try_scrolling (Lisp_Object window, bool just_this_one_p,
 	amount_to_scroll = scroll_max;
       else
 	{
-	  aggressive = BVAR (current_buffer, scroll_up_aggressively);
+	  aggressive = BVAR_OR_DEFAULT (current_buffer, scroll_up_aggressively);
 	  height = WINDOW_BOX_TEXT_HEIGHT (w);
 	  if (NUMBERP (aggressive))
 	    {
@@ -17610,7 +17610,8 @@ try_scrolling (Lisp_Object window, bool just_this_one_p,
 	    amount_to_scroll = scroll_max;
 	  else
 	    {
-	      aggressive = BVAR (current_buffer, scroll_down_aggressively);
+	      aggressive = BVAR_OR_DEFAULT (current_buffer,
+                                           scroll_down_aggressively);
 	      height = WINDOW_BOX_TEXT_HEIGHT (w);
 	      if (NUMBERP (aggressive))
 		{
@@ -17997,7 +17998,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp,
 	      must_scroll = true;
 	    }
 	  else if (rc != CURSOR_MOVEMENT_SUCCESS
-		   && !NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)))
+		   && !NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_display_reordering)))
 	    {
 	      struct glyph_row *row1;
 
@@ -18061,7 +18062,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp,
 	  else if (scroll_p)
 	    rc = CURSOR_MOVEMENT_MUST_SCROLL;
 	  else if (rc != CURSOR_MOVEMENT_SUCCESS
-		   && !NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)))
+		   && !NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_display_reordering)))
 	    {
 	      /* With bidi-reordered rows, there could be more than
 		 one candidate row whose start and end positions
@@ -18906,8 +18907,8 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
        || (scroll_minibuffer_conservatively && MINI_WINDOW_P (w))
        || 0 < emacs_scroll_step
        || temp_scroll_step
-       || NUMBERP (BVAR (current_buffer, scroll_up_aggressively))
-       || NUMBERP (BVAR (current_buffer, scroll_down_aggressively)))
+       || NUMBERP (BVAR_OR_DEFAULT (current_buffer, scroll_up_aggressively))
+       || NUMBERP (BVAR_OR_DEFAULT (current_buffer, scroll_down_aggressively)))
       && CHARPOS (startp) >= BEGV
       && CHARPOS (startp) <= ZV)
     {
@@ -18981,8 +18982,8 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
       scrolling_up = PT > margin_pos;
       aggressive =
 	scrolling_up
-	? BVAR (current_buffer, scroll_up_aggressively)
-	: BVAR (current_buffer, scroll_down_aggressively);
+	? BVAR_OR_DEFAULT (current_buffer, scroll_up_aggressively)
+	: BVAR_OR_DEFAULT (current_buffer, scroll_down_aggressively);
 
       if (!MINI_WINDOW_P (w)
 	  && (scroll_conservatively > SCROLL_LIMIT || NUMBERP (aggressive)))
@@ -19917,7 +19918,7 @@ try_window_reusing_current_matrix (struct window *w)
 		 bidi-reordered glyph rows.  Let set_cursor_from_row
 		 figure out where to put the cursor, and if it fails,
 		 give up.  */
-	      if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)))
+	      if (!NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_display_reordering)))
 		{
 		  if (!set_cursor_from_row (w, row, w->current_matrix,
 					    0, 0, 0, 0))
@@ -20236,7 +20237,7 @@ row_containing_pos (struct window *w, ptrdiff_t charpos,
 	{
 	  struct glyph *g;
 
-	  if (NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))
+	  if (NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_display_reordering))
 	      || (!best_row && !row->continued_p))
 	    return row;
 	  /* In bidi-reordered rows, there could be several rows whose
@@ -20406,7 +20407,7 @@ try_window_id (struct window *w)
      wrapped line can change the wrap position, altering the line
      above it.  It might be worthwhile to handle this more
      intelligently, but for now just redisplay from scratch.  */
-  if (!NILP (BVAR (XBUFFER (w->contents), word_wrap)))
+  if (!NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), word_wrap)))
     GIVE_UP (21);
 
   /* Under bidi reordering, adding or deleting a character in the
@@ -20417,13 +20418,13 @@ try_window_id (struct window *w)
      to find the paragraph limits and widen the range of redisplayed
      lines to that, but for now just give up this optimization and
      redisplay from scratch.  */
-  if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))
-      && NILP (BVAR (XBUFFER (w->contents), bidi_paragraph_direction)))
+  if (!NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_display_reordering))
+      && NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_paragraph_direction)))
     GIVE_UP (22);
 
   /* Give up if the buffer has line-spacing set, as Lisp-level changes
      to that variable require thorough redisplay.  */
-  if (!NILP (BVAR (XBUFFER (w->contents), extra_line_spacing)))
+  if (!NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), extra_line_spacing)))
     GIVE_UP (23);
 
   /* Give up if display-line-numbers is in relative mode, or when the
@@ -23532,7 +23533,7 @@ display_line (struct it *it, int cursor_vpos)
 	      if (!row_has_glyphs)
 		row->displays_text_p = false;
 
-	      if (!NILP (BVAR (XBUFFER (it->w->contents), indicate_empty_lines))
+	      if (!NILP (BVAR_OR_DEFAULT (XBUFFER (it->w->contents), indicate_empty_lines))
 		  && (!MINI_WINDOW_P (it->w)))
 		row->indicate_empty_line_p = true;
 	    }
@@ -24306,14 +24307,14 @@ See also `bidi-paragraph-direction'.  */)
       buf = XBUFFER (buffer);
     }
 
-  if (NILP (BVAR (buf, bidi_display_reordering))
+  if (NILP (BVAR_OR_DEFAULT (buf, bidi_display_reordering))
       || NILP (BVAR (buf, enable_multibyte_characters))
       /* When we are loading loadup.el, the character property tables
 	 needed for bidi iteration are not yet available.  */
       || redisplay__inhibit_bidi)
     return Qleft_to_right;
-  else if (!NILP (BVAR (buf, bidi_paragraph_direction)))
-    return BVAR (buf, bidi_paragraph_direction);
+  else if (!NILP (BVAR_OR_DEFAULT (buf, bidi_paragraph_direction)))
+    return BVAR_OR_DEFAULT (buf, bidi_paragraph_direction);
   else
     {
       /* Determine the direction from buffer text.  We could try to
@@ -24457,7 +24458,7 @@ the `bidi-class' property of a character.  */)
     {
       /* Nothing this fancy can happen in unibyte buffers, or in a
 	 buffer that disabled reordering, or if FROM is at EOB.  */
-      if (NILP (BVAR (buf, bidi_display_reordering))
+      if (NILP (BVAR_OR_DEFAULT (buf, bidi_display_reordering))
 	  || NILP (BVAR (buf, enable_multibyte_characters))
 	  /* When we are loading loadup.el, the character property
 	     tables needed for bidi iteration are not yet
@@ -25412,7 +25413,7 @@ display_mode_lines (struct window *w)
       /* Select mode line face based on the real selected window.  */
       display_mode_line (w, CURRENT_MODE_LINE_FACE_ID_3 (sel_w, sel_w, w),
 			 NILP (window_mode_line_format)
-			 ? BVAR (current_buffer, mode_line_format)
+			 ? BVAR_OR_DEFAULT (current_buffer, mode_line_format)
 			 : window_mode_line_format);
       ++n;
     }
@@ -25424,7 +25425,7 @@ display_mode_lines (struct window *w)
 
       display_mode_line (w, TAB_LINE_FACE_ID,
 			 NILP (window_tab_line_format)
-			 ? BVAR (current_buffer, tab_line_format)
+			 ? BVAR_OR_DEFAULT (current_buffer, tab_line_format)
 			 : window_tab_line_format);
       ++n;
     }
@@ -25436,7 +25437,7 @@ display_mode_lines (struct window *w)
 
       display_mode_line (w, HEADER_LINE_FACE_ID,
 			 NILP (window_header_line_format)
-			 ? BVAR (current_buffer, header_line_format)
+			 ? BVAR_OR_DEFAULT (current_buffer, header_line_format)
 			 : window_header_line_format);
       ++n;
     }
@@ -26971,7 +26972,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
 					 (FRAME_TERMINAL_CODING (f)->id),
 					 p, false);
 	  }
-	p = decode_mode_spec_coding (BVAR (b, buffer_file_coding_system),
+	p = decode_mode_spec_coding (BVAR_OR_DEFAULT (b, buffer_file_coding_system),
 				     p, eol_flag);
 
 #if false /* This proves to be annoying; I think we can do without. -- rms.  */
@@ -27035,8 +27036,8 @@ display_count_lines (ptrdiff_t start_byte,
   /* If we are not in selective display mode,
      check only for newlines.  */
   bool selective_display
-    = (!NILP (BVAR (current_buffer, selective_display))
-       && !FIXNUMP (BVAR (current_buffer, selective_display)));
+    = (!NILP (BVAR_OR_DEFAULT (current_buffer, selective_display))
+       && !FIXNUMP (BVAR_OR_DEFAULT (current_buffer, selective_display)));
 
   if (count > 0)
     {
@@ -31350,13 +31351,14 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
     {
       if (w == XWINDOW (echo_area_window))
 	{
-	  if (EQ (BVAR (b, cursor_type), Qt) || NILP (BVAR (b, cursor_type)))
+	  if (EQ (BVAR_OR_DEFAULT (b, cursor_type), Qt) || NILP (BVAR_OR_DEFAULT (b, cursor_type)))
 	    {
 	      *width = FRAME_CURSOR_WIDTH (f);
 	      return FRAME_DESIRED_CURSOR (f);
 	    }
 	  else
-	    return get_specified_cursor_type (BVAR (b, cursor_type), width);
+	    return get_specified_cursor_type (BVAR_OR_DEFAULT (b, cursor_type),
+                                              width);
 	}
 
       *active_cursor = false;
@@ -31378,23 +31380,24 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
     }
 
   /* Never display a cursor in a window in which cursor-type is nil.  */
-  if (NILP (BVAR (b, cursor_type)))
+  if (NILP (BVAR_OR_DEFAULT (b, cursor_type)))
     return NO_CURSOR;
 
   /* Get the normal cursor type for this window.  */
-  if (EQ (BVAR (b, cursor_type), Qt))
+  if (EQ (BVAR_OR_DEFAULT (b, cursor_type), Qt))
     {
       cursor_type = FRAME_DESIRED_CURSOR (f);
       *width = FRAME_CURSOR_WIDTH (f);
     }
   else
-    cursor_type = get_specified_cursor_type (BVAR (b, cursor_type), width);
+    cursor_type = get_specified_cursor_type (BVAR_OR_DEFAULT (b, cursor_type),
+                                             width);
 
   /* Use cursor-in-non-selected-windows instead
      for non-selected window or frame.  */
   if (non_selected)
     {
-      alt_cursor = BVAR (b, cursor_in_non_selected_windows);
+      alt_cursor = BVAR_OR_DEFAULT (b, cursor_in_non_selected_windows);
       if (!EQ (Qt, alt_cursor))
 	return get_specified_cursor_type (alt_cursor, width);
       /* t means modify the normal cursor type.  */
@@ -31428,7 +31431,7 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
 		     should cover most of the "tiny" icons people may
 		     use.  */
 		  if (!img->mask
-		      || (CONSP (BVAR (b, cursor_type))
+		      || (CONSP (BVAR_OR_DEFAULT (b, cursor_type))
 			  && img->width > max (*width, WINDOW_FRAME_COLUMN_WIDTH (w))
 			  && img->height > max (*width, WINDOW_FRAME_LINE_HEIGHT (w))))
 		    cursor_type = HOLLOW_BOX_CURSOR;
@@ -31448,7 +31451,7 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
   /* Cursor is blinked off, so determine how to "toggle" it.  */
 
   /* First look for an entry matching the buffer's cursor-type in blink-cursor-alist.  */
-  if ((alt_cursor = Fassoc (BVAR (b, cursor_type), Vblink_cursor_alist, Qnil), !NILP (alt_cursor)))
+  if ((alt_cursor = Fassoc (BVAR_OR_DEFAULT (b, cursor_type), Vblink_cursor_alist, Qnil), !NILP (alt_cursor)))
     return get_specified_cursor_type (XCDR (alt_cursor), width);
 
   /* Then see if frame has specified a specific blink off cursor type.  */
@@ -33853,11 +33856,10 @@ note_mouse_highlight (struct frame *f, int x, int y)
 		     necessarily display the character whose position
 		     is the smallest.  */
 		  Lisp_Object lim1
-		    = NILP (BVAR (XBUFFER (buffer), bidi_display_reordering))
+		    = NILP (BVAR_OR_DEFAULT (XBUFFER(buffer), bidi_display_reordering))
 		    ? Fmarker_position (w->start)
 		    : Qnil;
-		  Lisp_Object lim2
-		    = NILP (BVAR (XBUFFER (buffer), bidi_display_reordering))
+		  Lisp_Object lim2 = NILP (BVAR_OR_DEFAULT (XBUFFER(buffer), bidi_display_reordering))
 		    ? make_fixnum (BUF_Z (XBUFFER (buffer))
 				   - w->window_end_pos)
 		    : Qnil;
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 14/15] Remove PER_BUFFER_IDX and buffer_local_flags
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:35:05 +0000
Resent-Message-ID: <handler.48264.B48264.1620336858855 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336858855
          (code B ref 48264); Thu, 06 May 2021 21:35:05 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:18 +0000
Received: from localhost ([127.0.0.1]:39891 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldR-0000Dd-BC
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:18 -0400
Received: from venus.catern.com ([68.183.49.163]:41542)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leldF-0000BP-40
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:07 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336844; bh=sg32AbGjF1uOZMKjZ5EJHEhp85e47GiQfAe/rICpPIk=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=YUHbV4B1IoVucymsmoCNaYAEhTzVe/kDjHio+VA2dp4JB3jfgKt7PT//0vuFVL7GB
 Pel+tj2zH/rGeOOLPwhKR0W3bJ9OaZaWzskFXI0sQtDzYi6gX+lJWxMVqWqJ8FGgHF
 6ZXcXyRhRDIVToaEgLvA0Ql4YOJyXVgu6CaHXkZs=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id C67E02E966E;
 Thu,  6 May 2021 21:34:04 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:45 -0400
Message-Id: <20210506213346.9730-15-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Previously, we maintained an "index" starting at 1 for each BVAR with
a default value, stored in buffer_local_flags; it was used to index
into local_flags.

After previous commits, we don't need this index for anything anymore.
So we can delete it.

* src/buffer.h (buffer_local_flags, PER_BUFFER_VAR_IDX)
(valid_per_buffer_idx, PER_BUFFER_IDX): Delete.
(BUFFER_DEFAULT_VALUE_P): Remove usage of PER_BUFFER_IDX.
* src/buffer.c (buffer_local_flags, last_per_buffer_idx)
(valid_per_buffer_idx): Delete.
(init_buffer_once): Don't initialize buffer_local_flags.
(defvar_per_buffer): Remove usage of PER_BUFFER_IDX.
* src/buffer.h (BUFFER_DEFAULT_VALUE_P):
* src/data.c (default_value): Remove usage of PER_BUFFER_IDX.
---
 src/buffer.c | 172 ---------------------------------------------------
 src/buffer.h |  53 ----------------
 src/data.c   |   1 -
 3 files changed, 226 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 097d03690a..abf112a898 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -59,25 +59,6 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 
 struct buffer buffer_defaults;
 
-/* This structure marks which slots in a buffer have corresponding
-   default values in buffer_defaults.
-   Each such slot has a value in this structure.
-   The value is a positive Lisp integer that must be smaller than
-   MAX_PER_BUFFER_VARS.
-
-   When a buffer has its own local value for a slot,
-   the entry for that slot (found in the same slot in this structure)
-   is turned on in the buffer's local_flags array.
-
-   If a slot in this structure is -1, then even though there may
-   be a DEFVAR_PER_BUFFER for the slot, there is no default value for it;
-   and the corresponding slot in buffer_defaults is not used.
-
-   If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is
-   zero, that is a bug.  */
-
-struct buffer buffer_local_flags;
-
 /* This structure holds the names of symbols whose values may be
    buffer-local.  It is indexed and accessed in the same way as the above.  */
 
@@ -94,10 +75,6 @@ struct buffer buffer_local_symbols;
   ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM,				\
 		    min (PTRDIFF_MAX, SIZE_MAX) / word_size))
 
-/* Number of per-buffer variables used.  */
-
-static int last_per_buffer_idx;
-
 static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay,
                                     bool after, Lisp_Object arg1,
                                     Lisp_Object arg2, Lisp_Object arg3);
@@ -328,11 +305,6 @@ bset_right_fringe_width (struct buffer *b, Lisp_Object val)
   b->right_fringe_width_ = val;
 }
 static void
-bset_save_length (struct buffer *b, Lisp_Object val)
-{
-  b->save_length_ = val;
-}
-static void
 bset_scroll_bar_width (struct buffer *b, Lisp_Object val)
 {
   b->scroll_bar_width_ = val;
@@ -679,12 +651,6 @@ set_buffer_overlays_after (struct buffer *b, struct Lisp_Overlay *o)
   b->overlays_after = o;
 }
 
-bool
-valid_per_buffer_idx (int idx)
-{
-  return 0 <= idx && idx < last_per_buffer_idx;
-}
-
 /* Clone per-buffer values of buffer FROM.
 
    Buffer TO gets the same per-buffer values as FROM, with the
@@ -5123,131 +5089,6 @@ free_buffer_text (struct buffer *b)
 void
 init_buffer_once (void)
 {
-  /* TODO: clean up the buffer-local machinery.  Right now,
-     we have:
-
-     buffer_defaults: default values of buffer-locals
-     buffer_local_flags: metadata
-     buffer_local_symbols: metadata
-
-     There must be a simpler way to store the metadata.
-  */
-
-  int idx;
-
-  /* 0 means not a lisp var, -1 means always local, else mask.  */
-  memset (&buffer_local_flags, 0, sizeof buffer_local_flags);
-  bset_filename (&buffer_local_flags, make_fixnum (-1));
-  bset_directory (&buffer_local_flags, make_fixnum (-1));
-  bset_backed_up (&buffer_local_flags, make_fixnum (-1));
-  bset_save_length (&buffer_local_flags, make_fixnum (-1));
-  bset_auto_save_file_name (&buffer_local_flags, make_fixnum (-1));
-  bset_read_only (&buffer_local_flags, make_fixnum (-1));
-  bset_major_mode (&buffer_local_flags, make_fixnum (-1));
-  bset_local_minor_modes (&buffer_local_flags, make_fixnum (-1));
-  bset_mode_name (&buffer_local_flags, make_fixnum (-1));
-  bset_undo_list (&buffer_local_flags, make_fixnum (-1));
-  bset_mark_active (&buffer_local_flags, make_fixnum (-1));
-  bset_point_before_scroll (&buffer_local_flags, make_fixnum (-1));
-  bset_file_truename (&buffer_local_flags, make_fixnum (-1));
-  bset_invisibility_spec (&buffer_local_flags, make_fixnum (-1));
-  bset_file_format (&buffer_local_flags, make_fixnum (-1));
-  bset_auto_save_file_format (&buffer_local_flags, make_fixnum (-1));
-  bset_display_count (&buffer_local_flags, make_fixnum (-1));
-  bset_display_time (&buffer_local_flags, make_fixnum (-1));
-  bset_enable_multibyte_characters (&buffer_local_flags, make_fixnum (-1));
-
-  /* These used to be stuck at 0 by default, but now that the all-zero value
-     means Qnil, we have to initialize them explicitly.  */
-  bset_name (&buffer_local_flags, make_fixnum (0));
-  bset_mark (&buffer_local_flags, make_fixnum (0));
-  bset_local_var_alist (&buffer_local_flags, make_fixnum (0));
-  bset_keymap (&buffer_local_flags, make_fixnum (0));
-  bset_downcase_table (&buffer_local_flags, make_fixnum (0));
-  bset_upcase_table (&buffer_local_flags, make_fixnum (0));
-  bset_case_canon_table (&buffer_local_flags, make_fixnum (0));
-  bset_case_eqv_table (&buffer_local_flags, make_fixnum (0));
-  bset_width_table (&buffer_local_flags, make_fixnum (0));
-  bset_pt_marker (&buffer_local_flags, make_fixnum (0));
-  bset_begv_marker (&buffer_local_flags, make_fixnum (0));
-  bset_zv_marker (&buffer_local_flags, make_fixnum (0));
-  bset_last_selected_window (&buffer_local_flags, make_fixnum (0));
-
-  idx = 1;
-  XSETFASTINT (BVAR (&buffer_local_flags, mode_line_format), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, abbrev_mode), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, overwrite_mode), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, case_fold_search), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, auto_fill_function), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, selective_display), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, selective_display_ellipses), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, tab_width), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, truncate_lines), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, word_wrap), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, ctl_arrow), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, fill_column), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, left_margin), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, abbrev_table), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, display_table), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, syntax_table), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, cache_long_scans), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, category_table), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, bidi_display_reordering), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_direction), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_separate_re), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_start_re), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, buffer_file_coding_system), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, left_margin_cols), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, right_margin_cols), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, left_fringe_width), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, right_fringe_width), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, fringes_outside_margins), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, scroll_bar_width), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, scroll_bar_height), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, vertical_scroll_bar_type), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, horizontal_scroll_bar_type), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, indicate_empty_lines), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, indicate_buffer_boundaries), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, fringe_indicator_alist), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, fringe_cursor_alist), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, scroll_up_aggressively), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, scroll_down_aggressively), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, header_line_format), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, tab_line_format), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, cursor_type), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx;
-
-  /* buffer_local_flags contains no pointers, so it's safe to treat it
-     as a blob for pdumper.  */
-  PDUMPER_REMEMBER_SCALAR (buffer_local_flags);
-
-  /* Need more room? */
-  if (idx >= MAX_PER_BUFFER_VARS)
-    emacs_abort ();
-  last_per_buffer_idx = idx;
-  PDUMPER_REMEMBER_SCALAR (last_per_buffer_idx);
-
-  /* Make sure all markable slots in buffer_defaults
-     are initialized reasonably, so mark_buffer won't choke.  */
-  reset_buffer (&buffer_defaults);
-  eassert (NILP (BVAR (&buffer_defaults, name)));
-  eassert (NILP (BVAR (&buffer_local_symbols, name)));
-  reset_buffer (&buffer_local_symbols);
-  /* Prevent GC from getting confused.  */
-  buffer_defaults.text = &buffer_defaults.own_text;
-  buffer_local_symbols.text = &buffer_local_symbols.own_text;
-  /* No one will share the text with these buffers, but let's play it safe.  */
-  buffer_defaults.indirections = 0;
-  buffer_local_symbols.indirections = 0;
-  /* Likewise no one will display them.  */
-  buffer_defaults.window_count = 0;
-  buffer_local_symbols.window_count = 0;
-  set_buffer_intervals (&buffer_defaults, NULL);
-  set_buffer_intervals (&buffer_local_symbols, NULL);
-  /* This is not strictly necessary, but let's make them initialized.  */
-  bset_name (&buffer_defaults, build_pure_c_string (" *buffer-defaults*"));
-  bset_name (&buffer_local_symbols, build_pure_c_string (" *buffer-local-symbols*"));
   BUFFER_PVEC_INIT (&buffer_defaults);
   BUFFER_PVEC_INIT (&buffer_local_symbols);
 
@@ -5308,14 +5149,6 @@ init_buffer_once (void)
   bset_scroll_up_aggressively (&buffer_defaults, Qnil);
   bset_scroll_down_aggressively (&buffer_defaults, Qnil);
 
-  /* Assign the local-flags to the slots that have default values.
-     The local flag is a bit that is used in the buffer
-     to say that it has its own local value for the slot.
-     The local flag bits are in the local_var_flags slot of the buffer.  */
-
-  /* Nothing can work if this isn't true.  */
-  { verify (sizeof (EMACS_INT) == word_size); }
-
   Vbuffer_alist = Qnil;
   current_buffer = 0;
   pdumper_remember_lv_ptr_raw (&current_buffer, Lisp_Vectorlike);
@@ -5479,11 +5312,6 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring,
   sym->u.s.redirect = SYMBOL_FORWARDED;
   SET_SYMBOL_FWD (sym, bo_fwd);
   XSETSYMBOL (PER_BUFFER_SYMBOL (offset), sym);
-
-  if (PER_BUFFER_IDX (offset) == 0)
-    /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
-       slot of buffer_local_flags.  */
-    emacs_abort ();
 }
 
 
diff --git a/src/buffer.h b/src/buffer.h
index fc67b220e4..c765ea4347 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1107,22 +1107,6 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
 
 extern struct buffer buffer_defaults;
 
-/* This structure marks which slots in a buffer have corresponding
-   default values in buffer_defaults.
-   Each such slot has a nonzero value in this structure.
-   The value has only one nonzero bit.
-
-   When a buffer has its own local value for a slot,
-   the entry for that slot (found in the same slot in this structure)
-   is turned on in the buffer's local_flags array.
-
-   If a slot in this structure is zero, then even though there may
-   be a Lisp-level local variable for the slot, it has no default value,
-   and the corresponding slot in buffer_defaults is not used.  */
-
-
-extern struct buffer buffer_local_flags;
-
 /* For each buffer slot, this points to the Lisp symbol name
    for that slot in the current buffer.  It is 0 for slots
    that don't have such names.  */
@@ -1401,43 +1385,6 @@ OVERLAY_POSITION (Lisp_Object p)
        offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \
        offset += word_size)
 
-/* Return the index of buffer-local variable VAR.  Each per-buffer
-   variable has an index > 0 associated with it, except when it always
-   has buffer-local values, in which case the index is -1.  If this is
-   0, this is a bug and means that the slot of VAR in
-   buffer_local_flags wasn't initialized.  */
-
-#define PER_BUFFER_VAR_IDX(VAR) \
-    PER_BUFFER_IDX (PER_BUFFER_VAR_OFFSET (VAR))
-
-extern bool valid_per_buffer_idx (int);
-
-/* Return the index value of the per-buffer variable at offset OFFSET
-   in the buffer structure.
-
-   If the slot OFFSET has a corresponding default value in
-   buffer_defaults, the index value is positive and has only one
-   nonzero bit.  When a buffer has its own local value for a slot, the
-   bit for that slot (found in the same slot in this structure) is
-   turned on in the buffer's local_flags array.
-
-   If the index value is -1, even though there may be a
-   DEFVAR_PER_BUFFER for the slot, there is no default value for it;
-   and the corresponding slot in buffer_defaults is not used.
-
-   If the index value is -2, then there is no DEFVAR_PER_BUFFER for
-   the slot, but there is a default value which is copied into each
-   new buffer.
-
-   If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is
-   zero, that is a bug.  */
-
-INLINE int
-PER_BUFFER_IDX (ptrdiff_t offset)
-{
-  return XFIXNUM (*(Lisp_Object *) (offset + (char *) &buffer_local_flags));
-}
-
 /* Functions to get and set default value of the per-buffer
    variable at offset OFFSET in the buffer structure.  */
 
diff --git a/src/data.c b/src/data.c
index 4e58c6c815..9e38a68817 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1758,7 +1758,6 @@ default_value (Lisp_Object symbol)
 	if (BUFFER_OBJFWDP (valcontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
-	    eassert (PER_BUFFER_IDX (offset) != 0);
             return per_buffer_default (offset);
 	  }
 
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 06 May 2021 21:35:06 +0000
Resent-Message-ID: <handler.48264.B48264.1620336860861 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.1620336860861
          (code B ref 48264); Thu, 06 May 2021 21:35:06 +0000
Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:20 +0000
Received: from localhost ([127.0.0.1]:39893 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leldS-0000Dk-EN
	for submit <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:20 -0400
Received: from venus.catern.com ([68.183.49.163]:41534)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1leldF-0000B5-MX
 for 48264 <at> debbugs.gnu.org; Thu, 06 May 2021 17:34:09 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620336845; bh=q2dZEn/ggv4TFXPAy5S+UQXcPxJqtbDgn/lyRTjDkuA=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=f5gu4dtR2TzRdcK6tQaVg3AXBEY3LjR43L7jxImBCta1CXSieWw8cc0Ennab04Kuy
 hp4JOs5rdsgT7yCDYu/m02r7xPXW7T44d3tVkfWwrwMSaGjDKhyQZP1am4jUppKa7/
 1ht24mrz6nPKddcHFFCfJxZc4A6x6QGflzIxBiTM=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 617C12E966D;
 Thu,  6 May 2021 21:34:05 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Thu,  6 May 2021 17:33:46 -0400
Message-Id: <20210506213346.9730-16-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <877dkbsj9d.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

By using the BVAR_FIELD and BVAR_DEFAULTED_FIELD macros anywhere we
would otherwise use the raw name of a buffer field (which is only in a
few places), we can make sure that BVAR and BVAR_OR_DEFAULT are used
on the correct fields.

* src/alloc.c (allocate_buffer):
* src/buffer.c (bset_abbrev_mode):
(bset_bidi_display_reordering):
(bset_fringe_cursor_alist):
(bset_left_fringe_width):
(bset_mode_line_format):
(bset_overwrite_mode):
(bset_right_fringe_width):
(bset_scroll_bar_width):
(reset_buffer_local_variables):
(init_buffer_once):
(syms_of_buffer):
* src/buffer.h (BVAR_DEFAULTED_FIELD):
(struct buffer):
(bset_bidi_paragraph_direction):
(bset_left_margin_cols):
(bset_truncate_lines):
(PER_BUFFER_VAR_DEFAULTED_OFFSET):
* src/category.c (bset_category_table):
* src/syntax.c (bset_syntax_table): Use BVAR_FIELD,
BVAR_DEFAULTED_FIELD, and BVAR_DEFAULTED.
---
 src/alloc.c    |   3 +-
 src/buffer.c   | 166 ++++++++++++++++++++++-----------------------
 src/buffer.h   | 180 ++++++++++++++++++++++++++-----------------------
 src/category.c |   2 +-
 src/category.h |   2 +-
 src/syntax.c   |   2 +-
 src/syntax.h   |   2 +-
 7 files changed, 183 insertions(+), 174 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 76d8c7ddd1..b711aa904c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3389,7 +3389,8 @@ struct buffer *
 allocate_buffer (void)
 {
   struct buffer *b
-    = ALLOCATE_PSEUDOVECTOR (struct buffer, cursor_in_non_selected_windows_,
+    = ALLOCATE_PSEUDOVECTOR (struct buffer,
+			     BVAR_DEFAULTED_FIELD (cursor_in_non_selected_windows),
 			     PVEC_BUFFER);
   BUFFER_PVEC_INIT (b);
   /* Note that the rest fields of B are not initialized.  */
diff --git a/src/buffer.c b/src/buffer.c
index abf112a898..e048e7559f 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -122,17 +122,17 @@ fix_position (Lisp_Object pos)
 static void
 bset_abbrev_mode (struct buffer *b, Lisp_Object val)
 {
-  b->abbrev_mode_ = val;
+  b->BVAR_DEFAULTED_FIELD(abbrev_mode) = val;
 }
 static void
 bset_abbrev_table (struct buffer *b, Lisp_Object val)
 {
-  b->abbrev_table_ = val;
+  b->BVAR_DEFAULTED_FIELD(abbrev_table) = val;
 }
 static void
 bset_auto_fill_function (struct buffer *b, Lisp_Object val)
 {
-  b->auto_fill_function_ = val;
+  b->BVAR_DEFAULTED_FIELD(auto_fill_function) = val;
 }
 static void
 bset_auto_save_file_format (struct buffer *b, Lisp_Object val)
@@ -157,52 +157,52 @@ bset_begv_marker (struct buffer *b, Lisp_Object val)
 static void
 bset_bidi_display_reordering (struct buffer *b, Lisp_Object val)
 {
-  b->bidi_display_reordering_ = val;
+  b->BVAR_DEFAULTED_FIELD(bidi_display_reordering) = val;
 }
 static void
 bset_bidi_paragraph_start_re (struct buffer *b, Lisp_Object val)
 {
-  b->bidi_paragraph_start_re_ = val;
+  b->BVAR_DEFAULTED_FIELD(bidi_paragraph_start_re) = val;
 }
 static void
 bset_bidi_paragraph_separate_re (struct buffer *b, Lisp_Object val)
 {
-  b->bidi_paragraph_separate_re_ = val;
+  b->BVAR_DEFAULTED_FIELD(bidi_paragraph_separate_re) = val;
 }
 static void
 bset_buffer_file_coding_system (struct buffer *b, Lisp_Object val)
 {
-  b->buffer_file_coding_system_ = val;
+  b->BVAR_DEFAULTED_FIELD(buffer_file_coding_system) = val;
 }
 static void
 bset_case_fold_search (struct buffer *b, Lisp_Object val)
 {
-  b->case_fold_search_ = val;
+  b->BVAR_DEFAULTED_FIELD(case_fold_search) = val;
 }
 static void
 bset_ctl_arrow (struct buffer *b, Lisp_Object val)
 {
-  b->ctl_arrow_ = val;
+  b->BVAR_DEFAULTED_FIELD(ctl_arrow) = val;
 }
 static void
 bset_cursor_in_non_selected_windows (struct buffer *b, Lisp_Object val)
 {
-  b->cursor_in_non_selected_windows_ = val;
+  b->BVAR_DEFAULTED_FIELD(cursor_in_non_selected_windows) = val;
 }
 static void
 bset_cursor_type (struct buffer *b, Lisp_Object val)
 {
-  b->cursor_type_ = val;
+  b->BVAR_DEFAULTED_FIELD(cursor_type) = val;
 }
 static void
 bset_display_table (struct buffer *b, Lisp_Object val)
 {
-  b->display_table_ = val;
+  b->BVAR_DEFAULTED_FIELD(display_table) = val;
 }
 static void
 bset_extra_line_spacing (struct buffer *b, Lisp_Object val)
 {
-  b->extra_line_spacing_ = val;
+  b->BVAR_DEFAULTED_FIELD(extra_line_spacing) = val;
 }
 static void
 bset_file_format (struct buffer *b, Lisp_Object val)
@@ -217,37 +217,37 @@ bset_file_truename (struct buffer *b, Lisp_Object val)
 static void
 bset_fringe_cursor_alist (struct buffer *b, Lisp_Object val)
 {
-  b->fringe_cursor_alist_ = val;
+  b->BVAR_DEFAULTED_FIELD(fringe_cursor_alist) = val;
 }
 static void
 bset_fringe_indicator_alist (struct buffer *b, Lisp_Object val)
 {
-  b->fringe_indicator_alist_ = val;
+  b->BVAR_DEFAULTED_FIELD(fringe_indicator_alist) = val;
 }
 static void
 bset_fringes_outside_margins (struct buffer *b, Lisp_Object val)
 {
-  b->fringes_outside_margins_ = val;
+  b->BVAR_DEFAULTED_FIELD(fringes_outside_margins) = val;
 }
 static void
 bset_header_line_format (struct buffer *b, Lisp_Object val)
 {
-  b->header_line_format_ = val;
+  b->BVAR_DEFAULTED_FIELD(header_line_format) = val;
 }
 static void
 bset_tab_line_format (struct buffer *b, Lisp_Object val)
 {
-  b->tab_line_format_ = val;
+  b->BVAR_DEFAULTED_FIELD(tab_line_format) = val;
 }
 static void
 bset_indicate_buffer_boundaries (struct buffer *b, Lisp_Object val)
 {
-  b->indicate_buffer_boundaries_ = val;
+  b->BVAR_DEFAULTED_FIELD(indicate_buffer_boundaries) = val;
 }
 static void
 bset_indicate_empty_lines (struct buffer *b, Lisp_Object val)
 {
-  b->indicate_empty_lines_ = val;
+  b->BVAR_DEFAULTED_FIELD(indicate_empty_lines) = val;
 }
 static void
 bset_invisibility_spec (struct buffer *b, Lisp_Object val)
@@ -257,7 +257,7 @@ bset_invisibility_spec (struct buffer *b, Lisp_Object val)
 static void
 bset_left_fringe_width (struct buffer *b, Lisp_Object val)
 {
-  b->left_fringe_width_ = val;
+  b->BVAR_DEFAULTED_FIELD(left_fringe_width) = val;
 }
 static void
 bset_major_mode (struct buffer *b, Lisp_Object val)
@@ -277,7 +277,7 @@ bset_mark (struct buffer *b, Lisp_Object val)
 static void
 bset_mode_line_format (struct buffer *b, Lisp_Object val)
 {
-  b->mode_line_format_ = val;
+  b->BVAR_DEFAULTED_FIELD(mode_line_format) = val;
 }
 static void
 bset_mode_name (struct buffer *b, Lisp_Object val)
@@ -292,7 +292,7 @@ bset_name (struct buffer *b, Lisp_Object val)
 static void
 bset_overwrite_mode (struct buffer *b, Lisp_Object val)
 {
-  b->overwrite_mode_ = val;
+  b->BVAR_DEFAULTED_FIELD(overwrite_mode) = val;
 }
 static void
 bset_pt_marker (struct buffer *b, Lisp_Object val)
@@ -302,52 +302,52 @@ bset_pt_marker (struct buffer *b, Lisp_Object val)
 static void
 bset_right_fringe_width (struct buffer *b, Lisp_Object val)
 {
-  b->right_fringe_width_ = val;
+  b->BVAR_DEFAULTED_FIELD(right_fringe_width) = val;
 }
 static void
 bset_scroll_bar_width (struct buffer *b, Lisp_Object val)
 {
-  b->scroll_bar_width_ = val;
+  b->BVAR_DEFAULTED_FIELD(scroll_bar_width) = val;
 }
 static void
 bset_scroll_bar_height (struct buffer *b, Lisp_Object val)
 {
-  b->scroll_bar_height_ = val;
+  b->BVAR_DEFAULTED_FIELD(scroll_bar_height) = val;
 }
 static void
 bset_scroll_down_aggressively (struct buffer *b, Lisp_Object val)
 {
-  b->scroll_down_aggressively_ = val;
+  b->BVAR_DEFAULTED_FIELD(scroll_down_aggressively) = val;
 }
 static void
 bset_scroll_up_aggressively (struct buffer *b, Lisp_Object val)
 {
-  b->scroll_up_aggressively_ = val;
+  b->BVAR_DEFAULTED_FIELD(scroll_up_aggressively) = val;
 }
 static void
 bset_selective_display (struct buffer *b, Lisp_Object val)
 {
-  b->selective_display_ = val;
+  b->BVAR_DEFAULTED_FIELD(selective_display) = val;
 }
 static void
 bset_selective_display_ellipses (struct buffer *b, Lisp_Object val)
 {
-  b->selective_display_ellipses_ = val;
+  b->BVAR_DEFAULTED_FIELD(selective_display_ellipses) = val;
 }
 static void
 bset_vertical_scroll_bar_type (struct buffer *b, Lisp_Object val)
 {
-  b->vertical_scroll_bar_type_ = val;
+  b->BVAR_DEFAULTED_FIELD(vertical_scroll_bar_type) = val;
 }
 static void
 bset_horizontal_scroll_bar_type (struct buffer *b, Lisp_Object val)
 {
-  b->horizontal_scroll_bar_type_ = val;
+  b->BVAR_DEFAULTED_FIELD(horizontal_scroll_bar_type) = val;
 }
 static void
 bset_word_wrap (struct buffer *b, Lisp_Object val)
 {
-  b->word_wrap_ = val;
+  b->BVAR_DEFAULTED_FIELD(word_wrap) = val;
 }
 static void
 bset_zv_marker (struct buffer *b, Lisp_Object val)
@@ -1062,9 +1062,9 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
                /* Special case these two for backwards-compat; they're
                   flagged as permanent-locals in bindings.el, even
                   though they do have default values. */
-               || (offset != PER_BUFFER_VAR_OFFSET (truncate_lines)
+               || (offset != PER_BUFFER_VAR_DEFAULTED_OFFSET (truncate_lines)
                    && offset !=
-                   PER_BUFFER_VAR_OFFSET (buffer_file_coding_system)))))
+                   PER_BUFFER_VAR_DEFAULTED_OFFSET (buffer_file_coding_system)))))
         KILL_PER_BUFFER_VALUE (b, offset);
     }
 }
@@ -5098,8 +5098,8 @@ init_buffer_once (void)
   FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
     {
       /* These are initialized before us. */
-      if (!(offset == PER_BUFFER_VAR_OFFSET (syntax_table)
-            || offset == PER_BUFFER_VAR_OFFSET (category_table)))
+      if (!(offset == PER_BUFFER_VAR_DEFAULTED_OFFSET (syntax_table)
+            || offset == PER_BUFFER_VAR_DEFAULTED_OFFSET (category_table)))
         set_per_buffer_default (offset, Qunbound);
     }
   set_per_buffer_default (PER_BUFFER_VAR_OFFSET (undo_list), Qunbound);
@@ -5117,7 +5117,7 @@ init_buffer_once (void)
   bset_abbrev_table (&buffer_defaults, Qnil);
   bset_display_table (&buffer_defaults, Qnil);
 
-  XSETFASTINT (BVAR (&buffer_defaults, tab_width), 8);
+  XSETFASTINT (BVAR_DEFAULTED (&buffer_defaults, tab_width), 8);
   bset_truncate_lines (&buffer_defaults, Qnil);
   bset_word_wrap (&buffer_defaults, Qnil);
   bset_ctl_arrow (&buffer_defaults, Qt);
@@ -5130,11 +5130,11 @@ init_buffer_once (void)
   bset_cursor_in_non_selected_windows (&buffer_defaults, Qt);
 
   bset_buffer_file_coding_system (&buffer_defaults, Qnil);
-  XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70);
-  XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0);
+  XSETFASTINT (BVAR_DEFAULTED (&buffer_defaults, fill_column), 70);
+  XSETFASTINT (BVAR_DEFAULTED (&buffer_defaults, left_margin), 0);
   bset_cache_long_scans (&buffer_defaults, Qt);
-  XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0);
-  XSETFASTINT (BVAR (&buffer_defaults, right_margin_cols), 0);
+  XSETFASTINT (BVAR_DEFAULTED (&buffer_defaults, left_margin_cols), 0);
+  XSETFASTINT (BVAR_DEFAULTED (&buffer_defaults, right_margin_cols), 0);
   bset_left_fringe_width (&buffer_defaults, Qnil);
   bset_right_fringe_width (&buffer_defaults, Qnil);
   bset_fringes_outside_margins (&buffer_defaults, Qnil);
@@ -5363,20 +5363,20 @@ syms_of_buffer (void)
 	build_pure_c_string ("Attempt to modify a protected field"));
 
   DEFVAR_PER_BUFFER ("tab-line-format",
-		     &BVAR (current_buffer, tab_line_format),
+		     &BVAR_DEFAULTED (current_buffer, tab_line_format),
 		     Qnil,
 		     doc: /* Analogous to `mode-line-format', but controls the tab line.
 The tab line appears, optionally, at the top of a window;
 the mode line appears at the bottom.  */);
 
   DEFVAR_PER_BUFFER ("header-line-format",
-		     &BVAR (current_buffer, header_line_format),
+		     &BVAR_DEFAULTED (current_buffer, header_line_format),
 		     Qnil,
 		     doc: /* Analogous to `mode-line-format', but controls the header line.
 The header line appears, optionally, at the top of a window;
 the mode line appears at the bottom.  */);
 
-  DEFVAR_PER_BUFFER ("mode-line-format", &BVAR (current_buffer, mode_line_format),
+  DEFVAR_PER_BUFFER ("mode-line-format", &BVAR_DEFAULTED (current_buffer, mode_line_format),
 		     Qnil,
 		     doc: /* Template for displaying mode line for current buffer.
 
@@ -5462,18 +5462,18 @@ Usually a string, but can use any of the constructs for `mode-line-format',
 which see.
 Format with `format-mode-line' to produce a string value.  */);
 
-  DEFVAR_PER_BUFFER ("local-abbrev-table", &BVAR (current_buffer, abbrev_table), Qnil,
+  DEFVAR_PER_BUFFER ("local-abbrev-table", &BVAR_DEFAULTED (current_buffer, abbrev_table), Qnil,
 		     doc: /* Local (mode-specific) abbrev table of current buffer.  */);
 
-  DEFVAR_PER_BUFFER ("abbrev-mode", &BVAR (current_buffer, abbrev_mode), Qnil,
+  DEFVAR_PER_BUFFER ("abbrev-mode", &BVAR_DEFAULTED (current_buffer, abbrev_mode), Qnil,
 		     doc: /*  Non-nil if Abbrev mode is enabled.
 Use the command `abbrev-mode' to change this variable.  */);
 
-  DEFVAR_PER_BUFFER ("case-fold-search", &BVAR (current_buffer, case_fold_search),
+  DEFVAR_PER_BUFFER ("case-fold-search", &BVAR_DEFAULTED (current_buffer, case_fold_search),
 		     Qnil,
 		     doc: /* Non-nil if searches and matches should ignore case.  */);
 
-  DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column),
+  DEFVAR_PER_BUFFER ("fill-column", &BVAR_DEFAULTED (current_buffer, fill_column),
 		     Qintegerp,
 		     doc: /* Column beyond which automatic line-wrapping should happen.
 It is used by filling commands, such as `fill-region' and `fill-paragraph',
@@ -5481,19 +5481,19 @@ and by `auto-fill-mode', which see.
 See also `current-fill-column'.
 Interactively, you can set the buffer local value using \\[set-fill-column].  */);
 
-  DEFVAR_PER_BUFFER ("left-margin", &BVAR (current_buffer, left_margin),
+  DEFVAR_PER_BUFFER ("left-margin", &BVAR_DEFAULTED (current_buffer, left_margin),
 		     Qintegerp,
 		     doc: /* Column for the default `indent-line-function' to indent to.
 Linefeed indents to this column in Fundamental mode.  */);
 
-  DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width),
+  DEFVAR_PER_BUFFER ("tab-width", &BVAR_DEFAULTED (current_buffer, tab_width),
 		     Qintegerp,
 		     doc: /* Distance between tab stops (for display of tab characters), in columns.
 NOTE: This controls the display width of a TAB character, and not
 the size of an indentation step.
 This should be an integer greater than zero.  */);
 
-  DEFVAR_PER_BUFFER ("ctl-arrow", &BVAR (current_buffer, ctl_arrow), Qnil,
+  DEFVAR_PER_BUFFER ("ctl-arrow", &BVAR_DEFAULTED (current_buffer, ctl_arrow), Qnil,
 		     doc: /* Non-nil means display control chars with uparrow.
 A value of nil means use backslash and octal digits.
 This variable does not apply to characters whose display is specified
@@ -5514,7 +5514,7 @@ See also Info node `(elisp)Text Representations'.  */);
   make_symbol_constant (intern_c_string ("enable-multibyte-characters"));
 
   DEFVAR_PER_BUFFER ("buffer-file-coding-system",
-		     &BVAR (current_buffer, buffer_file_coding_system), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, buffer_file_coding_system), Qnil,
 		     doc: /* Coding system to be used for encoding the buffer contents on saving.
 This variable applies to saving the buffer, and also to `write-region'
 and other functions that use `write-region'.
@@ -5532,7 +5532,7 @@ The variable `coding-system-for-write', if non-nil, overrides this variable.
 This variable is never applied to a way of decoding a file while reading it.  */);
 
   DEFVAR_PER_BUFFER ("bidi-display-reordering",
-		     &BVAR (current_buffer, bidi_display_reordering), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, bidi_display_reordering), Qnil,
 		     doc: /* Non-nil means reorder bidirectional text for display in the visual order.
 Setting this to nil is intended for use in debugging the display code.
 Don't set to nil in normal sessions, as that is not supported.
@@ -5540,7 +5540,7 @@ See also `bidi-paragraph-direction'; setting that non-nil might
 speed up redisplay.  */);
 
   DEFVAR_PER_BUFFER ("bidi-paragraph-start-re",
-		     &BVAR (current_buffer, bidi_paragraph_start_re), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, bidi_paragraph_start_re), Qnil,
 		     doc: /* If non-nil, a regexp matching a line that starts OR separates paragraphs.
 
 The value of nil means to use empty lines as lines that start and
@@ -5562,7 +5562,7 @@ set both these variables to "^".
 See also `bidi-paragraph-direction'.  */);
 
   DEFVAR_PER_BUFFER ("bidi-paragraph-separate-re",
-		     &BVAR (current_buffer, bidi_paragraph_separate_re), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, bidi_paragraph_separate_re), Qnil,
 		     doc: /* If non-nil, a regexp matching a line that separates paragraphs.
 
 The value of nil means to use empty lines as paragraph separators.
@@ -5583,7 +5583,7 @@ set both these variables to "^".
 See also `bidi-paragraph-direction'.  */);
 
   DEFVAR_PER_BUFFER ("bidi-paragraph-direction",
-		     &BVAR (current_buffer, bidi_paragraph_direction), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, bidi_paragraph_direction), Qnil,
 		     doc: /* If non-nil, forces directionality of text paragraphs in the buffer.
 
 If this is nil (the default), the direction of each paragraph is
@@ -5594,7 +5594,7 @@ Any other value is treated as nil.
 This variable has no effect unless the buffer's value of
 `bidi-display-reordering' is non-nil.  */);
 
- DEFVAR_PER_BUFFER ("truncate-lines", &BVAR (current_buffer, truncate_lines), Qnil,
+ DEFVAR_PER_BUFFER ("truncate-lines", &BVAR_DEFAULTED (current_buffer, truncate_lines), Qnil,
 		     doc: /* Non-nil means do not display continuation lines.
 Instead, give each line of text just one screen line.
 
@@ -5604,7 +5604,7 @@ and this buffer is not full-frame width.
 
 Minibuffers set this variable to nil.  */);
 
-  DEFVAR_PER_BUFFER ("word-wrap", &BVAR (current_buffer, word_wrap), Qnil,
+  DEFVAR_PER_BUFFER ("word-wrap", &BVAR_DEFAULTED (current_buffer, word_wrap), Qnil,
 		     doc: /* Non-nil means to use word-wrapping for continuation lines.
 When word-wrapping is on, continuation lines are wrapped at the space
 or tab character nearest to the right window edge.
@@ -5629,7 +5629,7 @@ It should be an absolute directory name; on GNU and Unix systems,
 these names start with `/' or `~' and end with `/'.
 To interactively change the default directory, use command `cd'. */);
 
-  DEFVAR_PER_BUFFER ("auto-fill-function", &BVAR (current_buffer, auto_fill_function),
+  DEFVAR_PER_BUFFER ("auto-fill-function", &BVAR_DEFAULTED (current_buffer, auto_fill_function),
 		     Qnil,
 		     doc: /* Function called (if non-nil) to perform auto-fill.
 It is called after self-inserting any character specified in
@@ -5671,7 +5671,7 @@ If you set this to -2, that means don't turn off auto-saving in this buffer
 if its text size shrinks.   If you use `buffer-swap-text' on a buffer,
 you probably should set this to -2 in that buffer.  */);
 
-  DEFVAR_PER_BUFFER ("selective-display", &BVAR (current_buffer, selective_display),
+  DEFVAR_PER_BUFFER ("selective-display", &BVAR_DEFAULTED (current_buffer, selective_display),
 		     Qnil,
 		     doc: /* Non-nil enables selective display.
 
@@ -5684,11 +5684,11 @@ in a file, save the ^M as a newline.  This usage is obsolete; use
 overlays or text properties instead.  */);
 
   DEFVAR_PER_BUFFER ("selective-display-ellipses",
-		     &BVAR (current_buffer, selective_display_ellipses),
+		     &BVAR_DEFAULTED (current_buffer, selective_display_ellipses),
 		     Qnil,
 		     doc: /* Non-nil means display ... on previous line when a line is invisible.  */);
 
-  DEFVAR_PER_BUFFER ("overwrite-mode", &BVAR (current_buffer, overwrite_mode),
+  DEFVAR_PER_BUFFER ("overwrite-mode", &BVAR_DEFAULTED (current_buffer, overwrite_mode),
 		     Qoverwrite_mode,
 		     doc: /* Non-nil if self-insertion should replace existing text.
 The value should be one of `overwrite-mode-textual',
@@ -5698,7 +5698,7 @@ inserts at the end of a line, and inserts when point is before a tab,
 until the tab is filled in.
 If `overwrite-mode-binary', self-insertion replaces newlines and tabs too.  */);
 
-  DEFVAR_PER_BUFFER ("buffer-display-table", &BVAR (current_buffer, display_table),
+  DEFVAR_PER_BUFFER ("buffer-display-table", &BVAR_DEFAULTED (current_buffer, display_table),
 		     Qnil,
 		     doc: /* Display table that controls display of the contents of current buffer.
 
@@ -5735,7 +5735,7 @@ In addition, a char-table has six extra slots to control the display of:
 
 See also the functions `display-table-slot' and `set-display-table-slot'.  */);
 
-  DEFVAR_PER_BUFFER ("left-margin-width", &BVAR (current_buffer, left_margin_cols),
+  DEFVAR_PER_BUFFER ("left-margin-width", &BVAR_DEFAULTED (current_buffer, left_margin_cols),
 		     Qintegerp,
 		     doc: /* Width in columns of left marginal area for display of a buffer.
 A value of nil means no marginal area.
@@ -5743,7 +5743,7 @@ A value of nil means no marginal area.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("right-margin-width", &BVAR (current_buffer, right_margin_cols),
+  DEFVAR_PER_BUFFER ("right-margin-width", &BVAR_DEFAULTED (current_buffer, right_margin_cols),
 		     Qintegerp,
 		     doc: /* Width in columns of right marginal area for display of a buffer.
 A value of nil means no marginal area.
@@ -5751,7 +5751,7 @@ A value of nil means no marginal area.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("left-fringe-width", &BVAR (current_buffer, left_fringe_width),
+  DEFVAR_PER_BUFFER ("left-fringe-width", &BVAR_DEFAULTED (current_buffer, left_fringe_width),
 		     Qintegerp,
 		     doc: /* Width of this buffer's left fringe (in pixels).
 A value of 0 means no left fringe is shown in this buffer's window.
@@ -5760,7 +5760,7 @@ A value of nil means to use the left fringe width from the window's frame.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("right-fringe-width", &BVAR (current_buffer, right_fringe_width),
+  DEFVAR_PER_BUFFER ("right-fringe-width", &BVAR_DEFAULTED (current_buffer, right_fringe_width),
 		     Qintegerp,
 		     doc: /* Width of this buffer's right fringe (in pixels).
 A value of 0 means no right fringe is shown in this buffer's window.
@@ -5769,7 +5769,7 @@ A value of nil means to use the right fringe width from the window's frame.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("fringes-outside-margins", &BVAR (current_buffer, fringes_outside_margins),
+  DEFVAR_PER_BUFFER ("fringes-outside-margins", &BVAR_DEFAULTED (current_buffer, fringes_outside_margins),
 		     Qnil,
 		     doc: /* Non-nil means to display fringes outside display margins.
 A value of nil means to display fringes between margins and buffer text.
@@ -5777,17 +5777,17 @@ A value of nil means to display fringes between margins and buffer text.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("scroll-bar-width", &BVAR (current_buffer, scroll_bar_width),
+  DEFVAR_PER_BUFFER ("scroll-bar-width", &BVAR_DEFAULTED (current_buffer, scroll_bar_width),
 		     Qintegerp,
 		     doc: /* Width of this buffer's vertical scroll bars in pixels.
 A value of nil means to use the scroll bar width from the window's frame.  */);
 
-  DEFVAR_PER_BUFFER ("scroll-bar-height", &BVAR (current_buffer, scroll_bar_height),
+  DEFVAR_PER_BUFFER ("scroll-bar-height", &BVAR_DEFAULTED (current_buffer, scroll_bar_height),
 		     Qintegerp,
 		     doc: /* Height of this buffer's horizontal scroll bars in pixels.
 A value of nil means to use the scroll bar height from the window's frame.  */);
 
-  DEFVAR_PER_BUFFER ("vertical-scroll-bar", &BVAR (current_buffer, vertical_scroll_bar_type),
+  DEFVAR_PER_BUFFER ("vertical-scroll-bar", &BVAR_DEFAULTED (current_buffer, vertical_scroll_bar_type),
 		     Qvertical_scroll_bar,
 		     doc: /* Position of this buffer's vertical scroll bar.
 The value takes effect whenever you tell a window to display this buffer;
@@ -5797,7 +5797,7 @@ A value of `left' or `right' means put the vertical scroll bar at that side
 of the window; a value of nil means don't show any vertical scroll bars.
 A value of t (the default) means do whatever the window's frame specifies.  */);
 
-  DEFVAR_PER_BUFFER ("horizontal-scroll-bar", &BVAR (current_buffer, horizontal_scroll_bar_type),
+  DEFVAR_PER_BUFFER ("horizontal-scroll-bar", &BVAR_DEFAULTED (current_buffer, horizontal_scroll_bar_type),
 		     Qnil,
 		     doc: /* Position of this buffer's horizontal scroll bar.
 The value takes effect whenever you tell a window to display this buffer;
@@ -5809,13 +5809,13 @@ A value of t (the default) means do whatever the window's frame
 specifies.  */);
 
   DEFVAR_PER_BUFFER ("indicate-empty-lines",
-		     &BVAR (current_buffer, indicate_empty_lines), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, indicate_empty_lines), Qnil,
 		     doc: /* Visually indicate empty lines after the buffer end.
 If non-nil, a bitmap is displayed in the left fringe of a window on
 window-systems.  */);
 
   DEFVAR_PER_BUFFER ("indicate-buffer-boundaries",
-		     &BVAR (current_buffer, indicate_buffer_boundaries), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, indicate_buffer_boundaries), Qnil,
 		     doc: /* Visually indicate buffer boundaries and scrolling.
 If non-nil, the first and last line of the buffer are marked in the fringe
 of a window on window-systems with angle bitmaps, or if the window can be
@@ -5840,7 +5840,7 @@ bitmaps in right fringe.  To show just the angle bitmaps in the left
 fringe, but no arrow bitmaps, use ((top .  left) (bottom . left)).  */);
 
   DEFVAR_PER_BUFFER ("fringe-indicator-alist",
-		     &BVAR (current_buffer, fringe_indicator_alist), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, fringe_indicator_alist), Qnil,
 		     doc: /* Mapping from logical to physical fringe indicator bitmaps.
 The value is an alist where each element (INDICATOR . BITMAPS)
 specifies the fringe bitmaps used to display a specific logical
@@ -5859,7 +5859,7 @@ last (only) line has no final newline.  BITMAPS may also be a single
 symbol which is used in both left and right fringes.  */);
 
   DEFVAR_PER_BUFFER ("fringe-cursor-alist",
-		     &BVAR (current_buffer, fringe_cursor_alist), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, fringe_cursor_alist), Qnil,
 		     doc: /* Mapping from logical to physical fringe cursor bitmaps.
 The value is an alist where each element (CURSOR . BITMAP)
 specifies the fringe bitmaps used to display a specific logical
@@ -5874,7 +5874,7 @@ BITMAP is the corresponding fringe bitmap shown for the logical
 cursor type.  */);
 
   DEFVAR_PER_BUFFER ("scroll-up-aggressively",
-		     &BVAR (current_buffer, scroll_up_aggressively), Qfraction,
+		     &BVAR_DEFAULTED (current_buffer, scroll_up_aggressively), Qfraction,
 		     doc: /* How far to scroll windows upward.
 If you move point off the bottom, the window scrolls automatically.
 This variable controls how far it scrolls.  The value nil, the default,
@@ -5887,7 +5887,7 @@ window scrolls by a full window height.  Meaningful values are
 between 0.0 and 1.0, inclusive.  */);
 
   DEFVAR_PER_BUFFER ("scroll-down-aggressively",
-		     &BVAR (current_buffer, scroll_down_aggressively), Qfraction,
+		     &BVAR_DEFAULTED (current_buffer, scroll_down_aggressively), Qfraction,
 		     doc: /* How far to scroll windows downward.
 If you move point off the top, the window scrolls automatically.
 This variable controls how far it scrolls.  The value nil, the default,
@@ -5987,7 +5987,7 @@ If the value of the variable is t, undo information is not recorded.  */);
   DEFVAR_PER_BUFFER ("mark-active", &BVAR (current_buffer, mark_active), Qnil,
 		     doc: /* Non-nil means the mark and region are currently active in this buffer.  */);
 
-  DEFVAR_PER_BUFFER ("cache-long-scans", &BVAR (current_buffer, cache_long_scans), Qnil,
+  DEFVAR_PER_BUFFER ("cache-long-scans", &BVAR_DEFAULTED (current_buffer, cache_long_scans), Qnil,
 		     doc: /* Non-nil means that Emacs should use caches in attempt to speedup buffer scans.
 
 There is no reason to set this to nil except for debugging purposes.
@@ -6094,7 +6094,7 @@ member of the list.  Any other non-nil value means disregard `buffer-read-only'
 and all `read-only' text properties.  */);
   Vinhibit_read_only = Qnil;
 
-  DEFVAR_PER_BUFFER ("cursor-type", &BVAR (current_buffer, cursor_type), Qnil,
+  DEFVAR_PER_BUFFER ("cursor-type", &BVAR_DEFAULTED (current_buffer, cursor_type), Qnil,
 		     doc: /* Cursor to use when this buffer is in the selected window.
 Values are interpreted as follows:
 
@@ -6118,7 +6118,7 @@ cursor's appearance is instead controlled by the variable
 `cursor-in-non-selected-windows'.  */);
 
   DEFVAR_PER_BUFFER ("line-spacing",
-		     &BVAR (current_buffer, extra_line_spacing), Qnumberp,
+		     &BVAR_DEFAULTED (current_buffer, extra_line_spacing), Qnumberp,
 		     doc: /* Additional space to put between lines when displaying a buffer.
 The space is measured in pixels, and put below lines on graphic displays,
 see `display-graphic-p'.
@@ -6126,7 +6126,7 @@ If value is a floating point number, it specifies the spacing relative
 to the default frame line height.  A value of nil means add no extra space.  */);
 
   DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows",
-		     &BVAR (current_buffer, cursor_in_non_selected_windows), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, cursor_in_non_selected_windows), Qnil,
 		     doc: /* Non-nil means show a cursor in non-selected windows.
 If nil, only shows a cursor in the selected window.
 If t, displays a cursor related to the usual cursor type
diff --git a/src/buffer.h b/src/buffer.h
index c765ea4347..e21a6e8767 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -280,13 +280,18 @@ struct buffer_text
     bool_bf redisplay : 1;
   };
 
+#define BVAR_FIELD(field) field ## _
+#define BVAR_DEFAULTED_FIELD(field) field ## _defaulted_
+
 /* Most code should use this macro to access Lisp fields in struct buffer.  */
 
-#define BVAR(buf, field) ((buf)->field ## _)
+#define BVAR(buf, field) ((buf)->BVAR_FIELD(field))
+
+#define BVAR_DEFAULTED(buf, field) ((buf)->BVAR_DEFAULTED_FIELD(field))
 
-#define BVAR_OR_DEFAULT(buf, field) (EQ (BVAR ((buf), field), Qunbound) \
-				     ? BVAR (&buffer_defaults, field) \
-				     : BVAR ((buf), field))
+#define BVAR_OR_DEFAULT(buf, field) (EQ (BVAR_DEFAULTED ((buf), field), Qunbound) \
+				     ? BVAR_DEFAULTED (&buffer_defaults, field) \
+				     : BVAR_DEFAULTED ((buf), field))
 
 /* Max number of builtin per-buffer variables.  */
 enum { MAX_PER_BUFFER_VARS = 50 };
@@ -302,17 +307,17 @@ struct buffer
   union vectorlike_header header;
 
   /* The name of this buffer.  */
-  Lisp_Object name_;
+  Lisp_Object BVAR_FIELD(name);
 
   /* The name of the file visited in this buffer, or nil.  */
-  Lisp_Object filename_;
+  Lisp_Object BVAR_FIELD(filename);
 
   /* Directory for expanding relative file names.  */
-  Lisp_Object directory_;
+  Lisp_Object BVAR_FIELD(directory);
 
   /* True if this buffer has been backed up (if you write to the visited
      file and it hasn't been backed up, then a backup will be made).  */
-  Lisp_Object backed_up_;
+  Lisp_Object BVAR_FIELD(backed_up);
 
   /* Length of file when last read or saved.
      -1 means auto saving turned off because buffer shrank a lot.
@@ -320,142 +325,142 @@ struct buffer
        (That value is used with buffer-swap-text.)
      This is not in the  struct buffer_text
      because it's not used in indirect buffers at all.  */
-  Lisp_Object save_length_;
+  Lisp_Object BVAR_FIELD(save_length);
 
   /* File name used for auto-saving this buffer.
      This is not in the  struct buffer_text
      because it's not used in indirect buffers at all.  */
-  Lisp_Object auto_save_file_name_;
+  Lisp_Object BVAR_FIELD(auto_save_file_name);
 
   /* Non-nil if buffer read-only.  */
-  Lisp_Object read_only_;
+  Lisp_Object BVAR_FIELD(read_only);
 
   /* "The mark".  This is a marker which may
      point into this buffer or may point nowhere.  */
-  Lisp_Object mark_;
+  Lisp_Object BVAR_FIELD(mark);
 
   /* Alist of elements (SYMBOL . VALUE-IN-THIS-BUFFER) for all
      per-buffer variables of this buffer.  For locally unbound
      symbols, just the symbol appears as the element.  */
-  Lisp_Object local_var_alist_;
+  Lisp_Object BVAR_FIELD(local_var_alist);
 
   /* Symbol naming major mode (e.g., lisp-mode).  */
-  Lisp_Object major_mode_;
+  Lisp_Object BVAR_FIELD(major_mode);
 
   /* Symbol listing all currently enabled minor modes.  */
-  Lisp_Object local_minor_modes_;
+  Lisp_Object BVAR_FIELD(local_minor_modes);
 
   /* Pretty name of major mode (e.g., "Lisp"). */
-  Lisp_Object mode_name_;
+  Lisp_Object BVAR_FIELD(mode_name);
 
   /* Mode line element that controls format of mode line.  */
-  Lisp_Object mode_line_format_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(mode_line_format);
 
   /* Analogous to mode_line_format for the line displayed at the top
      of windows.  Nil means don't display that line.  */
-  Lisp_Object header_line_format_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(header_line_format);
 
   /* Analogous to mode_line_format for the line displayed at the top
      of windows.  Nil means don't display that line.  */
-  Lisp_Object tab_line_format_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(tab_line_format);
 
   /* Keys that are bound local to this buffer.  */
-  Lisp_Object keymap_;
+  Lisp_Object BVAR_FIELD(keymap);
 
   /* This buffer's local abbrev table.  */
-  Lisp_Object abbrev_table_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(abbrev_table);
 
   /* This buffer's syntax table.  */
-  Lisp_Object syntax_table_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(syntax_table);
 
   /* This buffer's category table.  */
-  Lisp_Object category_table_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(category_table);
 
   /* Values of several buffer-local variables.  */
   /* tab-width is buffer-local so that redisplay can find it
      in buffers that are not current.  */
-  Lisp_Object case_fold_search_;
-  Lisp_Object tab_width_;
-  Lisp_Object fill_column_;
-  Lisp_Object left_margin_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(case_fold_search);
+  Lisp_Object BVAR_DEFAULTED_FIELD(tab_width);
+  Lisp_Object BVAR_DEFAULTED_FIELD(fill_column);
+  Lisp_Object BVAR_DEFAULTED_FIELD(left_margin);
 
   /* Function to call when insert space past fill column.  */
-  Lisp_Object auto_fill_function_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(auto_fill_function);
 
   /* Case table for case-conversion in this buffer.
      This char-table maps each char into its lower-case version.  */
-  Lisp_Object downcase_table_;
+  Lisp_Object BVAR_FIELD(downcase_table);
 
   /* Char-table mapping each char to its upper-case version.  */
-  Lisp_Object upcase_table_;
+  Lisp_Object BVAR_FIELD(upcase_table);
 
   /* Char-table for conversion for case-folding search.  */
-  Lisp_Object case_canon_table_;
+  Lisp_Object BVAR_FIELD(case_canon_table);
 
   /* Char-table of equivalences for case-folding search.  */
-  Lisp_Object case_eqv_table_;
+  Lisp_Object BVAR_FIELD(case_eqv_table);
 
   /* Non-nil means do not display continuation lines.  */
-  Lisp_Object truncate_lines_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(truncate_lines);
 
   /* Non-nil means to use word wrapping when displaying continuation lines.  */
-  Lisp_Object word_wrap_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(word_wrap);
 
   /* Non-nil means display ctl chars with uparrow.  */
-  Lisp_Object ctl_arrow_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(ctl_arrow);
 
   /* Non-nil means reorder bidirectional text for display in the
      visual order.  */
-  Lisp_Object bidi_display_reordering_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(bidi_display_reordering);
 
   /* If non-nil, specifies which direction of text to force in all the
      paragraphs of the buffer.  Nil means determine paragraph
      direction dynamically for each paragraph.  */
-  Lisp_Object bidi_paragraph_direction_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(bidi_paragraph_direction);
 
   /* If non-nil, a regular expression for bidi paragraph separator.  */
-  Lisp_Object bidi_paragraph_separate_re_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(bidi_paragraph_separate_re);
 
   /* If non-nil, a regular expression for bidi paragraph start.  */
-  Lisp_Object bidi_paragraph_start_re_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(bidi_paragraph_start_re);
 
   /* Non-nil means do selective display;
      see doc string in syms_of_buffer (buffer.c) for details.  */
-  Lisp_Object selective_display_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(selective_display);
 
   /* Non-nil means show ... at end of line followed by invisible lines.  */
-  Lisp_Object selective_display_ellipses_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(selective_display_ellipses);
 
   /* t if "self-insertion" should overwrite; `binary' if it should also
      overwrite newlines and tabs - for editing executables and the like.  */
-  Lisp_Object overwrite_mode_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(overwrite_mode);
 
   /* Non-nil means abbrev mode is on.  Expand abbrevs automatically.  */
-  Lisp_Object abbrev_mode_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(abbrev_mode);
 
   /* Display table to use for text in this buffer.  */
-  Lisp_Object display_table_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(display_table);
 
   /* t means the mark and region are currently active.  */
-  Lisp_Object mark_active_;
+  Lisp_Object BVAR_FIELD(mark_active);
 
   /* Non-nil means the buffer contents are regarded as multi-byte
      form of characters, not a binary code.  */
-  Lisp_Object enable_multibyte_characters_;
+  Lisp_Object BVAR_FIELD(enable_multibyte_characters);
 
   /* Coding system to be used for encoding the buffer contents on
      saving.  */
-  Lisp_Object buffer_file_coding_system_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(buffer_file_coding_system);
 
   /* List of symbols naming the file format used for visited file.  */
-  Lisp_Object file_format_;
+  Lisp_Object BVAR_FIELD(file_format);
 
   /* List of symbols naming the file format used for auto-save file.  */
-  Lisp_Object auto_save_file_format_;
+  Lisp_Object BVAR_FIELD(auto_save_file_format);
 
   /* True if the newline position cache, width run cache and BIDI paragraph
      cache are enabled.  See search.c, indent.c and bidi.c for details.  */
-  Lisp_Object cache_long_scans_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(cache_long_scans);
 
   /* If the width run cache is enabled, this table contains the
      character widths width_run_cache (see above) assumes.  When we
@@ -463,106 +468,106 @@ struct buffer
      current display table to see whether the display table has
      affected the widths of any characters.  If it has, we
      invalidate the width run cache, and re-initialize width_table.  */
-  Lisp_Object width_table_;
+  Lisp_Object BVAR_FIELD(width_table);
 
   /* In an indirect buffer, or a buffer that is the base of an
      indirect buffer, this holds a marker that records
      PT for this buffer when the buffer is not current.  */
-  Lisp_Object pt_marker_;
+  Lisp_Object BVAR_FIELD(pt_marker);
 
   /* In an indirect buffer, or a buffer that is the base of an
      indirect buffer, this holds a marker that records
      BEGV for this buffer when the buffer is not current.  */
-  Lisp_Object begv_marker_;
+  Lisp_Object BVAR_FIELD(begv_marker);
 
   /* In an indirect buffer, or a buffer that is the base of an
      indirect buffer, this holds a marker that records
      ZV for this buffer when the buffer is not current.  */
-  Lisp_Object zv_marker_;
+  Lisp_Object BVAR_FIELD(zv_marker);
 
   /* This holds the point value before the last scroll operation.
      Explicitly setting point sets this to nil.  */
-  Lisp_Object point_before_scroll_;
+  Lisp_Object BVAR_FIELD(point_before_scroll);
 
   /* Truename of the visited file, or nil.  */
-  Lisp_Object file_truename_;
+  Lisp_Object BVAR_FIELD(file_truename);
 
   /* Invisibility spec of this buffer.
      t => any non-nil `invisible' property means invisible.
      A list => `invisible' property means invisible
      if it is memq in that list.  */
-  Lisp_Object invisibility_spec_;
+  Lisp_Object BVAR_FIELD(invisibility_spec);
 
   /* This is the last window that was selected with this buffer in it,
      or nil if that window no longer displays this buffer.  */
-  Lisp_Object last_selected_window_;
+  Lisp_Object BVAR_FIELD(last_selected_window);
 
   /* Incremented each time the buffer is displayed in a window.  */
-  Lisp_Object display_count_;
+  Lisp_Object BVAR_FIELD(display_count);
 
   /* Widths of left and right marginal areas for windows displaying
      this buffer.  */
-  Lisp_Object left_margin_cols_;
-  Lisp_Object right_margin_cols_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(left_margin_cols);
+  Lisp_Object BVAR_DEFAULTED_FIELD(right_margin_cols);
 
   /* Widths of left and right fringe areas for windows displaying
      this buffer.  */
-  Lisp_Object left_fringe_width_;
-  Lisp_Object right_fringe_width_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(left_fringe_width);
+  Lisp_Object BVAR_DEFAULTED_FIELD(right_fringe_width);
 
   /* Non-nil means fringes are drawn outside display margins;
      othersize draw them between margin areas and text.  */
-  Lisp_Object fringes_outside_margins_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(fringes_outside_margins);
 
   /* Width, height and types of scroll bar areas for windows displaying
      this buffer.  */
-  Lisp_Object scroll_bar_width_;
-  Lisp_Object scroll_bar_height_;
-  Lisp_Object vertical_scroll_bar_type_;
-  Lisp_Object horizontal_scroll_bar_type_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(scroll_bar_width);
+  Lisp_Object BVAR_DEFAULTED_FIELD(scroll_bar_height);
+  Lisp_Object BVAR_DEFAULTED_FIELD(vertical_scroll_bar_type);
+  Lisp_Object BVAR_DEFAULTED_FIELD(horizontal_scroll_bar_type);
 
   /* Non-nil means indicate lines not displaying text (in a style
      like vi).  */
-  Lisp_Object indicate_empty_lines_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(indicate_empty_lines);
 
   /* Non-nil means indicate buffer boundaries and scrolling.  */
-  Lisp_Object indicate_buffer_boundaries_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(indicate_buffer_boundaries);
 
   /* Logical to physical fringe bitmap mappings.  */
-  Lisp_Object fringe_indicator_alist_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(fringe_indicator_alist);
 
   /* Logical to physical cursor bitmap mappings.  */
-  Lisp_Object fringe_cursor_alist_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(fringe_cursor_alist);
 
   /* Time stamp updated each time this buffer is displayed in a window.  */
-  Lisp_Object display_time_;
+  Lisp_Object BVAR_FIELD(display_time);
 
   /* If scrolling the display because point is below the bottom of a
      window showing this buffer, try to choose a window start so
      that point ends up this number of lines from the top of the
      window.  Nil means that scrolling method isn't used.  */
-  Lisp_Object scroll_up_aggressively_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(scroll_up_aggressively);
 
   /* If scrolling the display because point is above the top of a
      window showing this buffer, try to choose a window start so
      that point ends up this number of lines from the bottom of the
      window.  Nil means that scrolling method isn't used.  */
-  Lisp_Object scroll_down_aggressively_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(scroll_down_aggressively);
 
   /* Desired cursor type in this buffer.  See the doc string of
      per-buffer variable `cursor-type'.  */
-  Lisp_Object cursor_type_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(cursor_type);
 
   /* An integer > 0 means put that number of pixels below text lines
      in the display of this buffer.  */
-  Lisp_Object extra_line_spacing_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(extra_line_spacing);
 
   /* Cursor type to display in non-selected windows.
      t means to use hollow box cursor.
      See `cursor-type' for other values.  */
-  Lisp_Object cursor_in_non_selected_windows_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(cursor_in_non_selected_windows);
 
-  /* No more Lisp_Object beyond cursor_in_non_selected_windows_.
+  /* 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
@@ -714,12 +719,12 @@ XBUFFER (Lisp_Object a)
 INLINE void
 bset_bidi_paragraph_direction (struct buffer *b, Lisp_Object val)
 {
-  b->bidi_paragraph_direction_ = val;
+  b->BVAR_DEFAULTED_FIELD(bidi_paragraph_direction) = val;
 }
 INLINE void
 bset_cache_long_scans (struct buffer *b, Lisp_Object val)
 {
-  b->cache_long_scans_ = val;
+  b->BVAR_DEFAULTED_FIELD(cache_long_scans) = val;
 }
 INLINE void
 bset_case_canon_table (struct buffer *b, Lisp_Object val)
@@ -744,12 +749,12 @@ bset_display_count (struct buffer *b, Lisp_Object val)
 INLINE void
 bset_left_margin_cols (struct buffer *b, Lisp_Object val)
 {
-  b->left_margin_cols_ = val;
+  b->BVAR_DEFAULTED_FIELD(left_margin_cols) = val;
 }
 INLINE void
 bset_right_margin_cols (struct buffer *b, Lisp_Object val)
 {
-  b->right_margin_cols_ = val;
+  b->BVAR_DEFAULTED_FIELD(right_margin_cols) = val;
 }
 INLINE void
 bset_display_time (struct buffer *b, Lisp_Object val)
@@ -804,7 +809,7 @@ bset_read_only (struct buffer *b, Lisp_Object val)
 INLINE void
 bset_truncate_lines (struct buffer *b, Lisp_Object val)
 {
-  b->truncate_lines_ = val;
+  b->BVAR_DEFAULTED_FIELD(truncate_lines) = val;
 }
 INLINE void
 bset_undo_list (struct buffer *b, Lisp_Object val)
@@ -1047,7 +1052,7 @@ PTR_BYTE_POS (unsigned char const *ptr)
    structure, make sure that this is still correct.  */
 
 enum { BUFFER_LISP_SIZE = PSEUDOVECSIZE (struct buffer,
-					 cursor_in_non_selected_windows_) };
+					 BVAR_DEFAULTED_FIELD(cursor_in_non_selected_windows)) };
 
 /* Allocated size of the struct buffer part beyond leading
    Lisp_Objects, in word_size units.  */
@@ -1376,13 +1381,16 @@ OVERLAY_POSITION (Lisp_Object p)
 #define PER_BUFFER_VAR_OFFSET(VAR) \
   offsetof (struct buffer, VAR ## _)
 
+#define PER_BUFFER_VAR_DEFAULTED_OFFSET(VAR) \
+  offsetof (struct buffer, BVAR_DEFAULTED_FIELD(VAR))
+
 /* Used to iterate over normal Lisp_Object fields of struct buffer (all
    Lisp_Objects except undo_list).  If you add, remove, or reorder
    Lisp_Objects in a struct buffer, make sure that this is still correct.  */
 
 #define FOR_EACH_PER_BUFFER_OBJECT_AT(offset)				 \
   for (offset = PER_BUFFER_VAR_OFFSET (name);				 \
-       offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \
+       offset <= PER_BUFFER_VAR_DEFAULTED_OFFSET (cursor_in_non_selected_windows); \
        offset += word_size)
 
 /* Functions to get and set default value of the per-buffer
diff --git a/src/category.c b/src/category.c
index a9f5225df8..44b315d8b3 100644
--- a/src/category.c
+++ b/src/category.c
@@ -39,7 +39,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 static void
 bset_category_table (struct buffer *b, Lisp_Object val)
 {
-  b->category_table_ = val;
+  b->BVAR_DEFAULTED_FIELD(category_table) = val;
 }
 
 
diff --git a/src/category.h b/src/category.h
index cc32990478..eae3e121cd 100644
--- a/src/category.h
+++ b/src/category.h
@@ -94,7 +94,7 @@ CHAR_HAS_CATEGORY (int ch, int category)
 
 /* The standard category table is stored where it will automatically
    be used in all new buffers.  */
-#define Vstandard_category_table BVAR (&buffer_defaults, category_table)
+#define Vstandard_category_table BVAR_DEFAULTED (&buffer_defaults, category_table)
 
 /* Return the doc string of CATEGORY in category table TABLE.  */
 #define CATEGORY_DOCSTRING(table, category)				\
diff --git a/src/syntax.c b/src/syntax.c
index 4724b39097..473dd5f553 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -192,7 +192,7 @@ static void parse_sexp_propertize (ptrdiff_t charpos);
 static void
 bset_syntax_table (struct buffer *b, Lisp_Object val)
 {
-  b->syntax_table_ = val;
+  b->BVAR_DEFAULTED_FIELD(syntax_table) = val;
 }
 
 /* Whether the syntax of the character C has the prefix flag set.  */
diff --git a/src/syntax.h b/src/syntax.h
index c89797ea13..ecc0c55d55 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -31,7 +31,7 @@ extern void update_syntax_table_forward (ptrdiff_t, bool, Lisp_Object);
 
 /* The standard syntax table is stored where it will automatically
    be used in all new buffers.  */
-#define Vstandard_syntax_table BVAR (&buffer_defaults, syntax_table)
+#define Vstandard_syntax_table BVAR_DEFAULTED (&buffer_defaults, syntax_table)
 
 /* A syntax table is a chartable whose elements are cons cells
    (CODE+FLAGS . MATCHING-CHAR).  MATCHING-CHAR can be nil if the char
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 02/15] Take offset not idx in PER_BUFFER_VALUE_P
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 07:28:01 +0000
Resent-Message-ID: <handler.48264.B48264.162037246128032 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162037246128032
          (code B ref 48264); Fri, 07 May 2021 07:28:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 07:27:41 +0000
Received: from localhost ([127.0.0.1]:42286 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leutg-0007I4-WF
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 03:27:41 -0400
Received: from eggs.gnu.org ([209.51.188.92]:43872)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1leutb-0007Hx-Rg
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 03:27:39 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:44504)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1leutW-0000Xg-Gl; Fri, 07 May 2021 03:27:30 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1400
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1leutW-0005F0-2T; Fri, 07 May 2021 03:27:30 -0400
Date: Fri, 07 May 2021 10:27:20 +0300
Message-Id: <83eeejc8br.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <20210506213346.9730-3-sbaugh@HIDDEN> (message from Spencer
 Baugh on Thu, 6 May 2021 17:33:33 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-3-sbaugh@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Date: Thu,  6 May 2021 17:33:33 -0400
> Cc: Spencer Baugh <sbaugh@HIDDEN>
> 
> This improves clarity and allows us to more easily change how
> PER_BUFFER_VALUE_P works.
> 
> * src/buffer.h (PER_BUFFER_VALUE_P): Move to be in scope of
> PER_BUFFER_IDX.  Take offset instead of idx, and perform the common
> "idx == -1" check internally.
> * src/data.c (store_symval_forwarding, set_internal)
> (set_default_internal, Flocal_variable_p):
> * src/buffer.c (buffer_local_variables_1): Pass offset not idx to
> PER_BUFFER_VALUE_P, and remove idx == -1 checks.

This moves an INLINE function from a header to a C file, which I'd
prefer to avoid (due to all kind of subtle issues with inline
functions).  Can't you move PER_BUFFER_IDX to the header instead?

Thanks.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 07:30:02 +0000
Resent-Message-ID: <handler.48264.B48264.162037255728097 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162037255728097
          (code B ref 48264); Fri, 07 May 2021 07:30:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 07:29:17 +0000
Received: from localhost ([127.0.0.1]:42295 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leuvF-0007J7-A9
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 03:29:17 -0400
Received: from eggs.gnu.org ([209.51.188.92]:44068)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1leuvE-0007J1-85
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 03:29:16 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:44534)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1leuv8-0001kv-Vb; Fri, 07 May 2021 03:29:10 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1505
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1leuv8-0002gr-IH; Fri, 07 May 2021 03:29:10 -0400
Date: Fri, 07 May 2021 10:29:03 +0300
Message-Id: <83czu3c88w.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <20210506213346.9730-4-sbaugh@HIDDEN> (message from Spencer
 Baugh on Thu, 6 May 2021 17:33:34 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-4-sbaugh@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Date: Thu,  6 May 2021 17:33:34 -0400
> Cc: Spencer Baugh <sbaugh@HIDDEN>
> 
> This makes the code more clear and allows us to more easily change how
> this property is determined.

Does it?  Can you explain why you think so?  It looks like we are
replacing clear code with an equally clear different code.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 08/15] Set non-buffer-local BVARs to Qunbound
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 10:39:02 +0000
Resent-Message-ID: <handler.48264.B48264.162038389011441 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: sbaugh@HIDDEN, 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162038389011441
          (code B ref 48264); Fri, 07 May 2021 10:39:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 10:38:10 +0000
Received: from localhost ([127.0.0.1]:43081 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lexs2-0002yT-Bf
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 06:38:10 -0400
Received: from eggs.gnu.org ([209.51.188.92]:53048)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lexs0-0002yN-8z
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 06:38:08 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:59346)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lexru-0001jO-Ti; Fri, 07 May 2021 06:38:02 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1089
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lexru-0005Xa-Hi; Fri, 07 May 2021 06:38:02 -0400
Date: Fri, 07 May 2021 13:37:53 +0300
Message-Id: <83bl9mde2m.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <20210506213346.9730-9-sbaugh@HIDDEN> (message from Spencer
 Baugh on Thu, 6 May 2021 17:33:39 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-9-sbaugh@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Date: Thu,  6 May 2021 17:33:39 -0400
> Cc: Spencer Baugh <sbaugh@HIDDEN>
> 
> --- a/src/buffer.c
> +++ b/src/buffer.c
> @@ -54,8 +54,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
>     defined with DEFVAR_PER_BUFFER, that have special slots in each buffer.
>     The default value occupies the same slot in this structure
>     as an individual buffer's value occupies in that buffer.
> -   Setting the default value also goes through the alist of buffers
> -   and stores into each buffer that does not say it has a local value.  */
> +*/

This is a spurious change, please undo it.

> @@ -1107,8 +1109,7 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
>     that have special slots in each buffer.
>     The default value occupies the same slot in this structure
>     as an individual buffer's value occupies in that buffer.
> -   Setting the default value also goes through the alist of buffers
> -   and stores into each buffer that does not say it has a local value.  */
> +*/

Likewise.

> +INLINE Lisp_Object
> +bvar_get (struct buffer *b, ptrdiff_t offset)
   ^^^^^^^^
How about calling this buffer_local_value instead? or maybe
bvar_get_value?

> @@ -1511,7 +1519,7 @@ KILL_PER_BUFFER_VALUE (struct buffer *b, int offset)
>  {
>    int idx = PER_BUFFER_IDX (offset);
>    SET_PER_BUFFER_VALUE_P (b, idx, 0);
> -  set_per_buffer_value (b, offset, per_buffer_default (offset));
> +  set_per_buffer_value (b, offset, Qunbound);
>  }

Hmm... I'm probably missing something here: what about per-buffer
variables that do have default values? how's that implemented in this
new implementation?




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 10:43:02 +0000
Resent-Message-ID: <handler.48264.B48264.162038417211583 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162038417211583
          (code B ref 48264); Fri, 07 May 2021 10:43:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 10:42:52 +0000
Received: from localhost ([127.0.0.1]:43102 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lexwZ-00030l-Vo
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 06:42:52 -0400
Received: from eggs.gnu.org ([209.51.188.92]:54284)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lexwY-00030d-Kf
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 06:42:50 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:59992)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lexwR-0003h2-Iv; Fri, 07 May 2021 06:42:45 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1374
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lexwQ-0001uC-Vw; Fri, 07 May 2021 06:42:43 -0400
Date: Fri, 07 May 2021 13:42:36 +0300
Message-Id: <83a6p6ddur.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <20210506213346.9730-13-sbaugh@HIDDEN> (message from Spencer
 Baugh on Thu, 6 May 2021 17:33:43 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-13-sbaugh@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Date: Thu,  6 May 2021 17:33:43 -0400
> Cc: Spencer Baugh <sbaugh@HIDDEN>
> 
> * src/buffer.h (BUFFER_DEFAULT_VALUE_P):
> Check if field is Qunbound to determine if there's a default.

This should be filled with fill-paragraph.

> @@ -54,7 +54,8 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
>     defined with DEFVAR_PER_BUFFER, that have special slots in each buffer.
>     The default value occupies the same slot in this structure
>     as an individual buffer's value occupies in that buffer.
> -*/
> +   Slots in this structure which are set to Qunbound are permanently
> +   buffer-local. */
                  ^^
Two spaces after the period that ends a sentence, please.

> @@ -5252,6 +5253,15 @@ init_buffer_once (void)
>  
>    /* Set up the default values of various buffer slots.  */
>    /* Must do these before making the first buffer! */
> +  int offset;
> +  FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
> +    {
> +      /* These are initialized before us. */
                                         ^^
Typo: should be "use".  Also, please leave two spaces after the
period.

> +      if (!(offset == PER_BUFFER_VAR_OFFSET (syntax_table)
> +            || offset == PER_BUFFER_VAR_OFFSET (category_table)))

Please add a comment here about these two exemptions.  (And I cannot
say that I like such kludges; why doe we need it?)

> +  /* Sanity check that we didn't set the default for slots which
> +     are permanent-buffer-locals. */
                                   ^^
Two spaces again.

> --- a/src/buffer.h
> +++ b/src/buffer.h
> @@ -1102,7 +1102,8 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
>     that have special slots in each buffer.
>     The default value occupies the same slot in this structure
>     as an individual buffer's value occupies in that buffer.
> -*/
> +   Slots in this structure which are set to Qunbound are permanently
> +   buffer-local. */
                  ^^
And again.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 06/15] Rearrange set_internal for buffer forwarded symbols
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 10:47:01 +0000
Resent-Message-ID: <handler.48264.B48264.162038436611731 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162038436611731
          (code B ref 48264); Fri, 07 May 2021 10:47:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 10:46:06 +0000
Received: from localhost ([127.0.0.1]:43118 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lexzi-000339-Fz
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 06:46:06 -0400
Received: from eggs.gnu.org ([209.51.188.92]:54996)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lexzh-00032e-Pm
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 06:46:06 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:60424)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lexzZ-0005P9-Fp; Fri, 07 May 2021 06:46:00 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1604
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lexzZ-0006AW-45; Fri, 07 May 2021 06:45:57 -0400
Date: Fri, 07 May 2021 13:45:50 +0300
Message-Id: <838s4qddpd.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <20210506213346.9730-7-sbaugh@HIDDEN> (message from Spencer
 Baugh on Thu, 6 May 2021 17:33:37 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-7-sbaugh@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Date: Thu,  6 May 2021 17:33:37 -0400
> Cc: Spencer Baugh <sbaugh@HIDDEN>
> 
> --- a/src/data.c
> +++ b/src/data.c
> @@ -1320,6 +1320,9 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval,
>  	if (buf == NULL)
>  	  buf = current_buffer;
>  	set_per_buffer_value (buf, offset, newval);
> +        int idx = PER_BUFFER_IDX (offset);
> +        if (idx > 0)
> +          SET_PER_BUFFER_VALUE_P (buf, idx, 1);

It looks like you customized indent-tabs-mode to nil in C modes (or
maybe don't use Emacs?) because your indentation uses only spaces.
Please use our conventions in C sources, which uses TABs and spaces,
per indent-tabs-mode's default value.

This is a general comment, because I see signs of this in all of your
patches.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 07/15] Add BVAR_OR_DEFAULT macro as a stub
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 10:55:02 +0000
Resent-Message-ID: <handler.48264.B48264.162038487211947 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162038487211947
          (code B ref 48264); Fri, 07 May 2021 10:55:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 10:54:32 +0000
Received: from localhost ([127.0.0.1]:43152 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ley7s-00036d-As
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 06:54:32 -0400
Received: from eggs.gnu.org ([209.51.188.92]:56518)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1ley7q-00036X-Ox
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 06:54:31 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:33226)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1ley7l-0002Ag-Cb; Fri, 07 May 2021 06:54:25 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2113
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1ley7k-00073f-Vh; Fri, 07 May 2021 06:54:25 -0400
Date: Fri, 07 May 2021 13:54:15 +0300
Message-Id: <837dkaddbc.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <20210506213346.9730-8-sbaugh@HIDDEN> (message from Spencer
 Baugh on Thu, 6 May 2021 17:33:38 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-8-sbaugh@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Date: Thu,  6 May 2021 17:33:38 -0400
> Cc: Spencer Baugh <sbaugh@HIDDEN>
> 
> For buffer variables without a default, we still use BVAR.  For any
> buffer variable with a default, we use BVAR_OR_DEFAULT.  A later
> commit will statically enforce this.

This part says they are the same:

> --- a/src/buffer.h
> +++ b/src/buffer.h
> @@ -284,6 +284,8 @@ struct buffer_text
>  
>  #define BVAR(buf, field) ((buf)->field ## _)
>  
> +#define BVAR_OR_DEFAULT(buf, field) BVAR (buf, field)

What am I missing here?

Also, I have a question: suppose we have a variable that is defined
with DEFVAR_LISP, and then some Lisp calls make-variable-buffer-local:
how will that work with these two macros when the C code needs to
access the buffer-local value?




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 11:04:01 +0000
Resent-Message-ID: <handler.48264.B48264.162038542312333 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162038542312333
          (code B ref 48264); Fri, 07 May 2021 11:04:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 11:03:43 +0000
Received: from localhost ([127.0.0.1]:43199 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leyGl-0003Cr-Ip
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 07:03:43 -0400
Received: from eggs.gnu.org ([209.51.188.92]:58076)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1leyGj-0003Cl-OO
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 07:03:42 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:34526)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1leyGe-0008Bh-HU; Fri, 07 May 2021 07:03:36 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2676
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1leyGd-0002mv-Vf; Fri, 07 May 2021 07:03:36 -0400
Date: Fri, 07 May 2021 14:03:28 +0300
Message-Id: <835yzudcvz.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <20210506213346.9730-16-sbaugh@HIDDEN> (message from Spencer
 Baugh on Thu, 6 May 2021 17:33:46 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-16-sbaugh@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Date: Thu,  6 May 2021 17:33:46 -0400
> Cc: Spencer Baugh <sbaugh@HIDDEN>
> 
> diff --git a/src/buffer.c b/src/buffer.c
> index abf112a898..e048e7559f 100644
> --- a/src/buffer.c
> +++ b/src/buffer.c
> @@ -122,17 +122,17 @@ fix_position (Lisp_Object pos)
>  static void
>  bset_abbrev_mode (struct buffer *b, Lisp_Object val)
>  {
> -  b->abbrev_mode_ = val;
> +  b->BVAR_DEFAULTED_FIELD(abbrev_mode) = val;

Yuck!  Can we avoid having a macro in the struct field names?  I'd
prefer that the BVAR_DEFAULTED_FIELD macro accepted the buffer as
argument instead (if we need a macro at all; see below).

> --- a/src/buffer.h
> +++ b/src/buffer.h
> @@ -280,13 +280,18 @@ struct buffer_text
>      bool_bf redisplay : 1;
>    };
>  
> +#define BVAR_FIELD(field) field ## _
> +#define BVAR_DEFAULTED_FIELD(field) field ## _defaulted_

I'm not sure these changes are for the better.  Why not use _ and
_defaulted_ literally?  The macros don't make code easier to write,
and at least for me make it harder to understand (because I need to
look up the macro definition).

> @@ -714,12 +719,12 @@ XBUFFER (Lisp_Object a)
>  INLINE void
>  bset_bidi_paragraph_direction (struct buffer *b, Lisp_Object val)
>  {
> -  b->bidi_paragraph_direction_ = val;
> +  b->BVAR_DEFAULTED_FIELD(bidi_paragraph_direction) = val;
>  }
>  INLINE void
>  bset_cache_long_scans (struct buffer *b, Lisp_Object val)
>  {
> -  b->cache_long_scans_ = val;
> +  b->BVAR_DEFAULTED_FIELD(cache_long_scans) = val;
>  }
>  INLINE void
>  bset_case_canon_table (struct buffer *b, Lisp_Object val)
> @@ -744,12 +749,12 @@ bset_display_count (struct buffer *b, Lisp_Object val)
>  INLINE void
>  bset_left_margin_cols (struct buffer *b, Lisp_Object val)
>  {
> -  b->left_margin_cols_ = val;
> +  b->BVAR_DEFAULTED_FIELD(left_margin_cols) = val;
>  }

Hmm... I'm not sure I understand the effect of these.  Does it mean C
code can no longer set the buffer-local value of these variables, only
the default value?

> +#define PER_BUFFER_VAR_DEFAULTED_OFFSET(VAR) \
> +  offsetof (struct buffer, BVAR_DEFAULTED_FIELD(VAR))

Likewise here: I don't see how such macros make the code more
readable.  I think they make it less readable.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 00/15] Speeding up setting the default for DEFVAR_PER_BUFFER vars
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 11:06:01 +0000
Resent-Message-ID: <handler.48264.B48264.162038555512603 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162038555512603
          (code B ref 48264); Fri, 07 May 2021 11:06:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 11:05:55 +0000
Received: from localhost ([127.0.0.1]:43216 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1leyIt-0003HD-0c
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 07:05:55 -0400
Received: from eggs.gnu.org ([209.51.188.92]:58482)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1leyIq-0003H7-Og
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 07:05:53 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:34826)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1leyIl-00014G-KA; Fri, 07 May 2021 07:05:47 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2816
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1leyIk-00081o-KZ; Fri, 07 May 2021 07:05:47 -0400
Date: Fri, 07 May 2021 14:05:40 +0300
Message-Id: <834kfedcsb.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <20210506213346.9730-1-sbaugh@HIDDEN> (message from Spencer
 Baugh on Thu, 6 May 2021 17:33:31 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-1-sbaugh@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Date: Thu,  6 May 2021 17:33:31 -0400
> Cc: Spencer Baugh <sbaugh@HIDDEN>
> 
> This patch series fixes bug#48264 by speeding up changes to the
> default value for DEFVAR_PER_BUFFER vars, whether by let or
> set-default.  Such changes are now constant time, and run as fast as
> changes to non-default values.

[...]

I think some of this (the "new implementation") should be in some
commentary in buffer.c, and at least some of the rest should be in the
commit log message.  It makes no sense, IMNSHO, to have such a
detailed description here, and then lose it when installing the
changes.

Thanks.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 02/15] Take offset not idx in PER_BUFFER_VALUE_P
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 12:47:01 +0000
Resent-Message-ID: <handler.48264.B48264.162039156424513 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039156424513
          (code B ref 48264); Fri, 07 May 2021 12:47:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 12:46:04 +0000
Received: from localhost ([127.0.0.1]:43681 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lezrn-0006NJ-Op
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 08:46:03 -0400
Received: from venus.catern.com ([68.183.49.163]:59520)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lezrl-0006Mn-Cn
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 08:46:02 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620391560; bh=JiRDa3/IiRSskuDLyYpg6/9OoP/QP/Gr4XEkyuAn6ps=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=jaoLIL1vcK1t79cnXEdgebjF0FeDNfl9hE9e/iySNBaVgA9lTUS3FF3v0hk4ZB98/
 RqLnVzZUhNiZMeHgTcnJFQ29ZjVmKsbaQ+Fa8n9CgabyJegSQNV1JRCxunb5QPjnu+
 vZqUBuCetU12cYxU5UmwidVEaDjrBu8Cesd3AqUM=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 4DE442E4579;
 Fri,  7 May 2021 12:45:58 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83eeejc8br.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-3-sbaugh@HIDDEN> <83eeejc8br.fsf@HIDDEN>
Date: Fri, 07 May 2021 08:45:56 -0400
Message-ID: <87wnsar9tn.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Date: Thu,  6 May 2021 17:33:33 -0400
>> Cc: Spencer Baugh <sbaugh@HIDDEN>
>> 
>> This improves clarity and allows us to more easily change how
>> PER_BUFFER_VALUE_P works.
>> 
>> * src/buffer.h (PER_BUFFER_VALUE_P): Move to be in scope of
>> PER_BUFFER_IDX.  Take offset instead of idx, and perform the common
>> "idx == -1" check internally.
>> * src/data.c (store_symval_forwarding, set_internal)
>> (set_default_internal, Flocal_variable_p):
>> * src/buffer.c (buffer_local_variables_1): Pass offset not idx to
>> PER_BUFFER_VALUE_P, and remove idx == -1 checks.
>
> This moves an INLINE function from a header to a C file, which I'd
> prefer to avoid (due to all kind of subtle issues with inline
> functions).  Can't you move PER_BUFFER_IDX to the header instead?

You may have misread; PER_BUFFER_IDX and PER_BUFFER_VALUE_P are both
still in the header.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 12:51:01 +0000
Resent-Message-ID: <handler.48264.B48264.162039180224637 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039180224637
          (code B ref 48264); Fri, 07 May 2021 12:51:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 12:50:02 +0000
Received: from localhost ([127.0.0.1]:43699 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lezve-0006PG-Aj
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 08:50:02 -0400
Received: from venus.catern.com ([68.183.49.163]:59606)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lezvc-0006P0-IE
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 08:50:00 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620391799; bh=h4IFaEi+fcwqmhTufE5VBUGovUjcnmcueznvbRLvLtQ=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=c25Ka+9uk34yYoQgDIRycBHARKMX6fAOe987jgQFx6t30oriW+NZnwYW+tm8ov0lt
 JwrGWChLhhASEYQm6WZC2YIOoFjpqk3P5vIc4l9N0ouieFTn5cqPcAn8XC5ZGv3pr9
 jcAOOlsih57xkBylCKvRtYX0KMjz5kF/spnbJdBg=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id D792C2E4579;
 Fri,  7 May 2021 12:49:59 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83czu3c88w.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-4-sbaugh@HIDDEN> <83czu3c88w.fsf@HIDDEN>
Date: Fri, 07 May 2021 08:49:59 -0400
Message-ID: <87tuner9mw.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Date: Thu,  6 May 2021 17:33:34 -0400
>> Cc: Spencer Baugh <sbaugh@HIDDEN>
>> 
>> This makes the code more clear and allows us to more easily change how
>> this property is determined.
>
> Does it?  Can you explain why you think so?  It looks like we are
> replacing clear code with an equally clear different code.

Well, "if (idx > 0)" as a conditional requires a fair bit of digging in
the implementation of DEFVAR_PER_BUFFER variables to understand.  On the
other hand, "if (BUFFER_DEFAULT_VALUE_P (offset))" is immediately clear:
We're checking if this variable has a default value.

By hiding the implementation detail of "idx", we both remove the need to
know what idx is, and make it easier to later change the implementation
(as a later commit does).




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 02/15] Take offset not idx in PER_BUFFER_VALUE_P
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 12:55:02 +0000
Resent-Message-ID: <handler.48264.B48264.162039207824790 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039207824790
          (code B ref 48264); Fri, 07 May 2021 12:55:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 12:54:38 +0000
Received: from localhost ([127.0.0.1]:43724 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf006-0006Rm-If
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 08:54:38 -0400
Received: from eggs.gnu.org ([209.51.188.92]:55230)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lf005-0006Rg-8y
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 08:54:37 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:47000)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lezzz-0007Nl-Sg; Fri, 07 May 2021 08:54:31 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1691
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lezzz-0005Hx-Gs; Fri, 07 May 2021 08:54:31 -0400
Date: Fri, 07 May 2021 15:54:25 +0300
Message-Id: <83y2cqbt6m.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87wnsar9tn.fsf@HIDDEN> (message from Spencer Baugh on Fri,
 07 May 2021 08:45:56 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-3-sbaugh@HIDDEN> <83eeejc8br.fsf@HIDDEN>
 <87wnsar9tn.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Fri, 07 May 2021 08:45:56 -0400
> 
> > This moves an INLINE function from a header to a C file, which I'd
> > prefer to avoid (due to all kind of subtle issues with inline
> > functions).  Can't you move PER_BUFFER_IDX to the header instead?
> 
> You may have misread; PER_BUFFER_IDX and PER_BUFFER_VALUE_P are both
> still in the header.

Yes, sorry about that.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 08/15] Set non-buffer-local BVARs to Qunbound
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 12:55:02 +0000
Resent-Message-ID: <handler.48264.B48264.162039208124803 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039208124803
          (code B ref 48264); Fri, 07 May 2021 12:55:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 12:54:41 +0000
Received: from localhost ([127.0.0.1]:43727 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf008-0006Rz-PH
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 08:54:41 -0400
Received: from venus.catern.com ([68.183.49.163]:59718)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lf007-0006Rt-BY
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 08:54:39 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620392076; bh=d+RQCXnoYcLyVodYhpeccLd163O2xdRiGEA5xKRkF7M=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=VqJ83TaS6VjHwzVOqDiBGyEQedUtvmL5PvZCDNKK2OeglVBAJa0GBU8nnDZCLqhVy
 fPfgGZwecuuJtU/gnxDu5eYnubDP5XBAOf32pIAmh9jxe7+X0oSNA5ZYJdTGN30iQI
 RkI9z8J9qAxbiXGv7+5pDV3HgRh33BQFf28Qc9ik=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 620D42E9731;
 Fri,  7 May 2021 12:54:35 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83bl9mde2m.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-9-sbaugh@HIDDEN> <83bl9mde2m.fsf@HIDDEN>
Date: Fri, 07 May 2021 08:54:33 -0400
Message-ID: <87r1iir9fa.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Date: Thu,  6 May 2021 17:33:39 -0400
>> Cc: Spencer Baugh <sbaugh@HIDDEN>
>> 
>> --- a/src/buffer.c
>> +++ b/src/buffer.c
>> @@ -54,8 +54,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
>>     defined with DEFVAR_PER_BUFFER, that have special slots in each buffer.
>>     The default value occupies the same slot in this structure
>>     as an individual buffer's value occupies in that buffer.
>> -   Setting the default value also goes through the alist of buffers
>> -   and stores into each buffer that does not say it has a local value.  */
>> +*/
>
> This is a spurious change, please undo it.
>
>> @@ -1107,8 +1109,7 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
>>     that have special slots in each buffer.
>>     The default value occupies the same slot in this structure
>>     as an individual buffer's value occupies in that buffer.
>> -   Setting the default value also goes through the alist of buffers
>> -   and stores into each buffer that does not say it has a local value.  */
>> +*/
>
> Likewise.

Not sure what you mean about this being a spurious change - the comment
is no longer accurate, setting the default value no longer does that as
of this commit.

>> +INLINE Lisp_Object
>> +bvar_get (struct buffer *b, ptrdiff_t offset)
>    ^^^^^^^^
> How about calling this buffer_local_value instead? or maybe
> bvar_get_value?

Sure, any name works for me, although buffer_local_value already exists
(and does something different).  I can call it bvar_get_value though.

>> @@ -1511,7 +1519,7 @@ KILL_PER_BUFFER_VALUE (struct buffer *b, int offset)
>>  {
>>    int idx = PER_BUFFER_IDX (offset);
>>    SET_PER_BUFFER_VALUE_P (b, idx, 0);
>> -  set_per_buffer_value (b, offset, per_buffer_default (offset));
>> +  set_per_buffer_value (b, offset, Qunbound);
>>  }
>
> Hmm... I'm probably missing something here: what about per-buffer
> variables that do have default values? how's that implemented in this
> new implementation?

If a variable that does have a default value, then setting the
per-buffer variable to Qunbound will cause BVAR_OR_DEFAULT and bvar_get
to return the default value.

If the variable doesn't have a default value, then it's permanently
buffer-local and it was always unsafe to call KILL_PER_BUFFER_VALUE on
it - but fortunately, we never do that.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 12:59:01 +0000
Resent-Message-ID: <handler.48264.B48264.162039232024949 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039232024949
          (code B ref 48264); Fri, 07 May 2021 12:59:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 12:58:40 +0000
Received: from localhost ([127.0.0.1]:43752 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf040-0006UL-JC
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 08:58:40 -0400
Received: from eggs.gnu.org ([209.51.188.92]:56232)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lf03y-0006UF-Di
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 08:58:38 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:47146)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lf03t-0001EW-3y; Fri, 07 May 2021 08:58:33 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1938
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lf03r-0004Hj-VO; Fri, 07 May 2021 08:58:33 -0400
Date: Fri, 07 May 2021 15:58:23 +0300
Message-Id: <83wnsabt00.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87tuner9mw.fsf@HIDDEN> (message from Spencer Baugh on Fri,
 07 May 2021 08:49:59 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-4-sbaugh@HIDDEN> <83czu3c88w.fsf@HIDDEN>
 <87tuner9mw.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Fri, 07 May 2021 08:49:59 -0400
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> >> From: Spencer Baugh <sbaugh@HIDDEN>
> >> Date: Thu,  6 May 2021 17:33:34 -0400
> >> Cc: Spencer Baugh <sbaugh@HIDDEN>
> >> 
> >> This makes the code more clear and allows us to more easily change how
> >> this property is determined.
> >
> > Does it?  Can you explain why you think so?  It looks like we are
> > replacing clear code with an equally clear different code.
> 
> Well, "if (idx > 0)" as a conditional requires a fair bit of digging in
> the implementation of DEFVAR_PER_BUFFER variables to understand.  On the
> other hand, "if (BUFFER_DEFAULT_VALUE_P (offset))" is immediately clear:
> We're checking if this variable has a default value.

It's the other way around here: the test "if (idx > 0)" is clear,
whereas "if (BUFFER_DEFAULT_VALUE_P (offset))" makes me go look up the
definition of the macro, because the name is not expressive enough,
and the argument "offset" doesn't help, either.

> By hiding the implementation detail of "idx", we both remove the need to
> know what idx is, and make it easier to later change the implementation
> (as a later commit does).

I don't want to hide the implementation details, I want the code to
speak for itself.  If you can come up with a change that will make the
code really more clear, fine; otherwise I think we should add comments
there to explain the test.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 13:00:02 +0000
Resent-Message-ID: <handler.48264.B48264.162039237924998 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039237924998
          (code B ref 48264); Fri, 07 May 2021 13:00:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 12:59:39 +0000
Received: from localhost ([127.0.0.1]:43762 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf04w-0006V8-UL
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 08:59:39 -0400
Received: from venus.catern.com ([68.183.49.163]:59848)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lf04v-0006V2-ER
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 08:59:37 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620392376; bh=6JUIyAC5RGbdSeddad32OJxLSvpFGhNSLtE2Bn/uUmA=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=lyr7rEjmECWKG+A1hJ6znSbjiTUVMe4pSHiBCIdTKbxVbhvDStruTHJ3xFHaDELGF
 vG4Q6GepHwTHXAPcvGHf0hAJA6BmgGPr7gpM0eKrzgwnSSefsGTKseTYd0zPi472R7
 FHIPcD6+3W5RkKpH6JOdQufJst3nAVRjR6YvspMI=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id D54CB2E4579;
 Fri,  7 May 2021 12:59:36 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <835yzudcvz.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-16-sbaugh@HIDDEN> <835yzudcvz.fsf@HIDDEN>
Date: Fri, 07 May 2021 08:59:36 -0400
Message-ID: <87o8dmr96v.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Date: Thu,  6 May 2021 17:33:46 -0400
>> Cc: Spencer Baugh <sbaugh@HIDDEN>
>> 
>> diff --git a/src/buffer.c b/src/buffer.c
>> index abf112a898..e048e7559f 100644
>> --- a/src/buffer.c
>> +++ b/src/buffer.c
>> @@ -122,17 +122,17 @@ fix_position (Lisp_Object pos)
>>  static void
>>  bset_abbrev_mode (struct buffer *b, Lisp_Object val)
>>  {
>> -  b->abbrev_mode_ = val;
>> +  b->BVAR_DEFAULTED_FIELD(abbrev_mode) = val;
>
> Yuck!  Can we avoid having a macro in the struct field names?  I'd
> prefer that the BVAR_DEFAULTED_FIELD macro accepted the buffer as
> argument instead (if we need a macro at all; see below).

Ah, yes, I probably should have given a little more explanation of this.
I'm not tied to this approach, if we can think of a better way to make
it statically guaranteed that BVAR is only used with fields that have a
default.

>> --- a/src/buffer.h
>> +++ b/src/buffer.h
>> @@ -280,13 +280,18 @@ struct buffer_text
>>      bool_bf redisplay : 1;
>>    };
>>  
>> +#define BVAR_FIELD(field) field ## _
>> +#define BVAR_DEFAULTED_FIELD(field) field ## _defaulted_
>
> I'm not sure these changes are for the better.  Why not use _ and
> _defaulted_ literally?  The macros don't make code easier to write,
> and at least for me make it harder to understand (because I need to
> look up the macro definition).

Well, _ and _defaulted_ should never be written anywhere - any code that
wants to use a field should run it through BVAR_FIELD or
BVAR_DEFAULTED_FIELD.  This is also why these can't be written to take
the buffer as an argument - that wouldn't work for a few use cases.

>> @@ -714,12 +719,12 @@ XBUFFER (Lisp_Object a)
>>  INLINE void
>>  bset_bidi_paragraph_direction (struct buffer *b, Lisp_Object val)
>>  {
>> -  b->bidi_paragraph_direction_ = val;
>> +  b->BVAR_DEFAULTED_FIELD(bidi_paragraph_direction) = val;
>>  }
>>  INLINE void
>>  bset_cache_long_scans (struct buffer *b, Lisp_Object val)
>>  {
>> -  b->cache_long_scans_ = val;
>> +  b->BVAR_DEFAULTED_FIELD(cache_long_scans) = val;
>>  }
>>  INLINE void
>>  bset_case_canon_table (struct buffer *b, Lisp_Object val)
>> @@ -744,12 +749,12 @@ bset_display_count (struct buffer *b, Lisp_Object val)
>>  INLINE void
>>  bset_left_margin_cols (struct buffer *b, Lisp_Object val)
>>  {
>> -  b->left_margin_cols_ = val;
>> +  b->BVAR_DEFAULTED_FIELD(left_margin_cols) = val;
>>  }
>
> Hmm... I'm not sure I understand the effect of these.  Does it mean C
> code can no longer set the buffer-local value of these variables, only
> the default value?

No, this is purely just changing the name of the fields - it has no
impact on functionality, C code can still set the buffer-local
variables.

>> +#define PER_BUFFER_VAR_DEFAULTED_OFFSET(VAR) \
>> +  offsetof (struct buffer, BVAR_DEFAULTED_FIELD(VAR))
>
> Likewise here: I don't see how such macros make the code more
> readable.  I think they make it less readable.

I agree but I couldn't find a better way to ensure that BVAR and
BVAR_OR_DEFAULT are used on the correct fields.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 08/15] Set non-buffer-local BVARs to Qunbound
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 13:02:02 +0000
Resent-Message-ID: <handler.48264.B48264.162039247325175 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039247325175
          (code B ref 48264); Fri, 07 May 2021 13:02:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 13:01:13 +0000
Received: from localhost ([127.0.0.1]:43772 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf06T-0006Xz-DQ
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 09:01:13 -0400
Received: from eggs.gnu.org ([209.51.188.92]:56802)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lf06R-0006Xr-EI
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 09:01:11 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:47242)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lf06M-0002rD-6h; Fri, 07 May 2021 09:01:06 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2096
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lf06L-0005Uk-Q0; Fri, 07 May 2021 09:01:06 -0400
Date: Fri, 07 May 2021 16:00:59 +0300
Message-Id: <83v97ubsvo.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87r1iir9fa.fsf@HIDDEN> (message from Spencer Baugh on Fri,
 07 May 2021 08:54:33 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-9-sbaugh@HIDDEN> <83bl9mde2m.fsf@HIDDEN>
 <87r1iir9fa.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Fri, 07 May 2021 08:54:33 -0400
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> >> -   Setting the default value also goes through the alist of buffers
> >> -   and stores into each buffer that does not say it has a local value.  */
> >> +*/
> >
> > This is a spurious change, please undo it.
> >
> >> @@ -1107,8 +1109,7 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
> >>     that have special slots in each buffer.
> >>     The default value occupies the same slot in this structure
> >>     as an individual buffer's value occupies in that buffer.
> >> -   Setting the default value also goes through the alist of buffers
> >> -   and stores into each buffer that does not say it has a local value.  */
> >> +*/
> >
> > Likewise.
> 
> Not sure what you mean about this being a spurious change

I was talking about the added newline.  Sorry for not being more clear
about that.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 07/15] Add BVAR_OR_DEFAULT macro as a stub
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 13:06:01 +0000
Resent-Message-ID: <handler.48264.B48264.162039273125302 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039273125302
          (code B ref 48264); Fri, 07 May 2021 13:06:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 13:05:31 +0000
Received: from localhost ([127.0.0.1]:43792 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf0Ac-0006a2-VP
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 09:05:31 -0400
Received: from venus.catern.com ([68.183.49.163]:59996)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lf0Aa-0006Zw-Hb
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 09:05:29 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620392727; bh=rqx12c3duSB4+mpSWInFdQFSGLzwi3J+VzwkelfnGqA=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=jeT6VE1VqghrIhclHqCjsos1imiEc+QlR6mEVphqoRi3Jk4+gYqKvm1vekKRx3i5H
 bpmm/yamEhqdCi3XApcCmOjM1iwuEXMozhqh3b/aSiEigt+RO1wP1ngyGbKrlgKar0
 jt0QwOTg0u4PwvANatPF0VQOK+GUMzn31imH9QMM=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id A80D22E9748;
 Fri,  7 May 2021 13:05:27 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <837dkaddbc.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-8-sbaugh@HIDDEN> <837dkaddbc.fsf@HIDDEN>
Date: Fri, 07 May 2021 09:05:26 -0400
Message-ID: <87k0oar8x5.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Date: Thu,  6 May 2021 17:33:38 -0400
>> Cc: Spencer Baugh <sbaugh@HIDDEN>
>> 
>> For buffer variables without a default, we still use BVAR.  For any
>> buffer variable with a default, we use BVAR_OR_DEFAULT.  A later
>> commit will statically enforce this.
>
> This part says they are the same:
>
>> --- a/src/buffer.h
>> +++ b/src/buffer.h
>> @@ -284,6 +284,8 @@ struct buffer_text
>>  
>>  #define BVAR(buf, field) ((buf)->field ## _)
>>  
>> +#define BVAR_OR_DEFAULT(buf, field) BVAR (buf, field)
>
> What am I missing here?

The commit message is accurate - we indeed use BVAR for buffer variables
without a default, and BVAR_OR_DEFAULT for buffer variables with a
default.

It's just that in this commit, those two behave identically.  The
immediate next commit makes them different.

I split it up in this way because this commit is the result of a big
tree-wide sed, no actual meaningful change; I think it's much easier to
understand the next commit when the two are kept separate.

> Also, I have a question: suppose we have a variable that is defined
> with DEFVAR_LISP, and then some Lisp calls make-variable-buffer-local:
> how will that work with these two macros when the C code needs to
> access the buffer-local value?

Nothing in these changes affect variables that are made into
buffer-locals from Lisp code; these changes only affect variables
built-in to Emacs that were defined with DEFVAR_PER_BUFFER.  So that
will just work the same as it does today - accesses to such variables
don't go through BVAR today.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 13:10:02 +0000
Resent-Message-ID: <handler.48264.B48264.162039294125407 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039294125407
          (code B ref 48264); Fri, 07 May 2021 13:10:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 13:09:01 +0000
Received: from localhost ([127.0.0.1]:43808 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf0E1-0006bf-GJ
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 09:09:01 -0400
Received: from eggs.gnu.org ([209.51.188.92]:58870)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lf0Dz-0006bX-5n
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 09:08:59 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:47582)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lf0Du-0007is-1U; Fri, 07 May 2021 09:08:54 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2580
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lf0Dq-0000gv-9o; Fri, 07 May 2021 09:08:53 -0400
Date: Fri, 07 May 2021 16:08:41 +0300
Message-Id: <83tunebsiu.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87o8dmr96v.fsf@HIDDEN> (message from Spencer Baugh on Fri,
 07 May 2021 08:59:36 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-16-sbaugh@HIDDEN> <835yzudcvz.fsf@HIDDEN>
 <87o8dmr96v.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Fri, 07 May 2021 08:59:36 -0400
> 
> >> -  b->abbrev_mode_ = val;
> >> +  b->BVAR_DEFAULTED_FIELD(abbrev_mode) = val;
> >
> > Yuck!  Can we avoid having a macro in the struct field names?  I'd
> > prefer that the BVAR_DEFAULTED_FIELD macro accepted the buffer as
> > argument instead (if we need a macro at all; see below).
> 
> Ah, yes, I probably should have given a little more explanation of this.
> I'm not tied to this approach, if we can think of a better way to make
> it statically guaranteed that BVAR is only used with fields that have a
> default.

If the sole purpose is to be able to detect coding mistakes, then
there are other possibilities to do that, if the compiler cannot help
in a way that leaves the sources readable.

> >> @@ -714,12 +719,12 @@ XBUFFER (Lisp_Object a)
> >>  INLINE void
> >>  bset_bidi_paragraph_direction (struct buffer *b, Lisp_Object val)
> >>  {
> >> -  b->bidi_paragraph_direction_ = val;
> >> +  b->BVAR_DEFAULTED_FIELD(bidi_paragraph_direction) = val;
> >>  }
> >>  INLINE void
> >>  bset_cache_long_scans (struct buffer *b, Lisp_Object val)
> >>  {
> >> -  b->cache_long_scans_ = val;
> >> +  b->BVAR_DEFAULTED_FIELD(cache_long_scans) = val;
> >>  }
> >>  INLINE void
> >>  bset_case_canon_table (struct buffer *b, Lisp_Object val)
> >> @@ -744,12 +749,12 @@ bset_display_count (struct buffer *b, Lisp_Object val)
> >>  INLINE void
> >>  bset_left_margin_cols (struct buffer *b, Lisp_Object val)
> >>  {
> >> -  b->left_margin_cols_ = val;
> >> +  b->BVAR_DEFAULTED_FIELD(left_margin_cols) = val;
> >>  }
> >
> > Hmm... I'm not sure I understand the effect of these.  Does it mean C
> > code can no longer set the buffer-local value of these variables, only
> > the default value?
> 
> No, this is purely just changing the name of the fields - it has no
> impact on functionality, C code can still set the buffer-local
> variables.

Then I guess the _defaulted_ part is a misnomer?

> >> +#define PER_BUFFER_VAR_DEFAULTED_OFFSET(VAR) \
> >> +  offsetof (struct buffer, BVAR_DEFAULTED_FIELD(VAR))
> >
> > Likewise here: I don't see how such macros make the code more
> > readable.  I think they make it less readable.
> 
> I agree but I couldn't find a better way to ensure that BVAR and
> BVAR_OR_DEFAULT are used on the correct fields.

Maybe someone could come up with a trick to have the diagnostics
without twisting the sources so much.  Failing that, maybe we should
simply have a test to detect the mistakes?  That wouldn't prevent bad
code from being compiled, but it should reveal it soon enough, since
tests are regularly run on hydra.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 07/15] Add BVAR_OR_DEFAULT macro as a stub
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 13:13:01 +0000
Resent-Message-ID: <handler.48264.B48264.162039316225536 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039316225536
          (code B ref 48264); Fri, 07 May 2021 13:13:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 13:12:42 +0000
Received: from localhost ([127.0.0.1]:43825 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf0Ha-0006do-3H
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 09:12:42 -0400
Received: from eggs.gnu.org ([209.51.188.92]:59536)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lf0HY-0006de-T3
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 09:12:41 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:47714)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lf0HT-0001Z0-Ok; Fri, 07 May 2021 09:12:35 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2813
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lf0HT-0007As-C3; Fri, 07 May 2021 09:12:35 -0400
Date: Fri, 07 May 2021 16:12:29 +0300
Message-Id: <83pmy2bsci.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87k0oar8x5.fsf@HIDDEN> (message from Spencer Baugh on Fri,
 07 May 2021 09:05:26 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-8-sbaugh@HIDDEN> <837dkaddbc.fsf@HIDDEN>
 <87k0oar8x5.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Fri, 07 May 2021 09:05:26 -0400
> 
> >> +#define BVAR_OR_DEFAULT(buf, field) BVAR (buf, field)
> >
> > What am I missing here?
> 
> The commit message is accurate - we indeed use BVAR for buffer variables
> without a default, and BVAR_OR_DEFAULT for buffer variables with a
> default.
> 
> It's just that in this commit, those two behave identically.  The
> immediate next commit makes them different.

I thought I asked you not to make changes that are overwritten by
subsequent patches in the series, as it makes review harder.  It also
makes the supposedly separate changes in the set not really separate,
because one cannot revert one of them and still have a functional
Emacs.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 13:21:02 +0000
Resent-Message-ID: <handler.48264.B48264.162039363925863 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039363925863
          (code B ref 48264); Fri, 07 May 2021 13:21:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 13:20:39 +0000
Received: from localhost ([127.0.0.1]:43869 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf0PH-0006j5-4z
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 09:20:39 -0400
Received: from venus.catern.com ([68.183.49.163]:60302)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lf0PF-0006iz-C9
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 09:20:37 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620393636; bh=F3qjhXmbxeIU88xil+IzFVn+lL18J0pOULlbEMBJEn0=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=IvSCnnLBaskgGr9G4a6MvbfGoyNJZwA0d3utUarsaDGO+ZmBg+kHFe8Kch/CRVGow
 p2T0m4CZYPWMA36eLP5K83/F0/UF9C/b0lU/TOeejmEdIVRsnc7q75bZbgWaE2IXIP
 VXmwRBJfGE/Vvj1LQ9m3sZDxAKgp5Sb2OaNcXfTE=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id B03542E9752;
 Fri,  7 May 2021 13:20:34 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83a6p6ddur.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-13-sbaugh@HIDDEN> <83a6p6ddur.fsf@HIDDEN>
Date: Fri, 07 May 2021 09:20:33 -0400
Message-ID: <87fsyyr87y.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> +      if (!(offset == PER_BUFFER_VAR_OFFSET (syntax_table)
>> +            || offset == PER_BUFFER_VAR_OFFSET (category_table)))
>
> Please add a comment here about these two exemptions.  (And I cannot
> say that I like such kludges; why doe we need it?)

The syntax_table and category_table fields in buffer_defaults are used
through Vstandard_syntax_table and Vstandard_category_table (which are
just aliases to the fields in buffer_defaults); the initialization for
syntax.c and category.c runs before buffer.c, so they're already set at
this point.  I could reorder the initialization if you'd prefer that?
Or move the initialization into buffer.c?




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 07/15] Add BVAR_OR_DEFAULT macro as a stub
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 13:25:01 +0000
Resent-Message-ID: <handler.48264.B48264.162039384526009 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039384526009
          (code B ref 48264); Fri, 07 May 2021 13:25:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 13:24:05 +0000
Received: from localhost ([127.0.0.1]:43885 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf0Sb-0006lR-KE
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 09:24:05 -0400
Received: from venus.catern.com ([68.183.49.163]:60388)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lf0SZ-0006lL-TL
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 09:24:04 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620393843; bh=Wn8xoMppA6gPwiu9tL4qbMJMVW1zVHygcYvZ16khO6o=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=XXuLWmAjl3dMVnfNO0UqIwOlXvhLdYiko+jEiZLQ3vlgk/nmE3RV2J+zibmD0JP2E
 oMPhEeYlNUWZO4CP3u8vfrjH6C1TSCj8MH3OURGzYNN52SjASIDYYy7c9eOGzaXJJZ
 nQlYTnsoX5Oi+zqnSS3s8gt2d0Ua0jIG47+h3u6U=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 731AE2E9748;
 Fri,  7 May 2021 13:24:03 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83pmy2bsci.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-8-sbaugh@HIDDEN> <837dkaddbc.fsf@HIDDEN>
 <87k0oar8x5.fsf@HIDDEN> <83pmy2bsci.fsf@HIDDEN>
Date: Fri, 07 May 2021 09:24:02 -0400
Message-ID: <87czu2r825.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Cc: 48264 <at> debbugs.gnu.org
>> Date: Fri, 07 May 2021 09:05:26 -0400
>> 
>> >> +#define BVAR_OR_DEFAULT(buf, field) BVAR (buf, field)
>> >
>> > What am I missing here?
>> 
>> The commit message is accurate - we indeed use BVAR for buffer variables
>> without a default, and BVAR_OR_DEFAULT for buffer variables with a
>> default.
>> 
>> It's just that in this commit, those two behave identically.  The
>> immediate next commit makes them different.
>
> I thought I asked you not to make changes that are overwritten by
> subsequent patches in the series, as it makes review harder.  It also
> makes the supposedly separate changes in the set not really separate,
> because one cannot revert one of them and still have a functional
> Emacs.

Sure, I can merge the two changes together, I'll do that for the next
revision of the series.  Just felt this was easier to review.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 13:30:02 +0000
Resent-Message-ID: <handler.48264.B48264.162039417826134 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039417826134
          (code B ref 48264); Fri, 07 May 2021 13:30:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 13:29:38 +0000
Received: from localhost ([127.0.0.1]:43911 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf0Xy-0006nS-6U
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 09:29:38 -0400
Received: from eggs.gnu.org ([209.51.188.92]:36014)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lf0Xw-0006nM-JY
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 09:29:36 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:48000)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lf0Xr-0003GU-8Q; Fri, 07 May 2021 09:29:31 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3868
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lf0Xq-0001Jj-BL; Fri, 07 May 2021 09:29:30 -0400
Date: Fri, 07 May 2021 16:29:25 +0300
Message-Id: <83o8dmbrka.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87fsyyr87y.fsf@HIDDEN> (message from Spencer Baugh on Fri,
 07 May 2021 09:20:33 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-13-sbaugh@HIDDEN> <83a6p6ddur.fsf@HIDDEN>
 <87fsyyr87y.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Fri, 07 May 2021 09:20:33 -0400
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> >> From: Spencer Baugh <sbaugh@HIDDEN>
> >> +      if (!(offset == PER_BUFFER_VAR_OFFSET (syntax_table)
> >> +            || offset == PER_BUFFER_VAR_OFFSET (category_table)))
> >
> > Please add a comment here about these two exemptions.  (And I cannot
> > say that I like such kludges; why doe we need it?)
> 
> The syntax_table and category_table fields in buffer_defaults are used
> through Vstandard_syntax_table and Vstandard_category_table (which are
> just aliases to the fields in buffer_defaults); the initialization for
> syntax.c and category.c runs before buffer.c, so they're already set at
> this point.  I could reorder the initialization if you'd prefer that?
> Or move the initialization into buffer.c?

If it works to move init_buffer_once before init_syntax_once, I think
that'd be much better.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 07/15] Add BVAR_OR_DEFAULT macro as a stub
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 13:33:02 +0000
Resent-Message-ID: <handler.48264.B48264.162039435426336 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039435426336
          (code B ref 48264); Fri, 07 May 2021 13:33:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 13:32:34 +0000
Received: from localhost ([127.0.0.1]:43928 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf0ao-0006qi-K6
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 09:32:34 -0400
Received: from eggs.gnu.org ([209.51.188.92]:36834)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lf0am-0006qc-Uj
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 09:32:33 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:48114)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lf0ah-0004sU-PD; Fri, 07 May 2021 09:32:27 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4050
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lf0ah-0007FQ-Cs; Fri, 07 May 2021 09:32:27 -0400
Date: Fri, 07 May 2021 16:32:25 +0300
Message-Id: <83mtt6brfa.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87czu2r825.fsf@HIDDEN> (message from Spencer Baugh on Fri,
 07 May 2021 09:24:02 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-8-sbaugh@HIDDEN> <837dkaddbc.fsf@HIDDEN>
 <87k0oar8x5.fsf@HIDDEN> <83pmy2bsci.fsf@HIDDEN>
 <87czu2r825.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Fri, 07 May 2021 09:24:02 -0400
> 
> > I thought I asked you not to make changes that are overwritten by
> > subsequent patches in the series, as it makes review harder.  It also
> > makes the supposedly separate changes in the set not really separate,
> > because one cannot revert one of them and still have a functional
> > Emacs.
> 
> Sure, I can merge the two changes together, I'll do that for the next
> revision of the series.  Just felt this was easier to review.

Shorter patches are easier to review, indeed.  But if that requires
making spurious changes that aren't really meant to be in the final
version, the size of the diffs takes a back seat, because breaking the
patches in smaller parts makes the reviewer look at changes that
aren't real.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 13:39:01 +0000
Resent-Message-ID: <handler.48264.B48264.162039470426540 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039470426540
          (code B ref 48264); Fri, 07 May 2021 13:39:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 13:38:24 +0000
Received: from localhost ([127.0.0.1]:43960 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf0gR-0006u0-Qo
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 09:38:24 -0400
Received: from venus.catern.com ([68.183.49.163]:60826)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lf0gQ-0006ts-0N
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 09:38:22 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620394700; bh=R+D0AMYHALWduMcEiWsWMpd5Z/v/RJNSTlhFdYk0N2s=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=S7UHvNBJh7M8wv56JMXrKZJK+bN+SQuFdttI4lH0LQ90ab3z2j9/YS614y0yLVgkR
 MroagDXtbroin/OjRy3amG1s+ZopGQ7vL8Yu4i7dqvePS7p6rdLvLfwlvvkPFeUFQs
 ZT6wWXbYj+7yNAkv5ecQARWTsDPLnc2yCX5U+ys4=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 8F0EB2E9750;
 Fri,  7 May 2021 13:38:20 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83wnsabt00.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-4-sbaugh@HIDDEN> <83czu3c88w.fsf@HIDDEN>
 <87tuner9mw.fsf@HIDDEN> <83wnsabt00.fsf@HIDDEN>
Date: Fri, 07 May 2021 09:38:20 -0400
Message-ID: <87a6p6r7eb.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Cc: 48264 <at> debbugs.gnu.org
>> Date: Fri, 07 May 2021 08:49:59 -0400
>> 
>> Eli Zaretskii <eliz@HIDDEN> writes:
>> >> From: Spencer Baugh <sbaugh@HIDDEN>
>> >> Date: Thu,  6 May 2021 17:33:34 -0400
>> >> Cc: Spencer Baugh <sbaugh@HIDDEN>
>> >> 
>> >> This makes the code more clear and allows us to more easily change how
>> >> this property is determined.
>> >
>> > Does it?  Can you explain why you think so?  It looks like we are
>> > replacing clear code with an equally clear different code.
>> 
>> Well, "if (idx > 0)" as a conditional requires a fair bit of digging in
>> the implementation of DEFVAR_PER_BUFFER variables to understand.  On the
>> other hand, "if (BUFFER_DEFAULT_VALUE_P (offset))" is immediately clear:
>> We're checking if this variable has a default value.
>
> It's the other way around here: the test "if (idx > 0)" is clear,
> whereas "if (BUFFER_DEFAULT_VALUE_P (offset))" makes me go look up the
> definition of the macro, because the name is not expressive enough,
> and the argument "offset" doesn't help, either.

Sure; what about the name "BUFFER_VAR_HAS_DEFAULT_VALUE_P"?  More
verbose, but I think that makes the functionality sufficiently clear
that one won't need to look at the definition of the macro.

"idx > 0" is only clear if one has memorized how all the different
pieces of DEFVAR_PER_BUFFER metadata (such as the index) work.  But I
don't think a casual reader would have done that.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 13:43:01 +0000
Resent-Message-ID: <handler.48264.B48264.162039496026710 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039496026710
          (code B ref 48264); Fri, 07 May 2021 13:43:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 13:42:40 +0000
Received: from localhost ([127.0.0.1]:43989 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf0ka-0006wk-Iz
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 09:42:40 -0400
Received: from eggs.gnu.org ([209.51.188.92]:40672)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lf0kZ-0006we-5q
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 09:42:39 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:48696)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lf0kT-0002cr-Sm; Fri, 07 May 2021 09:42:33 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4666
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lf0kT-0003Mq-Gm; Fri, 07 May 2021 09:42:33 -0400
Date: Fri, 07 May 2021 16:42:28 +0300
Message-Id: <83lf8qbqyj.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87a6p6r7eb.fsf@HIDDEN> (message from Spencer Baugh on Fri,
 07 May 2021 09:38:20 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-4-sbaugh@HIDDEN> <83czu3c88w.fsf@HIDDEN>
 <87tuner9mw.fsf@HIDDEN> <83wnsabt00.fsf@HIDDEN>
 <87a6p6r7eb.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Fri, 07 May 2021 09:38:20 -0400
> 
> > It's the other way around here: the test "if (idx > 0)" is clear,
> > whereas "if (BUFFER_DEFAULT_VALUE_P (offset))" makes me go look up the
> > definition of the macro, because the name is not expressive enough,
> > and the argument "offset" doesn't help, either.
> 
> Sure; what about the name "BUFFER_VAR_HAS_DEFAULT_VALUE_P"?

Much better.  Maybe BVAR_HAS_DEFAULT_VALUE_P? it's shorter.

> "idx > 0" is only clear if one has memorized how all the different
> pieces of DEFVAR_PER_BUFFER metadata (such as the index) work.  But I
> don't think a casual reader would have done that.

Sure; but the number of such places is small, and we could have a
comment there explaining the semantics.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 14:16:01 +0000
Resent-Message-ID: <handler.48264.B48264.162039692528083 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039692528083
          (code B ref 48264); Fri, 07 May 2021 14:16:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 14:15:25 +0000
Received: from localhost ([127.0.0.1]:44188 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf1GG-0007It-Vd
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 10:15:25 -0400
Received: from venus.catern.com ([68.183.49.163]:33370)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lf1GF-0007In-A8
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 10:15:23 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620396917; bh=CMgz+Ep3vPY/wPOkG2tyso/ahVU1ghMRZw5yM1cKgGo=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=TcTgHqaSMVUBjp2S6ZIVms18szRfPebDvIxqnSJ0fRCtrddd3sT1qS0mMRaCXLggD
 fLMLWIo9/3wj0Fibo2nbbY7TTalJtm2SDZkQYx8x40IHBFFxEyYr5XlijzrjPzGu/c
 zbeRjC6FLvSsyUvF3aTpg5cSqaN+2qrnYcVFyQn8=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id CEB822E9760;
 Fri,  7 May 2021 14:15:15 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83o8dmbrka.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-13-sbaugh@HIDDEN> <83a6p6ddur.fsf@HIDDEN>
 <87fsyyr87y.fsf@HIDDEN> <83o8dmbrka.fsf@HIDDEN>
Date: Fri, 07 May 2021 10:15:14 -0400
Message-ID: <877dkar5ot.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Cc: 48264 <at> debbugs.gnu.org
>> Date: Fri, 07 May 2021 09:20:33 -0400
>> 
>> Eli Zaretskii <eliz@HIDDEN> writes:
>> >> From: Spencer Baugh <sbaugh@HIDDEN>
>> >> +      if (!(offset == PER_BUFFER_VAR_OFFSET (syntax_table)
>> >> +            || offset == PER_BUFFER_VAR_OFFSET (category_table)))
>> >
>> > Please add a comment here about these two exemptions.  (And I cannot
>> > say that I like such kludges; why doe we need it?)
>> 
>> The syntax_table and category_table fields in buffer_defaults are used
>> through Vstandard_syntax_table and Vstandard_category_table (which are
>> just aliases to the fields in buffer_defaults); the initialization for
>> syntax.c and category.c runs before buffer.c, so they're already set at
>> this point.  I could reorder the initialization if you'd prefer that?
>> Or move the initialization into buffer.c?
>
> If it works to move init_buffer_once before init_syntax_once, I think
> that'd be much better.

Hm, regrettably, it doesn't seem to be as simple as that; doing so
causes failures in dumping.  I now remember that I tried this before and
had much difficulty doing this by reordering the intialization.

I could try moving the initialization into buffer.c?




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 06/15] Rearrange set_internal for buffer forwarded symbols
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 14:27:02 +0000
Resent-Message-ID: <handler.48264.B48264.162039758928517 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039758928517
          (code B ref 48264); Fri, 07 May 2021 14:27:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 14:26:29 +0000
Received: from localhost ([127.0.0.1]:44253 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf1Qy-0007Pt-P3
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 10:26:28 -0400
Received: from venus.catern.com ([68.183.49.163]:33618)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lf1Qx-0007Pn-1V
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 10:26:27 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620397581; bh=+sX5Cj8JEeUvWtDc3Vtc74JNrbizF6CQTWPUUuclVgU=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=FYKMIGnk3Uer9Pru7dc8mXK2DzhJHVNb1+yChlI23mAQalfX0YCCwwOIBrSPVDi8O
 EruC1SiMF+svqwKuKvSrzd15jCNTGd2/ayOnQI5aoxRdPt+EABigviW8lD9BI6FWfU
 4F65uZFDAi5ICgaPYGIo8lpUE1MnDZPppa3j3qvA=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 452802E4579;
 Fri,  7 May 2021 14:26:21 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <838s4qddpd.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-7-sbaugh@HIDDEN> <838s4qddpd.fsf@HIDDEN>
Date: Fri, 07 May 2021 10:26:20 -0400
Message-ID: <874kfer56b.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Date: Thu,  6 May 2021 17:33:37 -0400
>> Cc: Spencer Baugh <sbaugh@HIDDEN>
>> 
>> --- a/src/data.c
>> +++ b/src/data.c
>> @@ -1320,6 +1320,9 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval,
>>  	if (buf == NULL)
>>  	  buf = current_buffer;
>>  	set_per_buffer_value (buf, offset, newval);
>> +        int idx = PER_BUFFER_IDX (offset);
>> +        if (idx > 0)
>> +          SET_PER_BUFFER_VALUE_P (buf, idx, 1);
>
> It looks like you customized indent-tabs-mode to nil in C modes (or
> maybe don't use Emacs?) because your indentation uses only spaces.
> Please use our conventions in C sources, which uses TABs and spaces,
> per indent-tabs-mode's default value.
>
> This is a general comment, because I see signs of this in all of your
> patches.

Sorry about that, I reverted indent-tabs-mode to t a while ago, but I
forgot to convert some of these some of these patches to use tabs.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 14:31:02 +0000
Resent-Message-ID: <handler.48264.B48264.162039785428741 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039785428741
          (code B ref 48264); Fri, 07 May 2021 14:31:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 14:30:54 +0000
Received: from localhost ([127.0.0.1]:44274 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf1VG-0007TV-AW
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 10:30:54 -0400
Received: from venus.catern.com ([68.183.49.163]:33728)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lf1VE-0007TO-Jw
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 10:30:53 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620397852; bh=4Av4wq2LJFpBPzqi7ZynhBJ4AMbrpRpXF/DvipR1034=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=FiBpge9DfPXwv4Tq4Y9BsOk/MvbhcfUlptObw/Ex2Lr2IH6ltvwQQDHM6nDz+cU1g
 y/+X7JiMyGGs0sFteQ6IcRcL9pcN8JeOBzSIRMq+3cQ0iVzhCVwQyskWegBVnQfsAF
 RJOix7Y11hUPNy8w08nfssP2N7tZE3Wi3ZorhjMo=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 327FD2E4579;
 Fri,  7 May 2021 14:30:52 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83lf8qbqyj.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-4-sbaugh@HIDDEN> <83czu3c88w.fsf@HIDDEN>
 <87tuner9mw.fsf@HIDDEN> <83wnsabt00.fsf@HIDDEN>
 <87a6p6r7eb.fsf@HIDDEN> <83lf8qbqyj.fsf@HIDDEN>
Date: Fri, 07 May 2021 10:30:51 -0400
Message-ID: <871rair4ys.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Cc: 48264 <at> debbugs.gnu.org
>> Date: Fri, 07 May 2021 09:38:20 -0400
>> 
>> > It's the other way around here: the test "if (idx > 0)" is clear,
>> > whereas "if (BUFFER_DEFAULT_VALUE_P (offset))" makes me go look up the
>> > definition of the macro, because the name is not expressive enough,
>> > and the argument "offset" doesn't help, either.
>> 
>> Sure; what about the name "BUFFER_VAR_HAS_DEFAULT_VALUE_P"?
>
> Much better.  Maybe BVAR_HAS_DEFAULT_VALUE_P? it's shorter.

Will change to that - with that change, is this patch fine, or would you
still prefer comments on the usage sites?




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 14:31:02 +0000
Resent-Message-ID: <handler.48264.B48264.162039786128755 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039786128755
          (code B ref 48264); Fri, 07 May 2021 14:31:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 14:31:01 +0000
Received: from localhost ([127.0.0.1]:44277 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf1VM-0007Tj-Hy
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 10:31:01 -0400
Received: from eggs.gnu.org ([209.51.188.92]:55814)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lf1VJ-0007TP-OH
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 10:30:58 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:50336)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lf1VE-0001DI-H3; Fri, 07 May 2021 10:30:52 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3653
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lf1VE-0007Yq-40; Fri, 07 May 2021 10:30:52 -0400
Date: Fri, 07 May 2021 17:30:47 +0300
Message-Id: <83im3uboq0.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <877dkar5ot.fsf@HIDDEN> (message from Spencer Baugh on Fri,
 07 May 2021 10:15:14 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-13-sbaugh@HIDDEN> <83a6p6ddur.fsf@HIDDEN>
 <87fsyyr87y.fsf@HIDDEN> <83o8dmbrka.fsf@HIDDEN>
 <877dkar5ot.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Fri, 07 May 2021 10:15:14 -0400
> 
> >> The syntax_table and category_table fields in buffer_defaults are used
> >> through Vstandard_syntax_table and Vstandard_category_table (which are
> >> just aliases to the fields in buffer_defaults); the initialization for
> >> syntax.c and category.c runs before buffer.c, so they're already set at
> >> this point.  I could reorder the initialization if you'd prefer that?
> >> Or move the initialization into buffer.c?
> >
> > If it works to move init_buffer_once before init_syntax_once, I think
> > that'd be much better.
> 
> Hm, regrettably, it doesn't seem to be as simple as that; doing so
> causes failures in dumping.  I now remember that I tried this before and
> had much difficulty doing this by reordering the intialization.
> 
> I could try moving the initialization into buffer.c?

Maybe making the Vstandard_syntax_table setup a separate function in
syntax.c, and then calling it from init_buffer_once?  IOW, leave only
the creation of Vstandard_syntax_table in init_syntax_once, and doing
the rest in init_buffer_once?  Does that work?




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 14:40:01 +0000
Resent-Message-ID: <handler.48264.B48264.162039837429024 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162039837429024
          (code B ref 48264); Fri, 07 May 2021 14:40:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 14:39:34 +0000
Received: from localhost ([127.0.0.1]:44315 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf1dd-0007Y4-Sn
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 10:39:34 -0400
Received: from eggs.gnu.org ([209.51.188.92]:57820)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lf1dc-0007Xy-83
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 10:39:32 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:50602)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lf1dT-0006lF-QE; Fri, 07 May 2021 10:39:26 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4180
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.86_2) (envelope-from <eliz@HIDDEN>)
 id 1lf1dT-0001Rr-CK; Fri, 07 May 2021 10:39:23 -0400
Date: Fri, 07 May 2021 17:39:21 +0300
Message-Id: <83fsyybobq.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <871rair4ys.fsf@HIDDEN> (message from Spencer Baugh on Fri,
 07 May 2021 10:30:51 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-4-sbaugh@HIDDEN> <83czu3c88w.fsf@HIDDEN>
 <87tuner9mw.fsf@HIDDEN> <83wnsabt00.fsf@HIDDEN>
 <87a6p6r7eb.fsf@HIDDEN> <83lf8qbqyj.fsf@HIDDEN>
 <871rair4ys.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Fri, 07 May 2021 10:30:51 -0400
> 
> >> Sure; what about the name "BUFFER_VAR_HAS_DEFAULT_VALUE_P"?
> >
> > Much better.  Maybe BVAR_HAS_DEFAULT_VALUE_P? it's shorter.
> 
> Will change to that - with that change, is this patch fine

Yes, thanks.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 21:36:02 +0000
Resent-Message-ID: <handler.48264.B48264.162042331114189 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162042331114189
          (code B ref 48264); Fri, 07 May 2021 21:36:02 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 21:35:11 +0000
Received: from localhost ([127.0.0.1]:46073 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf87q-0003gn-Le
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 17:35:10 -0400
Received: from venus.catern.com ([68.183.49.163]:42534)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lf87n-0003ge-Nk
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 17:35:09 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620423306; bh=xlCYopXgAt5vFqVGNbByynEe7DG0GNEFM6snOcweTzg=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=JXtfpvBWcGJQxU+FeIndNNRCYqjJyL4+RRAEQxU3/ZZTTCMc95rDOTyyaPqJl1vCI
 GAFVu3oXF7BOntUScxfg2xYbsgTCNlh/8rnG41DeBqzSPdRB2ODEp4eBW1gLhwpaGy
 hxQ11r4/xzDSYBU1+jk1TOGUusr/ts9f3n1O9soE=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id C31232E97B0;
 Fri,  7 May 2021 21:35:06 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83im3uboq0.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-13-sbaugh@HIDDEN> <83a6p6ddur.fsf@HIDDEN>
 <87fsyyr87y.fsf@HIDDEN> <83o8dmbrka.fsf@HIDDEN>
 <877dkar5ot.fsf@HIDDEN> <83im3uboq0.fsf@HIDDEN>
Date: Fri, 07 May 2021 17:35:05 -0400
Message-ID: <87r1iip6ra.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Cc: 48264 <at> debbugs.gnu.org
>> Date: Fri, 07 May 2021 10:15:14 -0400
>> 
>> >> The syntax_table and category_table fields in buffer_defaults are used
>> >> through Vstandard_syntax_table and Vstandard_category_table (which are
>> >> just aliases to the fields in buffer_defaults); the initialization for
>> >> syntax.c and category.c runs before buffer.c, so they're already set at
>> >> this point.  I could reorder the initialization if you'd prefer that?
>> >> Or move the initialization into buffer.c?
>> >
>> > If it works to move init_buffer_once before init_syntax_once, I think
>> > that'd be much better.
>> 
>> Hm, regrettably, it doesn't seem to be as simple as that; doing so
>> causes failures in dumping.  I now remember that I tried this before and
>> had much difficulty doing this by reordering the intialization.
>> 
>> I could try moving the initialization into buffer.c?
>
> Maybe making the Vstandard_syntax_table setup a separate function in
> syntax.c, and then calling it from init_buffer_once?  IOW, leave only
> the creation of Vstandard_syntax_table in init_syntax_once, and doing
> the rest in init_buffer_once?  Does that work?

OK, in the end I was able to get moving init_{syntax,category}_once
after init_buffer_once to work, by initializing the two variables to
Qnil in buffer.c.  I assume it wasn't working before because they were
Qunbound rather than Qnil, and something is checking NILP to see if the
variables are initialized. (Although not sure what).

So, I was able to remove the special case.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 07 May 2021 21:45:01 +0000
Resent-Message-ID: <handler.48264.B48264.162042384214518 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162042384214518
          (code B ref 48264); Fri, 07 May 2021 21:45:01 +0000
Received: (at 48264) by debbugs.gnu.org; 7 May 2021 21:44:02 +0000
Received: from localhost ([127.0.0.1]:46110 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lf8GP-0003lv-IN
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 17:44:02 -0400
Received: from venus.catern.com ([68.183.49.163]:42718)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lf8GH-0003lc-10
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 17:44:00 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620423832; bh=hVMOu2b7ZD0Y4mDWjCsVGq9ekYruT176xG/j0lDKaas=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=FRN1OQFdrX6mH4I7lOFA4/Fjr/xMGOR7P3YkxETWXnMXvG97lVNQofemMwLIrx0yh
 itLoeqWJ3dXcCZr8AGhzHZc9D/8m/zU48Rd/zCBoyP20VtLIznpXaAw0ZL7UN1bWtp
 TcD1etymfhd+I4/9Uq5P1E4QSBvoZsPveMSl642s=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 9500B2E9771;
 Fri,  7 May 2021 21:43:52 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83tunebsiu.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-16-sbaugh@HIDDEN> <835yzudcvz.fsf@HIDDEN>
 <87o8dmr96v.fsf@HIDDEN> <83tunebsiu.fsf@HIDDEN>
Date: Fri, 07 May 2021 17:43:51 -0400
Message-ID: <87mtt6p6co.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Cc: 48264 <at> debbugs.gnu.org
>> Date: Fri, 07 May 2021 08:59:36 -0400
>> Ah, yes, I probably should have given a little more explanation of this.
>> I'm not tied to this approach, if we can think of a better way to make
>> it statically guaranteed that BVAR is only used with fields that have a
>> default.
>
> If the sole purpose is to be able to detect coding mistakes, then
> there are other possibilities to do that, if the compiler cannot help
> in a way that leaves the sources readable.

Hopefully.  Although, I'm not sure this approach is fundamentally
unreadable?  The field names are already mangled with the trailing "_"
to stop direct access; this is just further mangling them.

>> > Hmm... I'm not sure I understand the effect of these.  Does it mean C
>> > code can no longer set the buffer-local value of these variables, only
>> > the default value?
>> 
>> No, this is purely just changing the name of the fields - it has no
>> impact on functionality, C code can still set the buffer-local
>> variables.
>
> Then I guess the _defaulted_ part is a misnomer?

Possibly; by "defaulted" I intended to mean that the field is one which
has a default.  But I freely acknowledge it's not a great name.  Keep in
mind though, this name isn't exposed to the programmer anywhere - it
might as well be _ABCDEFGHI_, nothing will change outside the definition
of the BVAR_DEFAULTED_FIELD macro.

>> >> +#define PER_BUFFER_VAR_DEFAULTED_OFFSET(VAR) \
>> >> +  offsetof (struct buffer, BVAR_DEFAULTED_FIELD(VAR))
>> >
>> > Likewise here: I don't see how such macros make the code more
>> > readable.  I think they make it less readable.
>> 
>> I agree but I couldn't find a better way to ensure that BVAR and
>> BVAR_OR_DEFAULT are used on the correct fields.
>
> Maybe someone could come up with a trick to have the diagnostics
> without twisting the sources so much.

Yes, I hope someone comes up with a better idea than me.

> Failing that, maybe we should simply have a test to detect the
> mistakes?  That wouldn't prevent bad code from being compiled, but it
> should reveal it soon enough, since tests are regularly run on hydra.

A conditionally-compiled runtime check would be very easy to add - I'd
just change BVAR to something like:

  (eassert (EQ (buffer_defaults->field ## _)); (buf)->field ## _)

Which would make sure that it's not used on anything with a default.
But of course that's substantially more annoying than a compile time
check...




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 00/15] Speeding up setting the default for DEFVAR_PER_BUFFER vars
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:02 +0000
Resent-Message-ID: <handler.48264.B48264.162043975624739 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043975624739
          (code B ref 48264); Sat, 08 May 2021 02:10:02 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:16 +0000
Received: from localhost ([127.0.0.1]:47142 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCP5-0006Qq-Du
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:16 -0400
Received: from venus.catern.com ([68.183.49.163]:47880)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCP4-0006QZ-3G
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:14 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439753; bh=O5yGip2XnbC0k+oNFDBnFhKL/77pSN17/l+uXLXQeeE=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=cMkBAYooW7mhEaEd3wX/chXKz+z4vMlcyY3p+EIZgz6BN+AT+EnXh/X6iiJ9vVmTg
 emwL16FgfmKUqKC77W6bNIn3nW4658jMMKgFvifyuYCN3Ni7L7CCD+XdPGf2X0U04x
 1ySU3mMWxoYyTpcGnBpQsWMRJchHLstPDTH14AS8=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id C5B152E9803;
 Sat,  8 May 2021 02:09:13 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:08:51 -0400
Message-Id: <20210508020905.13583-2-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This patch series fixes bug#48264 by speeding up changes to the
default value for DEFVAR_PER_BUFFER vars, whether by let or
set-default.  Such changes are now constant time, and run as fast as
changes to non-default values.

This change optimizes setting the default in exchange for a small
slowdown on every access to a DEFVAR_PER_BUFFER var that has a
default.  I've benchmarked this change (results posted in other
threads on emacs-devel) and found minimal slowdown in pure Lisp code,
and a 1-2% slowdown in the display engine.

=== Background on DEFVAR_PER_BUFFER variables ===

DEFVAR_PER_BUFFER is a C macro which sets up a correspondence between a
Lisp symbol and a field of type Lisp_Object in the C `struct buffer'
struct.  There are a finite number of such fields, and DEFVAR_PER_BUFFER
is called for a subset of them.

Each DEFVAR_PER_BUFFER variable appears to Lisp code as a buffer-local
variable, and should behave like pure Lisp buffer-local variables.  Each
DEFVAR_PER_BUFFER variable is either permanently buffer-local, or has a
default value which is used by buffers that don't currently have a
buffer-local binding.

If a buffer has a buffer-local binding for one of these variables, then
the per-buffer value is stored in the corresponding field in that
buffer's `struct buffer'.

Default values for these variables are stored in a global `struct
buffer' C variable, `buffer_defaults'.  This struct does not correspond
to a real buffer, and its non-DEFVAR_PER_BUFFER fields are unused.  When
a variable's default value is changed, the corresponding field is
changed in (at least) buffer_defaults.  When `default-value' is used to
read a DEFVAR_PER_BUFFER variable's default value, it's read from
buffer_defaults.

The underlying fields in `struct buffer' used with DEFVAR_PER_BUFFER are
also read and written directly from C, through the BVAR macro.  The BVAR
macro takes a pointer to a `struct buffer' and the name of a field in
`struct buffer', and evaluates to the value for that field.

The variables must behave the same both when used through the symbol in
Lisp, and used through BVAR in C.  For example, if BVAR reads a field
from a buffer that does not have a buffer-local binding for that field,
it should evaluate to the default value for that field.

=== Old implementation ===

In the old implementation, both the permanently buffer-local
DEFVAR_PER_BUFFER variables and the variables with defaults values
were accessed in the same way: Through the BVAR macro.

The BVAR macro is essentially a no-op.  It turns into a simple field
dereference, essentially:

  #define BVAR(buf, field) (buf)->field

We simply read the field directly out of the specific `struct buffer'
we're working with.  Neither BVAR nor surrounding C code checks whether
a buffer has a buffer-local binding for a variable before using this
field, and at no point does most code check what value is in
buffer_defaults.

This is fine for permanently buffer-local DEFVAR_PER_BUFFER variables,
which have no default value.

For variables which are not permanently buffer-local, though, this means
we need to ensure that the C Lisp_Object field always contains the
"correct" value for the variable, whether that's a currently
buffer-local value, or the global default value.

If there is a buffer-local binding, then the field contains the
per-buffer value, and all is well.

If there is no buffer-local binding, then we need to ensure that the
field contains the global default value.

To do this, whenever the global default value changes, we iterate over
all buffers, and if there's no buffer-local binding, set the field to
the new default value. This is O(n) in the number of buffers open in
Emacs - quite slow.

= Old implementation: local_flags and buffer_local_flags =

Also, we frequently need to know whether a variable has a buffer-local
binding.  We maintain this information with the `local_flags' field in
`struct buffer', which is a char array with an entry for each
DEFVAR_PER_BUFFER variable.

When we create or kill a buffer-local binding for a DEFVAR_PER_BUFFER
variable, we update local_flags.

To support local_flags, we need even further metadata;
buffer_local_flags is a global, initialized at startup and constant
after that, which maps the offsets of the DEFVAR_PER_BUFFER C fields to
indices in local_flags.  We perform a lookup in buffer_local_flags
whenever we need to change local_flags for a variable.

=== New implementation ===

In the new implementation, we use separate macros for permanently
buffer-local variables and for variables with defaults.

Permanently buffer-local variables use BVAR, which stays the same.

Variables with defaults now use BVAR_OR_DEFAULT, which does a bit more
work.
Simplifying a bit:

  #define BVAR_OR_DEFAULT(buf, field) \
    EQ ((buf)->field, Qunbound) ? buffer_defaults.field : (buf)->field

We now use Qunbound as a sentinel to tell us whether the buffer has a
buffer-local binding for this field or not.  If the field contains
Qunbound, we should use the default value out of buffer_defaults; if
not, there's a buffer-local binding, and we should use the per-buffer
value.

We no longer need to iterate over all buffers whenever we change the
default value.  So setting the default value is now fast.

= New implementation: No more local_flags and buffer_local_flags =

Both of these are now useless and can be deleted.

When we create a buffer-local binding for a DEFVAR_PER_BUFFER variable,
we simply set the field.  When we kill a buffer-local binding, we set
the field to Qunbound.  There's no additional metadata.

=== Individual commits ===

See the individual commit messages for more.

  Stop checking the constant default for enable_multibyte_characters

This removes a defunct default that still existed for
enable_multibyte_characters, making it work like all the other
permanently buffer-local variables, which simplifies the rest of our
changes.

  Take offset not idx in PER_BUFFER_VALUE_P
  Add and use BVAR_HAS_DEFAULT_VALUE_P
  Combine unnecessarily separate loops in buffer.c
  Add and use KILL_PER_BUFFER_VALUE
  Rearrange set_internal for buffer forwarded symbols

These change or add abstractions for accessing buffer Lisp_Object
fields, to remove dependencies on implementation details which will
change.

  Use BVAR_OR_DEFAULT for per-buffer vars with defaults

This is the heart of the patch series; it add BVAR_OR_DEFAULT as
described above.

  Remove unnecessary Qunbound check
  Get rid of buffer_permanent_local_flags array
  Delete SET_PER_BUFFER_VALUE_P and buffer local_flags field
  Set buffer_defaults fields without a default to Qunbound
  Assert that PER_BUFFER_IDX for Lisp variables is not 0
  Remove PER_BUFFER_IDX and buffer_local_flags

These remove various forms of metadata maintained in buffer.c which
are no longer necessary after our change.

  Add and use BVAR_FIELD macros

This enforces statically that BVAR_OR_DEFAULT is only used for fields
with defaults, and that BVAR is only used for fields without defaults.

Changes from v3:
- Fixed formatting to correctly use tabs, not spaces
- Renamed BUFFER_DEFAULT_VALUE_P to BVAR_HAS_DEFAULT_VALUE_P.
- Removed special case for {syntax,category}_table in init_buffer_once
- Miscellaneous formatting fixes

Spencer Baugh (14):
  Stop checking the constant default for enable_multibyte_characters
  Take offset not idx in PER_BUFFER_VALUE_P
  Add and use BVAR_HAS_DEFAULT_VALUE_P
  Combine unnecessarily separate loops in buffer.c
  Add and use KILL_PER_BUFFER_VALUE
  Rearrange set_internal for buffer forwarded symbols
  Use BVAR_OR_DEFAULT for per-buffer vars with defaults
  Remove unnecessary Qunbound check
  Get rid of buffer_permanent_local_flags array
  Delete SET_PER_BUFFER_VALUE_P and buffer local_flags field
  Set buffer_defaults fields without a default to Qunbound
  Assert that PER_BUFFER_IDX for Lisp variables is not 0
  Remove PER_BUFFER_IDX and buffer_local_flags
  Add and use BVAR_FIELD macros

 lisp/bindings.el       |   3 +-
 src/alloc.c            |   3 +-
 src/bidi.c             |  19 +-
 src/buffer.c           | 443 ++++++++++++-----------------------------
 src/buffer.h           | 302 +++++++++++++---------------
 src/category.c         |  12 +-
 src/category.h         |   2 +-
 src/cmds.c             |   6 +-
 src/data.c             |  82 ++------
 src/editfns.c          |   4 +-
 src/emacs.c            |   4 +-
 src/fileio.c           |   9 +-
 src/fns.c              |   8 +-
 src/fringe.c           |  21 +-
 src/hbfont.c           |   2 +-
 src/indent.c           |  34 ++--
 src/msdos.c            |   6 +-
 src/pdumper.c          |   3 -
 src/print.c            |   6 +-
 src/process.c          |  15 +-
 src/search.c           |  21 +-
 src/syntax.c           |  13 +-
 src/syntax.h           |   7 +-
 src/window.c           |  29 +--
 src/xdisp.c            | 130 ++++++------
 test/src/data-tests.el |   1 -
 26 files changed, 455 insertions(+), 730 deletions(-)

-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 00/15] Speeding up setting the default for DEFVAR_PER_BUFFER vars
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:02 +0000
Resent-Message-ID: <handler.48264.B48264.162043975824760 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043975824760
          (code B ref 48264); Sat, 08 May 2021 02:10:02 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:18 +0000
Received: from localhost ([127.0.0.1]:47147 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCP8-0006RH-7G
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:18 -0400
Received: from venus.catern.com ([68.183.49.163]:47872)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCP3-0006QY-Kb
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:15 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439752; bh=q2skZYdZV73MIKMCr2rG4O3reurWTJHhN13gT2u0huc=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=EsHnCUQPZhA7QWKpXy5Jw9PGeRsaYEgMUUzS8l9pfl45eM8gZE5UYl8GRXlLlp76o
 lku/p9FOvF0/lYOqeHmY2SCauLmBR2k99bRVuTA1OjAxtWsPr8NX30aNi71Iy9tk+7
 lvaLJNuhLGzLa9wwyFMpvbe384Vg45g6ZKdEnZLU=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id D00802E97B0;
 Sat,  8 May 2021 02:09:12 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:08:50 -0400
Message-Id: <20210508020905.13583-1-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210506213346.9730-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This patch series fixes bug#48264 by speeding up changes to the
default value for DEFVAR_PER_BUFFER vars, whether by let or
set-default.  Such changes are now constant time, and run as fast as
changes to non-default values.

This change optimizes setting the default in exchange for a small
slowdown on every access to a DEFVAR_PER_BUFFER var that has a
default.  I've benchmarked this change (results posted in other
threads on emacs-devel) and found minimal slowdown in pure Lisp code,
and a 1-2% slowdown in the display engine.

=== Background on DEFVAR_PER_BUFFER variables ===

DEFVAR_PER_BUFFER is a C macro which sets up a correspondence between a
Lisp symbol and a field of type Lisp_Object in the C `struct buffer'
struct.  There are a finite number of such fields, and DEFVAR_PER_BUFFER
is called for a subset of them.

Each DEFVAR_PER_BUFFER variable appears to Lisp code as a buffer-local
variable, and should behave like pure Lisp buffer-local variables.  Each
DEFVAR_PER_BUFFER variable is either permanently buffer-local, or has a
default value which is used by buffers that don't currently have a
buffer-local binding.

If a buffer has a buffer-local binding for one of these variables, then
the per-buffer value is stored in the corresponding field in that
buffer's `struct buffer'.

Default values for these variables are stored in a global `struct
buffer' C variable, `buffer_defaults'.  This struct does not correspond
to a real buffer, and its non-DEFVAR_PER_BUFFER fields are unused.  When
a variable's default value is changed, the corresponding field is
changed in (at least) buffer_defaults.  When `default-value' is used to
read a DEFVAR_PER_BUFFER variable's default value, it's read from
buffer_defaults.

The underlying fields in `struct buffer' used with DEFVAR_PER_BUFFER are
also read and written directly from C, through the BVAR macro.  The BVAR
macro takes a pointer to a `struct buffer' and the name of a field in
`struct buffer', and evaluates to the value for that field.

The variables must behave the same both when used through the symbol in
Lisp, and used through BVAR in C.  For example, if BVAR reads a field
from a buffer that does not have a buffer-local binding for that field,
it should evaluate to the default value for that field.

=== Old implementation ===

In the old implementation, both the permanently buffer-local
DEFVAR_PER_BUFFER variables and the variables with defaults values
were accessed in the same way: Through the BVAR macro.

The BVAR macro is essentially a no-op.  It turns into a simple field
dereference, essentially:

  #define BVAR(buf, field) (buf)->field

We simply read the field directly out of the specific `struct buffer'
we're working with.  Neither BVAR nor surrounding C code checks whether
a buffer has a buffer-local binding for a variable before using this
field, and at no point does most code check what value is in
buffer_defaults.

This is fine for permanently buffer-local DEFVAR_PER_BUFFER variables,
which have no default value.

For variables which are not permanently buffer-local, though, this means
we need to ensure that the C Lisp_Object field always contains the
"correct" value for the variable, whether that's a currently
buffer-local value, or the global default value.

If there is a buffer-local binding, then the field contains the
per-buffer value, and all is well.

If there is no buffer-local binding, then we need to ensure that the
field contains the global default value.

To do this, whenever the global default value changes, we iterate over
all buffers, and if there's no buffer-local binding, set the field to
the new default value. This is O(n) in the number of buffers open in
Emacs - quite slow.

= Old implementation: local_flags and buffer_local_flags =

Also, we frequently need to know whether a variable has a buffer-local
binding.  We maintain this information with the `local_flags' field in
`struct buffer', which is a char array with an entry for each
DEFVAR_PER_BUFFER variable.

When we create or kill a buffer-local binding for a DEFVAR_PER_BUFFER
variable, we update local_flags.

To support local_flags, we need even further metadata;
buffer_local_flags is a global, initialized at startup and constant
after that, which maps the offsets of the DEFVAR_PER_BUFFER C fields to
indices in local_flags.  We perform a lookup in buffer_local_flags
whenever we need to change local_flags for a variable.

=== New implementation ===

In the new implementation, we use separate macros for permanently
buffer-local variables and for variables with defaults.

Permanently buffer-local variables use BVAR, which stays the same.

Variables with defaults now use BVAR_OR_DEFAULT, which does a bit more
work.
Simplifying a bit:

  #define BVAR_OR_DEFAULT(buf, field) \
    EQ ((buf)->field, Qunbound) ? buffer_defaults.field : (buf)->field

We now use Qunbound as a sentinel to tell us whether the buffer has a
buffer-local binding for this field or not.  If the field contains
Qunbound, we should use the default value out of buffer_defaults; if
not, there's a buffer-local binding, and we should use the per-buffer
value.

We no longer need to iterate over all buffers whenever we change the
default value.  So setting the default value is now fast.

= New implementation: No more local_flags and buffer_local_flags =

Both of these are now useless and can be deleted.

When we create a buffer-local binding for a DEFVAR_PER_BUFFER variable,
we simply set the field.  When we kill a buffer-local binding, we set
the field to Qunbound.  There's no additional metadata.

=== Individual commits ===

See the individual commit messages for more.

  Stop checking the constant default for enable_multibyte_characters

This removes a defunct default that still existed for
enable_multibyte_characters, making it work like all the other
permanently buffer-local variables, which simplifies the rest of our
changes.

  Take offset not idx in PER_BUFFER_VALUE_P
  Add and use BUFFER_DEFAULT_VALUE_P
  Combine unnecessarily separate loops in buffer.c
  Add and use KILL_PER_BUFFER_VALUE
  Rearrange set_internal for buffer forwarded symbols

These change or add abstractions for accessing buffer Lisp_Object
fields, to remove dependencies on implementation details which will
change.

  Add BVAR_OR_DEFAULT macro as a stub

This adds the BVAR_OR_DEFAULT macro without actually changing behavior
yet. This is the largest patch, since it needs to change code using
BVAR everywhere in Emacs.

  Set non-buffer-local BVARs to Qunbound

This is the heart of the patch series; it changes the behavior of
BVAR_OR_DEFAULT to match what was described above.

  Remove unnecessary Qunbound check
  Get rid of buffer_permanent_local_flags array
  Delete SET_PER_BUFFER_VALUE_P and buffer local_flags field
  Set buffer_defaults fields without a default to Qunbound
  Assert that PER_BUFFER_IDX for Lisp variables is not 0
  Remove PER_BUFFER_IDX and buffer_local_flags

These remove various forms of metadata maintained in buffer.c which
are no longer necessary after our change.

  Add and use BVAR_FIELD macros

This enforces statically that BVAR_OR_DEFAULT is only used for fields
with defaults, and that BVAR is only used for fields without defaults.

Spencer Baugh (15):
  Stop checking the constant default for enable_multibyte_characters
  Take offset not idx in PER_BUFFER_VALUE_P
  Add and use BUFFER_DEFAULT_VALUE_P
  Combine unnecessarily separate loops in buffer.c
  Add and use KILL_PER_BUFFER_VALUE
  Rearrange set_internal for buffer forwarded symbols
  Add BVAR_OR_DEFAULT macro as a stub
  Set non-buffer-local BVARs to Qunbound
  Remove unnecessary Qunbound check
  Get rid of buffer_permanent_local_flags array
  Delete SET_PER_BUFFER_VALUE_P and buffer local_flags field
  Set buffer_defaults fields without a default to Qunbound
  Assert that PER_BUFFER_IDX for Lisp variables is not 0
  Remove PER_BUFFER_IDX and buffer_local_flags
  Add and use BVAR_FIELD macros

 lisp/bindings.el       |   3 +-
 src/alloc.c            |   3 +-
 src/bidi.c             |  19 +-
 src/buffer.c           | 430 +++++++++++++----------------------------
 src/buffer.h           | 302 +++++++++++++----------------
 src/category.c         |  12 +-
 src/cmds.c             |   6 +-
 src/data.c             |  82 ++------
 src/editfns.c          |   4 +-
 src/fileio.c           |   9 +-
 src/fns.c              |   8 +-
 src/fringe.c           |  21 +-
 src/hbfont.c           |   2 +-
 src/indent.c           |  34 ++--
 src/msdos.c            |   6 +-
 src/pdumper.c          |   3 -
 src/print.c            |   6 +-
 src/process.c          |  15 +-
 src/search.c           |  21 +-
 src/syntax.c           |  13 +-
 src/syntax.h           |   5 +-
 src/window.c           |  29 +--
 src/xdisp.c            | 130 +++++++------
 test/src/data-tests.el |   1 -
 24 files changed, 448 insertions(+), 716 deletions(-)

-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 01/14] Stop checking the constant default for enable_multibyte_characters
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:02 +0000
Resent-Message-ID: <handler.48264.B48264.162043975924768 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043975924768
          (code B ref 48264); Sat, 08 May 2021 02:10:02 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:19 +0000
Received: from localhost ([127.0.0.1]:47149 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCP8-0006RJ-PX
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:19 -0400
Received: from venus.catern.com ([68.183.49.163]:47888)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCP4-0006Qf-RT
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:15 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439754; bh=h2sPxarE55m0+XsTg2l0mSbveap4YbIvUYTJNHbCHBQ=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=KTLrlcIyqy6w5CgE+A83eqq5CRqxhv/iEYL8u4yZZvLKqkIFdk1ZvjsbWam32BKTh
 gXPsqrXAnKX8mdvSMZdYqOrSwzAR/2WBv2drpIFU43FRxa6/aaAsu3O/74QhFSCaRJ
 bGpq74IWg2gtFfL2U8ciMFioBw9VFxSrWAcHoqcc=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 8DDE52E982B;
 Sat,  8 May 2021 02:09:14 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:08:52 -0400
Message-Id: <20210508020905.13583-3-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

The default is a constant "t", and can't be changed. So we don't need
to check it. This makes enable_multibyte_characters like every other
permanently buffer-local variable defined with DEFVAR_PER_BUFFER.

* src/buffer.c (reset_buffer, init_buffer):
* src/print.c (print_string, temp_output_buffer_setup):
* src/process.c (Fmake_pipe_process, Fmake_serial_process)
(set_network_socket_coding_system): Don't check buffer_defaults for
enable_multibyte_characters.
---
 src/buffer.c  |  5 +----
 src/print.c   |  6 ++----
 src/process.c | 15 ++++-----------
 3 files changed, 7 insertions(+), 19 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 8e33162989..8b3e15bc81 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -988,8 +988,7 @@ reset_buffer (register struct buffer *b)
   bset_last_selected_window (b, Qnil);
   bset_display_count (b, make_fixnum (0));
   bset_display_time (b, Qnil);
-  bset_enable_multibyte_characters
-    (b, BVAR (&buffer_defaults, enable_multibyte_characters));
+  bset_enable_multibyte_characters (b, Qt);
   bset_cursor_type (b, BVAR (&buffer_defaults, cursor_type));
   bset_extra_line_spacing (b, BVAR (&buffer_defaults, extra_line_spacing));
 
@@ -5406,8 +5405,6 @@ init_buffer (void)
 
   AUTO_STRING (scratch, "*scratch*");
   Fset_buffer (Fget_buffer_create (scratch, Qnil));
-  if (NILP (BVAR (&buffer_defaults, enable_multibyte_characters)))
-    Fset_buffer_multibyte (Qnil);
 
   char const *pwd = emacs_wd;
 
diff --git a/src/print.c b/src/print.c
index d4301fd7b6..653f17aa1d 100644
--- a/src/print.c
+++ b/src/print.c
@@ -453,8 +453,7 @@ print_string (Lisp_Object string, Lisp_Object printcharfun)
 	chars = SCHARS (string);
       else if (! print_escape_nonascii
 	       && (EQ (printcharfun, Qt)
-		   ? ! NILP (BVAR (&buffer_defaults, enable_multibyte_characters))
-		   : ! NILP (BVAR (current_buffer, enable_multibyte_characters))))
+		   || ! NILP (BVAR (current_buffer, enable_multibyte_characters))))
 	{
 	  /* If unibyte string STRING contains 8-bit codes, we must
 	     convert STRING to a multibyte string containing the same
@@ -572,8 +571,7 @@ temp_output_buffer_setup (const char *bufname)
   bset_undo_list (current_buffer, Qt);
   eassert (current_buffer->overlays_before == NULL);
   eassert (current_buffer->overlays_after == NULL);
-  bset_enable_multibyte_characters
-    (current_buffer, BVAR (&buffer_defaults, enable_multibyte_characters));
+  bset_enable_multibyte_characters (current_buffer, Qt);
   specbind (Qinhibit_read_only, Qt);
   specbind (Qinhibit_modification_hooks, Qt);
   Ferase_buffer ();
diff --git a/src/process.c b/src/process.c
index 84e301a87a..44ba6c578e 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2399,8 +2399,7 @@ usage:  (make-pipe-process &rest ARGS)  */)
       }
     else if (!NILP (Vcoding_system_for_read))
       val = Vcoding_system_for_read;
-    else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
-	     || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
+    else if (!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
       /* We dare not decode end-of-line format by setting VAL to
 	 Qraw_text, because the existing Emacs Lisp libraries
 	 assume that they receive bare code including a sequence of
@@ -2425,8 +2424,6 @@ usage:  (make-pipe-process &rest ARGS)  */)
       }
     else if (!NILP (Vcoding_system_for_write))
       val = Vcoding_system_for_write;
-    else if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
-      val = Qnil;
     else
       {
 	if (CONSP (coding_systems))
@@ -3124,8 +3121,7 @@ usage:  (make-serial-process &rest ARGS)  */)
     }
   else if (!NILP (Vcoding_system_for_read))
     val = Vcoding_system_for_read;
-  else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
-	   || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
+  else if (!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
     val = Qnil;
   pset_decode_coding_system (p, val);
 
@@ -3138,8 +3134,7 @@ usage:  (make-serial-process &rest ARGS)  */)
     }
   else if (!NILP (Vcoding_system_for_write))
     val = Vcoding_system_for_write;
-  else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
-	   || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
+  else if (!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
     val = Qnil;
   pset_encode_coding_system (p, val);
 
@@ -3181,9 +3176,7 @@ set_network_socket_coding_system (Lisp_Object proc, Lisp_Object host,
   else if (!NILP (Vcoding_system_for_read))
     val = Vcoding_system_for_read;
   else if ((!NILP (p->buffer)
-	    && NILP (BVAR (XBUFFER (p->buffer), enable_multibyte_characters)))
-	   || (NILP (p->buffer)
-	       && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
+	    && NILP (BVAR (XBUFFER (p->buffer), enable_multibyte_characters))))
     /* We dare not decode end-of-line format by setting VAL to
        Qraw_text, because the existing Emacs Lisp libraries
        assume that they receive bare code including a sequence of
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 02/14] Take offset not idx in PER_BUFFER_VALUE_P
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:03 +0000
Resent-Message-ID: <handler.48264.B48264.162043976024783 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043976024783
          (code B ref 48264); Sat, 08 May 2021 02:10:03 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:20 +0000
Received: from localhost ([127.0.0.1]:47152 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCP9-0006RR-8p
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:19 -0400
Received: from venus.catern.com ([68.183.49.163]:47894)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCP5-0006Qr-GP
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:16 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439755; bh=Qma0rUKzeh7JnjVA+FpsVJYp5tSJoSCqw7sDFOwzNE8=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=HtShTSxExXi9ixjjwg9LKoBgYYSvZjy4GMVKibxIaAWBxeHTfdjNoQTqSwLA34+lW
 wRE9u6moNWuVcAajZLAeGF8++9q2z5GMjsMOIRPR8NL+abbWPLsJDi1ir8e+HCIOJf
 KtcrxYfaDXTUpxPooBNE0DLAV+3N3vN9XzYM8kBs=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 41EAC2E97B0;
 Sat,  8 May 2021 02:09:15 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:08:53 -0400
Message-Id: <20210508020905.13583-4-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This improves clarity and allows us to more easily change how
PER_BUFFER_VALUE_P works.

* src/buffer.h (PER_BUFFER_VALUE_P): Move to be in scope of
PER_BUFFER_IDX.  Take offset instead of idx, and perform the common
"idx == -1" check internally.
* src/data.c (store_symval_forwarding, set_internal)
(set_default_internal, Flocal_variable_p):
* src/buffer.c (buffer_local_variables_1): Pass offset not idx to
PER_BUFFER_VALUE_P, and remove idx == -1 checks.
---
 src/buffer.c |  3 +--
 src/buffer.h | 21 +++++++++++----------
 src/data.c   | 11 +++++------
 3 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 8b3e15bc81..c395c6ec98 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1319,8 +1319,7 @@ buffer_lisp_local_variables (struct buffer *buf, bool clone)
 static Lisp_Object
 buffer_local_variables_1 (struct buffer *buf, int offset, Lisp_Object sym)
 {
-  int idx = PER_BUFFER_IDX (offset);
-  if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx))
+  if (PER_BUFFER_VALUE_P (buf, offset)
       && SYMBOLP (PER_BUFFER_SYMBOL (offset)))
     {
       sym = NILP (sym) ? PER_BUFFER_SYMBOL (offset) : sym;
diff --git a/src/buffer.h b/src/buffer.h
index 24e9c3fcbc..7367c2cb2b 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1415,16 +1415,6 @@ OVERLAY_POSITION (Lisp_Object p)
 
 extern bool valid_per_buffer_idx (int);
 
-/* Value is true if the variable with index IDX has a local value
-   in buffer B.  */
-
-INLINE bool
-PER_BUFFER_VALUE_P (struct buffer *b, int idx)
-{
-  eassert (valid_per_buffer_idx (idx));
-  return b->local_flags[idx];
-}
-
 /* Set whether per-buffer variable with index IDX has a buffer-local
    value in buffer B.  VAL zero means it hasn't.  */
 
@@ -1491,6 +1481,17 @@ set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
   *(Lisp_Object *)(offset + (char *) b) = value;
 }
 
+/* Value is true if the variable with offset OFFSET has a local value
+   in buffer B.  */
+
+INLINE bool
+PER_BUFFER_VALUE_P (struct buffer *b, int offset)
+{
+  int idx = PER_BUFFER_IDX (offset);
+  eassert (idx == -1 || valid_per_buffer_idx (idx));
+  return idx == -1 || b->local_flags[idx];
+}
+
 /* Downcase a character C, or make no change if that cannot be done.  */
 INLINE int
 downcase (int c)
diff --git a/src/data.c b/src/data.c
index d547f5da5e..bd399e0439 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1280,7 +1280,7 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval,
 	    {
 	      struct buffer *b = XBUFFER (buf);
 
-	      if (! PER_BUFFER_VALUE_P (b, idx))
+	      if (! PER_BUFFER_VALUE_P (b, offset))
 		set_per_buffer_value (b, offset, newval);
 	    }
 	}
@@ -1597,8 +1597,8 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
 	  {
 	    int offset = XBUFFER_OBJFWD (innercontents)->offset;
 	    int idx = PER_BUFFER_IDX (offset);
-	    if (idx > 0 && bindflag == SET_INTERNAL_SET
-	        && !PER_BUFFER_VALUE_P (buf, idx))
+	    if (bindflag == SET_INTERNAL_SET
+	        && !PER_BUFFER_VALUE_P (buf, offset))
 	      {
 		if (let_shadows_buffer_binding_p (sym))
 		  set_default_internal (symbol, newval, bindflag);
@@ -1899,7 +1899,7 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value,
 		  {
 		    struct buffer *b = XBUFFER (buf);
 
-		    if (!PER_BUFFER_VALUE_P (b, idx))
+		    if (!PER_BUFFER_VALUE_P (b, offset))
 		      set_per_buffer_value (b, offset, value);
 		  }
 	      }
@@ -2238,8 +2238,7 @@ BUFFER defaults to the current buffer.  */)
 	if (BUFFER_OBJFWDP (valcontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
-	    int idx = PER_BUFFER_IDX (offset);
-	    if (idx == -1 || PER_BUFFER_VALUE_P (buf, idx))
+	    if (PER_BUFFER_VALUE_P (buf, offset))
 	      return Qt;
 	  }
 	return Qnil;
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 03/14] Add and use BVAR_HAS_DEFAULT_VALUE_P
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:03 +0000
Resent-Message-ID: <handler.48264.B48264.162043976024791 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043976024791
          (code B ref 48264); Sat, 08 May 2021 02:10:03 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:20 +0000
Received: from localhost ([127.0.0.1]:47155 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCP9-0006Rg-VP
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:20 -0400
Received: from venus.catern.com ([68.183.49.163]:47900)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCP6-0006Qy-7n
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:16 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439756; bh=kEYkxeSGQimdK6uW9GbY9LPNZjf7OLcnf4FWQ/qfN18=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=Re3Af6eYBii7wMRVLkMMeOj3m3Ha8bnLtQgi1lGO7cNob6pSL1LV2Y+AmVVh8oggK
 rxAceFVBW5sdXgqJS4sJcM3l+aAzzhW5nLKmUXg37KiaVHAJI2OManTb8oQxiX0Rge
 4haKcYmIBC5XlQUDtEgJyasPd6wQBlkYbmnnBgik=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 002C22E982B;
 Sat,  8 May 2021 02:09:15 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:08:54 -0400
Message-Id: <20210508020905.13583-5-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This makes the code more clear and allows us to more easily change how
this property is determined.

* src/buffer.h (BVAR_HAS_DEFAULT_VALUE_P): New function.
* src/buffer.c (reset_buffer_local_variables):
* src/data.c (set_default_internal, Fkill_local_variable): Use
BVAR_HAS_DEFAULT_VALUE_P.
---
 src/buffer.c |  2 +-
 src/buffer.h | 10 ++++++++++
 src/data.c   |  5 ++---
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index c395c6ec98..efc85bf378 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1108,7 +1108,7 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
   FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
     {
       int idx = PER_BUFFER_IDX (offset);
-      if ((idx > 0
+      if ((BVAR_HAS_DEFAULT_VALUE_P (offset)
 	   && (permanent_too
 	       || buffer_permanent_local_flags[idx] == 0)))
 	set_per_buffer_value (b, offset, per_buffer_default (offset));
diff --git a/src/buffer.h b/src/buffer.h
index 7367c2cb2b..13fda0c702 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1481,6 +1481,16 @@ set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
   *(Lisp_Object *)(offset + (char *) b) = value;
 }
 
+/* Value is true if the variable with offset OFFSET has a default
+   value; false if the variable has no default, and is therefore
+   always local. */
+
+INLINE bool
+BVAR_HAS_DEFAULT_VALUE_P (int offset)
+{
+  return PER_BUFFER_IDX (offset) > 0;
+}
+
 /* Value is true if the variable with offset OFFSET has a local value
    in buffer B.  */
 
diff --git a/src/data.c b/src/data.c
index bd399e0439..891a81b7f3 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1879,13 +1879,12 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value,
 	if (BUFFER_OBJFWDP (valcontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
-	    int idx = PER_BUFFER_IDX (offset);
 
 	    set_per_buffer_default (offset, value);
 
 	    /* If this variable is not always local in all buffers,
 	       set it in the buffers that don't nominally have a local value.  */
-	    if (idx > 0)
+	    if (BVAR_HAS_DEFAULT_VALUE_P (offset))
 	      {
 		Lisp_Object buf, tail;
 
@@ -2157,7 +2156,7 @@ From now on the default value will apply in this buffer.  Return VARIABLE.  */)
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
 	    int idx = PER_BUFFER_IDX (offset);
 
-	    if (idx > 0)
+	    if (BVAR_HAS_DEFAULT_VALUE_P (offset))
 	      {
 		SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0);
 		set_per_buffer_value (current_buffer, offset,
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 04/14] Combine unnecessarily separate loops in buffer.c
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:04 +0000
Resent-Message-ID: <handler.48264.B48264.162043976124802 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043976124802
          (code B ref 48264); Sat, 08 May 2021 02:10:04 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:21 +0000
Received: from localhost ([127.0.0.1]:47158 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCPA-0006Ro-Db
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:20 -0400
Received: from venus.catern.com ([68.183.49.163]:47906)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCP7-0006RB-7X
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:17 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439757; bh=NU4eHuHwUlDI3TWKg5+NjNY0tOC+pHyFCBJ/jFbcXa8=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=QFAf3i5Fnq7aTyp1e3KlesXXTl8D/Q6BTDD4GngqMaLSQNiDgmo9GbI4v1NkbAiGU
 +szPuCqIGSpEYxd2HQOfwaXSRajdSda7NKmWs/HqO73UrgYCno2LbclBKiUXeroVNQ
 qhlI/px1uzxFJdScIMMc5loRn6quazc/i4TiPzBQ=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id F2B612E982B;
 Sat,  8 May 2021 02:09:16 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:08:55 -0400
Message-Id: <20210508020905.13583-6-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

These loops iterate over the same things with the same check.

* src/buffer.c (reset_buffer_local_variables): Combine loops.
---
 src/buffer.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index efc85bf378..4336e10a27 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1006,7 +1006,7 @@ reset_buffer (register struct buffer *b)
 static void
 reset_buffer_local_variables (struct buffer *b, bool permanent_too)
 {
-  int offset, i;
+  int offset;
 
   /* Reset the major mode to Fundamental, together with all the
      things that depend on the major mode.
@@ -1100,10 +1100,6 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
         }
     }
 
-  for (i = 0; i < last_per_buffer_idx; ++i)
-    if (permanent_too || buffer_permanent_local_flags[i] == 0)
-      SET_PER_BUFFER_VALUE_P (b, i, 0);
-
   /* For each slot that has a default value, copy that into the slot.  */
   FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
     {
@@ -1111,7 +1107,10 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
       if ((BVAR_HAS_DEFAULT_VALUE_P (offset)
 	   && (permanent_too
 	       || buffer_permanent_local_flags[idx] == 0)))
-	set_per_buffer_value (b, offset, per_buffer_default (offset));
+        {
+	  SET_PER_BUFFER_VALUE_P (b, idx, 0);
+	  set_per_buffer_value (b, offset, per_buffer_default (offset));
+        }
     }
 }
 
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 05/14] Add and use KILL_PER_BUFFER_VALUE
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:04 +0000
Resent-Message-ID: <handler.48264.B48264.162043976624833 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043976624833
          (code B ref 48264); Sat, 08 May 2021 02:10:04 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:26 +0000
Received: from localhost ([127.0.0.1]:47164 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCPF-0006SS-Tj
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:26 -0400
Received: from venus.catern.com ([68.183.49.163]:47912)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCP9-0006RP-31
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:19 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439758; bh=eSItpu2MwppAumL9g4PeP11fIX5ZBKEozvcUcsv/kio=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=T4YhwBvNQxuYuyu+bgKPWSuRsXn02/t4aNJ9+HpBfSMASESR/0QILV3IZLHy7SSa2
 8H1/nivihVsNHYBzQWjjfZ49qp3e+dInGHEZ2PUROOmeXWgkxXbZumanipEMjYj6iN
 2eZvtAvc0A8qpRKn+nqYzgPEEzWTgx0N2B9oRnJw=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 953BF2E982B;
 Sat,  8 May 2021 02:09:18 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:08:56 -0400
Message-Id: <20210508020905.13583-7-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This makes the code more clear and allows us to more easily change how
this function is implemented.

* src/buffer.h (KILL_PER_BUFFER_VALUE): New function.
* src/buffer.c (reset_buffer_local_variables):
* src/data.c (Fkill_local_variable): Use KILL_PER_BUFFER_VALUE.
---
 src/buffer.c |  5 +----
 src/buffer.h | 10 ++++++++++
 src/data.c   |  8 +-------
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 4336e10a27..2ecbaa91cc 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1107,10 +1107,7 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
       if ((BVAR_HAS_DEFAULT_VALUE_P (offset)
 	   && (permanent_too
 	       || buffer_permanent_local_flags[idx] == 0)))
-        {
-	  SET_PER_BUFFER_VALUE_P (b, idx, 0);
-	  set_per_buffer_value (b, offset, per_buffer_default (offset));
-        }
+        KILL_PER_BUFFER_VALUE (b, offset);
     }
 }
 
diff --git a/src/buffer.h b/src/buffer.h
index 13fda0c702..31ab4fb3dd 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1502,6 +1502,16 @@ PER_BUFFER_VALUE_P (struct buffer *b, int offset)
   return idx == -1 || b->local_flags[idx];
 }
 
+/* Kill the per-buffer binding for this value, if there is one. */
+
+INLINE void
+KILL_PER_BUFFER_VALUE (struct buffer *b, int offset)
+{
+  int idx = PER_BUFFER_IDX (offset);
+  SET_PER_BUFFER_VALUE_P (b, idx, 0);
+  set_per_buffer_value (b, offset, per_buffer_default (offset));
+}
+
 /* Downcase a character C, or make no change if that cannot be done.  */
 INLINE int
 downcase (int c)
diff --git a/src/data.c b/src/data.c
index 891a81b7f3..ec9fc57048 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2154,14 +2154,8 @@ From now on the default value will apply in this buffer.  Return VARIABLE.  */)
 	if (BUFFER_OBJFWDP (valcontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
-	    int idx = PER_BUFFER_IDX (offset);
-
 	    if (BVAR_HAS_DEFAULT_VALUE_P (offset))
-	      {
-		SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0);
-		set_per_buffer_value (current_buffer, offset,
-				      per_buffer_default (offset));
-	      }
+	      KILL_PER_BUFFER_VALUE (current_buffer, offset);
 	  }
 	return variable;
       }
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 06/14] Rearrange set_internal for buffer forwarded symbols
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:04 +0000
Resent-Message-ID: <handler.48264.B48264.162043976624841 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043976624841
          (code B ref 48264); Sat, 08 May 2021 02:10:04 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:26 +0000
Received: from localhost ([127.0.0.1]:47166 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCPG-0006SU-5X
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:26 -0400
Received: from venus.catern.com ([68.183.49.163]:47918)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCPA-0006Rl-2a
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:20 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439759; bh=XUJZohpHIICFCS2RL1sSMhF0QdxpPiAZV828tE1ts4E=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=VYxa+kJSt6voJ8jW8KTNNuQRzYLmR6DzoAzavvr0ikU7AWJPLm4wi4kXl7TNGTd/P
 WnzEZ6V5dFWrluH4X6rf027xrbL2DGc7/nWTJ+UY8nOpKI4nN8/dv3E0m+0K6lrZ2C
 4il4RefwO2854QMYqx0lB4ncXN1EOppazk03mzAU=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id C96C22E982B;
 Sat,  8 May 2021 02:09:19 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:08:57 -0400
Message-Id: <20210508020905.13583-8-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Previously, when setting buffer-local values for DEFVAR_PER_BUFFER
variables, the call to SET_PER_BUFFER_VALUE_P was far from the call to
set_per_buffer_value, even though they're conceptually tied together.

Now, the two calls are in the same place in store_symval_forwarding,
and we can delete the old call to SET_PER_BUFFER_VALUE_P in
set_internal.

Since we did this, we need to also avoid calling
store_symval_forwarding in set_internal when setting the default value
for a DEFVAR_PER_BUFFER variable.

This improves clarity quite a bit; it also makes it easier to later
merge set_per_buffer_value and SET_PER_BUFFER_VALUE_P together.

* src/data.c (store_symval_forwarding): Call SET_PER_BUFFER_VALUE_P
directly for buffer-forwarded symbols.
(set_internal): Don't call SET_PER_BUFFER_VALUE_P for buffer-forwarded
symbols.  Also don't call store_symval_forwarding when we're setting
the default value for a buffer-forwarded symbol.
---
 src/data.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/data.c b/src/data.c
index ec9fc57048..9d8b722a41 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1320,6 +1320,9 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval,
 	if (buf == NULL)
 	  buf = current_buffer;
 	set_per_buffer_value (buf, offset, newval);
+        int idx = PER_BUFFER_IDX (offset);
+        if (idx > 0)
+	  SET_PER_BUFFER_VALUE_P (buf, idx, 1);
       }
       break;
 
@@ -1593,17 +1596,16 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
 	struct buffer *buf
 	  = BUFFERP (where) ? XBUFFER (where) : current_buffer;
 	lispfwd innercontents = SYMBOL_FWD (sym);
+        bool should_store = true;
 	if (BUFFER_OBJFWDP (innercontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (innercontents)->offset;
-	    int idx = PER_BUFFER_IDX (offset);
 	    if (bindflag == SET_INTERNAL_SET
-	        && !PER_BUFFER_VALUE_P (buf, offset))
+	        && !PER_BUFFER_VALUE_P (buf, offset)
+		&& let_shadows_buffer_binding_p (sym))
 	      {
-		if (let_shadows_buffer_binding_p (sym))
-		  set_default_internal (symbol, newval, bindflag);
-		else
-		  SET_PER_BUFFER_VALUE_P (buf, idx, 1);
+		set_default_internal (symbol, newval, bindflag);
+		should_store = false;
 	      }
 	  }
 
@@ -1613,7 +1615,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
 	    sym->u.s.redirect = SYMBOL_PLAINVAL;
 	    SET_SYMBOL_VAL (sym, newval);
 	  }
-	else
+	else if (should_store)
 	  store_symval_forwarding (/* sym, */ innercontents, newval, buf);
 	break;
       }
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 08/14] Remove unnecessary Qunbound check
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:05 +0000
Resent-Message-ID: <handler.48264.B48264.162043976724849 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043976724849
          (code B ref 48264); Sat, 08 May 2021 02:10:05 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:27 +0000
Received: from localhost ([127.0.0.1]:47169 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCPG-0006Sc-Fg
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:26 -0400
Received: from venus.catern.com ([68.183.49.163]:47932)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCPD-0006S6-Fr
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:23 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439762; bh=Vs54MQsm/aEfY6ocrmkpUxgtyG9aXuExqSF90e8b5f8=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=CjZvoaaJ9+FBsRwNglKP2Qtn4CzL+xtwGa6pknC7G8Y8M5/zUGccQQ9Y8cA3gIHtJ
 wmhNGiaXtnQj5JrJ8o8yt+jLORoh6EuwnDKLDJsMdpYEEaFfK3lZExi83UYKk/lIiV
 M5EFSprZivbc298x+oPq24Tdv3cF4UhlSZQg+zcI=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id C6A812E9830;
 Sat,  8 May 2021 02:09:22 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:08:59 -0400
Message-Id: <20210508020905.13583-10-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

DEFVAR_PER_BUFFER variables (which this function deals with) cannot be
Qunbound anymore.

* src/buffer.c (buffer_local_variables_1): Remove Qunbound check.
---
 src/buffer.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 1acf0fa724..04f60a4215 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1315,8 +1315,7 @@ buffer_local_variables_1 (struct buffer *buf, int offset, Lisp_Object sym)
       && SYMBOLP (PER_BUFFER_SYMBOL (offset)))
     {
       sym = NILP (sym) ? PER_BUFFER_SYMBOL (offset) : sym;
-      Lisp_Object val = per_buffer_value (buf, offset);
-      return EQ (val, Qunbound) ? sym : Fcons (sym, val);
+      return Fcons (sym, per_buffer_value (buf, offset));
     }
   return Qnil;
 }
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 09/14] Get rid of buffer_permanent_local_flags array
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:05 +0000
Resent-Message-ID: <handler.48264.B48264.162043976724862 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043976724862
          (code B ref 48264); Sat, 08 May 2021 02:10:05 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:27 +0000
Received: from localhost ([127.0.0.1]:47171 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCPG-0006Sk-O3
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:27 -0400
Received: from venus.catern.com ([68.183.49.163]:47938)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCPE-0006SC-46
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:24 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439763; bh=6fVM7XuTTgg6VlRY7dA8Ez6u/mB6q2CfDPMKD8uSYaA=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=gpB85PkHSTusSoz8HBHSWYvQbl4WALOlALLajkVLxa7BO78I3XYfCufi8S893fJoz
 7r2jLeg9pahNRvZsODcyg9dnDslMjGL/gPtLlgv0QQgv+6vBvTXoGILpMto1kavehg
 IcO4YlH6qdH1JzuGoltF29+iW5iaZ4/pksPf4ffE=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id D7DE72E9830;
 Sat,  8 May 2021 02:09:23 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:09:00 -0400
Message-Id: <20210508020905.13583-11-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This array is unnecessary, its behavior is undesirable for new
variables, and it stands in the way of removing PER_BUFFER_IDX.

* lisp/bindings.el: Update comment to point to
reset_buffer_local_variables for information about
pseudo-permanent-locals.
* src/buffer.c (buffer_permanent_local_flags): Delete.
(reset_buffer_local_variables): Special case two
pseudo-permanent-locals for backwards-compatibility.
(init_buffer_once): Remove use of buffer_permanent_local_flags.
---
 lisp/bindings.el |  3 ++-
 src/buffer.c     | 26 ++++++++------------------
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/lisp/bindings.el b/lisp/bindings.el
index 6eac528eb6..902528a9ca 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -766,7 +766,8 @@ okay.  See `mode-line-format'.")
 ;; `kill-all-local-variables', because they have no default value.
 ;; For consistency, we give them the `permanent-local' property, even
 ;; though `kill-all-local-variables' does not actually consult it.
-;; See init_buffer_once in buffer.c for the origins of this list.
+;; See init_buffer_once and reset_buffer_local_variables in buffer.c
+;; for the origins of this list.
 
 (mapc (lambda (sym) (put sym 'permanent-local t))
       '(buffer-file-name default-directory buffer-backed-up
diff --git a/src/buffer.c b/src/buffer.c
index 04f60a4215..b4345ca308 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -92,10 +92,6 @@ struct buffer buffer_local_symbols;
   ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM,				\
 		    min (PTRDIFF_MAX, SIZE_MAX) / word_size))
 
-/* Flags indicating which built-in buffer-local variables
-   are permanent locals.  */
-static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS];
-
 /* Number of per-buffer variables used.  */
 
 static int last_per_buffer_idx;
@@ -1099,10 +1095,14 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
   /* For each slot that has a default value, copy that into the slot.  */
   FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
     {
-      int idx = PER_BUFFER_IDX (offset);
       if ((BVAR_HAS_DEFAULT_VALUE_P (offset)
 	   && (permanent_too
-	       || buffer_permanent_local_flags[idx] == 0)))
+	       /* Special case these two for backwards-compat; they're
+		  flagged as permanent-locals in bindings.el, even
+		  though they do have default values.  */
+	       || (offset != PER_BUFFER_VAR_OFFSET (truncate_lines)
+		   && offset !=
+		   PER_BUFFER_VAR_OFFSET (buffer_file_coding_system)))))
         KILL_PER_BUFFER_VALUE (b, offset);
     }
 }
@@ -5132,7 +5132,6 @@ init_buffer_once (void)
 
      buffer_defaults: default values of buffer-locals
      buffer_local_flags: metadata
-     buffer_permanent_local_flags: metadata
      buffer_local_symbols: metadata
 
      There must be a simpler way to store the metadata.
@@ -5140,11 +5139,6 @@ init_buffer_once (void)
 
   int idx;
 
-  /* Items flagged permanent get an explicit permanent-local property
-     added in bindings.el, for clarity.  */
-  PDUMPER_REMEMBER_SCALAR (buffer_permanent_local_flags);
-  memset (buffer_permanent_local_flags, 0, sizeof buffer_permanent_local_flags);
-
   /* 0 means not a lisp var, -1 means always local, else mask.  */
   memset (&buffer_local_flags, 0, sizeof buffer_local_flags);
   bset_filename (&buffer_local_flags, make_fixnum (-1));
@@ -5192,9 +5186,7 @@ init_buffer_once (void)
   XSETFASTINT (BVAR (&buffer_local_flags, selective_display), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, selective_display_ellipses), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, tab_width), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, truncate_lines), idx);
-  /* Make this one a permanent local.  */
-  buffer_permanent_local_flags[idx++] = 1;
+  XSETFASTINT (BVAR (&buffer_local_flags, truncate_lines), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, word_wrap), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, ctl_arrow), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, fill_column), idx); ++idx;
@@ -5208,9 +5200,7 @@ init_buffer_once (void)
   XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_direction), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_separate_re), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_start_re), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, buffer_file_coding_system), idx);
-  /* Make this one a permanent local.  */
-  buffer_permanent_local_flags[idx++] = 1;
+  XSETFASTINT (BVAR (&buffer_local_flags, buffer_file_coding_system), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, left_margin_cols), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, right_margin_cols), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, left_fringe_width), idx); ++idx;
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 07/14] Use BVAR_OR_DEFAULT for per-buffer vars with defaults
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:06 +0000
Resent-Message-ID: <handler.48264.B48264.162043978324888 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043978324888
          (code B ref 48264); Sat, 08 May 2021 02:10:06 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:43 +0000
Received: from localhost ([127.0.0.1]:47174 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCPI-0006Sx-Ej
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:43 -0400
Received: from venus.catern.com ([68.183.49.163]:47926)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCPC-0006S5-2i
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:24 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439761; bh=IyXh4BhdrdQmeE0RO4BvE7AV/h/LLZw+hEV4HJO3KKs=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=TV0M05GDkxYDPe3MLbT4Q0nDqwjhQStfSzgt66OJeJfrd53L3L4V8cHskXXOQVeM0
 tqiZP4xpt9QiLKBKzcnVEmySrIc3icwXRBlq5xC8WUzKWJe3mslce/0bKRFf3lxcCm
 +x+YmPLwGOr9fhFVKbk2vM1iIGO8fC2ooYbaeXWI=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id B33702E982B;
 Sat,  8 May 2021 02:09:21 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:08:58 -0400
Message-Id: <20210508020905.13583-9-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Previously, per-buffer variables with defaults and without defaults
were treated identically: To access the value of a per-buffer
variable, we only looked at the field in the current buffer.  As a
result, whenever we changed the default value for a per-buffer
variable, we had to iterate over all buffers to find and update
buffers without a local binding to match the new default.

Now, we treat per-buffer variables with defaults differently: we use
BVAR_OR_DEFAULT to access them.  BVAR_OR_DEFAULT falls back to using
the value in buffer_defaults if there is no local binding for the
per-buffer variable in the specified buffer.  So changing the default
value for a variable doesn't require iterating over all buffers, and
is therefore much faster.

We also now set fields which are not buffer-local to Qunbound, and use
that to determine if a buffer has a buffer-local binding for a
variable.  If the field contains Qunbound, BVAR_OR_DEFAULT uses the
default value out of buffer_defaults; if the field contains something
other than Qunbound, there's a buffer-local binding, and we use the
per-buffer value.

This information duplicates local_flags, which we'll delete in a
followup commit.

* src/buffer.h (BVAR_OR_DEFAULT): Add.
* src/bidi.c (bidi_at_paragraph_end, bidi_paragraph_cache_on_off)
(bidi_find_paragraph_start):
* src/buffer.c (swapfield_defaulted, Fbuffer_swap_text):
* src/buffer.h (SANE_TAB_WIDTH, CHARACTER_WIDTH):
* src/category.c (check_category_table, Fcategory_table)
(char_category_set):
* src/cmds.c (internal_self_insert):
* src/editfns.c (Fcompare_buffer_substrings)
(Fchar_equal):
* src/fileio.c (choose_write_coding_system):
* src/fns.c (extract_data_from_object):
* src/fringe.c (get_logical_cursor_bitmap, get_logical_fringe_bitmap)
(update_window_fringes):
* src/hbfont.c (hbfont_shape):
* src/indent.c (buffer_display_table, width_run_cache_on_off, current_column)
(scan_for_column, compute_motion, vmotion):
* src/msdos.c (IT_frame_up_to_date):
* src/search.c (compile_pattern_1, compile_pattern, looking_at_1)
(string_match_1, newline_cache_on_off, search_command, Fnewline_cache_check):
* src/syntax.c
(update_syntax_table, Fsyntax_table, Fmodify_syntax_entry):
* src/syntax.h
(syntax_property_entry, SETUP_BUFFER_SYNTAX_TABLE):
* src/window.c
(window_display_table, set_window_buffer, window_wants_mode_line)
(window_wants_header_line, window_wants_tab_line):
* src/xdisp.c
(fill_column_indicator_column, default_line_pixel_height, pos_visible_p)
(init_iterator, reseat_to_string, set_message_1)
(text_outside_line_unchanged_p, try_scrolling, try_cursor_movement)
(redisplay_window, try_window_reusing_current_matrix, row_containing_pos)
(try_window_id, display_line, Fcurrent_bidi_paragraph_direction)
(Fbidi_find_overridden_directionality, display_mode_lines, decode_mode_spec)
(display_count_lines, get_window_cursor_type, note_mouse_highlight):
Use BVAR_OR_DEFAULT.
* src/buffer.h (bvar_get_value): Add an offset-based function version
of BVAR_OR_DEFAULT.
(PER_BUFFER_VALUE_P): Check if value is Qunbound instead of checking
local_flags.
(KILL_PER_BUFFER_VALUE): Set killed buffer-local vars to Qunbound, not
the default value.
* src/buffer.c (reset_buffer): Set killed buffer-local vars to
Qunbound, not the default value.
(buffer_local_value): Use bvar_get_value so we look up defaults.
(init_buffer_once): Don't call reset_buffer_local_variables on
pseudobuffers, so we don't set all their values to Qunbound.
* src/data.c (do_symval_forwarding): Use bvar_get_value so we look up
defaults.
(store_symval_forwarding, set_default_internal): Don't loop all over
buffers when setting buffer defaults; this fixes bug#41029.
* test/src/data-tests.el (data-tests--set-default-per-buffer): Enable,
this is fixed now.
---
 src/bidi.c             |  19 +++---
 src/buffer.c           |  24 ++++----
 src/buffer.h           |  27 ++++++---
 src/category.c         |   6 +-
 src/cmds.c             |   6 +-
 src/data.c             |  50 +---------------
 src/editfns.c          |   4 +-
 src/fileio.c           |   9 +--
 src/fns.c              |   8 ++-
 src/fringe.c           |  21 ++++---
 src/hbfont.c           |   2 +-
 src/indent.c           |  34 +++++------
 src/msdos.c            |   6 +-
 src/search.c           |  21 +++----
 src/syntax.c           |   7 ++-
 src/syntax.h           |   5 +-
 src/window.c           |  29 ++++-----
 src/xdisp.c            | 130 +++++++++++++++++++++--------------------
 test/src/data-tests.el |   1 -
 19 files changed, 191 insertions(+), 218 deletions(-)

diff --git a/src/bidi.c b/src/bidi.c
index 1413ba6b88..0d0587f5f5 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -1451,12 +1451,12 @@ bidi_at_paragraph_end (ptrdiff_t charpos, ptrdiff_t bytepos)
   Lisp_Object start_re;
   ptrdiff_t val;
 
-  if (STRINGP (BVAR (current_buffer, bidi_paragraph_separate_re)))
-    sep_re = BVAR (current_buffer, bidi_paragraph_separate_re);
+  if (STRINGP (BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_separate_re)))
+    sep_re = BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_separate_re);
   else
     sep_re = paragraph_separate_re;
-  if (STRINGP (BVAR (current_buffer, bidi_paragraph_start_re)))
-    start_re = BVAR (current_buffer, bidi_paragraph_start_re);
+  if (STRINGP (BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_start_re)))
+    start_re = BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_start_re);
   else
     start_re = paragraph_start_re;
 
@@ -1500,10 +1500,10 @@ bidi_paragraph_cache_on_off (void)
      This is because doing so will just make the cache pure overhead,
      since if we turn it on via indirect buffer, it will be
      immediately turned off by its base buffer.  */
-  if (NILP (BVAR (current_buffer, cache_long_scans)))
+  if (NILP (BVAR_OR_DEFAULT (current_buffer, cache_long_scans)))
     {
       if (!indirect_p
-	  || NILP (BVAR (cache_buffer, cache_long_scans)))
+	  || NILP (BVAR_OR_DEFAULT (cache_buffer, cache_long_scans)))
 	{
 	  if (cache_buffer->bidi_paragraph_cache)
 	    {
@@ -1516,7 +1516,7 @@ bidi_paragraph_cache_on_off (void)
   else
     {
       if (!indirect_p
-	  || !NILP (BVAR (cache_buffer, cache_long_scans)))
+	  || !NILP (BVAR_OR_DEFAULT (cache_buffer, cache_long_scans)))
 	{
 	  if (!cache_buffer->bidi_paragraph_cache)
 	    cache_buffer->bidi_paragraph_cache = new_region_cache ();
@@ -1538,9 +1538,8 @@ bidi_paragraph_cache_on_off (void)
 static ptrdiff_t
 bidi_find_paragraph_start (ptrdiff_t pos, ptrdiff_t pos_byte)
 {
-  Lisp_Object re =
-    STRINGP (BVAR (current_buffer, bidi_paragraph_start_re))
-    ? BVAR (current_buffer, bidi_paragraph_start_re)
+  Lisp_Object re = STRINGP (BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_start_re))
+    ? BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_start_re)
     : paragraph_start_re;
   ptrdiff_t limit = ZV, limit_byte = ZV_BYTE;
   struct region_cache *bpc = bidi_paragraph_cache_on_off ();
diff --git a/src/buffer.c b/src/buffer.c
index 2ecbaa91cc..1acf0fa724 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -53,9 +53,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 /* This structure holds the default values of the buffer-local variables
    defined with DEFVAR_PER_BUFFER, that have special slots in each buffer.
    The default value occupies the same slot in this structure
-   as an individual buffer's value occupies in that buffer.
-   Setting the default value also goes through the alist of buffers
-   and stores into each buffer that does not say it has a local value.  */
+   as an individual buffer's value occupies in that buffer.  */
 
 struct buffer buffer_defaults;
 
@@ -989,8 +987,6 @@ reset_buffer (register struct buffer *b)
   bset_display_count (b, make_fixnum (0));
   bset_display_time (b, Qnil);
   bset_enable_multibyte_characters (b, Qt);
-  bset_cursor_type (b, BVAR (&buffer_defaults, cursor_type));
-  bset_extra_line_spacing (b, BVAR (&buffer_defaults, extra_line_spacing));
 
   b->display_error_modiff = 0;
 }
@@ -1260,7 +1256,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object buffer)
       {
 	lispfwd fwd = SYMBOL_FWD (sym);
 	if (BUFFER_OBJFWDP (fwd))
-	  result = per_buffer_value (buf, XBUFFER_OBJFWD (fwd)->offset);
+	  result = bvar_get_value (buf, XBUFFER_OBJFWD (fwd)->offset);
 	else
 	  result = Fdefault_value (variable);
 	break;
@@ -2382,6 +2378,12 @@ results, see Info node `(elisp)Swapping Text'.  */)
     bset_##field (other_buffer, BVAR (current_buffer, field));	\
     bset_##field (current_buffer, tmp##field);			\
   } while (0)
+#define swapfield_defaulted(field, type) \
+  do {							\
+    type tmp##field = BVAR_OR_DEFAULT (other_buffer, field);		\
+    bset_##field (other_buffer, BVAR_OR_DEFAULT (current_buffer, field));	\
+    bset_##field (current_buffer, tmp##field);			\
+  } while (0)
 
   swapfield (own_text, struct buffer_text);
   eassert (current_buffer->text == &current_buffer->own_text);
@@ -2415,10 +2417,10 @@ results, see Info node `(elisp)Swapping Text'.  */)
   swapfield_ (mark, Lisp_Object);
   swapfield_ (mark_active, Lisp_Object); /* Belongs with the `mark'.  */
   swapfield_ (enable_multibyte_characters, Lisp_Object);
-  swapfield_ (bidi_display_reordering, Lisp_Object);
-  swapfield_ (bidi_paragraph_direction, Lisp_Object);
-  swapfield_ (bidi_paragraph_separate_re, Lisp_Object);
-  swapfield_ (bidi_paragraph_start_re, Lisp_Object);
+  swapfield_defaulted (bidi_display_reordering, Lisp_Object);
+  swapfield_defaulted (bidi_paragraph_direction, Lisp_Object);
+  swapfield_defaulted (bidi_paragraph_separate_re, Lisp_Object);
+  swapfield_defaulted (bidi_paragraph_start_re, Lisp_Object);
   /* FIXME: Not sure what we should do with these *_marker fields.
      Hopefully they're just nil anyway.  */
   swapfield_ (pt_marker, Lisp_Object);
@@ -5245,10 +5247,8 @@ init_buffer_once (void)
      are initialized reasonably, so mark_buffer won't choke.  */
   reset_buffer (&buffer_defaults);
   eassert (NILP (BVAR (&buffer_defaults, name)));
-  reset_buffer_local_variables (&buffer_defaults, 1);
   eassert (NILP (BVAR (&buffer_local_symbols, name)));
   reset_buffer (&buffer_local_symbols);
-  reset_buffer_local_variables (&buffer_local_symbols, 1);
   /* Prevent GC from getting confused.  */
   buffer_defaults.text = &buffer_defaults.own_text;
   buffer_local_symbols.text = &buffer_local_symbols.own_text;
diff --git a/src/buffer.h b/src/buffer.h
index 31ab4fb3dd..db725250d6 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -284,6 +284,10 @@ struct buffer_text
 
 #define BVAR(buf, field) ((buf)->field ## _)
 
+#define BVAR_OR_DEFAULT(buf, field) (EQ (BVAR ((buf), field), Qunbound) \
+				     ? BVAR (&buffer_defaults, field) \
+				     : BVAR ((buf), field))
+
 /* Max number of builtin per-buffer variables.  */
 enum { MAX_PER_BUFFER_VARS = 50 };
 
@@ -1104,9 +1108,7 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
 /* This structure holds the default values of the buffer-local variables
    that have special slots in each buffer.
    The default value occupies the same slot in this structure
-   as an individual buffer's value occupies in that buffer.
-   Setting the default value also goes through the alist of buffers
-   and stores into each buffer that does not say it has a local value.  */
+   as an individual buffer's value occupies in that buffer.  */
 
 extern struct buffer buffer_defaults;
 
@@ -1497,9 +1499,16 @@ BVAR_HAS_DEFAULT_VALUE_P (int offset)
 INLINE bool
 PER_BUFFER_VALUE_P (struct buffer *b, int offset)
 {
-  int idx = PER_BUFFER_IDX (offset);
-  eassert (idx == -1 || valid_per_buffer_idx (idx));
-  return idx == -1 || b->local_flags[idx];
+  return !EQ (per_buffer_value (b, offset), Qunbound);
+}
+
+INLINE Lisp_Object
+bvar_get_value (struct buffer *b, ptrdiff_t offset)
+{
+  Lisp_Object val = per_buffer_value (b, offset);
+  return EQ (val, Qunbound)
+    ? per_buffer_default (offset)
+    : val;
 }
 
 /* Kill the per-buffer binding for this value, if there is one. */
@@ -1509,7 +1518,7 @@ KILL_PER_BUFFER_VALUE (struct buffer *b, int offset)
 {
   int idx = PER_BUFFER_IDX (offset);
   SET_PER_BUFFER_VALUE_P (b, idx, 0);
-  set_per_buffer_value (b, offset, per_buffer_default (offset));
+  set_per_buffer_value (b, offset, Qunbound);
 }
 
 /* Downcase a character C, or make no change if that cannot be done.  */
@@ -1556,7 +1565,7 @@ sanitize_tab_width (Lisp_Object width)
 INLINE int
 SANE_TAB_WIDTH (struct buffer *buf)
 {
-  return sanitize_tab_width (BVAR (buf, tab_width));
+  return sanitize_tab_width (BVAR_OR_DEFAULT (buf, tab_width));
 }
 
 /* Return a non-outlandish value for a character width.  */
@@ -1580,7 +1589,7 @@ CHARACTER_WIDTH (int c)
 			(XFIXNUM (CHAR_TABLE_REF (Vchar_width_table, c))))
 	  : c == '\t' ? SANE_TAB_WIDTH (current_buffer)
 	  : c == '\n' ? 0
-	  : !NILP (BVAR (current_buffer, ctl_arrow)) ? 2 : 4);
+	  : !NILP (BVAR_OR_DEFAULT (current_buffer, ctl_arrow)) ? 2 : 4);
 }
 
 
diff --git a/src/category.c b/src/category.c
index ec8f61f7f0..522f4da697 100644
--- a/src/category.c
+++ b/src/category.c
@@ -180,7 +180,7 @@ static Lisp_Object
 check_category_table (Lisp_Object table)
 {
   if (NILP (table))
-    return BVAR (current_buffer, category_table);
+    return BVAR_OR_DEFAULT (current_buffer, category_table);
   CHECK_TYPE (!NILP (Fcategory_table_p (table)), Qcategory_table_p, table);
   return table;
 }
@@ -190,7 +190,7 @@ DEFUN ("category-table", Fcategory_table, Scategory_table, 0, 0, 0,
 This is the one specified by the current buffer.  */)
   (void)
 {
-  return BVAR (current_buffer, category_table);
+  return BVAR_OR_DEFAULT (current_buffer, category_table);
 }
 
 DEFUN ("standard-category-table", Fstandard_category_table,
@@ -281,7 +281,7 @@ Return TABLE.  */)
 Lisp_Object
 char_category_set (int c)
 {
-  return CHAR_TABLE_REF (BVAR (current_buffer, category_table), c);
+  return CHAR_TABLE_REF (BVAR_OR_DEFAULT (current_buffer, category_table), c);
 }
 
 DEFUN ("char-category-set", Fchar_category_set, Schar_category_set, 1, 1, 0,
diff --git a/src/cmds.c b/src/cmds.c
index c8a96d918c..a355142480 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -320,7 +320,7 @@ internal_self_insert (int c, EMACS_INT n)
   ptrdiff_t chars_to_delete = 0;
   ptrdiff_t spaces_to_insert = 0;
 
-  overwrite = BVAR (current_buffer, overwrite_mode);
+  overwrite = BVAR_OR_DEFAULT (current_buffer, overwrite_mode);
   if (!NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions))
     hairy = 1;
 
@@ -406,7 +406,7 @@ internal_self_insert (int c, EMACS_INT n)
 
   synt = SYNTAX (c);
 
-  if (!NILP (BVAR (current_buffer, abbrev_mode))
+  if (!NILP (BVAR_OR_DEFAULT (current_buffer, abbrev_mode))
       && synt != Sword
       && NILP (BVAR (current_buffer, read_only))
       && PT > BEGV
@@ -474,7 +474,7 @@ internal_self_insert (int c, EMACS_INT n)
   if ((CHAR_TABLE_P (Vauto_fill_chars)
        ? !NILP (CHAR_TABLE_REF (Vauto_fill_chars, c))
        : (c == ' ' || c == '\n'))
-      && !NILP (BVAR (current_buffer, auto_fill_function)))
+      && !NILP (BVAR_OR_DEFAULT (current_buffer, auto_fill_function)))
     {
       Lisp_Object auto_fill_result;
 
diff --git a/src/data.c b/src/data.c
index 9d8b722a41..6835699236 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1161,8 +1161,8 @@ do_symval_forwarding (lispfwd valcontents)
       return *XOBJFWD (valcontents)->objvar;
 
     case Lisp_Fwd_Buffer_Obj:
-      return per_buffer_value (current_buffer,
-			       XBUFFER_OBJFWD (valcontents)->offset);
+      return bvar_get_value (current_buffer,
+			     XBUFFER_OBJFWD (valcontents)->offset);
 
     case Lisp_Fwd_Kboard_Obj:
       /* We used to simply use current_kboard here, but from Lisp
@@ -1259,31 +1259,6 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval,
 
     case Lisp_Fwd_Obj:
       *XOBJFWD (valcontents)->objvar = newval;
-
-      /* If this variable is a default for something stored
-	 in the buffer itself, such as default-fill-column,
-	 find the buffers that don't have local values for it
-	 and update them.  */
-      if (XOBJFWD (valcontents)->objvar > (Lisp_Object *) &buffer_defaults
-	  && XOBJFWD (valcontents)->objvar < (Lisp_Object *) (&buffer_defaults + 1))
-	{
-	  int offset = ((char *) XOBJFWD (valcontents)->objvar
-			- (char *) &buffer_defaults);
-	  int idx = PER_BUFFER_IDX (offset);
-
-	  Lisp_Object tail, buf;
-
-	  if (idx <= 0)
-	    break;
-
-	  FOR_EACH_LIVE_BUFFER (tail, buf)
-	    {
-	      struct buffer *b = XBUFFER (buf);
-
-	      if (! PER_BUFFER_VALUE_P (b, offset))
-		set_per_buffer_value (b, offset, newval);
-	    }
-	}
       break;
 
     case Lisp_Fwd_Buffer_Obj:
@@ -1883,27 +1858,6 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value,
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
 
 	    set_per_buffer_default (offset, value);
-
-	    /* If this variable is not always local in all buffers,
-	       set it in the buffers that don't nominally have a local value.  */
-	    if (BVAR_HAS_DEFAULT_VALUE_P (offset))
-	      {
-		Lisp_Object buf, tail;
-
-		/* Do this only in live buffers, so that if there are
-		   a lot of buffers which are dead, that doesn't slow
-		   down let-binding of variables that are
-		   automatically local when set, like
-		   case-fold-search.  This is for Lisp programs that
-		   let-bind such variables in their inner loops.  */
-		FOR_EACH_LIVE_BUFFER (tail, buf)
-		  {
-		    struct buffer *b = XBUFFER (buf);
-
-		    if (!PER_BUFFER_VALUE_P (b, offset))
-		      set_per_buffer_value (b, offset, value);
-		  }
-	      }
 	  }
 	else
           set_internal (symbol, value, Qnil, bindflag);
diff --git a/src/editfns.c b/src/editfns.c
index 04b8e85d9c..01e56843a6 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1769,7 +1769,7 @@ determines whether case is significant or ignored.  */)
   register EMACS_INT begp1, endp1, begp2, endp2, temp;
   register struct buffer *bp1, *bp2;
   register Lisp_Object trt
-    = (!NILP (BVAR (current_buffer, case_fold_search))
+    = (!NILP (BVAR_OR_DEFAULT (current_buffer, case_fold_search))
        ? BVAR (current_buffer, case_canon_table) : Qnil);
   ptrdiff_t chars = 0;
   ptrdiff_t i1, i2, i1_byte, i2_byte;
@@ -4022,7 +4022,7 @@ Case is ignored if `case-fold-search' is non-nil in the current buffer.  */)
 
   if (XFIXNUM (c1) == XFIXNUM (c2))
     return Qt;
-  if (NILP (BVAR (current_buffer, case_fold_search)))
+  if (NILP (BVAR_OR_DEFAULT (current_buffer, case_fold_search)))
     return Qnil;
 
   i1 = XFIXNAT (c1);
diff --git a/src/fileio.c b/src/fileio.c
index 741e297d29..2c941d82cc 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4919,7 +4919,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
       bool using_default_coding = 0;
       bool force_raw_text = 0;
 
-      val = BVAR (current_buffer, buffer_file_coding_system);
+      val = BVAR_OR_DEFAULT (current_buffer, buffer_file_coding_system);
       if (NILP (val)
 	  || NILP (Flocal_variable_p (Qbuffer_file_coding_system, Qnil)))
 	{
@@ -4942,7 +4942,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
 	{
 	  /* If we still have not decided a coding system, use the
 	     current buffer's value of buffer-file-coding-system.  */
-	  val = BVAR (current_buffer, buffer_file_coding_system);
+	  val = BVAR_OR_DEFAULT (current_buffer, buffer_file_coding_system);
 	  using_default_coding = 1;
 	}
 
@@ -4974,7 +4974,8 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
 	 format, we use that of `buffer-file-coding-system'.  */
       if (! using_default_coding)
 	{
-	  Lisp_Object dflt = BVAR (&buffer_defaults, buffer_file_coding_system);
+	  Lisp_Object dflt = BVAR_OR_DEFAULT (&buffer_defaults,
+					     buffer_file_coding_system);
 
 	  if (! NILP (dflt))
 	    val = coding_inherit_eol_type (val, dflt);
@@ -4989,7 +4990,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
   val = coding_inherit_eol_type (val, eol_parent);
   setup_coding_system (val, coding);
 
-  if (!STRINGP (start) && EQ (Qt, BVAR (current_buffer, selective_display)))
+  if (!STRINGP (start) && EQ (Qt, BVAR_OR_DEFAULT (current_buffer, selective_display)))
     coding->mode |= CODING_MODE_SELECTIVE_DISPLAY;
   return val;
 }
diff --git a/src/fns.c b/src/fns.c
index 41429c8863..283ee96143 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -5416,7 +5416,8 @@ extract_data_from_object (Lisp_Object spec,
 	    {
 	      bool force_raw_text = false;
 
-	      coding_system = BVAR (XBUFFER (object), buffer_file_coding_system);
+	      coding_system = BVAR_OR_DEFAULT (XBUFFER(object),
+					      buffer_file_coding_system);
 	      if (NILP (coding_system)
 		  || NILP (Flocal_variable_p (Qbuffer_file_coding_system, Qnil)))
 		{
@@ -5437,11 +5438,12 @@ extract_data_from_object (Lisp_Object spec,
 		}
 
 	      if (NILP (coding_system)
-		  && !NILP (BVAR (XBUFFER (object), buffer_file_coding_system)))
+		  && !NILP (BVAR_OR_DEFAULT (XBUFFER(object), buffer_file_coding_system)))
 		{
 		  /* If we still have not decided a coding system, use the
 		     default value of buffer-file-coding-system.  */
-		  coding_system = BVAR (XBUFFER (object), buffer_file_coding_system);
+		  coding_system = BVAR_OR_DEFAULT (XBUFFER(object),
+						  buffer_file_coding_system);
 		}
 
 	      if (!force_raw_text
diff --git a/src/fringe.c b/src/fringe.c
index 65c9a84ac9..42ba9b0682 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -697,7 +697,8 @@ get_logical_cursor_bitmap (struct window *w, Lisp_Object cursor)
 {
   Lisp_Object cmap, bm = Qnil;
 
-  if ((cmap = BVAR (XBUFFER (w->contents), fringe_cursor_alist)), !NILP (cmap))
+  if ((cmap = BVAR_OR_DEFAULT (XBUFFER(w->contents), fringe_cursor_alist)),
+      !NILP (cmap))
     {
       bm = Fassq (cursor, cmap);
       if (CONSP (bm))
@@ -707,9 +708,9 @@ get_logical_cursor_bitmap (struct window *w, Lisp_Object cursor)
 	  return lookup_fringe_bitmap (bm);
 	}
     }
-  if (EQ (cmap, BVAR (&buffer_defaults, fringe_cursor_alist)))
+  if (EQ (cmap, BVAR_OR_DEFAULT (&buffer_defaults, fringe_cursor_alist)))
     return NO_FRINGE_BITMAP;
-  bm = Fassq (cursor, BVAR (&buffer_defaults, fringe_cursor_alist));
+  bm = Fassq (cursor, BVAR_OR_DEFAULT (&buffer_defaults, fringe_cursor_alist));
   if (!CONSP (bm) || ((bm = XCDR (bm)), NILP (bm)))
     return NO_FRINGE_BITMAP;
   return lookup_fringe_bitmap (bm);
@@ -734,7 +735,8 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, in
      If partial, lookup partial bitmap in default value if not found here.
      If not partial, or no partial spec is present, use non-partial bitmap.  */
 
-  if ((cmap = BVAR (XBUFFER (w->contents), fringe_indicator_alist)), !NILP (cmap))
+  if ((cmap = BVAR_OR_DEFAULT (XBUFFER(w->contents), fringe_indicator_alist)),
+      !NILP (cmap))
     {
       bm1 = Fassq (bitmap, cmap);
       if (CONSP (bm1))
@@ -768,10 +770,11 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, in
 	}
     }
 
-  if (!EQ (cmap, BVAR (&buffer_defaults, fringe_indicator_alist))
-      && !NILP (BVAR (&buffer_defaults, fringe_indicator_alist)))
+  if (!EQ (cmap, BVAR_OR_DEFAULT (&buffer_defaults, fringe_indicator_alist))
+      && !NILP (BVAR_OR_DEFAULT (&buffer_defaults, fringe_indicator_alist)))
     {
-      bm2 = Fassq (bitmap, BVAR (&buffer_defaults, fringe_indicator_alist));
+      bm2 = Fassq (bitmap,
+		   BVAR_OR_DEFAULT (&buffer_defaults, fringe_indicator_alist));
       if (CONSP (bm2))
 	{
 	  if ((bm2 = XCDR (bm2)), !NILP (bm2))
@@ -970,7 +973,7 @@ update_window_fringes (struct window *w, bool keep_current_p)
     return 0;
 
   if (!MINI_WINDOW_P (w)
-      && (ind = BVAR (XBUFFER (w->contents), indicate_buffer_boundaries), !NILP (ind)))
+      && (ind = BVAR_OR_DEFAULT (XBUFFER (w->contents), indicate_buffer_boundaries), !NILP (ind)))
     {
       if (EQ (ind, Qleft) || EQ (ind, Qright))
 	boundary_top = boundary_bot = arrow_top = arrow_bot = ind;
@@ -1031,7 +1034,7 @@ update_window_fringes (struct window *w, bool keep_current_p)
 	}
     }
 
-  empty_pos = BVAR (XBUFFER (w->contents), indicate_empty_lines);
+  empty_pos = BVAR_OR_DEFAULT (XBUFFER (w->contents), indicate_empty_lines);
   if (!NILP (empty_pos) && !EQ (empty_pos, Qright))
     empty_pos = WINDOW_LEFT_FRINGE_WIDTH (w) == 0 ? Qright : Qleft;
 
diff --git a/src/hbfont.c b/src/hbfont.c
index e9f4085b1a..5f8f4d2445 100644
--- a/src/hbfont.c
+++ b/src/hbfont.c
@@ -443,7 +443,7 @@ hbfont_shape (Lisp_Object lgstring, Lisp_Object direction)
       /* If they bind bidi-display-reordering to nil, the DIRECTION
 	 they provide is meaningless, and we should let HarfBuzz guess
 	 the real direction.  */
-      && !NILP (BVAR (current_buffer, bidi_display_reordering)))
+      && !NILP (BVAR_OR_DEFAULT (current_buffer, bidi_display_reordering)))
     {
       hb_direction_t dir = HB_DIRECTION_LTR;
       if (EQ (direction, QL2R))
diff --git a/src/indent.c b/src/indent.c
index 6246b544fb..d30b5b3ad9 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -60,7 +60,7 @@ buffer_display_table (void)
 {
   Lisp_Object thisbuf;
 
-  thisbuf = BVAR (current_buffer, display_table);
+  thisbuf = BVAR_OR_DEFAULT (current_buffer, display_table);
   if (DISP_TABLE_P (thisbuf))
     return XCHAR_TABLE (thisbuf);
   if (DISP_TABLE_P (Vstandard_display_table))
@@ -153,13 +153,13 @@ width_run_cache_on_off (void)
       indirect_p = true;
     }
 
-  if (NILP (BVAR (current_buffer, cache_long_scans))
+  if (NILP (BVAR_OR_DEFAULT (current_buffer, cache_long_scans))
       /* And, for the moment, this feature doesn't work on multibyte
          characters.  */
       || !NILP (BVAR (current_buffer, enable_multibyte_characters)))
     {
       if (!indirect_p
-	  || NILP (BVAR (cache_buffer, cache_long_scans))
+	  || NILP (BVAR_OR_DEFAULT (cache_buffer, cache_long_scans))
 	  || !NILP (BVAR (cache_buffer, enable_multibyte_characters)))
 	{
 	  /* It should be off.  */
@@ -175,7 +175,7 @@ width_run_cache_on_off (void)
   else
     {
       if (!indirect_p
-	  || (!NILP (BVAR (cache_buffer, cache_long_scans))
+	  || (!NILP (BVAR_OR_DEFAULT (cache_buffer, cache_long_scans))
 	      && NILP (BVAR (cache_buffer, enable_multibyte_characters))))
 	{
 	  /* It should be on.  */
@@ -334,7 +334,7 @@ current_column (void)
   ptrdiff_t post_tab;
   int c;
   int tab_width = SANE_TAB_WIDTH (current_buffer);
-  bool ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
+  bool ctl_arrow = !NILP (BVAR_OR_DEFAULT (current_buffer, ctl_arrow));
   struct Lisp_Char_Table *dp = buffer_display_table ();
 
   if (PT == last_known_column_point
@@ -416,7 +416,7 @@ current_column (void)
 	    col++;
 	  else if (c == '\n'
 		   || (c == '\r'
-		       && EQ (BVAR (current_buffer, selective_display), Qt)))
+		       && EQ (BVAR_OR_DEFAULT (current_buffer, selective_display), Qt)))
 	    {
 	      ptr++;
 	      goto start_of_line_found;
@@ -531,7 +531,7 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol,
 		 ptrdiff_t *prevpos, ptrdiff_t *prevbpos, ptrdiff_t *prevcol)
 {
   int tab_width = SANE_TAB_WIDTH (current_buffer);
-  bool ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
+  bool ctl_arrow = !NILP (BVAR_OR_DEFAULT (current_buffer, ctl_arrow));
   struct Lisp_Char_Table *dp = buffer_display_table ();
   bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
   struct composition_it cmp_it;
@@ -652,7 +652,7 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol,
 
 	      if (c == '\n')
 		goto endloop;
-	      if (c == '\r' && EQ (BVAR (current_buffer, selective_display), Qt))
+	      if (c == '\r' && EQ (BVAR_OR_DEFAULT (current_buffer, selective_display), Qt))
 		goto endloop;
 	      if (c == '\t')
 		{
@@ -670,7 +670,7 @@ scan_for_column (ptrdiff_t *endpos, EMACS_INT *goalcol,
 
 	  if (c == '\n')
 	    goto endloop;
-	  if (c == '\r' && EQ (BVAR (current_buffer, selective_display), Qt))
+	  if (c == '\r' && EQ (BVAR_OR_DEFAULT (current_buffer, selective_display), Qt))
 	    goto endloop;
 	  if (c == '\t')
 	    {
@@ -1131,12 +1131,12 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos,
   ptrdiff_t pos_byte;
   int c = 0;
   int tab_width = SANE_TAB_WIDTH (current_buffer);
-  bool ctl_arrow = !NILP (BVAR (current_buffer, ctl_arrow));
+  bool ctl_arrow = !NILP (BVAR_OR_DEFAULT (current_buffer, ctl_arrow));
   struct Lisp_Char_Table *dp = window_display_table (win);
   EMACS_INT selective
-    = (FIXNUMP (BVAR (current_buffer, selective_display))
-       ? XFIXNUM (BVAR (current_buffer, selective_display))
-       : !NILP (BVAR (current_buffer, selective_display)) ? -1 : 0);
+    = (FIXNUMP (BVAR_OR_DEFAULT (current_buffer, selective_display))
+       ? XFIXNUM (BVAR_OR_DEFAULT (current_buffer, selective_display))
+       : !NILP (BVAR_OR_DEFAULT (current_buffer, selective_display)) ? -1 : 0);
   ptrdiff_t selective_rlen
     = (selective && dp && VECTORP (DISP_INVIS_VECTOR (dp))
        ? ASIZE (DISP_INVIS_VECTOR (dp)) : 0);
@@ -1352,7 +1352,7 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos,
 	    }
 
 	  if (hscroll || truncate
-	      || !NILP (BVAR (current_buffer, truncate_lines)))
+	      || !NILP (BVAR_OR_DEFAULT (current_buffer, truncate_lines)))
 	    {
 	      /* Truncating: skip to newline, unless we are already past
                  TO (we need to go back below).  */
@@ -1837,10 +1837,10 @@ vmotion (ptrdiff_t from, ptrdiff_t from_byte,
   register ptrdiff_t first;
   ptrdiff_t lmargin = hscroll > 0 ? 1 - hscroll : 0;
   ptrdiff_t selective
-    = (FIXNUMP (BVAR (current_buffer, selective_display))
-       ? clip_to_bounds (-1, XFIXNUM (BVAR (current_buffer, selective_display)),
+    = (FIXNUMP (BVAR_OR_DEFAULT (current_buffer, selective_display))
+       ? clip_to_bounds (-1, XFIXNUM (BVAR_OR_DEFAULT (current_buffer, selective_display)),
 			 PTRDIFF_MAX)
-       : !NILP (BVAR (current_buffer, selective_display)) ? -1 : 0);
+       : !NILP (BVAR_OR_DEFAULT (current_buffer, selective_display)) ? -1 : 0);
   Lisp_Object window;
   bool did_motion;
   /* This is the object we use for fetching character properties.  */
diff --git a/src/msdos.c b/src/msdos.c
index 5da01c9e7c..e3426d9403 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -1321,12 +1321,12 @@ IT_frame_up_to_date (struct frame *f)
     {
       struct buffer *b = XBUFFER (sw->contents);
 
-      if (EQ (BVAR (b,cursor_type), Qt))
+      if (EQ (BVAR_OR_DEFAULT (b, cursor_type), Qt))
 	new_cursor = frame_desired_cursor;
-      else if (NILP (BVAR (b, cursor_type))) /* nil means no cursor */
+      else if (NILP (BVAR_OR_DEFAULT (b, cursor_type))) /* nil means no cursor */
 	new_cursor = Fcons (Qbar, make_fixnum (0));
       else
-	new_cursor = BVAR (b, cursor_type);
+	new_cursor = BVAR_OR_DEFAULT (b, cursor_type);
     }
 
   IT_set_cursor_type (f, new_cursor);
diff --git a/src/search.c b/src/search.c
index c757bf3d1f..107034bf62 100644
--- a/src/search.c
+++ b/src/search.c
@@ -125,7 +125,8 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern,
 
   /* If the compiled pattern hard codes some of the contents of the
      syntax-table, it can only be reused with *this* syntax table.  */
-  cp->syntax_table = cp->buf.used_syntax ? BVAR (current_buffer, syntax_table) : Qt;
+  cp->syntax_table = cp->buf.used_syntax ? BVAR_OR_DEFAULT (current_buffer,
+							   syntax_table) : Qt;
 
   if (val)
     xsignal1 (Qinvalid_regexp, build_string (val));
@@ -219,7 +220,7 @@ compile_pattern (Lisp_Object pattern, struct re_registers *regp,
 	  && EQ (cp->buf.translate, translate)
 	  && cp->posix == posix
 	  && (EQ (cp->syntax_table, Qt)
-	      || EQ (cp->syntax_table, BVAR (current_buffer, syntax_table)))
+	      || EQ (cp->syntax_table, BVAR_OR_DEFAULT (current_buffer, syntax_table)))
 	  && !NILP (Fequal (cp->f_whitespace_regexp, Vsearch_spaces_regexp))
 	  && cp->buf.charset_unibyte == charset_unibyte)
 	break;
@@ -282,7 +283,7 @@ looking_at_1 (Lisp_Object string, bool posix)
   struct regexp_cache *cache_entry = compile_pattern (
     string,
     preserve_match_data ? &search_regs : NULL,
-    (!NILP (BVAR (current_buffer, case_fold_search))
+    (!NILP (BVAR_OR_DEFAULT (current_buffer, case_fold_search))
      ? BVAR (current_buffer, case_canon_table) : Qnil),
     posix,
     !NILP (BVAR (current_buffer, enable_multibyte_characters)));
@@ -401,7 +402,7 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start,
   bufp = &compile_pattern (regexp,
                            (NILP (Vinhibit_changing_match_data)
                             ? &search_regs : NULL),
-                           (!NILP (BVAR (current_buffer, case_fold_search))
+			   (!NILP (BVAR_OR_DEFAULT (current_buffer, case_fold_search))
                             ? BVAR (current_buffer, case_canon_table) : Qnil),
                            posix,
                            STRING_MULTIBYTE (string))->buf;
@@ -592,10 +593,10 @@ newline_cache_on_off (struct buffer *buf)
      This is because doing so will just make the cache pure overhead,
      since if we turn it on via indirect buffer, it will be
      immediately turned off by its base buffer.  */
-  if (NILP (BVAR (buf, cache_long_scans)))
+  if (NILP (BVAR_OR_DEFAULT (buf, cache_long_scans)))
     {
       if (!indirect_p
-	  || NILP (BVAR (base_buf, cache_long_scans)))
+	  || NILP (BVAR_OR_DEFAULT (base_buf, cache_long_scans)))
 	{
 	  /* It should be off.  */
 	  if (base_buf->newline_cache)
@@ -609,7 +610,7 @@ newline_cache_on_off (struct buffer *buf)
   else
     {
       if (!indirect_p
-	  || !NILP (BVAR (base_buf, cache_long_scans)))
+	  || !NILP (BVAR_OR_DEFAULT (base_buf, cache_long_scans)))
 	{
 	  /* It should be on.  */
 	  if (base_buf->newline_cache == 0)
@@ -1048,10 +1049,10 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
 			 BVAR (current_buffer, case_eqv_table));
 
   np = search_buffer (string, PT, PT_BYTE, lim, lim_byte, n, RE,
-		      (!NILP (BVAR (current_buffer, case_fold_search))
+		      (!NILP (BVAR_OR_DEFAULT (current_buffer, case_fold_search))
 		       ? BVAR (current_buffer, case_canon_table)
 		       : Qnil),
-		      (!NILP (BVAR (current_buffer, case_fold_search))
+		      (!NILP (BVAR_OR_DEFAULT (current_buffer, case_fold_search))
 		       ? BVAR (current_buffer, case_eqv_table)
 		       : Qnil),
 		      posix);
@@ -3275,7 +3276,7 @@ the buffer.  If the buffer doesn't have a cache, the value is nil.  */)
     buf = buf->base_buffer;
 
   /* If the buffer doesn't have a newline cache, return nil.  */
-  if (NILP (BVAR (buf, cache_long_scans))
+  if (NILP (BVAR_OR_DEFAULT (buf, cache_long_scans))
       || buf->newline_cache == NULL)
     return Qnil;
 
diff --git a/src/syntax.c b/src/syntax.c
index 9fbf88535f..17753f50b7 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -416,7 +416,8 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, bool init,
       else
 	{
 	  gl_state.use_global = 0;
-	  gl_state.current_syntax_table = BVAR (current_buffer, syntax_table);
+	  gl_state.current_syntax_table = BVAR_OR_DEFAULT (current_buffer,
+							  syntax_table);
 	}
     }
 
@@ -998,7 +999,7 @@ DEFUN ("syntax-table", Fsyntax_table, Ssyntax_table, 0, 0, 0,
 This is the one specified by the current buffer.  */)
   (void)
 {
-  return BVAR (current_buffer, syntax_table);
+  return BVAR_OR_DEFAULT (current_buffer, syntax_table);
 }
 
 DEFUN ("standard-syntax-table", Fstandard_syntax_table,
@@ -1254,7 +1255,7 @@ usage: (modify-syntax-entry CHAR NEWENTRY &optional SYNTAX-TABLE)  */)
     CHECK_CHARACTER (c);
 
   if (NILP (syntax_table))
-    syntax_table = BVAR (current_buffer, syntax_table);
+    syntax_table = BVAR_OR_DEFAULT (current_buffer, syntax_table);
   else
     check_syntax_table (syntax_table);
 
diff --git a/src/syntax.h b/src/syntax.h
index 66ee139a96..187946c899 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -103,7 +103,7 @@ syntax_property_entry (int c, bool via_property)
     return (gl_state.use_global
 	    ? gl_state.global_code
 	    : CHAR_TABLE_REF (gl_state.current_syntax_table, c));
-  return CHAR_TABLE_REF (BVAR (current_buffer, syntax_table), c);
+  return CHAR_TABLE_REF (BVAR_OR_DEFAULT (current_buffer, syntax_table), c);
 }
 INLINE Lisp_Object
 SYNTAX_ENTRY (int c)
@@ -212,7 +212,8 @@ SETUP_BUFFER_SYNTAX_TABLE (void)
 {
   gl_state.use_global = false;
   gl_state.e_property_truncated = false;
-  gl_state.current_syntax_table = BVAR (current_buffer, syntax_table);
+  gl_state.current_syntax_table = BVAR_OR_DEFAULT (current_buffer,
+						  syntax_table);
 }
 
 extern ptrdiff_t scan_words (ptrdiff_t, EMACS_INT);
diff --git a/src/window.c b/src/window.c
index 0a14eca58f..b85f758679 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2315,8 +2315,8 @@ window_display_table (struct window *w)
     {
       struct buffer *b = XBUFFER (w->contents);
 
-      if (DISP_TABLE_P (BVAR (b, display_table)))
-	dp = XCHAR_TABLE (BVAR (b, display_table));
+      if (DISP_TABLE_P (BVAR_OR_DEFAULT (b, display_table)))
+	dp = XCHAR_TABLE (BVAR_OR_DEFAULT (b, display_table));
       else if (DISP_TABLE_P (Vstandard_display_table))
 	dp = XCHAR_TABLE (Vstandard_display_table);
     }
@@ -4044,17 +4044,18 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer,
       /* Set fringes and scroll bars from buffer unless they have been
 	 declared as persistent.  */
       if (!w->fringes_persistent)
-	set_window_fringes (w, BVAR (b, left_fringe_width),
-			    BVAR (b, right_fringe_width),
-			    BVAR (b, fringes_outside_margins), Qnil);
+	set_window_fringes (w, BVAR_OR_DEFAULT (b, left_fringe_width),
+			    BVAR_OR_DEFAULT (b, right_fringe_width),
+			    BVAR_OR_DEFAULT (b, fringes_outside_margins), Qnil);
       if (!w->scroll_bars_persistent)
-	set_window_scroll_bars (w, BVAR (b, scroll_bar_width),
-				BVAR (b, vertical_scroll_bar_type),
-				BVAR (b, scroll_bar_height),
-				BVAR (b, horizontal_scroll_bar_type), Qnil);
+	set_window_scroll_bars (w, BVAR_OR_DEFAULT (b, scroll_bar_width),
+				BVAR_OR_DEFAULT (b, vertical_scroll_bar_type),
+				BVAR_OR_DEFAULT (b, scroll_bar_height),
+				BVAR_OR_DEFAULT (b, horizontal_scroll_bar_type),
+				Qnil);
       /* Set left and right marginal area width from buffer.  */
-      set_window_margins (w, BVAR (b, left_margin_cols),
-			  BVAR (b, right_margin_cols));
+      set_window_margins (w, BVAR_OR_DEFAULT (b, left_margin_cols),
+			  BVAR_OR_DEFAULT (b, right_margin_cols));
       apply_window_adjustment (w);
     }
 
@@ -5372,7 +5373,7 @@ window_wants_mode_line (struct window *w)
 	  && !WINDOW_PSEUDO_P (w)
 	  && !EQ (window_mode_line_format, Qnone)
 	  && (!NILP (window_mode_line_format)
-	      || !NILP (BVAR (XBUFFER (WINDOW_BUFFER (w)), mode_line_format)))
+	      || !NILP (BVAR_OR_DEFAULT (XBUFFER(WINDOW_BUFFER(w)), mode_line_format)))
 	  && WINDOW_PIXEL_HEIGHT (w) > WINDOW_FRAME_LINE_HEIGHT (w));
 }
 
@@ -5401,7 +5402,7 @@ window_wants_header_line (struct window *w)
 	  && !WINDOW_PSEUDO_P (w)
 	  && !EQ (window_header_line_format, Qnone)
 	  && (!NILP (window_header_line_format)
-	      || !NILP (BVAR (XBUFFER (WINDOW_BUFFER (w)), header_line_format)))
+	      || !NILP (BVAR_OR_DEFAULT (XBUFFER(WINDOW_BUFFER(w)), header_line_format)))
 	  && (WINDOW_PIXEL_HEIGHT (w)
 	      > (window_wants_mode_line (w)
 		 ? 2 * WINDOW_FRAME_LINE_HEIGHT (w)
@@ -5435,7 +5436,7 @@ window_wants_tab_line (struct window *w)
 	  && !WINDOW_PSEUDO_P (w)
 	  && !EQ (window_tab_line_format, Qnone)
 	  && (!NILP (window_tab_line_format)
-	      || !NILP (BVAR (XBUFFER (WINDOW_BUFFER (w)), tab_line_format)))
+	      || !NILP (BVAR_OR_DEFAULT (XBUFFER(WINDOW_BUFFER(w)), tab_line_format)))
 	  && (WINDOW_PIXEL_HEIGHT (w)
 	      > (((window_wants_mode_line (w) ? 1 : 0)
 		  + (window_wants_header_line (w) ? 1 : 0)
diff --git a/src/xdisp.c b/src/xdisp.c
index 23b4ba5c39..d978bf69e6 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -595,7 +595,7 @@ fill_column_indicator_column (struct it *it, int char_width)
       && CHARACTERP (Vdisplay_fill_column_indicator_character))
     {
       Lisp_Object col = (EQ (Vdisplay_fill_column_indicator_column, Qt)
-			 ? BVAR (current_buffer, fill_column)
+			 ? BVAR_OR_DEFAULT (current_buffer, fill_column)
 			 : Vdisplay_fill_column_indicator_column);
 
       /* The stretch width needs to consider the latter
@@ -1543,10 +1543,10 @@ default_line_pixel_height (struct window *w)
   if (!FRAME_INITIAL_P (f) && BUFFERP (w->contents))
     {
       struct buffer *b = XBUFFER (w->contents);
-      Lisp_Object val = BVAR (b, extra_line_spacing);
+      Lisp_Object val = BVAR_OR_DEFAULT (b, extra_line_spacing);
 
       if (NILP (val))
-	val = BVAR (&buffer_defaults, extra_line_spacing);
+	val = BVAR_OR_DEFAULT (&buffer_defaults, extra_line_spacing);
       if (!NILP (val))
 	{
 	  if (RANGED_FIXNUMP (0, val, INT_MAX))
@@ -1684,7 +1684,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
       w->mode_line_height
 	= display_mode_line (w, CURRENT_MODE_LINE_FACE_ID (w),
 			     NILP (window_mode_line_format)
-			     ? BVAR (current_buffer, mode_line_format)
+			     ? BVAR_OR_DEFAULT (current_buffer, mode_line_format)
 			     : window_mode_line_format);
     }
 
@@ -1696,7 +1696,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
       w->tab_line_height
 	= display_mode_line (w, TAB_LINE_FACE_ID,
 			     NILP (window_tab_line_format)
-			     ? BVAR (current_buffer, tab_line_format)
+			     ? BVAR_OR_DEFAULT (current_buffer, tab_line_format)
 			     : window_tab_line_format);
     }
 
@@ -1708,7 +1708,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
       w->header_line_height
 	= display_mode_line (w, HEADER_LINE_FACE_ID,
 			     NILP (window_header_line_format)
-			     ? BVAR (current_buffer, header_line_format)
+			     ? BVAR_OR_DEFAULT (current_buffer, header_line_format)
 			     : window_header_line_format);
     }
 
@@ -3205,10 +3205,10 @@ init_iterator (struct it *it, struct window *w,
   if (base_face_id == DEFAULT_FACE_ID
       && FRAME_WINDOW_P (it->f))
     {
-      if (FIXNATP (BVAR (current_buffer, extra_line_spacing)))
-	it->extra_line_spacing = XFIXNAT (BVAR (current_buffer, extra_line_spacing));
-      else if (FLOATP (BVAR (current_buffer, extra_line_spacing)))
-	it->extra_line_spacing = (XFLOAT_DATA (BVAR (current_buffer, extra_line_spacing))
+      if (FIXNATP (BVAR_OR_DEFAULT (current_buffer, extra_line_spacing)))
+	it->extra_line_spacing = XFIXNAT (BVAR_OR_DEFAULT (current_buffer, extra_line_spacing));
+      else if (FLOATP (BVAR_OR_DEFAULT (current_buffer, extra_line_spacing)))
+	it->extra_line_spacing = (XFLOAT_DATA (BVAR_OR_DEFAULT (current_buffer, extra_line_spacing))
 				  * FRAME_LINE_HEIGHT (it->f));
       else if (it->f->extra_line_spacing > 0)
 	it->extra_line_spacing = it->f->extra_line_spacing;
@@ -3226,19 +3226,19 @@ init_iterator (struct it *it, struct window *w,
   it->override_ascent = -1;
 
   /* Are control characters displayed as `^C'?  */
-  it->ctl_arrow_p = !NILP (BVAR (current_buffer, ctl_arrow));
+  it->ctl_arrow_p = !NILP (BVAR_OR_DEFAULT (current_buffer, ctl_arrow));
 
   /* -1 means everything between a CR and the following line end
      is invisible.  >0 means lines indented more than this value are
      invisible.  */
-  it->selective = (FIXNUMP (BVAR (current_buffer, selective_display))
+  it->selective = (FIXNUMP (BVAR_OR_DEFAULT (current_buffer, selective_display))
 		   ? (clip_to_bounds
-		      (-1, XFIXNUM (BVAR (current_buffer, selective_display)),
+		      (-1, XFIXNUM (BVAR_OR_DEFAULT (current_buffer, selective_display)),
 		       PTRDIFF_MAX))
-		   : (!NILP (BVAR (current_buffer, selective_display))
+		   : (!NILP (BVAR_OR_DEFAULT (current_buffer, selective_display))
 		      ? -1 : 0));
   it->selective_display_ellipsis_p
-    = !NILP (BVAR (current_buffer, selective_display_ellipses));
+    = !NILP (BVAR_OR_DEFAULT (current_buffer, selective_display_ellipses));
 
   /* Display table to use.  */
   it->dp = window_display_table (w);
@@ -3270,8 +3270,8 @@ init_iterator (struct it *it, struct window *w,
 	      /* PXW: Shall we do something about this?  */
 	      && (XFIXNUM (Vtruncate_partial_width_windows)
 		  <= WINDOW_TOTAL_COLS (it->w))))
-      && NILP (BVAR (current_buffer, truncate_lines)))
-    it->line_wrap = NILP (BVAR (current_buffer, word_wrap))
+      && NILP (BVAR_OR_DEFAULT (current_buffer, truncate_lines)))
+    it->line_wrap = NILP (BVAR_OR_DEFAULT (current_buffer, word_wrap))
       ? WINDOW_WRAP : WORD_WRAP;
 
   /* Get dimensions of truncation and continuation glyphs.  These are
@@ -3416,7 +3416,7 @@ init_iterator (struct it *it, struct window *w,
 	 available.  */
       it->bidi_p =
 	!redisplay__inhibit_bidi
-	&& !NILP (BVAR (current_buffer, bidi_display_reordering))
+	&& !NILP (BVAR_OR_DEFAULT (current_buffer, bidi_display_reordering))
 	&& it->multibyte_p;
 
       /* If we are to reorder bidirectional text, init the bidi
@@ -3438,10 +3438,10 @@ init_iterator (struct it *it, struct window *w,
 	    }
 	  /* Note the paragraph direction that this buffer wants to
 	     use.  */
-	  if (EQ (BVAR (current_buffer, bidi_paragraph_direction),
+	  if (EQ (BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_direction),
 		  Qleft_to_right))
 	    it->paragraph_embedding = L2R;
-	  else if (EQ (BVAR (current_buffer, bidi_paragraph_direction),
+	  else if (EQ (BVAR_OR_DEFAULT (current_buffer, bidi_paragraph_direction),
 		       Qright_to_left))
 	    it->paragraph_embedding = R2L;
 	  else
@@ -7208,7 +7208,7 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
      not yet available.  */
   it->bidi_p =
     !redisplay__inhibit_bidi
-    && !NILP (BVAR (&buffer_defaults, bidi_display_reordering));
+    && !NILP (BVAR_OR_DEFAULT (&buffer_defaults, bidi_display_reordering));
 
   if (s == NULL)
     {
@@ -12140,7 +12140,7 @@ set_message_1 (void *a1, Lisp_Object string)
     Fset_buffer_multibyte (Qt);
 
   bset_truncate_lines (current_buffer, message_truncate_lines ? Qt : Qnil);
-  if (!NILP (BVAR (current_buffer, bidi_display_reordering)))
+  if (!NILP (BVAR_OR_DEFAULT (current_buffer, bidi_display_reordering)))
     bset_bidi_paragraph_direction (current_buffer, Qleft_to_right);
 
   /* Insert new message at BEG.  */
@@ -15187,8 +15187,8 @@ text_outside_line_unchanged_p (struct window *w,
       /* If selective display, can't optimize if changes start at the
 	 beginning of the line.  */
       if (unchanged_p
-	  && FIXNUMP (BVAR (current_buffer, selective_display))
-	  && XFIXNUM (BVAR (current_buffer, selective_display)) > 0
+	  && FIXNUMP (BVAR_OR_DEFAULT (current_buffer, selective_display))
+	  && XFIXNUM (BVAR_OR_DEFAULT (current_buffer, selective_display)) > 0
 	  && (BEG_UNCHANGED < start || GPT <= start))
 	unchanged_p = false;
 
@@ -15216,8 +15216,8 @@ text_outside_line_unchanged_p (struct window *w,
 	 require redisplaying the whole paragraph.  It might be worthwhile
 	 to find the paragraph limits and widen the range of redisplayed
 	 lines to that, but for now just give up this optimization.  */
-      if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))
-	  && NILP (BVAR (XBUFFER (w->contents), bidi_paragraph_direction)))
+      if (!NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_display_reordering))
+	  && NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_paragraph_direction)))
 	unchanged_p = false;
     }
 
@@ -17395,8 +17395,8 @@ try_scrolling (Lisp_Object window, bool just_this_one_p,
       int scroll_lines = clip_to_bounds (0, scroll_lines_max, 1000000);
       scroll_max = scroll_lines * frame_line_height;
     }
-  else if (NUMBERP (BVAR (current_buffer, scroll_down_aggressively))
-	   || NUMBERP (BVAR (current_buffer, scroll_up_aggressively)))
+  else if (NUMBERP (BVAR_OR_DEFAULT (current_buffer, scroll_down_aggressively))
+	   || NUMBERP (BVAR_OR_DEFAULT (current_buffer, scroll_up_aggressively)))
     /* We're trying to scroll because of aggressive scrolling but no
        scroll_step is set.  Choose an arbitrary one.  */
     scroll_max = 10 * frame_line_height;
@@ -17494,7 +17494,7 @@ try_scrolling (Lisp_Object window, bool just_this_one_p,
 	amount_to_scroll = scroll_max;
       else
 	{
-	  aggressive = BVAR (current_buffer, scroll_up_aggressively);
+	  aggressive = BVAR_OR_DEFAULT (current_buffer, scroll_up_aggressively);
 	  height = WINDOW_BOX_TEXT_HEIGHT (w);
 	  if (NUMBERP (aggressive))
 	    {
@@ -17610,7 +17610,8 @@ try_scrolling (Lisp_Object window, bool just_this_one_p,
 	    amount_to_scroll = scroll_max;
 	  else
 	    {
-	      aggressive = BVAR (current_buffer, scroll_down_aggressively);
+	      aggressive = BVAR_OR_DEFAULT (current_buffer,
+					   scroll_down_aggressively);
 	      height = WINDOW_BOX_TEXT_HEIGHT (w);
 	      if (NUMBERP (aggressive))
 		{
@@ -17997,7 +17998,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp,
 	      must_scroll = true;
 	    }
 	  else if (rc != CURSOR_MOVEMENT_SUCCESS
-		   && !NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)))
+		   && !NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_display_reordering)))
 	    {
 	      struct glyph_row *row1;
 
@@ -18061,7 +18062,7 @@ try_cursor_movement (Lisp_Object window, struct text_pos startp,
 	  else if (scroll_p)
 	    rc = CURSOR_MOVEMENT_MUST_SCROLL;
 	  else if (rc != CURSOR_MOVEMENT_SUCCESS
-		   && !NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)))
+		   && !NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_display_reordering)))
 	    {
 	      /* With bidi-reordered rows, there could be more than
 		 one candidate row whose start and end positions
@@ -18906,8 +18907,8 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
        || (scroll_minibuffer_conservatively && MINI_WINDOW_P (w))
        || 0 < emacs_scroll_step
        || temp_scroll_step
-       || NUMBERP (BVAR (current_buffer, scroll_up_aggressively))
-       || NUMBERP (BVAR (current_buffer, scroll_down_aggressively)))
+       || NUMBERP (BVAR_OR_DEFAULT (current_buffer, scroll_up_aggressively))
+       || NUMBERP (BVAR_OR_DEFAULT (current_buffer, scroll_down_aggressively)))
       && CHARPOS (startp) >= BEGV
       && CHARPOS (startp) <= ZV)
     {
@@ -18981,8 +18982,8 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
       scrolling_up = PT > margin_pos;
       aggressive =
 	scrolling_up
-	? BVAR (current_buffer, scroll_up_aggressively)
-	: BVAR (current_buffer, scroll_down_aggressively);
+	? BVAR_OR_DEFAULT (current_buffer, scroll_up_aggressively)
+	: BVAR_OR_DEFAULT (current_buffer, scroll_down_aggressively);
 
       if (!MINI_WINDOW_P (w)
 	  && (scroll_conservatively > SCROLL_LIMIT || NUMBERP (aggressive)))
@@ -19917,7 +19918,7 @@ try_window_reusing_current_matrix (struct window *w)
 		 bidi-reordered glyph rows.  Let set_cursor_from_row
 		 figure out where to put the cursor, and if it fails,
 		 give up.  */
-	      if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)))
+	      if (!NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_display_reordering)))
 		{
 		  if (!set_cursor_from_row (w, row, w->current_matrix,
 					    0, 0, 0, 0))
@@ -20236,7 +20237,7 @@ row_containing_pos (struct window *w, ptrdiff_t charpos,
 	{
 	  struct glyph *g;
 
-	  if (NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))
+	  if (NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_display_reordering))
 	      || (!best_row && !row->continued_p))
 	    return row;
 	  /* In bidi-reordered rows, there could be several rows whose
@@ -20406,7 +20407,7 @@ try_window_id (struct window *w)
      wrapped line can change the wrap position, altering the line
      above it.  It might be worthwhile to handle this more
      intelligently, but for now just redisplay from scratch.  */
-  if (!NILP (BVAR (XBUFFER (w->contents), word_wrap)))
+  if (!NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), word_wrap)))
     GIVE_UP (21);
 
   /* Under bidi reordering, adding or deleting a character in the
@@ -20417,13 +20418,13 @@ try_window_id (struct window *w)
      to find the paragraph limits and widen the range of redisplayed
      lines to that, but for now just give up this optimization and
      redisplay from scratch.  */
-  if (!NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering))
-      && NILP (BVAR (XBUFFER (w->contents), bidi_paragraph_direction)))
+  if (!NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_display_reordering))
+      && NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), bidi_paragraph_direction)))
     GIVE_UP (22);
 
   /* Give up if the buffer has line-spacing set, as Lisp-level changes
      to that variable require thorough redisplay.  */
-  if (!NILP (BVAR (XBUFFER (w->contents), extra_line_spacing)))
+  if (!NILP (BVAR_OR_DEFAULT (XBUFFER(w->contents), extra_line_spacing)))
     GIVE_UP (23);
 
   /* Give up if display-line-numbers is in relative mode, or when the
@@ -23532,7 +23533,7 @@ display_line (struct it *it, int cursor_vpos)
 	      if (!row_has_glyphs)
 		row->displays_text_p = false;
 
-	      if (!NILP (BVAR (XBUFFER (it->w->contents), indicate_empty_lines))
+	      if (!NILP (BVAR_OR_DEFAULT (XBUFFER (it->w->contents), indicate_empty_lines))
 		  && (!MINI_WINDOW_P (it->w)))
 		row->indicate_empty_line_p = true;
 	    }
@@ -24306,14 +24307,14 @@ See also `bidi-paragraph-direction'.  */)
       buf = XBUFFER (buffer);
     }
 
-  if (NILP (BVAR (buf, bidi_display_reordering))
+  if (NILP (BVAR_OR_DEFAULT (buf, bidi_display_reordering))
       || NILP (BVAR (buf, enable_multibyte_characters))
       /* When we are loading loadup.el, the character property tables
 	 needed for bidi iteration are not yet available.  */
       || redisplay__inhibit_bidi)
     return Qleft_to_right;
-  else if (!NILP (BVAR (buf, bidi_paragraph_direction)))
-    return BVAR (buf, bidi_paragraph_direction);
+  else if (!NILP (BVAR_OR_DEFAULT (buf, bidi_paragraph_direction)))
+    return BVAR_OR_DEFAULT (buf, bidi_paragraph_direction);
   else
     {
       /* Determine the direction from buffer text.  We could try to
@@ -24457,7 +24458,7 @@ the `bidi-class' property of a character.  */)
     {
       /* Nothing this fancy can happen in unibyte buffers, or in a
 	 buffer that disabled reordering, or if FROM is at EOB.  */
-      if (NILP (BVAR (buf, bidi_display_reordering))
+      if (NILP (BVAR_OR_DEFAULT (buf, bidi_display_reordering))
 	  || NILP (BVAR (buf, enable_multibyte_characters))
 	  /* When we are loading loadup.el, the character property
 	     tables needed for bidi iteration are not yet
@@ -25412,7 +25413,7 @@ display_mode_lines (struct window *w)
       /* Select mode line face based on the real selected window.  */
       display_mode_line (w, CURRENT_MODE_LINE_FACE_ID_3 (sel_w, sel_w, w),
 			 NILP (window_mode_line_format)
-			 ? BVAR (current_buffer, mode_line_format)
+			 ? BVAR_OR_DEFAULT (current_buffer, mode_line_format)
 			 : window_mode_line_format);
       ++n;
     }
@@ -25424,7 +25425,7 @@ display_mode_lines (struct window *w)
 
       display_mode_line (w, TAB_LINE_FACE_ID,
 			 NILP (window_tab_line_format)
-			 ? BVAR (current_buffer, tab_line_format)
+			 ? BVAR_OR_DEFAULT (current_buffer, tab_line_format)
 			 : window_tab_line_format);
       ++n;
     }
@@ -25436,7 +25437,7 @@ display_mode_lines (struct window *w)
 
       display_mode_line (w, HEADER_LINE_FACE_ID,
 			 NILP (window_header_line_format)
-			 ? BVAR (current_buffer, header_line_format)
+			 ? BVAR_OR_DEFAULT (current_buffer, header_line_format)
 			 : window_header_line_format);
       ++n;
     }
@@ -26971,7 +26972,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
 					 (FRAME_TERMINAL_CODING (f)->id),
 					 p, false);
 	  }
-	p = decode_mode_spec_coding (BVAR (b, buffer_file_coding_system),
+	p = decode_mode_spec_coding (BVAR_OR_DEFAULT (b, buffer_file_coding_system),
 				     p, eol_flag);
 
 #if false /* This proves to be annoying; I think we can do without. -- rms.  */
@@ -27035,8 +27036,8 @@ display_count_lines (ptrdiff_t start_byte,
   /* If we are not in selective display mode,
      check only for newlines.  */
   bool selective_display
-    = (!NILP (BVAR (current_buffer, selective_display))
-       && !FIXNUMP (BVAR (current_buffer, selective_display)));
+    = (!NILP (BVAR_OR_DEFAULT (current_buffer, selective_display))
+       && !FIXNUMP (BVAR_OR_DEFAULT (current_buffer, selective_display)));
 
   if (count > 0)
     {
@@ -31350,13 +31351,14 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
     {
       if (w == XWINDOW (echo_area_window))
 	{
-	  if (EQ (BVAR (b, cursor_type), Qt) || NILP (BVAR (b, cursor_type)))
+	  if (EQ (BVAR_OR_DEFAULT (b, cursor_type), Qt) || NILP (BVAR_OR_DEFAULT (b, cursor_type)))
 	    {
 	      *width = FRAME_CURSOR_WIDTH (f);
 	      return FRAME_DESIRED_CURSOR (f);
 	    }
 	  else
-	    return get_specified_cursor_type (BVAR (b, cursor_type), width);
+	    return get_specified_cursor_type (BVAR_OR_DEFAULT (b, cursor_type),
+					      width);
 	}
 
       *active_cursor = false;
@@ -31378,23 +31380,24 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
     }
 
   /* Never display a cursor in a window in which cursor-type is nil.  */
-  if (NILP (BVAR (b, cursor_type)))
+  if (NILP (BVAR_OR_DEFAULT (b, cursor_type)))
     return NO_CURSOR;
 
   /* Get the normal cursor type for this window.  */
-  if (EQ (BVAR (b, cursor_type), Qt))
+  if (EQ (BVAR_OR_DEFAULT (b, cursor_type), Qt))
     {
       cursor_type = FRAME_DESIRED_CURSOR (f);
       *width = FRAME_CURSOR_WIDTH (f);
     }
   else
-    cursor_type = get_specified_cursor_type (BVAR (b, cursor_type), width);
+    cursor_type = get_specified_cursor_type (BVAR_OR_DEFAULT (b, cursor_type),
+					     width);
 
   /* Use cursor-in-non-selected-windows instead
      for non-selected window or frame.  */
   if (non_selected)
     {
-      alt_cursor = BVAR (b, cursor_in_non_selected_windows);
+      alt_cursor = BVAR_OR_DEFAULT (b, cursor_in_non_selected_windows);
       if (!EQ (Qt, alt_cursor))
 	return get_specified_cursor_type (alt_cursor, width);
       /* t means modify the normal cursor type.  */
@@ -31428,7 +31431,7 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
 		     should cover most of the "tiny" icons people may
 		     use.  */
 		  if (!img->mask
-		      || (CONSP (BVAR (b, cursor_type))
+		      || (CONSP (BVAR_OR_DEFAULT (b, cursor_type))
 			  && img->width > max (*width, WINDOW_FRAME_COLUMN_WIDTH (w))
 			  && img->height > max (*width, WINDOW_FRAME_LINE_HEIGHT (w))))
 		    cursor_type = HOLLOW_BOX_CURSOR;
@@ -31448,7 +31451,7 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
   /* Cursor is blinked off, so determine how to "toggle" it.  */
 
   /* First look for an entry matching the buffer's cursor-type in blink-cursor-alist.  */
-  if ((alt_cursor = Fassoc (BVAR (b, cursor_type), Vblink_cursor_alist, Qnil), !NILP (alt_cursor)))
+  if ((alt_cursor = Fassoc (BVAR_OR_DEFAULT (b, cursor_type), Vblink_cursor_alist, Qnil), !NILP (alt_cursor)))
     return get_specified_cursor_type (XCDR (alt_cursor), width);
 
   /* Then see if frame has specified a specific blink off cursor type.  */
@@ -33853,11 +33856,10 @@ note_mouse_highlight (struct frame *f, int x, int y)
 		     necessarily display the character whose position
 		     is the smallest.  */
 		  Lisp_Object lim1
-		    = NILP (BVAR (XBUFFER (buffer), bidi_display_reordering))
+		    = NILP (BVAR_OR_DEFAULT (XBUFFER(buffer), bidi_display_reordering))
 		    ? Fmarker_position (w->start)
 		    : Qnil;
-		  Lisp_Object lim2
-		    = NILP (BVAR (XBUFFER (buffer), bidi_display_reordering))
+		  Lisp_Object lim2 = NILP (BVAR_OR_DEFAULT (XBUFFER(buffer), bidi_display_reordering))
 		    ? make_fixnum (BUF_Z (XBUFFER (buffer))
 				   - w->window_end_pos)
 		    : Qnil;
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index b1e5fa0767..eae2109fe6 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -424,7 +424,6 @@ comparing the subr with a much slower lisp implementation."
   (with-no-warnings (should (setq :keyword :keyword))))
 
 (ert-deftest data-tests--set-default-per-buffer ()
-  :expected-result t ;; Not fixed yet!
   ;; FIXME: Performance tests are inherently unreliable.
   ;; Using wall-clock time makes it even worse, so don't bother unless
   ;; we have the primitive to measure cpu-time.
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 10/14] Delete SET_PER_BUFFER_VALUE_P and buffer local_flags field
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:06 +0000
Resent-Message-ID: <handler.48264.B48264.162043978424895 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043978424895
          (code B ref 48264); Sat, 08 May 2021 02:10:06 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:44 +0000
Received: from localhost ([127.0.0.1]:47179 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCPX-0006TN-Ji
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:44 -0400
Received: from venus.catern.com ([68.183.49.163]:47938)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCPE-0006SC-TM
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:25 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439764; bh=MEyy0A2YP8u5ssAThorcbaLAo1cSywAys80Leu8gxqY=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=DbI29vwbWLPpLT/AMM1mpms2qWy4FqNvRgqgmvTp3w9MNzn0stXqiLC3Vn1AQ2+jM
 idDOtpq/1pfsvMus0OlLxyaPqedtH9w+EmEWOmQHxZLIxg4NdZp7BeLfBnL9VMvL2J
 ToIjloE5pL+tsHg3vcPfc4HtMYMfN2aJFjul6wy0=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id C734F2E9830;
 Sat,  8 May 2021 02:09:24 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:09:01 -0400
Message-Id: <20210508020905.13583-12-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

SET_PER_BUFFER_VALUE_P is now obsolete.  Whether a per-buffer variable
has a buffer-local value is now determined purely by the value stored
in the field; if it's set to Qunbound, there's no buffer-local value,
and anything else means there is a buffer-local value.  Thus merely
setting the field is sufficient to make the variable buffer-local, and
so we have no more need for a separate SET_PER_BUFFER_VALUE_P to
update the metadata, nor any need for the metadata itself.

* src/buffer.h (struct buffer): Remove local_flags field.
(SET_PER_BUFFER_VALUE_P): Remove.
(KILL_PER_BUFFER_VALUE): Stop using SET_PER_BUFFER_VALUE_P.
* src/buffer.c (Fget_buffer_create, clone_per_buffer_values)
(Fmake_indirect_buffer): Stop initializing local_flags.
* src/category.c (Fset_category_table):
* src/data.c (store_symval_forwarding):
* src/syntax.c (Fset_syntax_table): Stop using SET_PER_BUFFER_VALUE_P.
* src/pdumper.c (dump_buffer): Stop dumping local_flags field.
---
 src/buffer.c   |  6 ------
 src/buffer.h   | 19 -------------------
 src/category.c |  4 ----
 src/data.c     |  3 ---
 src/pdumper.c  |  3 ---
 src/syntax.c   |  4 ----
 6 files changed, 39 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index b4345ca308..a7d31c1e5b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -560,8 +560,6 @@ even if it is dead.  The return value is never nil.  */)
   /* No one shows us now.  */
   b->window_count = 0;
 
-  memset (&b->local_flags, 0, sizeof (b->local_flags));
-
   BUF_GAP_SIZE (b) = 20;
   block_input ();
   /* We allocate extra 1-byte at the tail and keep it always '\0' for
@@ -717,8 +715,6 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to)
       set_per_buffer_value (to, offset, obj);
     }
 
-  memcpy (to->local_flags, from->local_flags, sizeof to->local_flags);
-
   set_buffer_overlays_before (to, copy_overlays (to, from->overlays_before));
   set_buffer_overlays_after (to, copy_overlays (to, from->overlays_after));
 
@@ -820,8 +816,6 @@ CLONE nil means the indirect buffer's state is reset to default values.  */)
   /* Always -1 for an indirect buffer.  */
   b->window_count = -1;
 
-  memset (&b->local_flags, 0, sizeof (b->local_flags));
-
   b->pt = b->base_buffer->pt;
   b->begv = b->base_buffer->begv;
   b->zv = b->base_buffer->zv;
diff --git a/src/buffer.h b/src/buffer.h
index db725250d6..0445fe0edf 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -605,13 +605,6 @@ struct buffer
      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
-     in buffer_local_flags as a Lisp integer.  If the index is -1,
-     this means the variable is always local in all buffers.  */
-  char local_flags[MAX_PER_BUFFER_VARS];
-
   /* Set to the modtime of the visited file when read or written.
      modtime.tv_nsec == NONEXISTENT_MODTIME_NSECS means
      visited file was nonexistent.  modtime.tv_nsec ==
@@ -1417,16 +1410,6 @@ OVERLAY_POSITION (Lisp_Object p)
 
 extern bool valid_per_buffer_idx (int);
 
-/* Set whether per-buffer variable with index IDX has a buffer-local
-   value in buffer B.  VAL zero means it hasn't.  */
-
-INLINE void
-SET_PER_BUFFER_VALUE_P (struct buffer *b, int idx, bool val)
-{
-  eassert (valid_per_buffer_idx (idx));
-  b->local_flags[idx] = val;
-}
-
 /* Return the index value of the per-buffer variable at offset OFFSET
    in the buffer structure.
 
@@ -1516,8 +1499,6 @@ bvar_get_value (struct buffer *b, ptrdiff_t offset)
 INLINE void
 KILL_PER_BUFFER_VALUE (struct buffer *b, int offset)
 {
-  int idx = PER_BUFFER_IDX (offset);
-  SET_PER_BUFFER_VALUE_P (b, idx, 0);
   set_per_buffer_value (b, offset, Qunbound);
 }
 
diff --git a/src/category.c b/src/category.c
index 522f4da697..a9f5225df8 100644
--- a/src/category.c
+++ b/src/category.c
@@ -268,12 +268,8 @@ DEFUN ("set-category-table", Fset_category_table, Sset_category_table, 1, 1, 0,
 Return TABLE.  */)
   (Lisp_Object table)
 {
-  int idx;
   table = check_category_table (table);
   bset_category_table (current_buffer, table);
-  /* Indicate that this buffer now has a specified category table.  */
-  idx = PER_BUFFER_VAR_IDX (category_table);
-  SET_PER_BUFFER_VALUE_P (current_buffer, idx, 1);
   return table;
 }
 
diff --git a/src/data.c b/src/data.c
index 6835699236..30f8523af8 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1295,9 +1295,6 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval,
 	if (buf == NULL)
 	  buf = current_buffer;
 	set_per_buffer_value (buf, offset, newval);
-        int idx = PER_BUFFER_IDX (offset);
-        if (idx > 0)
-	  SET_PER_BUFFER_VALUE_P (buf, idx, 1);
       }
       break;
 
diff --git a/src/pdumper.c b/src/pdumper.c
index dfc7388b63..1e2e5238c7 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2802,9 +2802,6 @@ dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer)
   DUMP_FIELD_COPY (out, buffer, indirections);
   DUMP_FIELD_COPY (out, buffer, window_count);
 
-  memcpy (out->local_flags,
-          &buffer->local_flags,
-          sizeof (out->local_flags));
   DUMP_FIELD_COPY (out, buffer, modtime);
   DUMP_FIELD_COPY (out, buffer, modtime_size);
   DUMP_FIELD_COPY (out, buffer, auto_save_modified);
diff --git a/src/syntax.c b/src/syntax.c
index 17753f50b7..f2fbab1525 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1042,12 +1042,8 @@ DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0,
 One argument, a syntax table.  */)
   (Lisp_Object table)
 {
-  int idx;
   check_syntax_table (table);
   bset_syntax_table (current_buffer, table);
-  /* Indicate that this buffer now has a specified syntax table.  */
-  idx = PER_BUFFER_VAR_IDX (syntax_table);
-  SET_PER_BUFFER_VALUE_P (current_buffer, idx, 1);
   return table;
 }
 
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 11/14] Set buffer_defaults fields without a default to Qunbound
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:06 +0000
Resent-Message-ID: <handler.48264.B48264.162043978524902 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043978524902
          (code B ref 48264); Sat, 08 May 2021 02:10:06 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:45 +0000
Received: from localhost ([127.0.0.1]:47181 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCPY-0006TU-Gh
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:44 -0400
Received: from venus.catern.com ([68.183.49.163]:47950)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCPG-0006Sa-C7
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:26 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439765; bh=t1knBI2Ey3Z4g+LeC6FVD6cdXbxwEYJwDoVV7+tN6zU=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=UwUpJ7WooUFgPG5B6vOOvgDOepwX6gAIZ0xwXt+owbqPt4tdBU21pkgJNk+dZRAWP
 wEJTlrOZZ8QkWS0uPAZyDTIEgAP3hgD1l61ccPM6rGWHg+LX1uCqekO8sSpEoLByjt
 FMqDgtpv4XDrZP6HpZb5WW+IDnEKpygnHIxl47EM=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 7ACC92E9830;
 Sat,  8 May 2021 02:09:25 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:09:02 -0400
Message-Id: <20210508020905.13583-13-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

In this way, we can be more sure that we aren't accidentally using
these fields.  We can also use the fact that fields without a default
are set to Qunbound to implement BUFFER_DEFAULT_VALUE_P.

* src/buffer.c (init_buffer_once): Set unused buffer_defaults fields
to Qunbound.
* src/buffer.h (BUFFER_DEFAULT_VALUE_P): Check if field is Qunbound to
determine if there's a default.
---
 src/buffer.c | 42 ++++++++++++++++++++++++++++++------------
 src/buffer.h |  6 ++++--
 src/emacs.c  |  4 ++--
 3 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index a7d31c1e5b..a5606ce1d1 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -53,7 +53,9 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 /* This structure holds the default values of the buffer-local variables
    defined with DEFVAR_PER_BUFFER, that have special slots in each buffer.
    The default value occupies the same slot in this structure
-   as an individual buffer's value occupies in that buffer.  */
+   as an individual buffer's value occupies in that buffer.
+   Slots in this structure which are set to Qunbound are permanently
+   buffer-local.  */
 
 struct buffer buffer_defaults;
 
@@ -5251,6 +5253,10 @@ init_buffer_once (void)
 
   /* Set up the default values of various buffer slots.  */
   /* Must do these before making the first buffer! */
+  int offset;
+  FOR_EACH_PER_BUFFER_OBJECT_AT (offset)
+    set_per_buffer_default (offset, Qunbound);
+  set_per_buffer_default (PER_BUFFER_VAR_OFFSET (undo_list), Qunbound);
 
   /* real setup is done in bindings.el */
   bset_mode_line_format (&buffer_defaults, build_pure_c_string ("%-"));
@@ -5264,13 +5270,9 @@ init_buffer_once (void)
   bset_selective_display_ellipses (&buffer_defaults, Qt);
   bset_abbrev_table (&buffer_defaults, Qnil);
   bset_display_table (&buffer_defaults, Qnil);
-  bset_undo_list (&buffer_defaults, Qnil);
-  bset_mark_active (&buffer_defaults, Qnil);
-  bset_file_format (&buffer_defaults, Qnil);
-  bset_auto_save_file_format (&buffer_defaults, Qt);
-  set_buffer_overlays_before (&buffer_defaults, NULL);
-  set_buffer_overlays_after (&buffer_defaults, NULL);
-  buffer_defaults.overlay_center = BEG;
+  /* Later further initialized by init_{syntax,category}_once.  */
+  BVAR (&buffer_defaults, syntax_table) = Qnil;
+  BVAR (&buffer_defaults, category_table) = Qnil;
 
   XSETFASTINT (BVAR (&buffer_defaults, tab_width), 8);
   bset_truncate_lines (&buffer_defaults, Qnil);
@@ -5284,13 +5286,10 @@ init_buffer_once (void)
   bset_extra_line_spacing (&buffer_defaults, Qnil);
   bset_cursor_in_non_selected_windows (&buffer_defaults, Qt);
 
-  bset_enable_multibyte_characters (&buffer_defaults, Qt);
   bset_buffer_file_coding_system (&buffer_defaults, Qnil);
   XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70);
   XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0);
   bset_cache_long_scans (&buffer_defaults, Qt);
-  bset_file_truename (&buffer_defaults, Qnil);
-  XSETFASTINT (BVAR (&buffer_defaults, display_count), 0);
   XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0);
   XSETFASTINT (BVAR (&buffer_defaults, right_margin_cols), 0);
   bset_left_fringe_width (&buffer_defaults, Qnil);
@@ -5306,7 +5305,6 @@ init_buffer_once (void)
   bset_fringe_cursor_alist (&buffer_defaults, Qnil);
   bset_scroll_up_aggressively (&buffer_defaults, Qnil);
   bset_scroll_down_aggressively (&buffer_defaults, Qnil);
-  bset_display_time (&buffer_defaults, Qnil);
 
   /* Assign the local-flags to the slots that have default values.
      The local flag is a bit that is used in the buffer
@@ -5332,6 +5330,26 @@ init_buffer_once (void)
   DEFSYM (Qkill_buffer_hook, "kill-buffer-hook");
   Fput (Qkill_buffer_hook, Qpermanent_local, Qt);
 
+  /* Sanity check that we didn't set the default for slots which
+     are permanent-buffer-locals.  */
+  eassert (EQ (BVAR (&buffer_defaults, filename), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, directory), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, backed_up), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, save_length), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, auto_save_file_name), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, read_only), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, mode_name), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, undo_list), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, mark_active), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, point_before_scroll), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, file_truename), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, invisibility_spec), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, file_format), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, auto_save_file_format), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, display_count), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, display_time), Qunbound));
+  eassert (EQ (BVAR (&buffer_defaults, enable_multibyte_characters), Qunbound));
+
   /* Super-magic invisible buffer.  */
   Vprin1_to_string_buffer =
     Fget_buffer_create (build_pure_c_string (" prin1"), Qt);
diff --git a/src/buffer.h b/src/buffer.h
index 0445fe0edf..728dbb5272 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1101,7 +1101,9 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
 /* This structure holds the default values of the buffer-local variables
    that have special slots in each buffer.
    The default value occupies the same slot in this structure
-   as an individual buffer's value occupies in that buffer.  */
+   as an individual buffer's value occupies in that buffer.
+   Slots in this structure which are set to Qunbound are permanently
+   buffer-local. */
 
 extern struct buffer buffer_defaults;
 
@@ -1473,7 +1475,7 @@ set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
 INLINE bool
 BVAR_HAS_DEFAULT_VALUE_P (int offset)
 {
-  return PER_BUFFER_IDX (offset) > 0;
+  return !EQ (per_buffer_default (offset), Qunbound);
 }
 
 /* Value is true if the variable with offset OFFSET has a local value
diff --git a/src/emacs.c b/src/emacs.c
index 9157cd84a9..a1ea9d8a8b 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1787,10 +1787,10 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
       init_eval_once ();
       init_charset_once ();
       init_coding_once ();
-      init_syntax_once ();	/* Create standard syntax table.  */
-      init_category_once ();	/* Create standard category table.  */
       init_casetab_once ();	/* Must be done before init_buffer_once.  */
       init_buffer_once ();	/* Create buffer table and some buffers.  */
+      init_syntax_once ();	/* Create standard syntax table.  */
+      init_category_once ();	/* Create standard category table.  */
       init_minibuf_once ();	/* Create list of minibuffers.  */
 				/* Must precede init_window_once.  */
 
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 13/14] Remove PER_BUFFER_IDX and buffer_local_flags
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:07 +0000
Resent-Message-ID: <handler.48264.B48264.162043978524909 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043978524909
          (code B ref 48264); Sat, 08 May 2021 02:10:07 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:45 +0000
Received: from localhost ([127.0.0.1]:47183 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCPZ-0006Tb-0h
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:45 -0400
Received: from venus.catern.com ([68.183.49.163]:47962)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCPJ-0006T3-KC
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:31 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439768; bh=yXWHCJCgqx5np/y+y+KxJCtRJNnoWXuX6U/LW66HBJ4=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=mj/662pKGaB6ZCIx+Wm5ZL8OB1Rlz3SJA3yHIUGifTAyv21txZ7fnysE4VRM+l2WB
 PXdmhIQCPw/pdLXVsGnK/44S6meni5sWp/dk0JB5KEmCUnPQaWNDzuOz8j97KzXUz2
 7nCuyfUNsOEwQHHgoXDVk/Rp53/ubpoeKzWOZzb0=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id E8BE22E9839;
 Sat,  8 May 2021 02:09:27 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:09:04 -0400
Message-Id: <20210508020905.13583-15-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Previously, we maintained an "index" starting at 1 for each BVAR with
a default value, stored in buffer_local_flags; it was used to index
into local_flags.

After previous commits, we don't need this index for anything anymore.
So we can delete it.

* src/buffer.h (buffer_local_flags, PER_BUFFER_VAR_IDX)
(valid_per_buffer_idx, PER_BUFFER_IDX): Delete.
(BUFFER_DEFAULT_VALUE_P): Remove usage of PER_BUFFER_IDX.
* src/buffer.c (buffer_local_flags, last_per_buffer_idx)
(valid_per_buffer_idx): Delete.
(init_buffer_once): Don't initialize buffer_local_flags.
(defvar_per_buffer): Remove usage of PER_BUFFER_IDX.
* src/buffer.h (BUFFER_DEFAULT_VALUE_P):
* src/data.c (default_value): Remove usage of PER_BUFFER_IDX.
---
 src/buffer.c | 172 ---------------------------------------------------
 src/buffer.h |  53 ----------------
 src/data.c   |   1 -
 3 files changed, 226 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index a5606ce1d1..764c0cb6ed 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -59,25 +59,6 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 
 struct buffer buffer_defaults;
 
-/* This structure marks which slots in a buffer have corresponding
-   default values in buffer_defaults.
-   Each such slot has a value in this structure.
-   The value is a positive Lisp integer that must be smaller than
-   MAX_PER_BUFFER_VARS.
-
-   When a buffer has its own local value for a slot,
-   the entry for that slot (found in the same slot in this structure)
-   is turned on in the buffer's local_flags array.
-
-   If a slot in this structure is -1, then even though there may
-   be a DEFVAR_PER_BUFFER for the slot, there is no default value for it;
-   and the corresponding slot in buffer_defaults is not used.
-
-   If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is
-   zero, that is a bug.  */
-
-struct buffer buffer_local_flags;
-
 /* This structure holds the names of symbols whose values may be
    buffer-local.  It is indexed and accessed in the same way as the above.  */
 
@@ -94,10 +75,6 @@ struct buffer buffer_local_symbols;
   ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM,				\
 		    min (PTRDIFF_MAX, SIZE_MAX) / word_size))
 
-/* Number of per-buffer variables used.  */
-
-static int last_per_buffer_idx;
-
 static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay,
                                     bool after, Lisp_Object arg1,
                                     Lisp_Object arg2, Lisp_Object arg3);
@@ -328,11 +305,6 @@ bset_right_fringe_width (struct buffer *b, Lisp_Object val)
   b->right_fringe_width_ = val;
 }
 static void
-bset_save_length (struct buffer *b, Lisp_Object val)
-{
-  b->save_length_ = val;
-}
-static void
 bset_scroll_bar_width (struct buffer *b, Lisp_Object val)
 {
   b->scroll_bar_width_ = val;
@@ -679,12 +651,6 @@ set_buffer_overlays_after (struct buffer *b, struct Lisp_Overlay *o)
   b->overlays_after = o;
 }
 
-bool
-valid_per_buffer_idx (int idx)
-{
-  return 0 <= idx && idx < last_per_buffer_idx;
-}
-
 /* Clone per-buffer values of buffer FROM.
 
    Buffer TO gets the same per-buffer values as FROM, with the
@@ -5123,131 +5089,6 @@ free_buffer_text (struct buffer *b)
 void
 init_buffer_once (void)
 {
-  /* TODO: clean up the buffer-local machinery.  Right now,
-     we have:
-
-     buffer_defaults: default values of buffer-locals
-     buffer_local_flags: metadata
-     buffer_local_symbols: metadata
-
-     There must be a simpler way to store the metadata.
-  */
-
-  int idx;
-
-  /* 0 means not a lisp var, -1 means always local, else mask.  */
-  memset (&buffer_local_flags, 0, sizeof buffer_local_flags);
-  bset_filename (&buffer_local_flags, make_fixnum (-1));
-  bset_directory (&buffer_local_flags, make_fixnum (-1));
-  bset_backed_up (&buffer_local_flags, make_fixnum (-1));
-  bset_save_length (&buffer_local_flags, make_fixnum (-1));
-  bset_auto_save_file_name (&buffer_local_flags, make_fixnum (-1));
-  bset_read_only (&buffer_local_flags, make_fixnum (-1));
-  bset_major_mode (&buffer_local_flags, make_fixnum (-1));
-  bset_local_minor_modes (&buffer_local_flags, make_fixnum (-1));
-  bset_mode_name (&buffer_local_flags, make_fixnum (-1));
-  bset_undo_list (&buffer_local_flags, make_fixnum (-1));
-  bset_mark_active (&buffer_local_flags, make_fixnum (-1));
-  bset_point_before_scroll (&buffer_local_flags, make_fixnum (-1));
-  bset_file_truename (&buffer_local_flags, make_fixnum (-1));
-  bset_invisibility_spec (&buffer_local_flags, make_fixnum (-1));
-  bset_file_format (&buffer_local_flags, make_fixnum (-1));
-  bset_auto_save_file_format (&buffer_local_flags, make_fixnum (-1));
-  bset_display_count (&buffer_local_flags, make_fixnum (-1));
-  bset_display_time (&buffer_local_flags, make_fixnum (-1));
-  bset_enable_multibyte_characters (&buffer_local_flags, make_fixnum (-1));
-
-  /* These used to be stuck at 0 by default, but now that the all-zero value
-     means Qnil, we have to initialize them explicitly.  */
-  bset_name (&buffer_local_flags, make_fixnum (0));
-  bset_mark (&buffer_local_flags, make_fixnum (0));
-  bset_local_var_alist (&buffer_local_flags, make_fixnum (0));
-  bset_keymap (&buffer_local_flags, make_fixnum (0));
-  bset_downcase_table (&buffer_local_flags, make_fixnum (0));
-  bset_upcase_table (&buffer_local_flags, make_fixnum (0));
-  bset_case_canon_table (&buffer_local_flags, make_fixnum (0));
-  bset_case_eqv_table (&buffer_local_flags, make_fixnum (0));
-  bset_width_table (&buffer_local_flags, make_fixnum (0));
-  bset_pt_marker (&buffer_local_flags, make_fixnum (0));
-  bset_begv_marker (&buffer_local_flags, make_fixnum (0));
-  bset_zv_marker (&buffer_local_flags, make_fixnum (0));
-  bset_last_selected_window (&buffer_local_flags, make_fixnum (0));
-
-  idx = 1;
-  XSETFASTINT (BVAR (&buffer_local_flags, mode_line_format), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, abbrev_mode), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, overwrite_mode), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, case_fold_search), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, auto_fill_function), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, selective_display), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, selective_display_ellipses), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, tab_width), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, truncate_lines), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, word_wrap), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, ctl_arrow), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, fill_column), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, left_margin), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, abbrev_table), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, display_table), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, syntax_table), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, cache_long_scans), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, category_table), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, bidi_display_reordering), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_direction), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_separate_re), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, bidi_paragraph_start_re), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, buffer_file_coding_system), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, left_margin_cols), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, right_margin_cols), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, left_fringe_width), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, right_fringe_width), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, fringes_outside_margins), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, scroll_bar_width), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, scroll_bar_height), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, vertical_scroll_bar_type), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, horizontal_scroll_bar_type), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, indicate_empty_lines), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, indicate_buffer_boundaries), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, fringe_indicator_alist), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, fringe_cursor_alist), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, scroll_up_aggressively), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, scroll_down_aggressively), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, header_line_format), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, tab_line_format), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, cursor_type), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx;
-  XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), idx); ++idx;
-
-  /* buffer_local_flags contains no pointers, so it's safe to treat it
-     as a blob for pdumper.  */
-  PDUMPER_REMEMBER_SCALAR (buffer_local_flags);
-
-  /* Need more room? */
-  if (idx >= MAX_PER_BUFFER_VARS)
-    emacs_abort ();
-  last_per_buffer_idx = idx;
-  PDUMPER_REMEMBER_SCALAR (last_per_buffer_idx);
-
-  /* Make sure all markable slots in buffer_defaults
-     are initialized reasonably, so mark_buffer won't choke.  */
-  reset_buffer (&buffer_defaults);
-  eassert (NILP (BVAR (&buffer_defaults, name)));
-  eassert (NILP (BVAR (&buffer_local_symbols, name)));
-  reset_buffer (&buffer_local_symbols);
-  /* Prevent GC from getting confused.  */
-  buffer_defaults.text = &buffer_defaults.own_text;
-  buffer_local_symbols.text = &buffer_local_symbols.own_text;
-  /* No one will share the text with these buffers, but let's play it safe.  */
-  buffer_defaults.indirections = 0;
-  buffer_local_symbols.indirections = 0;
-  /* Likewise no one will display them.  */
-  buffer_defaults.window_count = 0;
-  buffer_local_symbols.window_count = 0;
-  set_buffer_intervals (&buffer_defaults, NULL);
-  set_buffer_intervals (&buffer_local_symbols, NULL);
-  /* This is not strictly necessary, but let's make them initialized.  */
-  bset_name (&buffer_defaults, build_pure_c_string (" *buffer-defaults*"));
-  bset_name (&buffer_local_symbols, build_pure_c_string (" *buffer-local-symbols*"));
   BUFFER_PVEC_INIT (&buffer_defaults);
   BUFFER_PVEC_INIT (&buffer_local_symbols);
 
@@ -5306,14 +5147,6 @@ init_buffer_once (void)
   bset_scroll_up_aggressively (&buffer_defaults, Qnil);
   bset_scroll_down_aggressively (&buffer_defaults, Qnil);
 
-  /* Assign the local-flags to the slots that have default values.
-     The local flag is a bit that is used in the buffer
-     to say that it has its own local value for the slot.
-     The local flag bits are in the local_var_flags slot of the buffer.  */
-
-  /* Nothing can work if this isn't true.  */
-  { verify (sizeof (EMACS_INT) == word_size); }
-
   Vbuffer_alist = Qnil;
   current_buffer = 0;
   pdumper_remember_lv_ptr_raw (&current_buffer, Lisp_Vectorlike);
@@ -5477,11 +5310,6 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring,
   sym->u.s.redirect = SYMBOL_FORWARDED;
   SET_SYMBOL_FWD (sym, bo_fwd);
   XSETSYMBOL (PER_BUFFER_SYMBOL (offset), sym);
-
-  if (PER_BUFFER_IDX (offset) == 0)
-    /* Did a DEFVAR_PER_BUFFER without initializing the corresponding
-       slot of buffer_local_flags.  */
-    emacs_abort ();
 }
 
 
diff --git a/src/buffer.h b/src/buffer.h
index 728dbb5272..f78046a9a8 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1107,22 +1107,6 @@ BUFFER_CHECK_INDIRECTION (struct buffer *b)
 
 extern struct buffer buffer_defaults;
 
-/* This structure marks which slots in a buffer have corresponding
-   default values in buffer_defaults.
-   Each such slot has a nonzero value in this structure.
-   The value has only one nonzero bit.
-
-   When a buffer has its own local value for a slot,
-   the entry for that slot (found in the same slot in this structure)
-   is turned on in the buffer's local_flags array.
-
-   If a slot in this structure is zero, then even though there may
-   be a Lisp-level local variable for the slot, it has no default value,
-   and the corresponding slot in buffer_defaults is not used.  */
-
-
-extern struct buffer buffer_local_flags;
-
 /* For each buffer slot, this points to the Lisp symbol name
    for that slot in the current buffer.  It is 0 for slots
    that don't have such names.  */
@@ -1401,43 +1385,6 @@ OVERLAY_POSITION (Lisp_Object p)
        offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \
        offset += word_size)
 
-/* Return the index of buffer-local variable VAR.  Each per-buffer
-   variable has an index > 0 associated with it, except when it always
-   has buffer-local values, in which case the index is -1.  If this is
-   0, this is a bug and means that the slot of VAR in
-   buffer_local_flags wasn't initialized.  */
-
-#define PER_BUFFER_VAR_IDX(VAR) \
-    PER_BUFFER_IDX (PER_BUFFER_VAR_OFFSET (VAR))
-
-extern bool valid_per_buffer_idx (int);
-
-/* Return the index value of the per-buffer variable at offset OFFSET
-   in the buffer structure.
-
-   If the slot OFFSET has a corresponding default value in
-   buffer_defaults, the index value is positive and has only one
-   nonzero bit.  When a buffer has its own local value for a slot, the
-   bit for that slot (found in the same slot in this structure) is
-   turned on in the buffer's local_flags array.
-
-   If the index value is -1, even though there may be a
-   DEFVAR_PER_BUFFER for the slot, there is no default value for it;
-   and the corresponding slot in buffer_defaults is not used.
-
-   If the index value is -2, then there is no DEFVAR_PER_BUFFER for
-   the slot, but there is a default value which is copied into each
-   new buffer.
-
-   If a slot in this structure corresponding to a DEFVAR_PER_BUFFER is
-   zero, that is a bug.  */
-
-INLINE int
-PER_BUFFER_IDX (ptrdiff_t offset)
-{
-  return XFIXNUM (*(Lisp_Object *) (offset + (char *) &buffer_local_flags));
-}
-
 /* Functions to get and set default value of the per-buffer
    variable at offset OFFSET in the buffer structure.  */
 
diff --git a/src/data.c b/src/data.c
index 758ff68d83..f93707d334 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1758,7 +1758,6 @@ default_value (Lisp_Object symbol)
 	if (BUFFER_OBJFWDP (valcontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
-	    eassert (PER_BUFFER_IDX (offset) != 0);
 	    return per_buffer_default (offset);
 	  }
 
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 14/14] Add and use BVAR_FIELD macros
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:07 +0000
Resent-Message-ID: <handler.48264.B48264.162043978824916 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043978824916
          (code B ref 48264); Sat, 08 May 2021 02:10:07 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:48 +0000
Received: from localhost ([127.0.0.1]:47185 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCPZ-0006Ti-PX
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:47 -0400
Received: from venus.catern.com ([68.183.49.163]:47968)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCPK-0006T4-CM
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:34 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439769; bh=33FmN1r5XS3B4DaKMt/mPRS1EtVqNrw99lRDvXu3Mxw=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=kBLzfvBLKEN34ByT3GXuo7G6DjSmqFFHd1rGJZZNGR5BGhThQQCeOJBB0GbMCaT2q
 kAED9cK9U6eL50JGMsxM1ZFJEBi68vgpeWtKn1oF7w18eul1Egp0c/meKAGhEL/yvB
 b09xTYw6R2OKLYSAbx7pzzfIEUyoQ9HaYYEWdMUs=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 152BB2E9835;
 Sat,  8 May 2021 02:09:29 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:09:05 -0400
Message-Id: <20210508020905.13583-16-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

By using the BVAR_FIELD and BVAR_DEFAULTED_FIELD macros anywhere we
would otherwise use the raw name of a buffer field (which is only in a
few places), we can make sure that BVAR and BVAR_OR_DEFAULT are used
on the correct fields.

* src/alloc.c (allocate_buffer):
* src/buffer.c (bset_abbrev_mode):
(bset_bidi_display_reordering):
(bset_fringe_cursor_alist):
(bset_left_fringe_width):
(bset_mode_line_format):
(bset_overwrite_mode):
(bset_right_fringe_width):
(bset_scroll_bar_width):
(reset_buffer_local_variables):
(init_buffer_once):
(syms_of_buffer):
* src/buffer.h (BVAR_DEFAULTED_FIELD):
(struct buffer):
(bset_bidi_paragraph_direction):
(bset_left_margin_cols):
(bset_truncate_lines):
(PER_BUFFER_VAR_DEFAULTED_OFFSET):
* src/category.c (bset_category_table):
* src/syntax.c (bset_syntax_table): Use BVAR_FIELD,
BVAR_DEFAULTED_FIELD, and BVAR_DEFAULTED.
---
 src/alloc.c    |   3 +-
 src/buffer.c   | 166 ++++++++++++++++++++++-----------------------
 src/buffer.h   | 180 ++++++++++++++++++++++++++-----------------------
 src/category.c |   2 +-
 src/category.h |   2 +-
 src/syntax.c   |   2 +-
 src/syntax.h   |   2 +-
 7 files changed, 183 insertions(+), 174 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 76d8c7ddd1..b711aa904c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3389,7 +3389,8 @@ struct buffer *
 allocate_buffer (void)
 {
   struct buffer *b
-    = ALLOCATE_PSEUDOVECTOR (struct buffer, cursor_in_non_selected_windows_,
+    = ALLOCATE_PSEUDOVECTOR (struct buffer,
+			     BVAR_DEFAULTED_FIELD (cursor_in_non_selected_windows),
 			     PVEC_BUFFER);
   BUFFER_PVEC_INIT (b);
   /* Note that the rest fields of B are not initialized.  */
diff --git a/src/buffer.c b/src/buffer.c
index 764c0cb6ed..47524de868 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -122,17 +122,17 @@ fix_position (Lisp_Object pos)
 static void
 bset_abbrev_mode (struct buffer *b, Lisp_Object val)
 {
-  b->abbrev_mode_ = val;
+  b->BVAR_DEFAULTED_FIELD(abbrev_mode) = val;
 }
 static void
 bset_abbrev_table (struct buffer *b, Lisp_Object val)
 {
-  b->abbrev_table_ = val;
+  b->BVAR_DEFAULTED_FIELD(abbrev_table) = val;
 }
 static void
 bset_auto_fill_function (struct buffer *b, Lisp_Object val)
 {
-  b->auto_fill_function_ = val;
+  b->BVAR_DEFAULTED_FIELD(auto_fill_function) = val;
 }
 static void
 bset_auto_save_file_format (struct buffer *b, Lisp_Object val)
@@ -157,52 +157,52 @@ bset_begv_marker (struct buffer *b, Lisp_Object val)
 static void
 bset_bidi_display_reordering (struct buffer *b, Lisp_Object val)
 {
-  b->bidi_display_reordering_ = val;
+  b->BVAR_DEFAULTED_FIELD(bidi_display_reordering) = val;
 }
 static void
 bset_bidi_paragraph_start_re (struct buffer *b, Lisp_Object val)
 {
-  b->bidi_paragraph_start_re_ = val;
+  b->BVAR_DEFAULTED_FIELD(bidi_paragraph_start_re) = val;
 }
 static void
 bset_bidi_paragraph_separate_re (struct buffer *b, Lisp_Object val)
 {
-  b->bidi_paragraph_separate_re_ = val;
+  b->BVAR_DEFAULTED_FIELD(bidi_paragraph_separate_re) = val;
 }
 static void
 bset_buffer_file_coding_system (struct buffer *b, Lisp_Object val)
 {
-  b->buffer_file_coding_system_ = val;
+  b->BVAR_DEFAULTED_FIELD(buffer_file_coding_system) = val;
 }
 static void
 bset_case_fold_search (struct buffer *b, Lisp_Object val)
 {
-  b->case_fold_search_ = val;
+  b->BVAR_DEFAULTED_FIELD(case_fold_search) = val;
 }
 static void
 bset_ctl_arrow (struct buffer *b, Lisp_Object val)
 {
-  b->ctl_arrow_ = val;
+  b->BVAR_DEFAULTED_FIELD(ctl_arrow) = val;
 }
 static void
 bset_cursor_in_non_selected_windows (struct buffer *b, Lisp_Object val)
 {
-  b->cursor_in_non_selected_windows_ = val;
+  b->BVAR_DEFAULTED_FIELD(cursor_in_non_selected_windows) = val;
 }
 static void
 bset_cursor_type (struct buffer *b, Lisp_Object val)
 {
-  b->cursor_type_ = val;
+  b->BVAR_DEFAULTED_FIELD(cursor_type) = val;
 }
 static void
 bset_display_table (struct buffer *b, Lisp_Object val)
 {
-  b->display_table_ = val;
+  b->BVAR_DEFAULTED_FIELD(display_table) = val;
 }
 static void
 bset_extra_line_spacing (struct buffer *b, Lisp_Object val)
 {
-  b->extra_line_spacing_ = val;
+  b->BVAR_DEFAULTED_FIELD(extra_line_spacing) = val;
 }
 static void
 bset_file_format (struct buffer *b, Lisp_Object val)
@@ -217,37 +217,37 @@ bset_file_truename (struct buffer *b, Lisp_Object val)
 static void
 bset_fringe_cursor_alist (struct buffer *b, Lisp_Object val)
 {
-  b->fringe_cursor_alist_ = val;
+  b->BVAR_DEFAULTED_FIELD(fringe_cursor_alist) = val;
 }
 static void
 bset_fringe_indicator_alist (struct buffer *b, Lisp_Object val)
 {
-  b->fringe_indicator_alist_ = val;
+  b->BVAR_DEFAULTED_FIELD(fringe_indicator_alist) = val;
 }
 static void
 bset_fringes_outside_margins (struct buffer *b, Lisp_Object val)
 {
-  b->fringes_outside_margins_ = val;
+  b->BVAR_DEFAULTED_FIELD(fringes_outside_margins) = val;
 }
 static void
 bset_header_line_format (struct buffer *b, Lisp_Object val)
 {
-  b->header_line_format_ = val;
+  b->BVAR_DEFAULTED_FIELD(header_line_format) = val;
 }
 static void
 bset_tab_line_format (struct buffer *b, Lisp_Object val)
 {
-  b->tab_line_format_ = val;
+  b->BVAR_DEFAULTED_FIELD(tab_line_format) = val;
 }
 static void
 bset_indicate_buffer_boundaries (struct buffer *b, Lisp_Object val)
 {
-  b->indicate_buffer_boundaries_ = val;
+  b->BVAR_DEFAULTED_FIELD(indicate_buffer_boundaries) = val;
 }
 static void
 bset_indicate_empty_lines (struct buffer *b, Lisp_Object val)
 {
-  b->indicate_empty_lines_ = val;
+  b->BVAR_DEFAULTED_FIELD(indicate_empty_lines) = val;
 }
 static void
 bset_invisibility_spec (struct buffer *b, Lisp_Object val)
@@ -257,7 +257,7 @@ bset_invisibility_spec (struct buffer *b, Lisp_Object val)
 static void
 bset_left_fringe_width (struct buffer *b, Lisp_Object val)
 {
-  b->left_fringe_width_ = val;
+  b->BVAR_DEFAULTED_FIELD(left_fringe_width) = val;
 }
 static void
 bset_major_mode (struct buffer *b, Lisp_Object val)
@@ -277,7 +277,7 @@ bset_mark (struct buffer *b, Lisp_Object val)
 static void
 bset_mode_line_format (struct buffer *b, Lisp_Object val)
 {
-  b->mode_line_format_ = val;
+  b->BVAR_DEFAULTED_FIELD(mode_line_format) = val;
 }
 static void
 bset_mode_name (struct buffer *b, Lisp_Object val)
@@ -292,7 +292,7 @@ bset_name (struct buffer *b, Lisp_Object val)
 static void
 bset_overwrite_mode (struct buffer *b, Lisp_Object val)
 {
-  b->overwrite_mode_ = val;
+  b->BVAR_DEFAULTED_FIELD(overwrite_mode) = val;
 }
 static void
 bset_pt_marker (struct buffer *b, Lisp_Object val)
@@ -302,52 +302,52 @@ bset_pt_marker (struct buffer *b, Lisp_Object val)
 static void
 bset_right_fringe_width (struct buffer *b, Lisp_Object val)
 {
-  b->right_fringe_width_ = val;
+  b->BVAR_DEFAULTED_FIELD(right_fringe_width) = val;
 }
 static void
 bset_scroll_bar_width (struct buffer *b, Lisp_Object val)
 {
-  b->scroll_bar_width_ = val;
+  b->BVAR_DEFAULTED_FIELD(scroll_bar_width) = val;
 }
 static void
 bset_scroll_bar_height (struct buffer *b, Lisp_Object val)
 {
-  b->scroll_bar_height_ = val;
+  b->BVAR_DEFAULTED_FIELD(scroll_bar_height) = val;
 }
 static void
 bset_scroll_down_aggressively (struct buffer *b, Lisp_Object val)
 {
-  b->scroll_down_aggressively_ = val;
+  b->BVAR_DEFAULTED_FIELD(scroll_down_aggressively) = val;
 }
 static void
 bset_scroll_up_aggressively (struct buffer *b, Lisp_Object val)
 {
-  b->scroll_up_aggressively_ = val;
+  b->BVAR_DEFAULTED_FIELD(scroll_up_aggressively) = val;
 }
 static void
 bset_selective_display (struct buffer *b, Lisp_Object val)
 {
-  b->selective_display_ = val;
+  b->BVAR_DEFAULTED_FIELD(selective_display) = val;
 }
 static void
 bset_selective_display_ellipses (struct buffer *b, Lisp_Object val)
 {
-  b->selective_display_ellipses_ = val;
+  b->BVAR_DEFAULTED_FIELD(selective_display_ellipses) = val;
 }
 static void
 bset_vertical_scroll_bar_type (struct buffer *b, Lisp_Object val)
 {
-  b->vertical_scroll_bar_type_ = val;
+  b->BVAR_DEFAULTED_FIELD(vertical_scroll_bar_type) = val;
 }
 static void
 bset_horizontal_scroll_bar_type (struct buffer *b, Lisp_Object val)
 {
-  b->horizontal_scroll_bar_type_ = val;
+  b->BVAR_DEFAULTED_FIELD(horizontal_scroll_bar_type) = val;
 }
 static void
 bset_word_wrap (struct buffer *b, Lisp_Object val)
 {
-  b->word_wrap_ = val;
+  b->BVAR_DEFAULTED_FIELD(word_wrap) = val;
 }
 static void
 bset_zv_marker (struct buffer *b, Lisp_Object val)
@@ -1062,9 +1062,9 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too)
 	       /* Special case these two for backwards-compat; they're
 		  flagged as permanent-locals in bindings.el, even
 		  though they do have default values.  */
-	       || (offset != PER_BUFFER_VAR_OFFSET (truncate_lines)
+	       || (offset != PER_BUFFER_VAR_DEFAULTED_OFFSET (truncate_lines)
 		   && offset !=
-		   PER_BUFFER_VAR_OFFSET (buffer_file_coding_system)))))
+		   PER_BUFFER_VAR_DEFAULTED_OFFSET (buffer_file_coding_system)))))
         KILL_PER_BUFFER_VALUE (b, offset);
     }
 }
@@ -5112,10 +5112,10 @@ init_buffer_once (void)
   bset_abbrev_table (&buffer_defaults, Qnil);
   bset_display_table (&buffer_defaults, Qnil);
   /* Later further initialized by init_{syntax,category}_once.  */
-  BVAR (&buffer_defaults, syntax_table) = Qnil;
-  BVAR (&buffer_defaults, category_table) = Qnil;
+  BVAR_DEFAULTED (&buffer_defaults, syntax_table) = Qnil;
+  BVAR_DEFAULTED (&buffer_defaults, category_table) = Qnil;
 
-  XSETFASTINT (BVAR (&buffer_defaults, tab_width), 8);
+  XSETFASTINT (BVAR_DEFAULTED (&buffer_defaults, tab_width), 8);
   bset_truncate_lines (&buffer_defaults, Qnil);
   bset_word_wrap (&buffer_defaults, Qnil);
   bset_ctl_arrow (&buffer_defaults, Qt);
@@ -5128,11 +5128,11 @@ init_buffer_once (void)
   bset_cursor_in_non_selected_windows (&buffer_defaults, Qt);
 
   bset_buffer_file_coding_system (&buffer_defaults, Qnil);
-  XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70);
-  XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0);
+  XSETFASTINT (BVAR_DEFAULTED (&buffer_defaults, fill_column), 70);
+  XSETFASTINT (BVAR_DEFAULTED (&buffer_defaults, left_margin), 0);
   bset_cache_long_scans (&buffer_defaults, Qt);
-  XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0);
-  XSETFASTINT (BVAR (&buffer_defaults, right_margin_cols), 0);
+  XSETFASTINT (BVAR_DEFAULTED (&buffer_defaults, left_margin_cols), 0);
+  XSETFASTINT (BVAR_DEFAULTED (&buffer_defaults, right_margin_cols), 0);
   bset_left_fringe_width (&buffer_defaults, Qnil);
   bset_right_fringe_width (&buffer_defaults, Qnil);
   bset_fringes_outside_margins (&buffer_defaults, Qnil);
@@ -5361,20 +5361,20 @@ syms_of_buffer (void)
 	build_pure_c_string ("Attempt to modify a protected field"));
 
   DEFVAR_PER_BUFFER ("tab-line-format",
-		     &BVAR (current_buffer, tab_line_format),
+		     &BVAR_DEFAULTED (current_buffer, tab_line_format),
 		     Qnil,
 		     doc: /* Analogous to `mode-line-format', but controls the tab line.
 The tab line appears, optionally, at the top of a window;
 the mode line appears at the bottom.  */);
 
   DEFVAR_PER_BUFFER ("header-line-format",
-		     &BVAR (current_buffer, header_line_format),
+		     &BVAR_DEFAULTED (current_buffer, header_line_format),
 		     Qnil,
 		     doc: /* Analogous to `mode-line-format', but controls the header line.
 The header line appears, optionally, at the top of a window;
 the mode line appears at the bottom.  */);
 
-  DEFVAR_PER_BUFFER ("mode-line-format", &BVAR (current_buffer, mode_line_format),
+  DEFVAR_PER_BUFFER ("mode-line-format", &BVAR_DEFAULTED (current_buffer, mode_line_format),
 		     Qnil,
 		     doc: /* Template for displaying mode line for current buffer.
 
@@ -5460,18 +5460,18 @@ Usually a string, but can use any of the constructs for `mode-line-format',
 which see.
 Format with `format-mode-line' to produce a string value.  */);
 
-  DEFVAR_PER_BUFFER ("local-abbrev-table", &BVAR (current_buffer, abbrev_table), Qnil,
+  DEFVAR_PER_BUFFER ("local-abbrev-table", &BVAR_DEFAULTED (current_buffer, abbrev_table), Qnil,
 		     doc: /* Local (mode-specific) abbrev table of current buffer.  */);
 
-  DEFVAR_PER_BUFFER ("abbrev-mode", &BVAR (current_buffer, abbrev_mode), Qnil,
+  DEFVAR_PER_BUFFER ("abbrev-mode", &BVAR_DEFAULTED (current_buffer, abbrev_mode), Qnil,
 		     doc: /*  Non-nil if Abbrev mode is enabled.
 Use the command `abbrev-mode' to change this variable.  */);
 
-  DEFVAR_PER_BUFFER ("case-fold-search", &BVAR (current_buffer, case_fold_search),
+  DEFVAR_PER_BUFFER ("case-fold-search", &BVAR_DEFAULTED (current_buffer, case_fold_search),
 		     Qnil,
 		     doc: /* Non-nil if searches and matches should ignore case.  */);
 
-  DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column),
+  DEFVAR_PER_BUFFER ("fill-column", &BVAR_DEFAULTED (current_buffer, fill_column),
 		     Qintegerp,
 		     doc: /* Column beyond which automatic line-wrapping should happen.
 It is used by filling commands, such as `fill-region' and `fill-paragraph',
@@ -5479,19 +5479,19 @@ and by `auto-fill-mode', which see.
 See also `current-fill-column'.
 Interactively, you can set the buffer local value using \\[set-fill-column].  */);
 
-  DEFVAR_PER_BUFFER ("left-margin", &BVAR (current_buffer, left_margin),
+  DEFVAR_PER_BUFFER ("left-margin", &BVAR_DEFAULTED (current_buffer, left_margin),
 		     Qintegerp,
 		     doc: /* Column for the default `indent-line-function' to indent to.
 Linefeed indents to this column in Fundamental mode.  */);
 
-  DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width),
+  DEFVAR_PER_BUFFER ("tab-width", &BVAR_DEFAULTED (current_buffer, tab_width),
 		     Qintegerp,
 		     doc: /* Distance between tab stops (for display of tab characters), in columns.
 NOTE: This controls the display width of a TAB character, and not
 the size of an indentation step.
 This should be an integer greater than zero.  */);
 
-  DEFVAR_PER_BUFFER ("ctl-arrow", &BVAR (current_buffer, ctl_arrow), Qnil,
+  DEFVAR_PER_BUFFER ("ctl-arrow", &BVAR_DEFAULTED (current_buffer, ctl_arrow), Qnil,
 		     doc: /* Non-nil means display control chars with uparrow.
 A value of nil means use backslash and octal digits.
 This variable does not apply to characters whose display is specified
@@ -5512,7 +5512,7 @@ See also Info node `(elisp)Text Representations'.  */);
   make_symbol_constant (intern_c_string ("enable-multibyte-characters"));
 
   DEFVAR_PER_BUFFER ("buffer-file-coding-system",
-		     &BVAR (current_buffer, buffer_file_coding_system), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, buffer_file_coding_system), Qnil,
 		     doc: /* Coding system to be used for encoding the buffer contents on saving.
 This variable applies to saving the buffer, and also to `write-region'
 and other functions that use `write-region'.
@@ -5530,7 +5530,7 @@ The variable `coding-system-for-write', if non-nil, overrides this variable.
 This variable is never applied to a way of decoding a file while reading it.  */);
 
   DEFVAR_PER_BUFFER ("bidi-display-reordering",
-		     &BVAR (current_buffer, bidi_display_reordering), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, bidi_display_reordering), Qnil,
 		     doc: /* Non-nil means reorder bidirectional text for display in the visual order.
 Setting this to nil is intended for use in debugging the display code.
 Don't set to nil in normal sessions, as that is not supported.
@@ -5538,7 +5538,7 @@ See also `bidi-paragraph-direction'; setting that non-nil might
 speed up redisplay.  */);
 
   DEFVAR_PER_BUFFER ("bidi-paragraph-start-re",
-		     &BVAR (current_buffer, bidi_paragraph_start_re), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, bidi_paragraph_start_re), Qnil,
 		     doc: /* If non-nil, a regexp matching a line that starts OR separates paragraphs.
 
 The value of nil means to use empty lines as lines that start and
@@ -5560,7 +5560,7 @@ set both these variables to "^".
 See also `bidi-paragraph-direction'.  */);
 
   DEFVAR_PER_BUFFER ("bidi-paragraph-separate-re",
-		     &BVAR (current_buffer, bidi_paragraph_separate_re), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, bidi_paragraph_separate_re), Qnil,
 		     doc: /* If non-nil, a regexp matching a line that separates paragraphs.
 
 The value of nil means to use empty lines as paragraph separators.
@@ -5581,7 +5581,7 @@ set both these variables to "^".
 See also `bidi-paragraph-direction'.  */);
 
   DEFVAR_PER_BUFFER ("bidi-paragraph-direction",
-		     &BVAR (current_buffer, bidi_paragraph_direction), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, bidi_paragraph_direction), Qnil,
 		     doc: /* If non-nil, forces directionality of text paragraphs in the buffer.
 
 If this is nil (the default), the direction of each paragraph is
@@ -5592,7 +5592,7 @@ Any other value is treated as nil.
 This variable has no effect unless the buffer's value of
 `bidi-display-reordering' is non-nil.  */);
 
- DEFVAR_PER_BUFFER ("truncate-lines", &BVAR (current_buffer, truncate_lines), Qnil,
+ DEFVAR_PER_BUFFER ("truncate-lines", &BVAR_DEFAULTED (current_buffer, truncate_lines), Qnil,
 		     doc: /* Non-nil means do not display continuation lines.
 Instead, give each line of text just one screen line.
 
@@ -5602,7 +5602,7 @@ and this buffer is not full-frame width.
 
 Minibuffers set this variable to nil.  */);
 
-  DEFVAR_PER_BUFFER ("word-wrap", &BVAR (current_buffer, word_wrap), Qnil,
+  DEFVAR_PER_BUFFER ("word-wrap", &BVAR_DEFAULTED (current_buffer, word_wrap), Qnil,
 		     doc: /* Non-nil means to use word-wrapping for continuation lines.
 When word-wrapping is on, continuation lines are wrapped at the space
 or tab character nearest to the right window edge.
@@ -5627,7 +5627,7 @@ It should be an absolute directory name; on GNU and Unix systems,
 these names start with `/' or `~' and end with `/'.
 To interactively change the default directory, use command `cd'. */);
 
-  DEFVAR_PER_BUFFER ("auto-fill-function", &BVAR (current_buffer, auto_fill_function),
+  DEFVAR_PER_BUFFER ("auto-fill-function", &BVAR_DEFAULTED (current_buffer, auto_fill_function),
 		     Qnil,
 		     doc: /* Function called (if non-nil) to perform auto-fill.
 It is called after self-inserting any character specified in
@@ -5669,7 +5669,7 @@ If you set this to -2, that means don't turn off auto-saving in this buffer
 if its text size shrinks.   If you use `buffer-swap-text' on a buffer,
 you probably should set this to -2 in that buffer.  */);
 
-  DEFVAR_PER_BUFFER ("selective-display", &BVAR (current_buffer, selective_display),
+  DEFVAR_PER_BUFFER ("selective-display", &BVAR_DEFAULTED (current_buffer, selective_display),
 		     Qnil,
 		     doc: /* Non-nil enables selective display.
 
@@ -5682,11 +5682,11 @@ in a file, save the ^M as a newline.  This usage is obsolete; use
 overlays or text properties instead.  */);
 
   DEFVAR_PER_BUFFER ("selective-display-ellipses",
-		     &BVAR (current_buffer, selective_display_ellipses),
+		     &BVAR_DEFAULTED (current_buffer, selective_display_ellipses),
 		     Qnil,
 		     doc: /* Non-nil means display ... on previous line when a line is invisible.  */);
 
-  DEFVAR_PER_BUFFER ("overwrite-mode", &BVAR (current_buffer, overwrite_mode),
+  DEFVAR_PER_BUFFER ("overwrite-mode", &BVAR_DEFAULTED (current_buffer, overwrite_mode),
 		     Qoverwrite_mode,
 		     doc: /* Non-nil if self-insertion should replace existing text.
 The value should be one of `overwrite-mode-textual',
@@ -5696,7 +5696,7 @@ inserts at the end of a line, and inserts when point is before a tab,
 until the tab is filled in.
 If `overwrite-mode-binary', self-insertion replaces newlines and tabs too.  */);
 
-  DEFVAR_PER_BUFFER ("buffer-display-table", &BVAR (current_buffer, display_table),
+  DEFVAR_PER_BUFFER ("buffer-display-table", &BVAR_DEFAULTED (current_buffer, display_table),
 		     Qnil,
 		     doc: /* Display table that controls display of the contents of current buffer.
 
@@ -5733,7 +5733,7 @@ In addition, a char-table has six extra slots to control the display of:
 
 See also the functions `display-table-slot' and `set-display-table-slot'.  */);
 
-  DEFVAR_PER_BUFFER ("left-margin-width", &BVAR (current_buffer, left_margin_cols),
+  DEFVAR_PER_BUFFER ("left-margin-width", &BVAR_DEFAULTED (current_buffer, left_margin_cols),
 		     Qintegerp,
 		     doc: /* Width in columns of left marginal area for display of a buffer.
 A value of nil means no marginal area.
@@ -5741,7 +5741,7 @@ A value of nil means no marginal area.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("right-margin-width", &BVAR (current_buffer, right_margin_cols),
+  DEFVAR_PER_BUFFER ("right-margin-width", &BVAR_DEFAULTED (current_buffer, right_margin_cols),
 		     Qintegerp,
 		     doc: /* Width in columns of right marginal area for display of a buffer.
 A value of nil means no marginal area.
@@ -5749,7 +5749,7 @@ A value of nil means no marginal area.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("left-fringe-width", &BVAR (current_buffer, left_fringe_width),
+  DEFVAR_PER_BUFFER ("left-fringe-width", &BVAR_DEFAULTED (current_buffer, left_fringe_width),
 		     Qintegerp,
 		     doc: /* Width of this buffer's left fringe (in pixels).
 A value of 0 means no left fringe is shown in this buffer's window.
@@ -5758,7 +5758,7 @@ A value of nil means to use the left fringe width from the window's frame.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("right-fringe-width", &BVAR (current_buffer, right_fringe_width),
+  DEFVAR_PER_BUFFER ("right-fringe-width", &BVAR_DEFAULTED (current_buffer, right_fringe_width),
 		     Qintegerp,
 		     doc: /* Width of this buffer's right fringe (in pixels).
 A value of 0 means no right fringe is shown in this buffer's window.
@@ -5767,7 +5767,7 @@ A value of nil means to use the right fringe width from the window's frame.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("fringes-outside-margins", &BVAR (current_buffer, fringes_outside_margins),
+  DEFVAR_PER_BUFFER ("fringes-outside-margins", &BVAR_DEFAULTED (current_buffer, fringes_outside_margins),
 		     Qnil,
 		     doc: /* Non-nil means to display fringes outside display margins.
 A value of nil means to display fringes between margins and buffer text.
@@ -5775,17 +5775,17 @@ A value of nil means to display fringes between margins and buffer text.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("scroll-bar-width", &BVAR (current_buffer, scroll_bar_width),
+  DEFVAR_PER_BUFFER ("scroll-bar-width", &BVAR_DEFAULTED (current_buffer, scroll_bar_width),
 		     Qintegerp,
 		     doc: /* Width of this buffer's vertical scroll bars in pixels.
 A value of nil means to use the scroll bar width from the window's frame.  */);
 
-  DEFVAR_PER_BUFFER ("scroll-bar-height", &BVAR (current_buffer, scroll_bar_height),
+  DEFVAR_PER_BUFFER ("scroll-bar-height", &BVAR_DEFAULTED (current_buffer, scroll_bar_height),
 		     Qintegerp,
 		     doc: /* Height of this buffer's horizontal scroll bars in pixels.
 A value of nil means to use the scroll bar height from the window's frame.  */);
 
-  DEFVAR_PER_BUFFER ("vertical-scroll-bar", &BVAR (current_buffer, vertical_scroll_bar_type),
+  DEFVAR_PER_BUFFER ("vertical-scroll-bar", &BVAR_DEFAULTED (current_buffer, vertical_scroll_bar_type),
 		     Qvertical_scroll_bar,
 		     doc: /* Position of this buffer's vertical scroll bar.
 The value takes effect whenever you tell a window to display this buffer;
@@ -5795,7 +5795,7 @@ A value of `left' or `right' means put the vertical scroll bar at that side
 of the window; a value of nil means don't show any vertical scroll bars.
 A value of t (the default) means do whatever the window's frame specifies.  */);
 
-  DEFVAR_PER_BUFFER ("horizontal-scroll-bar", &BVAR (current_buffer, horizontal_scroll_bar_type),
+  DEFVAR_PER_BUFFER ("horizontal-scroll-bar", &BVAR_DEFAULTED (current_buffer, horizontal_scroll_bar_type),
 		     Qnil,
 		     doc: /* Position of this buffer's horizontal scroll bar.
 The value takes effect whenever you tell a window to display this buffer;
@@ -5807,13 +5807,13 @@ A value of t (the default) means do whatever the window's frame
 specifies.  */);
 
   DEFVAR_PER_BUFFER ("indicate-empty-lines",
-		     &BVAR (current_buffer, indicate_empty_lines), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, indicate_empty_lines), Qnil,
 		     doc: /* Visually indicate empty lines after the buffer end.
 If non-nil, a bitmap is displayed in the left fringe of a window on
 window-systems.  */);
 
   DEFVAR_PER_BUFFER ("indicate-buffer-boundaries",
-		     &BVAR (current_buffer, indicate_buffer_boundaries), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, indicate_buffer_boundaries), Qnil,
 		     doc: /* Visually indicate buffer boundaries and scrolling.
 If non-nil, the first and last line of the buffer are marked in the fringe
 of a window on window-systems with angle bitmaps, or if the window can be
@@ -5838,7 +5838,7 @@ bitmaps in right fringe.  To show just the angle bitmaps in the left
 fringe, but no arrow bitmaps, use ((top .  left) (bottom . left)).  */);
 
   DEFVAR_PER_BUFFER ("fringe-indicator-alist",
-		     &BVAR (current_buffer, fringe_indicator_alist), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, fringe_indicator_alist), Qnil,
 		     doc: /* Mapping from logical to physical fringe indicator bitmaps.
 The value is an alist where each element (INDICATOR . BITMAPS)
 specifies the fringe bitmaps used to display a specific logical
@@ -5857,7 +5857,7 @@ last (only) line has no final newline.  BITMAPS may also be a single
 symbol which is used in both left and right fringes.  */);
 
   DEFVAR_PER_BUFFER ("fringe-cursor-alist",
-		     &BVAR (current_buffer, fringe_cursor_alist), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, fringe_cursor_alist), Qnil,
 		     doc: /* Mapping from logical to physical fringe cursor bitmaps.
 The value is an alist where each element (CURSOR . BITMAP)
 specifies the fringe bitmaps used to display a specific logical
@@ -5872,7 +5872,7 @@ BITMAP is the corresponding fringe bitmap shown for the logical
 cursor type.  */);
 
   DEFVAR_PER_BUFFER ("scroll-up-aggressively",
-		     &BVAR (current_buffer, scroll_up_aggressively), Qfraction,
+		     &BVAR_DEFAULTED (current_buffer, scroll_up_aggressively), Qfraction,
 		     doc: /* How far to scroll windows upward.
 If you move point off the bottom, the window scrolls automatically.
 This variable controls how far it scrolls.  The value nil, the default,
@@ -5885,7 +5885,7 @@ window scrolls by a full window height.  Meaningful values are
 between 0.0 and 1.0, inclusive.  */);
 
   DEFVAR_PER_BUFFER ("scroll-down-aggressively",
-		     &BVAR (current_buffer, scroll_down_aggressively), Qfraction,
+		     &BVAR_DEFAULTED (current_buffer, scroll_down_aggressively), Qfraction,
 		     doc: /* How far to scroll windows downward.
 If you move point off the top, the window scrolls automatically.
 This variable controls how far it scrolls.  The value nil, the default,
@@ -5985,7 +5985,7 @@ If the value of the variable is t, undo information is not recorded.  */);
   DEFVAR_PER_BUFFER ("mark-active", &BVAR (current_buffer, mark_active), Qnil,
 		     doc: /* Non-nil means the mark and region are currently active in this buffer.  */);
 
-  DEFVAR_PER_BUFFER ("cache-long-scans", &BVAR (current_buffer, cache_long_scans), Qnil,
+  DEFVAR_PER_BUFFER ("cache-long-scans", &BVAR_DEFAULTED (current_buffer, cache_long_scans), Qnil,
 		     doc: /* Non-nil means that Emacs should use caches in attempt to speedup buffer scans.
 
 There is no reason to set this to nil except for debugging purposes.
@@ -6092,7 +6092,7 @@ member of the list.  Any other non-nil value means disregard `buffer-read-only'
 and all `read-only' text properties.  */);
   Vinhibit_read_only = Qnil;
 
-  DEFVAR_PER_BUFFER ("cursor-type", &BVAR (current_buffer, cursor_type), Qnil,
+  DEFVAR_PER_BUFFER ("cursor-type", &BVAR_DEFAULTED (current_buffer, cursor_type), Qnil,
 		     doc: /* Cursor to use when this buffer is in the selected window.
 Values are interpreted as follows:
 
@@ -6116,7 +6116,7 @@ cursor's appearance is instead controlled by the variable
 `cursor-in-non-selected-windows'.  */);
 
   DEFVAR_PER_BUFFER ("line-spacing",
-		     &BVAR (current_buffer, extra_line_spacing), Qnumberp,
+		     &BVAR_DEFAULTED (current_buffer, extra_line_spacing), Qnumberp,
 		     doc: /* Additional space to put between lines when displaying a buffer.
 The space is measured in pixels, and put below lines on graphic displays,
 see `display-graphic-p'.
@@ -6124,7 +6124,7 @@ If value is a floating point number, it specifies the spacing relative
 to the default frame line height.  A value of nil means add no extra space.  */);
 
   DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows",
-		     &BVAR (current_buffer, cursor_in_non_selected_windows), Qnil,
+		     &BVAR_DEFAULTED (current_buffer, cursor_in_non_selected_windows), Qnil,
 		     doc: /* Non-nil means show a cursor in non-selected windows.
 If nil, only shows a cursor in the selected window.
 If t, displays a cursor related to the usual cursor type
diff --git a/src/buffer.h b/src/buffer.h
index f78046a9a8..2bbdfc6c0e 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -280,13 +280,18 @@ struct buffer_text
     bool_bf redisplay : 1;
   };
 
+#define BVAR_FIELD(field) field ## _
+#define BVAR_DEFAULTED_FIELD(field) field ## _defaulted_
+
 /* Most code should use this macro to access Lisp fields in struct buffer.  */
 
-#define BVAR(buf, field) ((buf)->field ## _)
+#define BVAR(buf, field) ((buf)->BVAR_FIELD(field))
+
+#define BVAR_DEFAULTED(buf, field) ((buf)->BVAR_DEFAULTED_FIELD(field))
 
-#define BVAR_OR_DEFAULT(buf, field) (EQ (BVAR ((buf), field), Qunbound) \
-				     ? BVAR (&buffer_defaults, field) \
-				     : BVAR ((buf), field))
+#define BVAR_OR_DEFAULT(buf, field) (EQ (BVAR_DEFAULTED ((buf), field), Qunbound) \
+				     ? BVAR_DEFAULTED (&buffer_defaults, field) \
+				     : BVAR_DEFAULTED ((buf), field))
 
 /* Max number of builtin per-buffer variables.  */
 enum { MAX_PER_BUFFER_VARS = 50 };
@@ -302,17 +307,17 @@ struct buffer
   union vectorlike_header header;
 
   /* The name of this buffer.  */
-  Lisp_Object name_;
+  Lisp_Object BVAR_FIELD(name);
 
   /* The name of the file visited in this buffer, or nil.  */
-  Lisp_Object filename_;
+  Lisp_Object BVAR_FIELD(filename);
 
   /* Directory for expanding relative file names.  */
-  Lisp_Object directory_;
+  Lisp_Object BVAR_FIELD(directory);
 
   /* True if this buffer has been backed up (if you write to the visited
      file and it hasn't been backed up, then a backup will be made).  */
-  Lisp_Object backed_up_;
+  Lisp_Object BVAR_FIELD(backed_up);
 
   /* Length of file when last read or saved.
      -1 means auto saving turned off because buffer shrank a lot.
@@ -320,142 +325,142 @@ struct buffer
        (That value is used with buffer-swap-text.)
      This is not in the  struct buffer_text
      because it's not used in indirect buffers at all.  */
-  Lisp_Object save_length_;
+  Lisp_Object BVAR_FIELD(save_length);
 
   /* File name used for auto-saving this buffer.
      This is not in the  struct buffer_text
      because it's not used in indirect buffers at all.  */
-  Lisp_Object auto_save_file_name_;
+  Lisp_Object BVAR_FIELD(auto_save_file_name);
 
   /* Non-nil if buffer read-only.  */
-  Lisp_Object read_only_;
+  Lisp_Object BVAR_FIELD(read_only);
 
   /* "The mark".  This is a marker which may
      point into this buffer or may point nowhere.  */
-  Lisp_Object mark_;
+  Lisp_Object BVAR_FIELD(mark);
 
   /* Alist of elements (SYMBOL . VALUE-IN-THIS-BUFFER) for all
      per-buffer variables of this buffer.  For locally unbound
      symbols, just the symbol appears as the element.  */
-  Lisp_Object local_var_alist_;
+  Lisp_Object BVAR_FIELD(local_var_alist);
 
   /* Symbol naming major mode (e.g., lisp-mode).  */
-  Lisp_Object major_mode_;
+  Lisp_Object BVAR_FIELD(major_mode);
 
   /* Symbol listing all currently enabled minor modes.  */
-  Lisp_Object local_minor_modes_;
+  Lisp_Object BVAR_FIELD(local_minor_modes);
 
   /* Pretty name of major mode (e.g., "Lisp"). */
-  Lisp_Object mode_name_;
+  Lisp_Object BVAR_FIELD(mode_name);
 
   /* Mode line element that controls format of mode line.  */
-  Lisp_Object mode_line_format_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(mode_line_format);
 
   /* Analogous to mode_line_format for the line displayed at the top
      of windows.  Nil means don't display that line.  */
-  Lisp_Object header_line_format_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(header_line_format);
 
   /* Analogous to mode_line_format for the line displayed at the top
      of windows.  Nil means don't display that line.  */
-  Lisp_Object tab_line_format_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(tab_line_format);
 
   /* Keys that are bound local to this buffer.  */
-  Lisp_Object keymap_;
+  Lisp_Object BVAR_FIELD(keymap);
 
   /* This buffer's local abbrev table.  */
-  Lisp_Object abbrev_table_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(abbrev_table);
 
   /* This buffer's syntax table.  */
-  Lisp_Object syntax_table_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(syntax_table);
 
   /* This buffer's category table.  */
-  Lisp_Object category_table_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(category_table);
 
   /* Values of several buffer-local variables.  */
   /* tab-width is buffer-local so that redisplay can find it
      in buffers that are not current.  */
-  Lisp_Object case_fold_search_;
-  Lisp_Object tab_width_;
-  Lisp_Object fill_column_;
-  Lisp_Object left_margin_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(case_fold_search);
+  Lisp_Object BVAR_DEFAULTED_FIELD(tab_width);
+  Lisp_Object BVAR_DEFAULTED_FIELD(fill_column);
+  Lisp_Object BVAR_DEFAULTED_FIELD(left_margin);
 
   /* Function to call when insert space past fill column.  */
-  Lisp_Object auto_fill_function_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(auto_fill_function);
 
   /* Case table for case-conversion in this buffer.
      This char-table maps each char into its lower-case version.  */
-  Lisp_Object downcase_table_;
+  Lisp_Object BVAR_FIELD(downcase_table);
 
   /* Char-table mapping each char to its upper-case version.  */
-  Lisp_Object upcase_table_;
+  Lisp_Object BVAR_FIELD(upcase_table);
 
   /* Char-table for conversion for case-folding search.  */
-  Lisp_Object case_canon_table_;
+  Lisp_Object BVAR_FIELD(case_canon_table);
 
   /* Char-table of equivalences for case-folding search.  */
-  Lisp_Object case_eqv_table_;
+  Lisp_Object BVAR_FIELD(case_eqv_table);
 
   /* Non-nil means do not display continuation lines.  */
-  Lisp_Object truncate_lines_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(truncate_lines);
 
   /* Non-nil means to use word wrapping when displaying continuation lines.  */
-  Lisp_Object word_wrap_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(word_wrap);
 
   /* Non-nil means display ctl chars with uparrow.  */
-  Lisp_Object ctl_arrow_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(ctl_arrow);
 
   /* Non-nil means reorder bidirectional text for display in the
      visual order.  */
-  Lisp_Object bidi_display_reordering_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(bidi_display_reordering);
 
   /* If non-nil, specifies which direction of text to force in all the
      paragraphs of the buffer.  Nil means determine paragraph
      direction dynamically for each paragraph.  */
-  Lisp_Object bidi_paragraph_direction_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(bidi_paragraph_direction);
 
   /* If non-nil, a regular expression for bidi paragraph separator.  */
-  Lisp_Object bidi_paragraph_separate_re_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(bidi_paragraph_separate_re);
 
   /* If non-nil, a regular expression for bidi paragraph start.  */
-  Lisp_Object bidi_paragraph_start_re_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(bidi_paragraph_start_re);
 
   /* Non-nil means do selective display;
      see doc string in syms_of_buffer (buffer.c) for details.  */
-  Lisp_Object selective_display_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(selective_display);
 
   /* Non-nil means show ... at end of line followed by invisible lines.  */
-  Lisp_Object selective_display_ellipses_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(selective_display_ellipses);
 
   /* t if "self-insertion" should overwrite; `binary' if it should also
      overwrite newlines and tabs - for editing executables and the like.  */
-  Lisp_Object overwrite_mode_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(overwrite_mode);
 
   /* Non-nil means abbrev mode is on.  Expand abbrevs automatically.  */
-  Lisp_Object abbrev_mode_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(abbrev_mode);
 
   /* Display table to use for text in this buffer.  */
-  Lisp_Object display_table_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(display_table);
 
   /* t means the mark and region are currently active.  */
-  Lisp_Object mark_active_;
+  Lisp_Object BVAR_FIELD(mark_active);
 
   /* Non-nil means the buffer contents are regarded as multi-byte
      form of characters, not a binary code.  */
-  Lisp_Object enable_multibyte_characters_;
+  Lisp_Object BVAR_FIELD(enable_multibyte_characters);
 
   /* Coding system to be used for encoding the buffer contents on
      saving.  */
-  Lisp_Object buffer_file_coding_system_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(buffer_file_coding_system);
 
   /* List of symbols naming the file format used for visited file.  */
-  Lisp_Object file_format_;
+  Lisp_Object BVAR_FIELD(file_format);
 
   /* List of symbols naming the file format used for auto-save file.  */
-  Lisp_Object auto_save_file_format_;
+  Lisp_Object BVAR_FIELD(auto_save_file_format);
 
   /* True if the newline position cache, width run cache and BIDI paragraph
      cache are enabled.  See search.c, indent.c and bidi.c for details.  */
-  Lisp_Object cache_long_scans_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(cache_long_scans);
 
   /* If the width run cache is enabled, this table contains the
      character widths width_run_cache (see above) assumes.  When we
@@ -463,106 +468,106 @@ struct buffer
      current display table to see whether the display table has
      affected the widths of any characters.  If it has, we
      invalidate the width run cache, and re-initialize width_table.  */
-  Lisp_Object width_table_;
+  Lisp_Object BVAR_FIELD(width_table);
 
   /* In an indirect buffer, or a buffer that is the base of an
      indirect buffer, this holds a marker that records
      PT for this buffer when the buffer is not current.  */
-  Lisp_Object pt_marker_;
+  Lisp_Object BVAR_FIELD(pt_marker);
 
   /* In an indirect buffer, or a buffer that is the base of an
      indirect buffer, this holds a marker that records
      BEGV for this buffer when the buffer is not current.  */
-  Lisp_Object begv_marker_;
+  Lisp_Object BVAR_FIELD(begv_marker);
 
   /* In an indirect buffer, or a buffer that is the base of an
      indirect buffer, this holds a marker that records
      ZV for this buffer when the buffer is not current.  */
-  Lisp_Object zv_marker_;
+  Lisp_Object BVAR_FIELD(zv_marker);
 
   /* This holds the point value before the last scroll operation.
      Explicitly setting point sets this to nil.  */
-  Lisp_Object point_before_scroll_;
+  Lisp_Object BVAR_FIELD(point_before_scroll);
 
   /* Truename of the visited file, or nil.  */
-  Lisp_Object file_truename_;
+  Lisp_Object BVAR_FIELD(file_truename);
 
   /* Invisibility spec of this buffer.
      t => any non-nil `invisible' property means invisible.
      A list => `invisible' property means invisible
      if it is memq in that list.  */
-  Lisp_Object invisibility_spec_;
+  Lisp_Object BVAR_FIELD(invisibility_spec);
 
   /* This is the last window that was selected with this buffer in it,
      or nil if that window no longer displays this buffer.  */
-  Lisp_Object last_selected_window_;
+  Lisp_Object BVAR_FIELD(last_selected_window);
 
   /* Incremented each time the buffer is displayed in a window.  */
-  Lisp_Object display_count_;
+  Lisp_Object BVAR_FIELD(display_count);
 
   /* Widths of left and right marginal areas for windows displaying
      this buffer.  */
-  Lisp_Object left_margin_cols_;
-  Lisp_Object right_margin_cols_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(left_margin_cols);
+  Lisp_Object BVAR_DEFAULTED_FIELD(right_margin_cols);
 
   /* Widths of left and right fringe areas for windows displaying
      this buffer.  */
-  Lisp_Object left_fringe_width_;
-  Lisp_Object right_fringe_width_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(left_fringe_width);
+  Lisp_Object BVAR_DEFAULTED_FIELD(right_fringe_width);
 
   /* Non-nil means fringes are drawn outside display margins;
      othersize draw them between margin areas and text.  */
-  Lisp_Object fringes_outside_margins_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(fringes_outside_margins);
 
   /* Width, height and types of scroll bar areas for windows displaying
      this buffer.  */
-  Lisp_Object scroll_bar_width_;
-  Lisp_Object scroll_bar_height_;
-  Lisp_Object vertical_scroll_bar_type_;
-  Lisp_Object horizontal_scroll_bar_type_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(scroll_bar_width);
+  Lisp_Object BVAR_DEFAULTED_FIELD(scroll_bar_height);
+  Lisp_Object BVAR_DEFAULTED_FIELD(vertical_scroll_bar_type);
+  Lisp_Object BVAR_DEFAULTED_FIELD(horizontal_scroll_bar_type);
 
   /* Non-nil means indicate lines not displaying text (in a style
      like vi).  */
-  Lisp_Object indicate_empty_lines_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(indicate_empty_lines);
 
   /* Non-nil means indicate buffer boundaries and scrolling.  */
-  Lisp_Object indicate_buffer_boundaries_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(indicate_buffer_boundaries);
 
   /* Logical to physical fringe bitmap mappings.  */
-  Lisp_Object fringe_indicator_alist_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(fringe_indicator_alist);
 
   /* Logical to physical cursor bitmap mappings.  */
-  Lisp_Object fringe_cursor_alist_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(fringe_cursor_alist);
 
   /* Time stamp updated each time this buffer is displayed in a window.  */
-  Lisp_Object display_time_;
+  Lisp_Object BVAR_FIELD(display_time);
 
   /* If scrolling the display because point is below the bottom of a
      window showing this buffer, try to choose a window start so
      that point ends up this number of lines from the top of the
      window.  Nil means that scrolling method isn't used.  */
-  Lisp_Object scroll_up_aggressively_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(scroll_up_aggressively);
 
   /* If scrolling the display because point is above the top of a
      window showing this buffer, try to choose a window start so
      that point ends up this number of lines from the bottom of the
      window.  Nil means that scrolling method isn't used.  */
-  Lisp_Object scroll_down_aggressively_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(scroll_down_aggressively);
 
   /* Desired cursor type in this buffer.  See the doc string of
      per-buffer variable `cursor-type'.  */
-  Lisp_Object cursor_type_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(cursor_type);
 
   /* An integer > 0 means put that number of pixels below text lines
      in the display of this buffer.  */
-  Lisp_Object extra_line_spacing_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(extra_line_spacing);
 
   /* Cursor type to display in non-selected windows.
      t means to use hollow box cursor.
      See `cursor-type' for other values.  */
-  Lisp_Object cursor_in_non_selected_windows_;
+  Lisp_Object BVAR_DEFAULTED_FIELD(cursor_in_non_selected_windows);
 
-  /* No more Lisp_Object beyond cursor_in_non_selected_windows_.
+  /* 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
@@ -714,12 +719,12 @@ XBUFFER (Lisp_Object a)
 INLINE void
 bset_bidi_paragraph_direction (struct buffer *b, Lisp_Object val)
 {
-  b->bidi_paragraph_direction_ = val;
+  b->BVAR_DEFAULTED_FIELD(bidi_paragraph_direction) = val;
 }
 INLINE void
 bset_cache_long_scans (struct buffer *b, Lisp_Object val)
 {
-  b->cache_long_scans_ = val;
+  b->BVAR_DEFAULTED_FIELD(cache_long_scans) = val;
 }
 INLINE void
 bset_case_canon_table (struct buffer *b, Lisp_Object val)
@@ -744,12 +749,12 @@ bset_display_count (struct buffer *b, Lisp_Object val)
 INLINE void
 bset_left_margin_cols (struct buffer *b, Lisp_Object val)
 {
-  b->left_margin_cols_ = val;
+  b->BVAR_DEFAULTED_FIELD(left_margin_cols) = val;
 }
 INLINE void
 bset_right_margin_cols (struct buffer *b, Lisp_Object val)
 {
-  b->right_margin_cols_ = val;
+  b->BVAR_DEFAULTED_FIELD(right_margin_cols) = val;
 }
 INLINE void
 bset_display_time (struct buffer *b, Lisp_Object val)
@@ -804,7 +809,7 @@ bset_read_only (struct buffer *b, Lisp_Object val)
 INLINE void
 bset_truncate_lines (struct buffer *b, Lisp_Object val)
 {
-  b->truncate_lines_ = val;
+  b->BVAR_DEFAULTED_FIELD(truncate_lines) = val;
 }
 INLINE void
 bset_undo_list (struct buffer *b, Lisp_Object val)
@@ -1047,7 +1052,7 @@ PTR_BYTE_POS (unsigned char const *ptr)
    structure, make sure that this is still correct.  */
 
 enum { BUFFER_LISP_SIZE = PSEUDOVECSIZE (struct buffer,
-					 cursor_in_non_selected_windows_) };
+					 BVAR_DEFAULTED_FIELD(cursor_in_non_selected_windows)) };
 
 /* Allocated size of the struct buffer part beyond leading
    Lisp_Objects, in word_size units.  */
@@ -1376,13 +1381,16 @@ OVERLAY_POSITION (Lisp_Object p)
 #define PER_BUFFER_VAR_OFFSET(VAR) \
   offsetof (struct buffer, VAR ## _)
 
+#define PER_BUFFER_VAR_DEFAULTED_OFFSET(VAR) \
+  offsetof (struct buffer, BVAR_DEFAULTED_FIELD(VAR))
+
 /* Used to iterate over normal Lisp_Object fields of struct buffer (all
    Lisp_Objects except undo_list).  If you add, remove, or reorder
    Lisp_Objects in a struct buffer, make sure that this is still correct.  */
 
 #define FOR_EACH_PER_BUFFER_OBJECT_AT(offset)				 \
   for (offset = PER_BUFFER_VAR_OFFSET (name);				 \
-       offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \
+       offset <= PER_BUFFER_VAR_DEFAULTED_OFFSET (cursor_in_non_selected_windows); \
        offset += word_size)
 
 /* Functions to get and set default value of the per-buffer
diff --git a/src/category.c b/src/category.c
index a9f5225df8..44b315d8b3 100644
--- a/src/category.c
+++ b/src/category.c
@@ -39,7 +39,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 static void
 bset_category_table (struct buffer *b, Lisp_Object val)
 {
-  b->category_table_ = val;
+  b->BVAR_DEFAULTED_FIELD(category_table) = val;
 }
 
 
diff --git a/src/category.h b/src/category.h
index cc32990478..eae3e121cd 100644
--- a/src/category.h
+++ b/src/category.h
@@ -94,7 +94,7 @@ CHAR_HAS_CATEGORY (int ch, int category)
 
 /* The standard category table is stored where it will automatically
    be used in all new buffers.  */
-#define Vstandard_category_table BVAR (&buffer_defaults, category_table)
+#define Vstandard_category_table BVAR_DEFAULTED (&buffer_defaults, category_table)
 
 /* Return the doc string of CATEGORY in category table TABLE.  */
 #define CATEGORY_DOCSTRING(table, category)				\
diff --git a/src/syntax.c b/src/syntax.c
index f2fbab1525..9c53dca5de 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -192,7 +192,7 @@ static void parse_sexp_propertize (ptrdiff_t charpos);
 static void
 bset_syntax_table (struct buffer *b, Lisp_Object val)
 {
-  b->syntax_table_ = val;
+  b->BVAR_DEFAULTED_FIELD(syntax_table) = val;
 }
 
 /* Whether the syntax of the character C has the prefix flag set.  */
diff --git a/src/syntax.h b/src/syntax.h
index 187946c899..b32b550fd7 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -31,7 +31,7 @@ extern void update_syntax_table_forward (ptrdiff_t, bool, Lisp_Object);
 
 /* The standard syntax table is stored where it will automatically
    be used in all new buffers.  */
-#define Vstandard_syntax_table BVAR (&buffer_defaults, syntax_table)
+#define Vstandard_syntax_table BVAR_DEFAULTED (&buffer_defaults, syntax_table)
 
 /* A syntax table is a chartable whose elements are cons cells
    (CODE+FLAGS . MATCHING-CHAR).  MATCHING-CHAR can be nil if the char
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 12/14] Assert that PER_BUFFER_IDX for Lisp variables is not 0
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 02:10:08 +0000
Resent-Message-ID: <handler.48264.B48264.162043978824922 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 48264 <at> debbugs.gnu.org
Cc: Spencer Baugh <sbaugh@HIDDEN>
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162043978824922
          (code B ref 48264); Sat, 08 May 2021 02:10:08 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:48 +0000
Received: from localhost ([127.0.0.1]:47187 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfCPb-0006Tp-Ud
	for submit <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:48 -0400
Received: from venus.catern.com ([68.183.49.163]:47956)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfCPH-0006Sv-Ac
 for 48264 <at> debbugs.gnu.org; Fri, 07 May 2021 22:09:42 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620439766; bh=ZE9Cwa8BBt02+uYxS7/iW4j7tc3H3sRNxIryYSbpCFo=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=DsytQO6RH0JzG4/U6LTByt06dxenpWbS4VhmWYw3LaXUuQEiyaXlUDlkPW/7akKuD
 rwrwe758Gw6RxdIzF8oFCY6VdpGyXF38BUEJmsWvE7sljkvbJ/cFVB9Ja2741YWNdi
 1NkK9BGQl4ODhMp8Nfot4A0I74vIl15G4Slf1DpY=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id A668F2E9834;
 Sat,  8 May 2021 02:09:26 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Fri,  7 May 2021 22:09:03 -0400
Message-Id: <20210508020905.13583-14-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

PER_BUFFER_IDX can't be 0 for Lisp variables - so this if-check was
always pointless.

* src/data.c (default_value): Change if to eassert.
---
 src/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/data.c b/src/data.c
index 30f8523af8..758ff68d83 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1758,8 +1758,8 @@ default_value (Lisp_Object symbol)
 	if (BUFFER_OBJFWDP (valcontents))
 	  {
 	    int offset = XBUFFER_OBJFWD (valcontents)->offset;
-	    if (PER_BUFFER_IDX (offset) != 0)
-	      return per_buffer_default (offset);
+	    eassert (PER_BUFFER_IDX (offset) != 0);
+	    return per_buffer_default (offset);
 	  }
 
 	/* For other variables, get the current value.  */
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 06:41:01 +0000
Resent-Message-ID: <handler.48264.B48264.16204560212701 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.16204560212701
          (code B ref 48264); Sat, 08 May 2021 06:41:01 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 06:40:21 +0000
Received: from localhost ([127.0.0.1]:48393 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfGdL-0000hV-JH
	for submit <at> debbugs.gnu.org; Sat, 08 May 2021 02:40:21 -0400
Received: from eggs.gnu.org ([209.51.188.92]:46066)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lfGdI-0000hI-RC
 for 48264 <at> debbugs.gnu.org; Sat, 08 May 2021 02:40:13 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:53460)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lfGdD-0004A7-HA; Sat, 08 May 2021 02:40:07 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3405
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1lfGdD-0006EQ-3e; Sat, 08 May 2021 02:40:07 -0400
Date: Sat, 08 May 2021 09:40:06 +0300
Message-Id: <83tundafuh.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87r1iip6ra.fsf@HIDDEN> (message from Spencer Baugh on Fri,
 07 May 2021 17:35:05 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-13-sbaugh@HIDDEN> <83a6p6ddur.fsf@HIDDEN>
 <87fsyyr87y.fsf@HIDDEN> <83o8dmbrka.fsf@HIDDEN>
 <877dkar5ot.fsf@HIDDEN> <83im3uboq0.fsf@HIDDEN>
 <87r1iip6ra.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Fri, 07 May 2021 17:35:05 -0400
> 
> OK, in the end I was able to get moving init_{syntax,category}_once
> after init_buffer_once to work, by initializing the two variables to
> Qnil in buffer.c.  I assume it wasn't working before because they were
> Qunbound rather than Qnil, and something is checking NILP to see if the
> variables are initialized. (Although not sure what).
> 
> So, I was able to remove the special case.

Great, thanks.  Please be sure to bootstrap as part of your tests, to
make sure this doesn't get in the way then, and also run all of the
tests in the test suite, fingers crossed.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 06:56:01 +0000
Resent-Message-ID: <handler.48264.B48264.16204569493093 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.16204569493093
          (code B ref 48264); Sat, 08 May 2021 06:56:01 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 06:55:49 +0000
Received: from localhost ([127.0.0.1]:48455 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfGsP-0000np-Be
	for submit <at> debbugs.gnu.org; Sat, 08 May 2021 02:55:49 -0400
Received: from eggs.gnu.org ([209.51.188.92]:47304)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lfGsN-0000ni-Nl
 for 48264 <at> debbugs.gnu.org; Sat, 08 May 2021 02:55:48 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:53522)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lfGsI-00052h-AH; Sat, 08 May 2021 02:55:42 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4360
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1lfGsH-0007E5-EF; Sat, 08 May 2021 02:55:42 -0400
Date: Sat, 08 May 2021 09:55:38 +0300
Message-Id: <83sg2xaf4l.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87mtt6p6co.fsf@HIDDEN> (message from Spencer Baugh on Fri,
 07 May 2021 17:43:51 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-16-sbaugh@HIDDEN> <835yzudcvz.fsf@HIDDEN>
 <87o8dmr96v.fsf@HIDDEN> <83tunebsiu.fsf@HIDDEN>
 <87mtt6p6co.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Fri, 07 May 2021 17:43:51 -0400
> 
> > If the sole purpose is to be able to detect coding mistakes, then
> > there are other possibilities to do that, if the compiler cannot help
> > in a way that leaves the sources readable.
> 
> Hopefully.  Although, I'm not sure this approach is fundamentally
> unreadable?  The field names are already mangled with the trailing "_"
> to stop direct access; this is just further mangling them.

Yes, but it's much more than just the appended _.

Consider also the case of some developer instructing a user to provide
values of these fields in a GDB session: currently we need to tell the
user to use just "p foo->bar_".  With this change, we'd need to make
the user type much more, and possibly also make sure Emacs is compiled
with -g3 to have the macros available to the debugger.

> >> No, this is purely just changing the name of the fields - it has no
> >> impact on functionality, C code can still set the buffer-local
> >> variables.
> >
> > Then I guess the _defaulted_ part is a misnomer?
> 
> Possibly; by "defaulted" I intended to mean that the field is one which
> has a default.  But I freely acknowledge it's not a great name.

So how about using _d_ of _def_instead?  It's much shorter and
expresses the purpose no worse than _defaulted_.

> Keep in mind though, this name isn't exposed to the programmer
> anywhere - it might as well be _ABCDEFGHI_, nothing will change
> outside the definition of the BVAR_DEFAULTED_FIELD macro.

See above: I'd prefer to get rid of the macro for this purpose.

> > Failing that, maybe we should simply have a test to detect the
> > mistakes?  That wouldn't prevent bad code from being compiled, but it
> > should reveal it soon enough, since tests are regularly run on hydra.
> 
> A conditionally-compiled runtime check would be very easy to add - I'd
> just change BVAR to something like:
> 
>   (eassert (EQ (buffer_defaults->field ## _)); (buf)->field ## _)
> 
> Which would make sure that it's not used on anything with a default.
> But of course that's substantially more annoying than a compile time
> check...

I'm not sure I understand why this is much more annoying, can you
elaborate?  We have similar assertions, conditioned on
ENABLE_CHECKING, elsewhere in our macros, like XWINDOW etc, so why not
here?




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 13:23:01 +0000
Resent-Message-ID: <handler.48264.B48264.16204801754810 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.16204801754810
          (code B ref 48264); Sat, 08 May 2021 13:23:01 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 13:22:55 +0000
Received: from localhost ([127.0.0.1]:50286 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfMv0-0001FW-OU
	for submit <at> debbugs.gnu.org; Sat, 08 May 2021 09:22:54 -0400
Received: from venus.catern.com ([68.183.49.163]:32838)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfMuz-0001FQ-5o
 for 48264 <at> debbugs.gnu.org; Sat, 08 May 2021 09:22:53 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620480172; bh=KJirdyQKrSOUgjoW85bB0KR5t2jkX4aCtHBM6gIT4Nc=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=DZyz6sNKBlElGiN/1M0IRoupgBG2I9B9G6K+q653fkt6VpkY3SfCQdqpw857RH9hU
 NOYrkl4UONlyVpuYQq05nRYC7g2C/OAnviuLVh0SRQZ1RoXvd9SVDz0Odk67eA6MM2
 LjRVdMJRNQ85Y7lMxZhArsWBoVm7ccQF9PyUdv0U=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 6D0E22E881A;
 Sat,  8 May 2021 13:22:52 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83tundafuh.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-13-sbaugh@HIDDEN> <83a6p6ddur.fsf@HIDDEN>
 <87fsyyr87y.fsf@HIDDEN> <83o8dmbrka.fsf@HIDDEN>
 <877dkar5ot.fsf@HIDDEN> <83im3uboq0.fsf@HIDDEN>
 <87r1iip6ra.fsf@HIDDEN> <83tundafuh.fsf@HIDDEN>
Date: Sat, 08 May 2021 09:22:52 -0400
Message-ID: <87fsyxpdg3.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Cc: 48264 <at> debbugs.gnu.org
>> Date: Fri, 07 May 2021 17:35:05 -0400
>> 
>> OK, in the end I was able to get moving init_{syntax,category}_once
>> after init_buffer_once to work, by initializing the two variables to
>> Qnil in buffer.c.  I assume it wasn't working before because they were
>> Qunbound rather than Qnil, and something is checking NILP to see if the
>> variables are initialized. (Although not sure what).
>> 
>> So, I was able to remove the special case.
>
> Great, thanks.  Please be sure to bootstrap as part of your tests, to
> make sure this doesn't get in the way then, and also run all of the
> tests in the test suite, fingers crossed.

Ype, the latest revision of the patch series passes `make check` after
every individual commit.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 13:36:01 +0000
Resent-Message-ID: <handler.48264.B48264.16204809385292 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.16204809385292
          (code B ref 48264); Sat, 08 May 2021 13:36:01 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 13:35:38 +0000
Received: from localhost ([127.0.0.1]:50360 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfN7J-0001NI-Pm
	for submit <at> debbugs.gnu.org; Sat, 08 May 2021 09:35:38 -0400
Received: from venus.catern.com ([68.183.49.163]:33124)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfN7H-0001NC-PX
 for 48264 <at> debbugs.gnu.org; Sat, 08 May 2021 09:35:36 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620480932; bh=bCLCuHnweiJw2p3H7bn/lQsciHEWM7EWqBVJyrdORgs=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=SFmXNBeQCD/gWegTrOdNblzuySz0NMFOQNaWTexck7/M0oUCOV1aSaK+j7S3NU437
 PhLS/5VrGQCp34/JblBqLTvn06PiraoZEBvOlabX23/Gb/vY5N+2eLmoRk0he/miiZ
 nr7Zhdc0TY5wFM7+Qrg7vEsF1bDRg+KP5olW41Vw=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 48CB42E95D8;
 Sat,  8 May 2021 13:35:32 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83sg2xaf4l.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-16-sbaugh@HIDDEN> <835yzudcvz.fsf@HIDDEN>
 <87o8dmr96v.fsf@HIDDEN> <83tunebsiu.fsf@HIDDEN>
 <87mtt6p6co.fsf@HIDDEN> <83sg2xaf4l.fsf@HIDDEN>
Date: Sat, 08 May 2021 09:35:31 -0400
Message-ID: <87czu1pcv0.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Cc: 48264 <at> debbugs.gnu.org
>> Date: Fri, 07 May 2021 17:43:51 -0400
>> 
>> > If the sole purpose is to be able to detect coding mistakes, then
>> > there are other possibilities to do that, if the compiler cannot help
>> > in a way that leaves the sources readable.
>> 
>> Hopefully.  Although, I'm not sure this approach is fundamentally
>> unreadable?  The field names are already mangled with the trailing "_"
>> to stop direct access; this is just further mangling them.
>
> Yes, but it's much more than just the appended _.
>
> Consider also the case of some developer instructing a user to provide
> values of these fields in a GDB session: currently we need to tell the
> user to use just "p foo->bar_".  With this change, we'd need to make
> the user type much more, and possibly also make sure Emacs is compiled
> with -g3 to have the macros available to the debugger.

Yes, that's fair.

>> >> No, this is purely just changing the name of the fields - it has no
>> >> impact on functionality, C code can still set the buffer-local
>> >> variables.
>> >
>> > Then I guess the _defaulted_ part is a misnomer?
>> 
>> Possibly; by "defaulted" I intended to mean that the field is one which
>> has a default.  But I freely acknowledge it's not a great name.
>
> So how about using _d_ of _def_instead?  It's much shorter and
> expresses the purpose no worse than _defaulted_.

Sure, that would work.

>> Keep in mind though, this name isn't exposed to the programmer
>> anywhere - it might as well be _ABCDEFGHI_, nothing will change
>> outside the definition of the BVAR_DEFAULTED_FIELD macro.
>
> See above: I'd prefer to get rid of the macro for this purpose.

Sure, we could mostly get rid of it, although it's important that the
argument to BVAR_OR_DEFAULT be "case_fold_search" rather than, say,
"case_fold_search_def", even if the field is named the latter.
Otherwise one might accidentally call BVAR with "case_fold_search_def",
which would compile but behave wrong at runtime - and preventing that is
the whole point of the different names.

>> > Failing that, maybe we should simply have a test to detect the
>> > mistakes?  That wouldn't prevent bad code from being compiled, but it
>> > should reveal it soon enough, since tests are regularly run on hydra.
>> 
>> A conditionally-compiled runtime check would be very easy to add - I'd
>> just change BVAR to something like:
>> 
>>   (eassert (EQ (buffer_defaults->field ## _)); (buf)->field ## _)
>> 
>> Which would make sure that it's not used on anything with a default.
>> But of course that's substantially more annoying than a compile time
>> check...
>
> I'm not sure I understand why this is much more annoying, can you
> elaborate?  We have similar assertions, conditioned on
> ENABLE_CHECKING, elsewhere in our macros, like XWINDOW etc, so why not
> here?

I mean that it's annoying that merely compiling doesn't detect the usage
error, one has to actually run tests.  Since it seems like an easy
mistake to make, that seems like it would be frustrating.  But of course
it's better than nothing and we can make it compile time later on.

If you think such a conditionally-compiled runtime check would be
acceptable for applying these changes, I can go ahead and write that.
I've actually just convinced myself that going with a runtime check at
first and figuring out a compile time check later is a good way to go.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 13:59:01 +0000
Resent-Message-ID: <handler.48264.B48264.16204823086377 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>, Stefan Monnier <monnier@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.16204823086377
          (code B ref 48264); Sat, 08 May 2021 13:59:01 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 13:58:28 +0000
Received: from localhost ([127.0.0.1]:50462 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfNTP-0001en-K5
	for submit <at> debbugs.gnu.org; Sat, 08 May 2021 09:58:27 -0400
Received: from eggs.gnu.org ([209.51.188.92]:54984)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lfNTO-0001eg-8n
 for 48264 <at> debbugs.gnu.org; Sat, 08 May 2021 09:58:26 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:34328)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lfNTI-0007CA-Hh; Sat, 08 May 2021 09:58:20 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2584
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1lfNTH-0002Nk-Ej; Sat, 08 May 2021 09:58:20 -0400
Date: Sat, 08 May 2021 16:58:17 +0300
Message-Id: <83a6p59vk6.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87czu1pcv0.fsf@HIDDEN> (message from Spencer Baugh on Sat,
 08 May 2021 09:35:31 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-16-sbaugh@HIDDEN> <835yzudcvz.fsf@HIDDEN>
 <87o8dmr96v.fsf@HIDDEN> <83tunebsiu.fsf@HIDDEN>
 <87mtt6p6co.fsf@HIDDEN> <83sg2xaf4l.fsf@HIDDEN>
 <87czu1pcv0.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Sat, 08 May 2021 09:35:31 -0400
> 
> > So how about using _d_ of _def_instead?  It's much shorter and
> > expresses the purpose no worse than _defaulted_.
> 
> Sure, that would work.
> 
> >> Keep in mind though, this name isn't exposed to the programmer
> >> anywhere - it might as well be _ABCDEFGHI_, nothing will change
> >> outside the definition of the BVAR_DEFAULTED_FIELD macro.
> >
> > See above: I'd prefer to get rid of the macro for this purpose.
> 
> Sure, we could mostly get rid of it, although it's important that the
> argument to BVAR_OR_DEFAULT be "case_fold_search" rather than, say,
> "case_fold_search_def", even if the field is named the latter.
> Otherwise one might accidentally call BVAR with "case_fold_search_def",
> which would compile but behave wrong at runtime - and preventing that is
> the whole point of the different names.

I agree, but I'm not sure I see the connection.  Can you tell how
getting rid of the macro in the likes of b->SOME_MACRO(foo) could run
afoul of the argument to BVAR_OR_DEFAULT?

> >>   (eassert (EQ (buffer_defaults->field ## _)); (buf)->field ## _)
> >> 
> >> Which would make sure that it's not used on anything with a default.
> >> But of course that's substantially more annoying than a compile time
> >> check...
> >
> > I'm not sure I understand why this is much more annoying, can you
> > elaborate?  We have similar assertions, conditioned on
> > ENABLE_CHECKING, elsewhere in our macros, like XWINDOW etc, so why not
> > here?
> 
> I mean that it's annoying that merely compiling doesn't detect the usage
> error, one has to actually run tests.

Well, with eassert just running Emacs will sooner or later crash with
SIGABRT, so I think it's acceptable.  Again, we do that in other
cases, quite a lot, actually, so there's no reason to treat this
particular case differently.

> If you think such a conditionally-compiled runtime check would be
> acceptable for applying these changes, I can go ahead and write that.

Yes, I think so.  But if Lars or Stefan think differently, I might
reconsider.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 17:14:01 +0000
Resent-Message-ID: <handler.48264.B48264.162049402812807 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162049402812807
          (code B ref 48264); Sat, 08 May 2021 17:14:01 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 17:13:48 +0000
Received: from localhost ([127.0.0.1]:51276 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfQWS-0003KV-4M
	for submit <at> debbugs.gnu.org; Sat, 08 May 2021 13:13:48 -0400
Received: from venus.catern.com ([68.183.49.163]:37404)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfQWO-0003KP-AZ
 for 48264 <at> debbugs.gnu.org; Sat, 08 May 2021 13:13:46 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620494023; bh=Htc4wMj8GirGEBAjyYd2rq/0rKSmBYN6DQdmesMjyfo=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=FQRFa8PdcxoeonGt5LFxzb6tPxj9ftZ7Z4jmLDNAfUwIfKeyUHI17Ob/YnZw2vydv
 twk+nCRFcJ0+rOUO1O+c6nI2Vt6vqfiFpxWNZXjijYcjEidQztdy1qd7dklOMrWWyb
 6dlHyWx+CUXP/H+YskXK3iA7Lsfzx1EtUghEcL2M=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id E170F2E9869;
 Sat,  8 May 2021 17:13:42 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83a6p59vk6.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-16-sbaugh@HIDDEN> <835yzudcvz.fsf@HIDDEN>
 <87o8dmr96v.fsf@HIDDEN> <83tunebsiu.fsf@HIDDEN>
 <87mtt6p6co.fsf@HIDDEN> <83sg2xaf4l.fsf@HIDDEN>
 <87czu1pcv0.fsf@HIDDEN> <83a6p59vk6.fsf@HIDDEN>
Date: Sat, 08 May 2021 13:13:42 -0400
Message-ID: <878s4pp2rd.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Cc: 48264 <at> debbugs.gnu.org
>> Date: Sat, 08 May 2021 09:35:31 -0400
>> >> Keep in mind though, this name isn't exposed to the programmer
>> >> anywhere - it might as well be _ABCDEFGHI_, nothing will change
>> >> outside the definition of the BVAR_DEFAULTED_FIELD macro.
>> >
>> > See above: I'd prefer to get rid of the macro for this purpose.
>> 
>> Sure, we could mostly get rid of it, although it's important that the
>> argument to BVAR_OR_DEFAULT be "case_fold_search" rather than, say,
>> "case_fold_search_def", even if the field is named the latter.
>> Otherwise one might accidentally call BVAR with "case_fold_search_def",
>> which would compile but behave wrong at runtime - and preventing that is
>> the whole point of the different names.
>
> I agree, but I'm not sure I see the connection.  Can you tell how
> getting rid of the macro in the likes of b->SOME_MACRO(foo) could run
> afoul of the argument to BVAR_OR_DEFAULT?

Just wanted to make sure we were on the same page.  I don't think
getting rid of the macro in b->SOME_MACRO(foo) will run afoul of the
argument to BVAR_OR_DEFAULT.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v4 00/15] Speeding up setting the default for DEFVAR_PER_BUFFER vars
Resent-From: Stefan Monnier <monnier@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 18:07:02 +0000
Resent-Message-ID: <handler.48264.B48264.162049718814804 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162049718814804
          (code B ref 48264); Sat, 08 May 2021 18:07:02 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 18:06:28 +0000
Received: from localhost ([127.0.0.1]:51521 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfRLP-0003qi-Pj
	for submit <at> debbugs.gnu.org; Sat, 08 May 2021 14:06:27 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:30862)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1lfRLN-0003qZ-U9
 for 48264 <at> debbugs.gnu.org; Sat, 08 May 2021 14:06:26 -0400
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 516E58090B;
 Sat,  8 May 2021 14:06:20 -0400 (EDT)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 160C380533;
 Sat,  8 May 2021 14:06:19 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1620497179;
 bh=j3ZzcC8iaj8jkWYEiG9bHi88D1ZyJn6fmc5FEAELoiA=;
 h=From:To:Cc:Subject:References:Date:In-Reply-To:From;
 b=OIXnwTPeqMyPxgdFtlqGMxeRsaBUr1vuF0bzgaZxpqIIudEGZf6Ahwuvdv5a17YLL
 iezqCCkQR8vBCEd2KCau+aP1Xxun4/fxFODr5YtEazbe7V6LSVTK0dB80Q+nCpzCLp
 /s7W2Yg67DiIJEbED3OoWABmpXFTfdHUEzM+R6qEVH2rUKg+hDITwTlZ/czhR+Owy6
 StUn/GPNW11Oy+v8Q23coPH4WhwPyqKRYPW2FC8y9KxWTJ7lKgIUaiYqr9mCYeGtVF
 hCgF0M5igCy/Gw56BJyheudDRCLmNCRRXOJKg4OrURRD01D8dlCxsI9buBXn1URtuP
 6xKZOURSL4p+w==
Received: from alfajor (76-10-140-76.dsl.teksavvy.com [76.10.140.76])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id DB9F112013B;
 Sat,  8 May 2021 14:06:18 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
Message-ID: <jwv1rah3yqp.fsf-monnier+emacs@HIDDEN>
References: <20210506213346.9730-1-sbaugh@HIDDEN>
 <20210508020905.13583-1-sbaugh@HIDDEN>
Date: Sat, 08 May 2021 14:06:18 -0400
In-Reply-To: <20210508020905.13583-1-sbaugh@HIDDEN> (Spencer Baugh's
 message of "Fri,  7 May 2021 22:08:50 -0400")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.025 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

I just took a look at your v4 patch set, and it looks really nice to me.
I had a few minor cosmetic comments about some of the patches, but it
only affects code which gets replaced by further patches, so I see no
need to take them into account.
Thanks,


        Stefan





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 08 May 2021 19:04:01 +0000
Resent-Message-ID: <handler.48264.B48264.162050063016683 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162050063016683
          (code B ref 48264); Sat, 08 May 2021 19:04:01 +0000
Received: (at 48264) by debbugs.gnu.org; 8 May 2021 19:03:50 +0000
Received: from localhost ([127.0.0.1]:51758 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfSEw-0004L1-HE
	for submit <at> debbugs.gnu.org; Sat, 08 May 2021 15:03:50 -0400
Received: from venus.catern.com ([68.183.49.163]:39502)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfSEt-0004Kv-RL
 for 48264 <at> debbugs.gnu.org; Sat, 08 May 2021 15:03:48 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620500627; bh=EXGb0UNPLth4UGLPK4Xc+kMtrNHeTwxri5xmrirSh5w=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=eeCOjeJxBjTzwtszq9jvES6Uc9LldlP6nlNfFWAaGA/Awk8REj8F1wcmehSzhWZVf
 vNAp+0vqwBqT3d1+9PvNiCkMSp1RtCCkcHwjXT/k2g0M8jp1hflt5ggiKs3RmPh8Wx
 EUDgHUGpQVZFkZpFy/vK0cwLXQYU0ymMPzsq83bU=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 4B1DA2E9363;
 Sat,  8 May 2021 19:03:47 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83a6p59vk6.fsf@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-16-sbaugh@HIDDEN> <835yzudcvz.fsf@HIDDEN>
 <87o8dmr96v.fsf@HIDDEN> <83tunebsiu.fsf@HIDDEN>
 <87mtt6p6co.fsf@HIDDEN> <83sg2xaf4l.fsf@HIDDEN>
 <87czu1pcv0.fsf@HIDDEN> <83a6p59vk6.fsf@HIDDEN>
Date: Sat, 08 May 2021 15:03:46 -0400
Message-ID: <875yztoxnx.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Cc: 48264 <at> debbugs.gnu.org
>> Date: Sat, 08 May 2021 09:35:31 -0400
>> If you think such a conditionally-compiled runtime check would be
>> acceptable for applying these changes, I can go ahead and write that.
>
> Yes, I think so.  But if Lars or Stefan think differently, I might
> reconsider.

In the process of implementing the runtime check, I, of course, came up
with a better compile-time check. How about this?

---
 src/buffer.h | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/buffer.h b/src/buffer.h
index f78046a9a8..a8a662b1ed 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -280,13 +280,25 @@ struct buffer_text
     bool_bf redisplay : 1;
   };
 
+/* This structure is used purely as a list of field names that are
+   permitted for use with BVAR; it's never actually instantiated.  */
+struct bvar_permanent_locals {
+  char name, filename, directory, backed_up, save_length, auto_save_file_name,
+    read_only, mark, local_var_alist, major_mode, local_minor_modes, mode_name,
+    keymap, downcase_table, upcase_table, case_canon_table, case_eqv_table,
+    mark_active, enable_multibyte_characters, file_format,
+    auto_save_file_format, width_table, pt_marker, begv_marker, zv_marker,
+    point_before_scroll, file_truename, invisibility_spec, last_selected_window,
+    display_count, display_time, undo_list;
+};
 /* Most code should use this macro to access Lisp fields in struct buffer.  */
 
-#define BVAR(buf, field) ((buf)->field ## _)
+#define BVAR(buf, field) \
+  *((void) offsetof (struct bvar_permanent_locals, field), &(buf)->field ## _)
 
-#define BVAR_OR_DEFAULT(buf, field) (EQ (BVAR ((buf), field), Qunbound) \
-				     ? BVAR (&buffer_defaults, field) \
-				     : BVAR ((buf), field))
+#define BVAR_OR_DEFAULT(buf, field) (EQ ((buf)->field ## _, Qunbound)	\
+				     ? buffer_defaults.field ## _	\
+				     : (buf)->field ## _)
 
 /* Max number of builtin per-buffer variables.  */
 enum { MAX_PER_BUFFER_VARS = 50 };
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 09 May 2021 08:11:02 +0000
Resent-Message-ID: <handler.48264.B48264.162054784331777 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: monnier@HIDDEN, 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162054784331777
          (code B ref 48264); Sun, 09 May 2021 08:11:02 +0000
Received: (at 48264) by debbugs.gnu.org; 9 May 2021 08:10:43 +0000
Received: from localhost ([127.0.0.1]:54937 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfeWQ-0008GT-UD
	for submit <at> debbugs.gnu.org; Sun, 09 May 2021 04:10:43 -0400
Received: from eggs.gnu.org ([209.51.188.92]:60740)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lfeWP-0008GN-HZ
 for 48264 <at> debbugs.gnu.org; Sun, 09 May 2021 04:10:41 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:55700)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lfeWJ-0006Bj-KE; Sun, 09 May 2021 04:10:35 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2450
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1lfeWI-00075Z-Kh; Sun, 09 May 2021 04:10:35 -0400
Date: Sun, 09 May 2021 11:10:33 +0300
Message-Id: <83im3s8gzq.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <875yztoxnx.fsf@HIDDEN> (message from Spencer Baugh on Sat,
 08 May 2021 15:03:46 -0400)
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-16-sbaugh@HIDDEN> <835yzudcvz.fsf@HIDDEN>
 <87o8dmr96v.fsf@HIDDEN> <83tunebsiu.fsf@HIDDEN>
 <87mtt6p6co.fsf@HIDDEN> <83sg2xaf4l.fsf@HIDDEN>
 <87czu1pcv0.fsf@HIDDEN> <83a6p59vk6.fsf@HIDDEN>
 <875yztoxnx.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: 48264 <at> debbugs.gnu.org
> Date: Sat, 08 May 2021 15:03:46 -0400
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> >> From: Spencer Baugh <sbaugh@HIDDEN>
> >> Cc: 48264 <at> debbugs.gnu.org
> >> Date: Sat, 08 May 2021 09:35:31 -0400
> >> If you think such a conditionally-compiled runtime check would be
> >> acceptable for applying these changes, I can go ahead and write that.
> >
> > Yes, I think so.  But if Lars or Stefan think differently, I might
> > reconsider.
> 
> In the process of implementing the runtime check, I, of course, came up
> with a better compile-time check. How about this?

LGTM, thanks.  But could you please run your benchmarks again, with
this implementation, to make sure we still get only a 1 - 2% slowdown
at worst?  I wouldn't expect the addition to matter in an optimized
build, but just to be sure...




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Lars Ingebrigtsen <larsi@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 09 May 2021 10:09:02 +0000
Resent-Message-ID: <handler.48264.B48264.162055494129344 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: Spencer Baugh <sbaugh@HIDDEN>, Stefan Monnier <monnier@HIDDEN>, 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162055494129344
          (code B ref 48264); Sun, 09 May 2021 10:09:02 +0000
Received: (at 48264) by debbugs.gnu.org; 9 May 2021 10:09:01 +0000
Received: from localhost ([127.0.0.1]:55239 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfgMu-0007dE-Sv
	for submit <at> debbugs.gnu.org; Sun, 09 May 2021 06:09:01 -0400
Received: from quimby.gnus.org ([95.216.78.240]:52446)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1lfgMs-0007d5-Tu
 for 48264 <at> debbugs.gnu.org; Sun, 09 May 2021 06:08:59 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To: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=0I4JIHCBTxT8e0rtUHYx1b+IO9KiWZPa9UyLMtdQPrU=; b=qFZY9qzZ/swiMJ1bsoS9qkvk2N
 QzcvnPB7WHrDdcn1/cEn0QilvlRtaG3/vrvZMrFgT9swxHkVCIhmz1difuIR/JqT16TdRGhLcTLqN
 hpfsnA8coQSVJDI8O88rccR30RBqCgg5staK5upxeUFXlYamd4Nbi2VlNhK8y2fPUq78=;
Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1lfgMk-00084W-Em; Sun, 09 May 2021 12:08:52 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
References: <877dkbsj9d.fsf@HIDDEN>
 <20210506213346.9730-16-sbaugh@HIDDEN> <835yzudcvz.fsf@HIDDEN>
 <87o8dmr96v.fsf@HIDDEN> <83tunebsiu.fsf@HIDDEN>
 <87mtt6p6co.fsf@HIDDEN> <83sg2xaf4l.fsf@HIDDEN>
 <87czu1pcv0.fsf@HIDDEN> <83a6p59vk6.fsf@HIDDEN>
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj
 SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAGFBMVEX9/P3T0tOdm5ts
 aGhPTEuBfX0/PDv////akPEOAAAAAWJLR0QHFmGI6wAAAAd0SU1FB+UFCQk0IccnOE0AAAGpSURB
 VDjLtZRLcsIwDIZJZtgnBfY00H2LzAGIhNeUTE9Q1/c/QvXLdh6Ubc3w0me9paxW/3La9pm0eiGh
 8+tf+cAi5MKpebDiJJ1wbZb3VRajoX5ONmQgQEU+ZmAg56MBvCeVmsiJB/BRX5cRHAimVKQaXnwo
 KnUGAQA/3ovCQOzMb7AI4k8Gdp8tVh80aB+b4ppLfonGm4E1Iah8ojm65OzOE1BTXkKffLM5gRtk
 qJkENuC4KHhkiIAtk2oCErQyuOD3DyDmDMUAywh8qnDKvWb+ItySXHpXgPBAU3JQ92KAGHJYY8is
 nrelhkE4NICoErBPALJwV07OWZSwfn03uSSOkga+1G5MYEtjVCi/3orXVF31kQmsaXdiP85IBogI
 l1I/qrexJMmUSJ6G3ZS5swA4z896aqDTbIWvZaTJp6HKafI4vVt0QVutHTKlcXhrNNWa7lGSfpr2
 ow4aOht81IruZ4uDeuvoaAuZ5vux2rk8JIHvyyU8Bt2doAmeHrf24DQq5tnWlq1vOz34U7UtHgXV
 /d4tlTfDZ9c1eFBknapYbdvnD490fgFY+rbxDBEtFgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0w
 NS0wOVQwOTo1MjozMiswMDowMBNi4QsAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDUtMDlUMDk6
 NTI6MzIrMDA6MDBiP1m3AAAAAElFTkSuQmCC
X-Now-Playing: Zonal's _Wrecked_: "System Error"
Date: Sun, 09 May 2021 12:08:49 +0200
In-Reply-To: <83a6p59vk6.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 08 May
 2021 16:58:17 +0300")
Message-ID: <87h7jcnrri.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  Eli Zaretskii <eliz@HIDDEN> writes: >> If you think such
 a conditionally-compiled runtime check would be >> acceptable for applying
 these changes, I can go ahead and write that. > > Yes, I think so. But if
 Lars or Stefan think different [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> If you think such a conditionally-compiled runtime check would be
>> acceptable for applying these changes, I can go ahead and write that.
>
> Yes, I think so.  But if Lars or Stefan think differently, I might
> reconsider.

I'd prefer compile time checks, certainly...  but I see that Spencer has
added a way to get those without adding the awkward struct accessor
macros now, so I guess the question is moot.

But listing the permanently local variables in a list like this:

+/* This structure is used purely as a list of field names that are
+   permitted for use with BVAR; it's never actually instantiated.  */
+struct bvar_permanent_locals {

at least requires commentary in the struct they're defined in so that we
don't remember to update the list when we add new permanently local
variables...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 09 May 2021 17:10:02 +0000
Resent-Message-ID: <handler.48264.B48264.162058018023276 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: Spencer Baugh <sbaugh@HIDDEN>, monnier@HIDDEN, 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162058018023276
          (code B ref 48264); Sun, 09 May 2021 17:10:02 +0000
Received: (at 48264) by debbugs.gnu.org; 9 May 2021 17:09:40 +0000
Received: from localhost ([127.0.0.1]:56364 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfmw0-00063L-5D
	for submit <at> debbugs.gnu.org; Sun, 09 May 2021 13:09:40 -0400
Received: from venus.catern.com ([68.183.49.163]:36596)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfmvx-000632-Sg
 for 48264 <at> debbugs.gnu.org; Sun, 09 May 2021 13:09:39 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620580176; bh=3EuCn7RdL0nePul5SKgMz2od+rEH4RXFC0jYR8HF8i8=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=l5KRJexANO6Y6MFegKzgwxWAMrzoI8SwIMnr07oGFqrzewtqqgogLghkiTygQ0EaH
 5ZhePY1PrjjKQa7ABYM+a2Op25ptfKy3kuiO3WVnQEeS+wV9/LCv9is64Xill3Cju8
 RZ/qS+wrrDa7TBBtd8uPHj7mMPs+WH8lnejUno+s=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 77EE02E92BC;
 Sun,  9 May 2021 17:09:36 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Sun,  9 May 2021 13:09:31 -0400
Message-Id: <20210509170933.27338-1-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <83im3s8gzq.fsf@HIDDEN>
References: <83im3s8gzq.fsf@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Cc: 48264 <at> debbugs.gnu.org
>> Date: Sat, 08 May 2021 15:03:46 -0400
>> 
>> Eli Zaretskii <eliz@HIDDEN> writes:
>> >> From: Spencer Baugh <sbaugh@HIDDEN>
>> >> Cc: 48264 <at> debbugs.gnu.org
>> >> Date: Sat, 08 May 2021 09:35:31 -0400
>> >> If you think such a conditionally-compiled runtime check would be
>> >> acceptable for applying these changes, I can go ahead and write that.
>> >
>> > Yes, I think so.  But if Lars or Stefan think differently, I might
>> > reconsider.
>> 
>> In the process of implementing the runtime check, I, of course, came up
>> with a better compile-time check. How about this?
>
> LGTM, thanks.  But could you please run your benchmarks again, with
> this implementation, to make sure we still get only a 1 - 2% slowdown
> at worst?  I wouldn't expect the addition to matter in an optimized
> build, but just to be sure...

I ran the benchmarks again and got similar results.

|                       |    On master | With my changes | Slowdown |
| shr-bench             | 2.2865667967 |    2.2762716187 |   -0.48% |
| delete *.elc and make |   52m12.627s |      51m56.780s |   -0.50% |
| xdisp-bench           | 6.1960484849 |    6.2269325793 |    0.49% |

Here's the two patches that are needed to add this compile-time check;
they apply cleanly on my v4 series, when the "Add and use BVAR_FIELD
macros" patch is removed.

Spencer Baugh (2):
  Take buffer field name in DEFVAR_PER_BUFFER
  Add compile-time check that BVAR is used correctly

 src/buffer.c   | 140 ++++++++++++++++++++++++-------------------------
 src/buffer.h   |  28 ++++++++--
 src/category.h |   2 +-
 src/syntax.h   |   2 +-
 4 files changed, 94 insertions(+), 78 deletions(-)

-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH 2/2] Add compile-time check that BVAR is used correctly
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 09 May 2021 17:10:02 +0000
Resent-Message-ID: <handler.48264.B48264.162058018023283 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: Spencer Baugh <sbaugh@HIDDEN>, monnier@HIDDEN, 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162058018023283
          (code B ref 48264); Sun, 09 May 2021 17:10:02 +0000
Received: (at 48264) by debbugs.gnu.org; 9 May 2021 17:09:40 +0000
Received: from localhost ([127.0.0.1]:56366 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfmw0-00063N-Ei
	for submit <at> debbugs.gnu.org; Sun, 09 May 2021 13:09:40 -0400
Received: from venus.catern.com ([68.183.49.163]:36620)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfmvz-000634-0r
 for 48264 <at> debbugs.gnu.org; Sun, 09 May 2021 13:09:39 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620580178; bh=wdleiMqhFMSbVkqOpPmOL2HECZt38PE/eJ/Es5C+3TY=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=XFF/lzfFrKsTpkAJw0P884D7gKvHmgWCs+H8MK2zPaiQj8O2dpoAj+mLiLMT0X5LN
 9bmlKuXHI+/PUS4IxlBWdVyMRkCln/E4yut4cNJUKXltq4c7C5mcIMi+uIDCEKnbtG
 StWkgfTExL+any+qfr7qhJXw+kL5lGWRV1GPQz68=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id B91312E9485;
 Sun,  9 May 2021 17:09:38 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Sun,  9 May 2021 13:09:33 -0400
Message-Id: <20210509170933.27338-3-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210509170933.27338-1-sbaugh@HIDDEN>
References: <83im3s8gzq.fsf@HIDDEN> <20210509170933.27338-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

BVAR should only be used for permanent-local buffer variables, so
we'll make a list of such variables and check that the field passed to
BVAR is in that list.  The added offsetof call will fail at compile
time if the passed field is not present in bvar_permanent_locals,
while not incurring any overhead at runtime.

We could add a similar check for BVAR_OR_DEFAULT, but it's not as
important since BVAR_OR_DEFAULT will work fine for any Lisp field.

* src/buffer.h (BVAR): Add compile-time check that the passed field is
permanently buffer-local.
(BVAR_OR_DEFAULT): Stop using BVAR, since this can be called on fields
which aren't permanently buffer-local.
(BVAR_DEFAULT): Add.
* src/buffer.c (init_buffer_once):
* src/category.h (Vstandard_category_table):
* src/syntax.h (Vstandard_syntax_table): Use BVAR_DEFAULT instead of
BVAR to access buffer_defaults fields that aren't permanently
buffer-local.
---
 src/buffer.c   | 14 +++++++-------
 src/buffer.h   | 28 +++++++++++++++++++++++-----
 src/category.h |  2 +-
 src/syntax.h   |  2 +-
 4 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index c0d72ef5c5..1ee804bd9d 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5112,10 +5112,10 @@ init_buffer_once (void)
   bset_abbrev_table (&buffer_defaults, Qnil);
   bset_display_table (&buffer_defaults, Qnil);
   /* Later further initialized by init_{syntax,category}_once.  */
-  BVAR (&buffer_defaults, syntax_table) = Qnil;
-  BVAR (&buffer_defaults, category_table) = Qnil;
+  BVAR_DEFAULT (syntax_table) = Qnil;
+  BVAR_DEFAULT (category_table) = Qnil;
 
-  XSETFASTINT (BVAR (&buffer_defaults, tab_width), 8);
+  XSETFASTINT (BVAR_DEFAULT (tab_width), 8);
   bset_truncate_lines (&buffer_defaults, Qnil);
   bset_word_wrap (&buffer_defaults, Qnil);
   bset_ctl_arrow (&buffer_defaults, Qt);
@@ -5128,11 +5128,11 @@ init_buffer_once (void)
   bset_cursor_in_non_selected_windows (&buffer_defaults, Qt);
 
   bset_buffer_file_coding_system (&buffer_defaults, Qnil);
-  XSETFASTINT (BVAR (&buffer_defaults, fill_column), 70);
-  XSETFASTINT (BVAR (&buffer_defaults, left_margin), 0);
+  XSETFASTINT (BVAR_DEFAULT (fill_column), 70);
+  XSETFASTINT (BVAR_DEFAULT (left_margin), 0);
   bset_cache_long_scans (&buffer_defaults, Qt);
-  XSETFASTINT (BVAR (&buffer_defaults, left_margin_cols), 0);
-  XSETFASTINT (BVAR (&buffer_defaults, right_margin_cols), 0);
+  XSETFASTINT (BVAR_DEFAULT (left_margin_cols), 0);
+  XSETFASTINT (BVAR_DEFAULT (right_margin_cols), 0);
   bset_left_fringe_width (&buffer_defaults, Qnil);
   bset_right_fringe_width (&buffer_defaults, Qnil);
   bset_fringes_outside_margins (&buffer_defaults, Qnil);
diff --git a/src/buffer.h b/src/buffer.h
index f78046a9a8..3e8198bb70 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -280,13 +280,31 @@ struct buffer_text
     bool_bf redisplay : 1;
   };
 
-/* Most code should use this macro to access Lisp fields in struct buffer.  */
+/* This structure is used purely as a list of field names that are
+   permitted for use with BVAR; it's never actually instantiated.  */
+struct bvar_permanent_locals {
+  char name, filename, directory, backed_up, save_length, auto_save_file_name,
+    read_only, mark, local_var_alist, major_mode, local_minor_modes, mode_name,
+    keymap, downcase_table, upcase_table, case_canon_table, case_eqv_table,
+    mark_active, enable_multibyte_characters, file_format,
+    auto_save_file_format, width_table, pt_marker, begv_marker, zv_marker,
+    point_before_scroll, file_truename, invisibility_spec, last_selected_window,
+    display_count, display_time, undo_list;
+};
+
+/* Most code should use BVAR or BVAR_OR_DEFAULT to access Lisp fields
+   in struct buffer.  BVAR should be used for fields that are
+   permanently buffer-local, and BVAR_OR_DEFAULT should be used for
+   fields that may not have a buffer-local binding and should use the
+   default in that case.  */
+#define BVAR(buf, field) \
+  *((void) offsetof (struct bvar_permanent_locals, field), &(buf)->field ## _)
 
-#define BVAR(buf, field) ((buf)->field ## _)
+#define BVAR_OR_DEFAULT(buf, field) (EQ ((buf)->field ## _, Qunbound)	\
+				     ? BVAR_DEFAULT(field)		\
+				     : (buf)->field ## _)
 
-#define BVAR_OR_DEFAULT(buf, field) (EQ (BVAR ((buf), field), Qunbound) \
-				     ? BVAR (&buffer_defaults, field) \
-				     : BVAR ((buf), field))
+#define BVAR_DEFAULT(field) buffer_defaults.field ## _
 
 /* Max number of builtin per-buffer variables.  */
 enum { MAX_PER_BUFFER_VARS = 50 };
diff --git a/src/category.h b/src/category.h
index cc32990478..85e872a940 100644
--- a/src/category.h
+++ b/src/category.h
@@ -94,7 +94,7 @@ CHAR_HAS_CATEGORY (int ch, int category)
 
 /* The standard category table is stored where it will automatically
    be used in all new buffers.  */
-#define Vstandard_category_table BVAR (&buffer_defaults, category_table)
+#define Vstandard_category_table BVAR_DEFAULT (category_table)
 
 /* Return the doc string of CATEGORY in category table TABLE.  */
 #define CATEGORY_DOCSTRING(table, category)				\
diff --git a/src/syntax.h b/src/syntax.h
index 187946c899..c85743808c 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -31,7 +31,7 @@ extern void update_syntax_table_forward (ptrdiff_t, bool, Lisp_Object);
 
 /* The standard syntax table is stored where it will automatically
    be used in all new buffers.  */
-#define Vstandard_syntax_table BVAR (&buffer_defaults, syntax_table)
+#define Vstandard_syntax_table BVAR_DEFAULT (syntax_table)
 
 /* A syntax table is a chartable whose elements are cons cells
    (CODE+FLAGS . MATCHING-CHAR).  MATCHING-CHAR can be nil if the char
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH 1/2] Take buffer field name in DEFVAR_PER_BUFFER
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 09 May 2021 17:10:03 +0000
Resent-Message-ID: <handler.48264.B48264.162058018223289 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>
Cc: Spencer Baugh <sbaugh@HIDDEN>, monnier@HIDDEN, 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162058018223289
          (code B ref 48264); Sun, 09 May 2021 17:10:03 +0000
Received: (at 48264) by debbugs.gnu.org; 9 May 2021 17:09:42 +0000
Received: from localhost ([127.0.0.1]:56368 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfmw0-00063U-RK
	for submit <at> debbugs.gnu.org; Sun, 09 May 2021 13:09:42 -0400
Received: from venus.catern.com ([68.183.49.163]:36610)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lfmvy-000633-EV
 for 48264 <at> debbugs.gnu.org; Sun, 09 May 2021 13:09:39 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620580178; bh=W9T4IRMqqb1VpjglXUGHSD4KlRjXCr0sDTZpRBeTujg=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References;
 b=Hw8oeNQSiGC8FyAZebCmyLBpaYeLTqBGAYkDrwYaim11NuwraXlH+GnwJKcsgST75
 n9LLYwQm9POWJxo542EoVXU8sqWvClrzVGbPpjjoT16vCF74boEQNruul+5aLwNHtM
 LhGWQCMFGczm7qa4uKAKKoZplt5CEhPz5Bm2xaUM=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id 20F7F2E8B14;
 Sun,  9 May 2021 17:09:38 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Sun,  9 May 2021 13:09:32 -0400
Message-Id: <20210509170933.27338-2-sbaugh@HIDDEN>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20210509170933.27338-1-sbaugh@HIDDEN>
References: <83im3s8gzq.fsf@HIDDEN> <20210509170933.27338-1-sbaugh@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

This makes the comment above the define of DEFVAR_PER_BUFFER correct -
it already says that vname is the name of the buffer slot.

* src/buffer.c (DEFVAR_PER_BUFFER): Take name of field as argument
(syms_of_buffer): Pass name of field as argument
---
 src/buffer.c | 126 +++++++++++++++++++++++++--------------------------
 1 file changed, 62 insertions(+), 64 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 764c0cb6ed..c0d72ef5c5 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5290,18 +5290,16 @@ init_buffer (void)
 #define DEFVAR_PER_BUFFER(lname, vname, predicate, doc)		\
   do {								\
     static struct Lisp_Buffer_Objfwd bo_fwd;			\
-    defvar_per_buffer (&bo_fwd, lname, vname, predicate);	\
+    defvar_per_buffer (&bo_fwd, lname, PER_BUFFER_VAR_OFFSET (vname), predicate); \
   } while (0)
 
 static void
 defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, const char *namestring,
-		   Lisp_Object *address, Lisp_Object predicate)
+		   int offset, Lisp_Object predicate)
 {
   struct Lisp_Symbol *sym;
-  int offset;
 
   sym = XSYMBOL (intern (namestring));
-  offset = (char *)address - (char *)current_buffer;
 
   bo_fwd->type = Lisp_Fwd_Buffer_Obj;
   bo_fwd->offset = offset;
@@ -5361,20 +5359,20 @@ syms_of_buffer (void)
 	build_pure_c_string ("Attempt to modify a protected field"));
 
   DEFVAR_PER_BUFFER ("tab-line-format",
-		     &BVAR (current_buffer, tab_line_format),
+		     tab_line_format,
 		     Qnil,
 		     doc: /* Analogous to `mode-line-format', but controls the tab line.
 The tab line appears, optionally, at the top of a window;
 the mode line appears at the bottom.  */);
 
   DEFVAR_PER_BUFFER ("header-line-format",
-		     &BVAR (current_buffer, header_line_format),
+		     header_line_format,
 		     Qnil,
 		     doc: /* Analogous to `mode-line-format', but controls the header line.
 The header line appears, optionally, at the top of a window;
 the mode line appears at the bottom.  */);
 
-  DEFVAR_PER_BUFFER ("mode-line-format", &BVAR (current_buffer, mode_line_format),
+  DEFVAR_PER_BUFFER ("mode-line-format", mode_line_format,
 		     Qnil,
 		     doc: /* Template for displaying mode line for current buffer.
 
@@ -5440,7 +5438,7 @@ A string is printed verbatim in the mode line except for %-constructs:
   %% -- print %.   %- -- print infinitely many dashes.
 Decimal digits after the % specify field width to which to pad.  */);
 
-  DEFVAR_PER_BUFFER ("major-mode", &BVAR (current_buffer, major_mode),
+  DEFVAR_PER_BUFFER ("major-mode", major_mode,
 		     Qsymbolp,
 		     doc: /* Symbol for current buffer's major mode.
 The default value (normally `fundamental-mode') affects new buffers.
@@ -5448,30 +5446,30 @@ A value of nil means to use the current buffer's major mode, provided
 it is not marked as "special".  */);
 
   DEFVAR_PER_BUFFER ("local-minor-modes",
-		     &BVAR (current_buffer, local_minor_modes),
+		     local_minor_modes,
 		     Qnil,
 		     doc: /* Minor modes currently active in the current buffer.
 This is a list of symbols, or nil if there are no minor modes active.  */);
 
-  DEFVAR_PER_BUFFER ("mode-name", &BVAR (current_buffer, mode_name),
+  DEFVAR_PER_BUFFER ("mode-name", mode_name,
                      Qnil,
 		     doc: /* Pretty name of current buffer's major mode.
 Usually a string, but can use any of the constructs for `mode-line-format',
 which see.
 Format with `format-mode-line' to produce a string value.  */);
 
-  DEFVAR_PER_BUFFER ("local-abbrev-table", &BVAR (current_buffer, abbrev_table), Qnil,
+  DEFVAR_PER_BUFFER ("local-abbrev-table", abbrev_table, Qnil,
 		     doc: /* Local (mode-specific) abbrev table of current buffer.  */);
 
-  DEFVAR_PER_BUFFER ("abbrev-mode", &BVAR (current_buffer, abbrev_mode), Qnil,
+  DEFVAR_PER_BUFFER ("abbrev-mode", abbrev_mode, Qnil,
 		     doc: /*  Non-nil if Abbrev mode is enabled.
 Use the command `abbrev-mode' to change this variable.  */);
 
-  DEFVAR_PER_BUFFER ("case-fold-search", &BVAR (current_buffer, case_fold_search),
+  DEFVAR_PER_BUFFER ("case-fold-search", case_fold_search,
 		     Qnil,
 		     doc: /* Non-nil if searches and matches should ignore case.  */);
 
-  DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column),
+  DEFVAR_PER_BUFFER ("fill-column", fill_column,
 		     Qintegerp,
 		     doc: /* Column beyond which automatic line-wrapping should happen.
 It is used by filling commands, such as `fill-region' and `fill-paragraph',
@@ -5479,26 +5477,26 @@ and by `auto-fill-mode', which see.
 See also `current-fill-column'.
 Interactively, you can set the buffer local value using \\[set-fill-column].  */);
 
-  DEFVAR_PER_BUFFER ("left-margin", &BVAR (current_buffer, left_margin),
+  DEFVAR_PER_BUFFER ("left-margin", left_margin,
 		     Qintegerp,
 		     doc: /* Column for the default `indent-line-function' to indent to.
 Linefeed indents to this column in Fundamental mode.  */);
 
-  DEFVAR_PER_BUFFER ("tab-width", &BVAR (current_buffer, tab_width),
+  DEFVAR_PER_BUFFER ("tab-width", tab_width,
 		     Qintegerp,
 		     doc: /* Distance between tab stops (for display of tab characters), in columns.
 NOTE: This controls the display width of a TAB character, and not
 the size of an indentation step.
 This should be an integer greater than zero.  */);
 
-  DEFVAR_PER_BUFFER ("ctl-arrow", &BVAR (current_buffer, ctl_arrow), Qnil,
+  DEFVAR_PER_BUFFER ("ctl-arrow", ctl_arrow, Qnil,
 		     doc: /* Non-nil means display control chars with uparrow.
 A value of nil means use backslash and octal digits.
 This variable does not apply to characters whose display is specified
 in the current display table (if there is one).  */);
 
   DEFVAR_PER_BUFFER ("enable-multibyte-characters",
-		     &BVAR (current_buffer, enable_multibyte_characters),
+		     enable_multibyte_characters,
 		     Qnil,
 		     doc: /* Non-nil means the buffer contents are regarded as multi-byte characters.
 Otherwise they are regarded as unibyte.  This affects the display,
@@ -5512,7 +5510,7 @@ See also Info node `(elisp)Text Representations'.  */);
   make_symbol_constant (intern_c_string ("enable-multibyte-characters"));
 
   DEFVAR_PER_BUFFER ("buffer-file-coding-system",
-		     &BVAR (current_buffer, buffer_file_coding_system), Qnil,
+		     buffer_file_coding_system, Qnil,
 		     doc: /* Coding system to be used for encoding the buffer contents on saving.
 This variable applies to saving the buffer, and also to `write-region'
 and other functions that use `write-region'.
@@ -5530,7 +5528,7 @@ The variable `coding-system-for-write', if non-nil, overrides this variable.
 This variable is never applied to a way of decoding a file while reading it.  */);
 
   DEFVAR_PER_BUFFER ("bidi-display-reordering",
-		     &BVAR (current_buffer, bidi_display_reordering), Qnil,
+		     bidi_display_reordering, Qnil,
 		     doc: /* Non-nil means reorder bidirectional text for display in the visual order.
 Setting this to nil is intended for use in debugging the display code.
 Don't set to nil in normal sessions, as that is not supported.
@@ -5538,7 +5536,7 @@ See also `bidi-paragraph-direction'; setting that non-nil might
 speed up redisplay.  */);
 
   DEFVAR_PER_BUFFER ("bidi-paragraph-start-re",
-		     &BVAR (current_buffer, bidi_paragraph_start_re), Qnil,
+		     bidi_paragraph_start_re, Qnil,
 		     doc: /* If non-nil, a regexp matching a line that starts OR separates paragraphs.
 
 The value of nil means to use empty lines as lines that start and
@@ -5560,7 +5558,7 @@ set both these variables to "^".
 See also `bidi-paragraph-direction'.  */);
 
   DEFVAR_PER_BUFFER ("bidi-paragraph-separate-re",
-		     &BVAR (current_buffer, bidi_paragraph_separate_re), Qnil,
+		     bidi_paragraph_separate_re, Qnil,
 		     doc: /* If non-nil, a regexp matching a line that separates paragraphs.
 
 The value of nil means to use empty lines as paragraph separators.
@@ -5581,7 +5579,7 @@ set both these variables to "^".
 See also `bidi-paragraph-direction'.  */);
 
   DEFVAR_PER_BUFFER ("bidi-paragraph-direction",
-		     &BVAR (current_buffer, bidi_paragraph_direction), Qnil,
+		     bidi_paragraph_direction, Qnil,
 		     doc: /* If non-nil, forces directionality of text paragraphs in the buffer.
 
 If this is nil (the default), the direction of each paragraph is
@@ -5592,7 +5590,7 @@ Any other value is treated as nil.
 This variable has no effect unless the buffer's value of
 `bidi-display-reordering' is non-nil.  */);
 
- DEFVAR_PER_BUFFER ("truncate-lines", &BVAR (current_buffer, truncate_lines), Qnil,
+ DEFVAR_PER_BUFFER ("truncate-lines", truncate_lines, Qnil,
 		     doc: /* Non-nil means do not display continuation lines.
 Instead, give each line of text just one screen line.
 
@@ -5602,7 +5600,7 @@ and this buffer is not full-frame width.
 
 Minibuffers set this variable to nil.  */);
 
-  DEFVAR_PER_BUFFER ("word-wrap", &BVAR (current_buffer, word_wrap), Qnil,
+  DEFVAR_PER_BUFFER ("word-wrap", word_wrap, Qnil,
 		     doc: /* Non-nil means to use word-wrapping for continuation lines.
 When word-wrapping is on, continuation lines are wrapped at the space
 or tab character nearest to the right window edge.
@@ -5620,14 +5618,14 @@ to t, and additionally redefines simple editing commands to act on
 visual lines rather than logical lines.  See the documentation of
 `visual-line-mode'.  */);
 
-  DEFVAR_PER_BUFFER ("default-directory", &BVAR (current_buffer, directory),
+  DEFVAR_PER_BUFFER ("default-directory", directory,
 		     Qstringp,
 		     doc: /* Name of default directory of current buffer.
 It should be an absolute directory name; on GNU and Unix systems,
 these names start with `/' or `~' and end with `/'.
 To interactively change the default directory, use command `cd'. */);
 
-  DEFVAR_PER_BUFFER ("auto-fill-function", &BVAR (current_buffer, auto_fill_function),
+  DEFVAR_PER_BUFFER ("auto-fill-function", auto_fill_function,
 		     Qnil,
 		     doc: /* Function called (if non-nil) to perform auto-fill.
 It is called after self-inserting any character specified in
@@ -5635,31 +5633,31 @@ the `auto-fill-chars' table.
 NOTE: This variable is not a hook;
 its value may not be a list of functions.  */);
 
-  DEFVAR_PER_BUFFER ("buffer-file-name", &BVAR (current_buffer, filename),
+  DEFVAR_PER_BUFFER ("buffer-file-name", filename,
 		     Qstringp,
 		     doc: /* Name of file visited in current buffer, or nil if not visiting a file.
 This should be an absolute file name.  */);
 
-  DEFVAR_PER_BUFFER ("buffer-file-truename", &BVAR (current_buffer, file_truename),
+  DEFVAR_PER_BUFFER ("buffer-file-truename", file_truename,
 		     Qstringp,
 		     doc: /* Abbreviated truename of file visited in current buffer, or nil if none.
 The truename of a file is calculated by `file-truename'
 and then abbreviated with `abbreviate-file-name'.  */);
 
   DEFVAR_PER_BUFFER ("buffer-auto-save-file-name",
-		     &BVAR (current_buffer, auto_save_file_name),
+		     auto_save_file_name,
 		     Qstringp,
 		     doc: /* Name of file for auto-saving current buffer.
 If it is nil, that means don't auto-save this buffer.  */);
 
-  DEFVAR_PER_BUFFER ("buffer-read-only", &BVAR (current_buffer, read_only), Qnil,
+  DEFVAR_PER_BUFFER ("buffer-read-only", read_only, Qnil,
 		     doc: /* Non-nil if this buffer is read-only.  */);
 
-  DEFVAR_PER_BUFFER ("buffer-backed-up", &BVAR (current_buffer, backed_up), Qnil,
+  DEFVAR_PER_BUFFER ("buffer-backed-up", backed_up, Qnil,
 		     doc: /* Non-nil if this buffer's file has been backed up.
 Backing up is done before the first time the file is saved.  */);
 
-  DEFVAR_PER_BUFFER ("buffer-saved-size", &BVAR (current_buffer, save_length),
+  DEFVAR_PER_BUFFER ("buffer-saved-size", save_length,
 		     Qintegerp,
 		     doc: /* Length of current buffer when last read in, saved or auto-saved.
 0 initially.
@@ -5669,7 +5667,7 @@ If you set this to -2, that means don't turn off auto-saving in this buffer
 if its text size shrinks.   If you use `buffer-swap-text' on a buffer,
 you probably should set this to -2 in that buffer.  */);
 
-  DEFVAR_PER_BUFFER ("selective-display", &BVAR (current_buffer, selective_display),
+  DEFVAR_PER_BUFFER ("selective-display", selective_display,
 		     Qnil,
 		     doc: /* Non-nil enables selective display.
 
@@ -5682,11 +5680,11 @@ in a file, save the ^M as a newline.  This usage is obsolete; use
 overlays or text properties instead.  */);
 
   DEFVAR_PER_BUFFER ("selective-display-ellipses",
-		     &BVAR (current_buffer, selective_display_ellipses),
+		     selective_display_ellipses,
 		     Qnil,
 		     doc: /* Non-nil means display ... on previous line when a line is invisible.  */);
 
-  DEFVAR_PER_BUFFER ("overwrite-mode", &BVAR (current_buffer, overwrite_mode),
+  DEFVAR_PER_BUFFER ("overwrite-mode", overwrite_mode,
 		     Qoverwrite_mode,
 		     doc: /* Non-nil if self-insertion should replace existing text.
 The value should be one of `overwrite-mode-textual',
@@ -5696,7 +5694,7 @@ inserts at the end of a line, and inserts when point is before a tab,
 until the tab is filled in.
 If `overwrite-mode-binary', self-insertion replaces newlines and tabs too.  */);
 
-  DEFVAR_PER_BUFFER ("buffer-display-table", &BVAR (current_buffer, display_table),
+  DEFVAR_PER_BUFFER ("buffer-display-table", display_table,
 		     Qnil,
 		     doc: /* Display table that controls display of the contents of current buffer.
 
@@ -5733,7 +5731,7 @@ In addition, a char-table has six extra slots to control the display of:
 
 See also the functions `display-table-slot' and `set-display-table-slot'.  */);
 
-  DEFVAR_PER_BUFFER ("left-margin-width", &BVAR (current_buffer, left_margin_cols),
+  DEFVAR_PER_BUFFER ("left-margin-width", left_margin_cols,
 		     Qintegerp,
 		     doc: /* Width in columns of left marginal area for display of a buffer.
 A value of nil means no marginal area.
@@ -5741,7 +5739,7 @@ A value of nil means no marginal area.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("right-margin-width", &BVAR (current_buffer, right_margin_cols),
+  DEFVAR_PER_BUFFER ("right-margin-width", right_margin_cols,
 		     Qintegerp,
 		     doc: /* Width in columns of right marginal area for display of a buffer.
 A value of nil means no marginal area.
@@ -5749,7 +5747,7 @@ A value of nil means no marginal area.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("left-fringe-width", &BVAR (current_buffer, left_fringe_width),
+  DEFVAR_PER_BUFFER ("left-fringe-width", left_fringe_width,
 		     Qintegerp,
 		     doc: /* Width of this buffer's left fringe (in pixels).
 A value of 0 means no left fringe is shown in this buffer's window.
@@ -5758,7 +5756,7 @@ A value of nil means to use the left fringe width from the window's frame.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("right-fringe-width", &BVAR (current_buffer, right_fringe_width),
+  DEFVAR_PER_BUFFER ("right-fringe-width", right_fringe_width,
 		     Qintegerp,
 		     doc: /* Width of this buffer's right fringe (in pixels).
 A value of 0 means no right fringe is shown in this buffer's window.
@@ -5767,7 +5765,7 @@ A value of nil means to use the right fringe width from the window's frame.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("fringes-outside-margins", &BVAR (current_buffer, fringes_outside_margins),
+  DEFVAR_PER_BUFFER ("fringes-outside-margins", fringes_outside_margins,
 		     Qnil,
 		     doc: /* Non-nil means to display fringes outside display margins.
 A value of nil means to display fringes between margins and buffer text.
@@ -5775,17 +5773,17 @@ A value of nil means to display fringes between margins and buffer text.
 Setting this variable does not take effect until a new buffer is displayed
 in a window.  To make the change take effect, call `set-window-buffer'.  */);
 
-  DEFVAR_PER_BUFFER ("scroll-bar-width", &BVAR (current_buffer, scroll_bar_width),
+  DEFVAR_PER_BUFFER ("scroll-bar-width", scroll_bar_width,
 		     Qintegerp,
 		     doc: /* Width of this buffer's vertical scroll bars in pixels.
 A value of nil means to use the scroll bar width from the window's frame.  */);
 
-  DEFVAR_PER_BUFFER ("scroll-bar-height", &BVAR (current_buffer, scroll_bar_height),
+  DEFVAR_PER_BUFFER ("scroll-bar-height", scroll_bar_height,
 		     Qintegerp,
 		     doc: /* Height of this buffer's horizontal scroll bars in pixels.
 A value of nil means to use the scroll bar height from the window's frame.  */);
 
-  DEFVAR_PER_BUFFER ("vertical-scroll-bar", &BVAR (current_buffer, vertical_scroll_bar_type),
+  DEFVAR_PER_BUFFER ("vertical-scroll-bar", vertical_scroll_bar_type,
 		     Qvertical_scroll_bar,
 		     doc: /* Position of this buffer's vertical scroll bar.
 The value takes effect whenever you tell a window to display this buffer;
@@ -5795,7 +5793,7 @@ A value of `left' or `right' means put the vertical scroll bar at that side
 of the window; a value of nil means don't show any vertical scroll bars.
 A value of t (the default) means do whatever the window's frame specifies.  */);
 
-  DEFVAR_PER_BUFFER ("horizontal-scroll-bar", &BVAR (current_buffer, horizontal_scroll_bar_type),
+  DEFVAR_PER_BUFFER ("horizontal-scroll-bar", horizontal_scroll_bar_type,
 		     Qnil,
 		     doc: /* Position of this buffer's horizontal scroll bar.
 The value takes effect whenever you tell a window to display this buffer;
@@ -5807,13 +5805,13 @@ A value of t (the default) means do whatever the window's frame
 specifies.  */);
 
   DEFVAR_PER_BUFFER ("indicate-empty-lines",
-		     &BVAR (current_buffer, indicate_empty_lines), Qnil,
+		     indicate_empty_lines, Qnil,
 		     doc: /* Visually indicate empty lines after the buffer end.
 If non-nil, a bitmap is displayed in the left fringe of a window on
 window-systems.  */);
 
   DEFVAR_PER_BUFFER ("indicate-buffer-boundaries",
-		     &BVAR (current_buffer, indicate_buffer_boundaries), Qnil,
+		     indicate_buffer_boundaries, Qnil,
 		     doc: /* Visually indicate buffer boundaries and scrolling.
 If non-nil, the first and last line of the buffer are marked in the fringe
 of a window on window-systems with angle bitmaps, or if the window can be
@@ -5838,7 +5836,7 @@ bitmaps in right fringe.  To show just the angle bitmaps in the left
 fringe, but no arrow bitmaps, use ((top .  left) (bottom . left)).  */);
 
   DEFVAR_PER_BUFFER ("fringe-indicator-alist",
-		     &BVAR (current_buffer, fringe_indicator_alist), Qnil,
+		     fringe_indicator_alist, Qnil,
 		     doc: /* Mapping from logical to physical fringe indicator bitmaps.
 The value is an alist where each element (INDICATOR . BITMAPS)
 specifies the fringe bitmaps used to display a specific logical
@@ -5857,7 +5855,7 @@ last (only) line has no final newline.  BITMAPS may also be a single
 symbol which is used in both left and right fringes.  */);
 
   DEFVAR_PER_BUFFER ("fringe-cursor-alist",
-		     &BVAR (current_buffer, fringe_cursor_alist), Qnil,
+		     fringe_cursor_alist, Qnil,
 		     doc: /* Mapping from logical to physical fringe cursor bitmaps.
 The value is an alist where each element (CURSOR . BITMAP)
 specifies the fringe bitmaps used to display a specific logical
@@ -5872,7 +5870,7 @@ BITMAP is the corresponding fringe bitmap shown for the logical
 cursor type.  */);
 
   DEFVAR_PER_BUFFER ("scroll-up-aggressively",
-		     &BVAR (current_buffer, scroll_up_aggressively), Qfraction,
+		     scroll_up_aggressively, Qfraction,
 		     doc: /* How far to scroll windows upward.
 If you move point off the bottom, the window scrolls automatically.
 This variable controls how far it scrolls.  The value nil, the default,
@@ -5885,7 +5883,7 @@ window scrolls by a full window height.  Meaningful values are
 between 0.0 and 1.0, inclusive.  */);
 
   DEFVAR_PER_BUFFER ("scroll-down-aggressively",
-		     &BVAR (current_buffer, scroll_down_aggressively), Qfraction,
+		     scroll_down_aggressively, Qfraction,
 		     doc: /* How far to scroll windows downward.
 If you move point off the top, the window scrolls automatically.
 This variable controls how far it scrolls.  The value nil, the default,
@@ -5936,7 +5934,7 @@ from happening repeatedly and making Emacs nonfunctional.  */);
 The functions are run using the `run-hooks' function.  */);
   Vfirst_change_hook = Qnil;
 
-  DEFVAR_PER_BUFFER ("buffer-undo-list", &BVAR (current_buffer, undo_list), Qnil,
+  DEFVAR_PER_BUFFER ("buffer-undo-list", undo_list, Qnil,
 		     doc: /* List of undo entries in current buffer.
 Recent changes come first; older changes follow newer.
 
@@ -5982,10 +5980,10 @@ the changes between two undo boundaries as a single step to be undone.
 
 If the value of the variable is t, undo information is not recorded.  */);
 
-  DEFVAR_PER_BUFFER ("mark-active", &BVAR (current_buffer, mark_active), Qnil,
+  DEFVAR_PER_BUFFER ("mark-active", mark_active, Qnil,
 		     doc: /* Non-nil means the mark and region are currently active in this buffer.  */);
 
-  DEFVAR_PER_BUFFER ("cache-long-scans", &BVAR (current_buffer, cache_long_scans), Qnil,
+  DEFVAR_PER_BUFFER ("cache-long-scans", cache_long_scans, Qnil,
 		     doc: /* Non-nil means that Emacs should use caches in attempt to speedup buffer scans.
 
 There is no reason to set this to nil except for debugging purposes.
@@ -6021,23 +6019,23 @@ maintained internally by the Emacs primitives.  Enabling or disabling
 the cache should not affect the behavior of any of the motion
 functions; it should only affect their performance.  */);
 
-  DEFVAR_PER_BUFFER ("point-before-scroll", &BVAR (current_buffer, point_before_scroll), Qnil,
+  DEFVAR_PER_BUFFER ("point-before-scroll", point_before_scroll, Qnil,
 		     doc: /* Value of point before the last series of scroll operations, or nil.  */);
 
-  DEFVAR_PER_BUFFER ("buffer-file-format", &BVAR (current_buffer, file_format), Qnil,
+  DEFVAR_PER_BUFFER ("buffer-file-format", file_format, Qnil,
 		     doc: /* List of formats to use when saving this buffer.
 Formats are defined by `format-alist'.  This variable is
 set when a file is visited.  */);
 
   DEFVAR_PER_BUFFER ("buffer-auto-save-file-format",
-		     &BVAR (current_buffer, auto_save_file_format), Qnil,
+		     auto_save_file_format, Qnil,
 		     doc: /* Format in which to write auto-save files.
 Should be a list of symbols naming formats that are defined in `format-alist'.
 If it is t, which is the default, auto-save files are written in the
 same format as a regular save would use.  */);
 
   DEFVAR_PER_BUFFER ("buffer-invisibility-spec",
-		     &BVAR (current_buffer, invisibility_spec), Qnil,
+		     invisibility_spec, Qnil,
 		     doc: /* Invisibility spec of this buffer.
 The default is t, which means that text is invisible if it has a non-nil
 `invisible' property.
@@ -6051,12 +6049,12 @@ Setting this variable is very fast, much faster than scanning all the text in
 the buffer looking for properties to change.  */);
 
   DEFVAR_PER_BUFFER ("buffer-display-count",
-		     &BVAR (current_buffer, display_count), Qintegerp,
+		     display_count, Qintegerp,
 		     doc: /* A number incremented each time this buffer is displayed in a window.
 The function `set-window-buffer' increments it.  */);
 
   DEFVAR_PER_BUFFER ("buffer-display-time",
-		     &BVAR (current_buffer, display_time), Qnil,
+		     display_time, Qnil,
 		     doc: /* Time stamp updated each time this buffer is displayed in a window.
 The function `set-window-buffer' updates this variable
 to the value obtained by calling `current-time'.
@@ -6092,7 +6090,7 @@ member of the list.  Any other non-nil value means disregard `buffer-read-only'
 and all `read-only' text properties.  */);
   Vinhibit_read_only = Qnil;
 
-  DEFVAR_PER_BUFFER ("cursor-type", &BVAR (current_buffer, cursor_type), Qnil,
+  DEFVAR_PER_BUFFER ("cursor-type", cursor_type, Qnil,
 		     doc: /* Cursor to use when this buffer is in the selected window.
 Values are interpreted as follows:
 
@@ -6116,7 +6114,7 @@ cursor's appearance is instead controlled by the variable
 `cursor-in-non-selected-windows'.  */);
 
   DEFVAR_PER_BUFFER ("line-spacing",
-		     &BVAR (current_buffer, extra_line_spacing), Qnumberp,
+		     extra_line_spacing, Qnumberp,
 		     doc: /* Additional space to put between lines when displaying a buffer.
 The space is measured in pixels, and put below lines on graphic displays,
 see `display-graphic-p'.
@@ -6124,7 +6122,7 @@ If value is a floating point number, it specifies the spacing relative
 to the default frame line height.  A value of nil means add no extra space.  */);
 
   DEFVAR_PER_BUFFER ("cursor-in-non-selected-windows",
-		     &BVAR (current_buffer, cursor_in_non_selected_windows), Qnil,
+		     cursor_in_non_selected_windows, Qnil,
 		     doc: /* Non-nil means show a cursor in non-selected windows.
 If nil, only shows a cursor in the selected window.
 If t, displays a cursor related to the usual cursor type
-- 
2.31.1





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH 2/2] Add compile-time check that BVAR is used correctly
Resent-From: Stefan Monnier <monnier@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 09 May 2021 18:10:03 +0000
Resent-Message-ID: <handler.48264.B48264.162058379327948 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: Eli Zaretskii <eliz@HIDDEN>, 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162058379327948
          (code B ref 48264); Sun, 09 May 2021 18:10:03 +0000
Received: (at 48264) by debbugs.gnu.org; 9 May 2021 18:09:53 +0000
Received: from localhost ([127.0.0.1]:56575 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfnsH-0007Gi-7H
	for submit <at> debbugs.gnu.org; Sun, 09 May 2021 14:09:53 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64268)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1lfnsF-0007GT-FE
 for 48264 <at> debbugs.gnu.org; Sun, 09 May 2021 14:09:51 -0400
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 336984409B0;
 Sun,  9 May 2021 14:09:46 -0400 (EDT)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 1892A44091E;
 Sun,  9 May 2021 14:09:45 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1620583785;
 bh=4ZXdcgA6o/My3Y4X1+DzOYrHtf4spOqLibtCK0aF+M4=;
 h=From:To:Cc:Subject:References:Date:In-Reply-To:From;
 b=OuhA9EOBkeCT6zxT1b9oR0fyA4+5kgUrKd2N2wlsuncyyef+2Vy80/+JQLPa97VR/
 BTDrHtbn/CCzHNfKwQMziIMfWmMVRlTz2leVwQ9pmQhyBA87AcIoBrmOScsDkRLqKV
 x8lmF2BGLUZZN7lUbS+z9aur+6NTZHoXSrccarUEQgONs6sGVJgIpnPzLhKE8t3/ik
 1IYA7uJxgsO9eQrTOTmUy3wH2qo2ZvptxMfYpyaBfvVNchymYI+i1azCsYKNCkhNoJ
 Dx/6HLdlD1T0Xi5rq4tDxltL8Vt5WXQLw3k7zag8d8NRv+KbtpMZBXfAfT2Vb9T3Wu
 edbt4VJBdofHQ==
Received: from alfajor (76-10-140-76.dsl.teksavvy.com [76.10.140.76])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C705512040E;
 Sun,  9 May 2021 14:09:44 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
Message-ID: <jwvh7jbye53.fsf-monnier+emacs@HIDDEN>
References: <83im3s8gzq.fsf@HIDDEN> <20210509170933.27338-1-sbaugh@HIDDEN>
 <20210509170933.27338-3-sbaugh@HIDDEN>
Date: Sun, 09 May 2021 14:09:43 -0400
In-Reply-To: <20210509170933.27338-3-sbaugh@HIDDEN> (Spencer Baugh's
 message of "Sun,  9 May 2021 13:09:33 -0400")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.082 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> BVAR should only be used for permanent-local buffer variables, so

BTW, I find this term slightly problematic: "permanent-local" already
has a slightly different meaning for normal variables.  Maybe we should
call them "really-permanent-local" or "always buffer-local" or
"buffer-local-only"?


        Stefan





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH 2/2] Add compile-time check that BVAR is used correctly
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 09 May 2021 18:30:03 +0000
Resent-Message-ID: <handler.48264.B48264.162058494929713 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Stefan Monnier <monnier@HIDDEN>
Cc: sbaugh@HIDDEN, 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162058494929713
          (code B ref 48264); Sun, 09 May 2021 18:30:03 +0000
Received: (at 48264) by debbugs.gnu.org; 9 May 2021 18:29:09 +0000
Received: from localhost ([127.0.0.1]:56599 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lfoAu-0007jA-KE
	for submit <at> debbugs.gnu.org; Sun, 09 May 2021 14:29:09 -0400
Received: from eggs.gnu.org ([209.51.188.92]:34410)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1lfoAs-0007iq-RI
 for 48264 <at> debbugs.gnu.org; Sun, 09 May 2021 14:29:07 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:39942)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1lfoAn-00068O-A9; Sun, 09 May 2021 14:29:01 -0400
Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4925
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1lfoAm-00072y-Bv; Sun, 09 May 2021 14:29:01 -0400
Date: Sun, 09 May 2021 21:29:03 +0300
Message-Id: <83h7jb7ocw.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <jwvh7jbye53.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Sun, 09 May 2021 14:09:43 -0400)
References: <83im3s8gzq.fsf@HIDDEN> <20210509170933.27338-1-sbaugh@HIDDEN>
 <20210509170933.27338-3-sbaugh@HIDDEN>
 <jwvh7jbye53.fsf-monnier+emacs@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Stefan Monnier <monnier@HIDDEN>
> Cc: Eli Zaretskii <eliz@HIDDEN>,  48264 <at> debbugs.gnu.org
> Date: Sun, 09 May 2021 14:09:43 -0400
> 
> > BVAR should only be used for permanent-local buffer variables, so
> 
> BTW, I find this term slightly problematic: "permanent-local" already
> has a slightly different meaning for normal variables.  Maybe we should
> call them "really-permanent-local" or "always buffer-local" or
> "buffer-local-only"?

I prefer "always buffer-local", as this is what we used until now (see
buffer.c).




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: [PATCH 2/2] Add compile-time check that BVAR is used correctly
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Mon, 10 May 2021 14:10:02 +0000
Resent-Message-ID: <handler.48264.B48264.162065575130139 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>
Cc: 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.162065575130139
          (code B ref 48264); Mon, 10 May 2021 14:10:02 +0000
Received: (at 48264) by debbugs.gnu.org; 10 May 2021 14:09:11 +0000
Received: from localhost ([127.0.0.1]:33945 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lg6at-0007q3-3m
	for submit <at> debbugs.gnu.org; Mon, 10 May 2021 10:09:11 -0400
Received: from venus.catern.com ([68.183.49.163]:33578)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1lg6aq-0007pt-Qf
 for 48264 <at> debbugs.gnu.org; Mon, 10 May 2021 10:09:09 -0400
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235;
 helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail;
 t=1620655747; bh=c0TG8ESYVJ4EoqemIWiUdA3zak9He3M/BeCexkKOr8s=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=DUNQ0Asjzbqc4l6K3yS2rhIMXEBKKb6W0JtFZkD3UZ6/iewJ7LIsWl0hA9U6QkztR
 Rs1V78f0VVEpk2hUKIBamvT1ogl430XH4FGMciIkkimxNZhNuK5CfCATyT8C6YWW2L
 2geHeVUytVkhBEJJ61A9yMQjoPc9CC8Ao58cuPdg=
Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235])
 by venus.catern.com (Postfix) with ESMTPSA id A30962E9A0D;
 Mon, 10 May 2021 14:09:07 +0000 (UTC)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <83h7jb7ocw.fsf@HIDDEN>
References: <83im3s8gzq.fsf@HIDDEN> <20210509170933.27338-1-sbaugh@HIDDEN>
 <20210509170933.27338-3-sbaugh@HIDDEN>
 <jwvh7jbye53.fsf-monnier+emacs@HIDDEN> <83h7jb7ocw.fsf@HIDDEN>
Date: Mon, 10 May 2021 10:09:06 -0400
Message-ID: <87y2cmof3x.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Stefan Monnier <monnier@HIDDEN>
>> Cc: Eli Zaretskii <eliz@HIDDEN>,  48264 <at> debbugs.gnu.org
>> Date: Sun, 09 May 2021 14:09:43 -0400
>> 
>> > BVAR should only be used for permanent-local buffer variables, so
>> 
>> BTW, I find this term slightly problematic: "permanent-local" already
>> has a slightly different meaning for normal variables.  Maybe we should
>> call them "really-permanent-local" or "always buffer-local" or
>> "buffer-local-only"?
>
> I prefer "always buffer-local", as this is what we used until now (see
> buffer.c).

True, will change the wording in a followup.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: 28.0.50; Changing the default for DEFVAR_PER_BUFFER variables takes O(#buffers) time
Resent-From: Lars Ingebrigtsen <larsi@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 01 Jul 2022 12:19:02 +0000
Resent-Message-ID: <handler.48264.B48264.16566779018110 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>, 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.16566779018110
          (code B ref 48264); Fri, 01 Jul 2022 12:19:02 +0000
Received: (at 48264) by debbugs.gnu.org; 1 Jul 2022 12:18:21 +0000
Received: from localhost ([127.0.0.1]:36555 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1o7FbJ-00026k-CW
	for submit <at> debbugs.gnu.org; Fri, 01 Jul 2022 08:18:21 -0400
Received: from quimby.gnus.org ([95.216.78.240]:54474)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1o7FbH-00026R-FN
 for 48264 <at> debbugs.gnu.org; Fri, 01 Jul 2022 08:18:20 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References:
 In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: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=9iKiNHcja73Z7Uramu2oWqTjv3r/qKiMH6J/PPLDlZ8=; b=bg11cPqd33txpTRp2XHTj6RskY
 76otEU12vE/1UeFCLVcrNnXL9FxZn67mHQFMClhrMPbda4G0HAhZRb079zBUL6wRBl3SD3uWEB3sS
 8743jVAJVK48NU0WBh/OFc2N81SrdCUY0vCxaLPIUN9EnokfbuhQHSuba9CBlv+nmBkk=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1o7Fb5-0006ws-UI; Fri, 01 Jul 2022 14:18:10 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
In-Reply-To: <87y2cmof3x.fsf@HIDDEN> (Spencer Baugh's message of "Mon, 10
 May 2021 10:09:06 -0400")
References: <83im3s8gzq.fsf@HIDDEN> <20210509170933.27338-1-sbaugh@HIDDEN>
 <20210509170933.27338-3-sbaugh@HIDDEN>
 <jwvh7jbye53.fsf-monnier+emacs@HIDDEN> <83h7jb7ocw.fsf@HIDDEN>
 <87y2cmof3x.fsf@HIDDEN>
X-Now-Playing: Moby's _Reprise: Remixes_: "Natural Blues (Moby's West Side
 Highway Remix)"
Date: Fri, 01 Jul 2022 14:18:06 +0200
Message-ID: <87bku958n5.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  Spencer Baugh <sbaugh@HIDDEN> writes: >>> BTW, I find
 this term slightly problematic: "permanent-local" already >>> has a slightly
 different meaning for normal variables. Maybe we should >>> call them
 "really-permanent-local" or "always b [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Spencer Baugh <sbaugh@HIDDEN> writes:

>>> BTW, I find this term slightly problematic: "permanent-local" already
>>> has a slightly different meaning for normal variables.  Maybe we should
>>> call them "really-permanent-local" or "always buffer-local" or
>>> "buffer-local-only"?
>>
>> I prefer "always buffer-local", as this is what we used until now (see
>> buffer.c).
>
> True, will change the wording in a followup.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

Lightly skimming this thread, it seemed like people agreed that this
patch set should be applied, but that didn't happen, as far as I can
tell.  Did you do any further work on this, Spencer?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Message received at control <at> debbugs.gnu.org:


Received: (at control) by debbugs.gnu.org; 1 Jul 2022 12:18:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jul 01 08:18:23 2022
Received: from localhost ([127.0.0.1]:36558 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1o7FbL-00026y-In
	for submit <at> debbugs.gnu.org; Fri, 01 Jul 2022 08:18:23 -0400
Received: from quimby.gnus.org ([95.216.78.240]:54486)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1o7FbJ-00026V-IC
 for control <at> debbugs.gnu.org; Fri, 01 Jul 2022 08:18:21 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc:
 MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=SQfHBU7aBkjMJ1WKcXAGwedmZn+lFxg8IyuNDAr88pg=; b=IV9ipjLhUAdtOANG5gOjfCGw/h
 QKjcAfai1JmIOUH1h+nbmADDJ1uAhiMAI9lJ3iy6UvJJCxiZSXLwb7UyJWAfKfg7Wyqe3fJ/plZM2
 t49tSmW6uA0Jzi1DSo1TWtyVUjvbMAYNWJat4t63GbHkOjxbhkDGM2kWPsV1nH1whBxM=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>) id 1o7FbB-0006wx-6X
 for control <at> debbugs.gnu.org; Fri, 01 Jul 2022 14:18:15 +0200
Date: Fri, 01 Jul 2022 14:18:12 +0200
Message-Id: <87a69t58mz.fsf@HIDDEN>
To: control <at> debbugs.gnu.org
From: Lars Ingebrigtsen <larsi@HIDDEN>
Subject: control message for bug #48264
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  tags 48264 + moreinfo quit 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: control
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

tags 48264 + moreinfo
quit





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: 28.0.50; Changing the default for DEFVAR_PER_BUFFER variables takes O(#buffers) time
Resent-From: Spencer Baugh <sbaugh@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 01 Jul 2022 18:50:02 +0000
Resent-Message-ID: <handler.48264.B48264.165670137912606 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: moreinfo
To: Lars Ingebrigtsen <larsi@HIDDEN>
Cc: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>, 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.165670137912606
          (code B ref 48264); Fri, 01 Jul 2022 18:50:02 +0000
Received: (at 48264) by debbugs.gnu.org; 1 Jul 2022 18:49:39 +0000
Received: from localhost ([127.0.0.1]:39157 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1o7Lhy-0003HG-QY
	for submit <at> debbugs.gnu.org; Fri, 01 Jul 2022 14:49:38 -0400
Received: from pnkfpfxf.outbound-mail.sendgrid.net ([50.31.63.175]:62548)
 by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from
 <bounces+21787432-3aec-48264=debbugs.gnu.org@HIDDEN>)
 id 1o7Lht-0003Gw-Gp
 for 48264 <at> debbugs.gnu.org; Fri, 01 Jul 2022 14:49:37 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com;
 h=from:subject:in-reply-to:references:mime-version:to:cc:content-type:
 content-transfer-encoding;
 s=s1; bh=FhViAzyAspYBtS1BzZKWO0J8co7HpfU1T+Hf3vZvYOM=;
 b=hbvznVHVgVbx0QzsTfISse4BkonfR9ufSM99GEj9OFJTCo/eViQOV64mCfvo8zE8wu1V
 h008jRnCj4GnGC832hV3uWxgDm1v5p6eU3jF5M+CQSRNCxWhLSCSs+vg8XDeBkbRH0teuS
 7NfDov69BoDi7RdHyt7ZFEAqxt4595Phg0AWGbEWibhGcg+vzcyekWtMUerwIeIB6tB35F
 FSxbTyXMi8fRusKpBWAZV0YCnWNAdJvxy0nltsJ0Tu6TnDUtgOW5jRI9p+TgUtfeNVWXmT
 9bZx5XEKZftC25jUTfh5zoGac3AD0jy3JZwAGW59Zzt9Q4LITwB00Z/eWlqDNrpw==
Received: by filterdrecv-5b8cd7cb77-kzhdk with SMTP id
 filterdrecv-5b8cd7cb77-kzhdk-1-62BF41B7-4A
 2022-07-01 18:49:27.824333148 +0000 UTC m=+1992322.681412441
Received: from earth.catern.com (unknown) by geopod-ismtpd-1-0 (SG) with ESMTP
 id q_Z7my6SSMiydyBQ5sO3Ag Fri, 01 Jul 2022 18:49:27.769 +0000 (UTC)
X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost;
 envelope-from=sbaugh@HIDDEN; receiver=<UNKNOWN> 
Received: from localhost (localhost [IPv6:::1])
 by earth.catern.com (Postfix) with ESMTPSA id 08A4D60080;
 Fri,  1 Jul 2022 14:49:26 -0400 (EDT)
From: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <87bku958n5.fsf_-_@HIDDEN>
References: <83im3s8gzq.fsf@HIDDEN> <20210509170933.27338-1-sbaugh@HIDDEN>
 <20210509170933.27338-3-sbaugh@HIDDEN>
 <jwvh7jbye53.fsf-monnier+emacs@HIDDEN> <83h7jb7ocw.fsf@HIDDEN>
 <87y2cmof3x.fsf@HIDDEN> <87bku958n5.fsf_-_@HIDDEN>
Date: Fri, 01 Jul 2022 18:49:27 +0000 (UTC)
Message-ID: <877d4weki1.fsf@HIDDEN>
MIME-Version: 1.0
X-SG-EID: GW3oCMoYnalRiojMOuLzE6x2H5kORXvlCdz1UwQVRMVT4fbh9ODEfCogOe74cOrI4e0V+MFZgakz9Re5a6/CguU2sa3MBSgDMFX6sS378JFE1VG/fN6rxLUgbjs8MsS6BfjwNCjkYid1o7Ra6OdgJB2CkdPDEsKC21GkFy7/g0ZUGEGkfafHYBo/nezUzfwkevoB09w2eybS1MdL9seKX7UbgN/IqOZo4KbEl+XJu9lHHbLFMpSDaox+CCqlFuHq
X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q==
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Lars Ingebrigtsen <larsi@HIDDEN> writes:
> Lightly skimming this thread, it seemed like people agreed that this
> patch set should be applied, but that didn't happen, as far as I can
> tell.  Did you do any further work on this, Spencer?

I was distracted by life, but I will rebase it and post it again in this
thread in the next week.

I do still really want this to land, since I still use Emacs with
thousands of buffers and that becomes annoyingly slow because of this
issue.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: 28.0.50; Changing the default for DEFVAR_PER_BUFFER variables takes O(#buffers) time
Resent-From: Lars Ingebrigtsen <larsi@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 02 Jul 2022 12:01:01 +0000
Resent-Message-ID: <handler.48264.B48264.165676325416655 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: moreinfo
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>, 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.165676325416655
          (code B ref 48264); Sat, 02 Jul 2022 12:01:01 +0000
Received: (at 48264) by debbugs.gnu.org; 2 Jul 2022 12:00:54 +0000
Received: from localhost ([127.0.0.1]:40056 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1o7bny-0004KZ-NB
	for submit <at> debbugs.gnu.org; Sat, 02 Jul 2022 08:00:54 -0400
Received: from quimby.gnus.org ([95.216.78.240]:37916)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1o7bnv-0004KM-WC
 for 48264 <at> debbugs.gnu.org; Sat, 02 Jul 2022 08:00:52 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References:
 In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: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=1pGc0Ww5lc4FcRbnufVRwd5C8vICzHwUzL1BXM0bEaE=; b=gtwH+HEiMmpOW08RpTjpCpwp/v
 3dW3a2WpCZwqt7o2hJQUilLiFkf/BXq3TUvs7HaWJZJ4Z3DB6Xxe8iY5vLmUg08AtTet2+MlGd/xE
 JhC1tJ5IWhQnuE39FFu2jP3s3Jm3OA8bDbQcnV/o0x5pURp+oJny/pxs355HRQWEKtYs=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1o7bnk-0001m7-Ee; Sat, 02 Jul 2022 14:00:42 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
In-Reply-To: <877d4weki1.fsf@HIDDEN> (Spencer Baugh's message of "Fri, 01
 Jul 2022 18:49:27 +0000 (UTC)")
References: <83im3s8gzq.fsf@HIDDEN> <20210509170933.27338-1-sbaugh@HIDDEN>
 <20210509170933.27338-3-sbaugh@HIDDEN>
 <jwvh7jbye53.fsf-monnier+emacs@HIDDEN> <83h7jb7ocw.fsf@HIDDEN>
 <87y2cmof3x.fsf@HIDDEN> <87bku958n5.fsf_-_@HIDDEN>
 <877d4weki1.fsf@HIDDEN>
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj
 SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAElBMVEXHvq9gW1ZSJywb
 FhWPV1v///9jtUDFAAAAAWJLR0QF+G/pxwAAAAd0SU1FB+YHAgs7B7pj094AAAG0SURBVDjLdZSB
 jesgDIadewyAORbAdICL6QA2x/4znQkkoVKepbYSX39s/xgA/hsBn8IDFCpcKDNxJotceuQfAKZM
 WV+VXlWkEr0k5FJ/usL+mV+RqEEjqm8lOhRdSeQrvQEUG+Gx2QSccNNeiQKGsABDfha55VVRmOJZ
 /vapILLiQ+otrIpjuR0Ch9RX3h3kAWaEfAO2jqM2ca21IZhgR7lyQyt0grKrtAu4kq/ku/pNnkF0
 zwpEuUHmFdzJR8cD8NndYcknwEewhxSdZbGPE1284jAtiVEN5BVQoETJJibq0fkE5lWwLzTbIxKt
 ihAoh05gQ7y9MrMLJUjfHMBFq4snaBhYvbRvqgDe3QpQ3UUQopoDsl3AMsHuAeHXO4aegxfQu/7n
 NSneVZ3A2bzp19L57rxtLzahLtXf1SuMDVUQ1QZ0jMnpbpQgiuJw65Z9WDLCRLSeR7dwDuiqsIHr
 a7FFRW1N9eMEA1q141D046AmmEWtyZPd7Ova2h2Uqyq/4X2fH8Bdbr8Fdr9brP0n10w8H4BSuS9Z
 sWefXEfy/lq88ljrrwEfWw0rknkRrgzjJJ7jD7BVjujBIt4hAAAAJXRFWHRkYXRlOmNyZWF0ZQAy
 MDIyLTA3LTAyVDExOjU5OjA3KzAwOjAw5y6ArwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMi0wNy0w
 MlQxMTo1OTowNyswMDowMJZzOBMAAAAASUVORK5CYII=
X-Now-Playing: The Clash's _Sandinista!_: "The Magnificent Seven"
Date: Sat, 02 Jul 2022 14:00:39 +0200
Message-ID: <87ilof3es8.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Spencer Baugh <sbaugh@HIDDEN> writes: > I was distracted
 by life, but I will rebase it and post it again in this > thread in the next
 week. Great! 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Spencer Baugh <sbaugh@HIDDEN> writes:

> I was distracted by life, but I will rebase it and post it again in this
> thread in the next week.

Great!

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#48264: 28.0.50; Changing the default for DEFVAR_PER_BUFFER variables takes O(#buffers) time
Resent-From: Lars Ingebrigtsen <larsi@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 02 Aug 2022 11:12:02 +0000
Resent-Message-ID: <handler.48264.B48264.16594386788347 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 48264
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: moreinfo
To: Spencer Baugh <sbaugh@HIDDEN>
Cc: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>, 48264 <at> debbugs.gnu.org
Received: via spool by 48264-submit <at> debbugs.gnu.org id=B48264.16594386788347
          (code B ref 48264); Tue, 02 Aug 2022 11:12:02 +0000
Received: (at 48264) by debbugs.gnu.org; 2 Aug 2022 11:11:18 +0000
Received: from localhost ([127.0.0.1]:42565 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oIpny-0002AZ-GF
	for submit <at> debbugs.gnu.org; Tue, 02 Aug 2022 07:11:18 -0400
Received: from quimby.gnus.org ([95.216.78.240]:56350)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1oIpnw-0002AM-Mj
 for 48264 <at> debbugs.gnu.org; Tue, 02 Aug 2022 07:11:17 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References:
 In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: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=y32A1zCH2hYFcKnuEJmc5Fq+ZFVPc04mOndplFnsDGw=; b=LO7OeeNbglBA7kEpQelOIPNXBM
 moKjOtCq7vdMqSPnl2lzCo163aAaMGK56SWA95OKF2lL9iasQGd0hwcpCApW85bdhs19Nvez21a9g
 x847tDlXQzOINxf7YhEEmWzK4YdDOIzclBGYZT7h57/UqI/WR2SEWStk0mnhJzhq4Nz0=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1oIpnm-0007ny-2K; Tue, 02 Aug 2022 13:11:08 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
In-Reply-To: <87ilof3es8.fsf@HIDDEN> (Lars Ingebrigtsen's message of "Sat,
 02 Jul 2022 14:00:39 +0200")
References: <83im3s8gzq.fsf@HIDDEN> <20210509170933.27338-1-sbaugh@HIDDEN>
 <20210509170933.27338-3-sbaugh@HIDDEN>
 <jwvh7jbye53.fsf-monnier+emacs@HIDDEN> <83h7jb7ocw.fsf@HIDDEN>
 <87y2cmof3x.fsf@HIDDEN> <87bku958n5.fsf_-_@HIDDEN>
 <877d4weki1.fsf@HIDDEN> <87ilof3es8.fsf@HIDDEN>
X-Now-Playing: The Bug's _In Blue_: "Destroy Me"
Date: Tue, 02 Aug 2022 13:11:05 +0200
Message-ID: <878ro6yk6u.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Lars Ingebrigtsen <larsi@HIDDEN> writes: >> I was
 distracted
 by life, but I will rebase it and post it again in this >> thread in the
 next week. > > Great! Just a ping: this was a month ago -- have you made any
 progress here, by any chance? 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Lars Ingebrigtsen <larsi@HIDDEN> writes:

>> I was distracted by life, but I will rebase it and post it again in this
>> thread in the next week.
>
> Great!

Just a ping: this was a month ago -- have you made any progress here, by
any chance?





Message received at control <at> debbugs.gnu.org:


Received: (at control) by debbugs.gnu.org; 31 Aug 2022 10:18:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Aug 31 06:18:30 2022
Received: from localhost ([127.0.0.1]:38278 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oTKnm-0003bK-LQ
	for submit <at> debbugs.gnu.org; Wed, 31 Aug 2022 06:18:30 -0400
Received: from quimby.gnus.org ([95.216.78.240]:40532)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1oTKnk-0003b4-Qy
 for control <at> debbugs.gnu.org; Wed, 31 Aug 2022 06:18:29 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc:
 MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=rTztvZYkBG4qEHZqhi9YSznM8yKO0wH6LL1KdrBJkog=; b=ITpR7vlXD4GbTv2HnPDVJ8NxHI
 d9tlyToR9lUsyXPsKQFfTTptAYmoQJ9O4oKPOWDLU3a/DncnXoykDr1iBEVLX8g3dcdKMxB9UH7oM
 UjwZ9iopuHfQb+o/5zZKAtdToTqPmRU+wGWfFIN29I0T+k2KZFV1JxuKtW4tLh4TBD3o=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>) id 1oTKnd-00007A-6j
 for control <at> debbugs.gnu.org; Wed, 31 Aug 2022 12:18:23 +0200
Date: Wed, 31 Aug 2022 12:18:20 +0200
Message-Id: <871qsw90nn.fsf@HIDDEN>
To: control <at> debbugs.gnu.org
From: Lars Ingebrigtsen <larsi@HIDDEN>
Subject: control message for bug #48264
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  tags 48264 - moreinfo quit 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: control
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

tags 48264 - moreinfo
quit






Last modified: Wed, 31 Aug 2022 10:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.