[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#48264: [PATCH v4 09/14] Get rid of buffer_permanent_local_flags arra
From: |
Spencer Baugh |
Subject: |
bug#48264: [PATCH v4 09/14] Get rid of buffer_permanent_local_flags array |
Date: |
Fri, 7 May 2021 22:09:00 -0400 |
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
- bug#48264: [PATCH v4 13/14] Remove PER_BUFFER_IDX and buffer_local_flags, (continued)
- bug#48264: [PATCH v4 13/14] Remove PER_BUFFER_IDX and buffer_local_flags, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 14/14] Add and use BVAR_FIELD macros, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 05/14] Add and use KILL_PER_BUFFER_VALUE, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 03/14] Add and use BVAR_HAS_DEFAULT_VALUE_P, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 01/14] Stop checking the constant default for enable_multibyte_characters, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 02/14] Take offset not idx in PER_BUFFER_VALUE_P, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 04/14] Combine unnecessarily separate loops in buffer.c, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 07/14] Use BVAR_OR_DEFAULT for per-buffer vars with defaults, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 10/14] Delete SET_PER_BUFFER_VALUE_P and buffer local_flags field, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 08/14] Remove unnecessary Qunbound check, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 09/14] Get rid of buffer_permanent_local_flags array,
Spencer Baugh <=
- bug#48264: [PATCH v4 12/14] Assert that PER_BUFFER_IDX for Lisp variables is not 0, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v4 00/15] Speeding up setting the default for DEFVAR_PER_BUFFER vars, Stefan Monnier, 2021/05/08
- bug#48264: [PATCH v3 02/15] Take offset not idx in PER_BUFFER_VALUE_P, Spencer Baugh, 2021/05/06
- bug#48264: [PATCH v3 04/15] Combine unnecessarily separate loops in buffer.c, Spencer Baugh, 2021/05/06
- bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P, Spencer Baugh, 2021/05/06