From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#48264: [PATCH v4 09/14] Get rid of buffer_permanent_local_flags array Date: Fri, 7 May 2021 22:09:00 -0400 Message-ID: <20210508020905.13583-11-sbaugh@catern.com> References: <20210506213346.9730-1-sbaugh@catern.com> <20210508020905.13583-1-sbaugh@catern.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="797"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Spencer Baugh To: 48264@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 08 04:49:00 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lfD1Y-000AZ0-6O for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 May 2021 04:49:00 +0200 Original-Received: from localhost ([::1]:44964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfD1X-0001Bl-83 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 May 2021 22:48:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfCPu-0001MH-6J for bug-gnu-emacs@gnu.org; Fri, 07 May 2021 22:10:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfCPt-0007YL-Tm for bug-gnu-emacs@gnu.org; Fri, 07 May 2021 22:10:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lfCPt-0006VH-PU for bug-gnu-emacs@gnu.org; Fri, 07 May 2021 22:10:05 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 08 May 2021 02:10:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48264 X-GNU-PR-Package: emacs Original-Received: via spool by 48264-submit@debbugs.gnu.org id=B48264.162043976724862 (code B ref 48264); Sat, 08 May 2021 02:10:05 +0000 Original-Received: (at 48264) by debbugs.gnu.org; 8 May 2021 02:09:27 +0000 Original-Received: from localhost ([127.0.0.1]:47171 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfCPG-0006Sk-O3 for submit@debbugs.gnu.org; Fri, 07 May 2021 22:09:27 -0400 Original-Received: from venus.catern.com ([68.183.49.163]:47938) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfCPE-0006SC-46 for 48264@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@catern.com; receiver= 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= Original-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) X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210508020905.13583-1-sbaugh@catern.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:205979 Archived-At: 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