[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P
From: |
Spencer Baugh |
Subject: |
bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P |
Date: |
Thu, 6 May 2021 17:33:34 -0400 |
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
- bug#48264: [PATCH v4 10/14] Delete SET_PER_BUFFER_VALUE_P and buffer local_flags field, (continued)
- 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, 2021/05/07
- 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 <=
- bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P, Eli Zaretskii, 2021/05/07
- bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P, Eli Zaretskii, 2021/05/07
- bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P, Eli Zaretskii, 2021/05/07
- bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P, Eli Zaretskii, 2021/05/07
bug#48264: [PATCH v3 05/15] Add and use KILL_PER_BUFFER_VALUE, Spencer Baugh, 2021/05/06
bug#48264: [PATCH v3 08/15] Set non-buffer-local BVARs to Qunbound, Spencer Baugh, 2021/05/06