[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 09/16] Add and use BUFFER_DEFAULT_VALUE_P
From: |
Spencer Baugh |
Subject: |
[PATCH v2 09/16] Add and use BUFFER_DEFAULT_VALUE_P |
Date: |
Sat, 21 Nov 2020 21:34:38 -0500 |
This makes the code more clear, IMO. And this gets rid of some more
usage of idx, which we'll remove later.
---
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 5333db73bd..47a40a4284 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1082,7 +1082,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)))
{
diff --git a/src/buffer.h b/src/buffer.h
index 69df791b53..16a5f223f8 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1486,6 +1486,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 47a1a6640f..bfb7decc09 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1720,13 +1720,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;
@@ -1996,7 +1995,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.28.0
- [PATCH v2 01/16] Add a test for let-binding unwinding, (continued)
- [PATCH v2 05/16] Add BVAR_DEFAULT for access to buffer defaults, Spencer Baugh, 2020/11/21
- [PATCH v2 02/16] Assert not local-variable-p after setq in let_default binding, Spencer Baugh, 2020/11/21
- Re: [PATCH v2 02/16] Assert not local-variable-p after setq in let_default binding, Stefan Monnier, 2020/11/25
- [PATCH v2 03/16] Stop checking the constant default for enable_multibyte_characters, Spencer Baugh, 2020/11/21
- Re: [PATCH v2 03/16] Stop checking the constant default for enable_multibyte_characters, Stefan Monnier, 2020/11/25
- [PATCH v2 04/16] Take buffer field name in DEFVAR_PER_BUFFER, Spencer Baugh, 2020/11/21
- [PATCH v2 08/16] Combine unnecessarily separate loops in buffer.c, Spencer Baugh, 2020/11/21
- [PATCH v2 09/16] Add and use BUFFER_DEFAULT_VALUE_P,
Spencer Baugh <=
- [PATCH v2 06/16] Use bset_* functions instead of BVAR, Spencer Baugh, 2020/11/21
- [PATCH v2 07/16] Take offset not idx in PER_BUFFER_VALUE_P, Spencer Baugh, 2020/11/21
- [PATCH v2 11/16] Assert that PER_BUFFER_IDX for Lisp variables is not 0, Spencer Baugh, 2020/11/21
- [PATCH v2 14/16] Remove unnecessary Qunbound check, Spencer Baugh, 2020/11/21
- [PATCH v2 10/16] Add and use KILL_PER_BUFFER_VALUE, Spencer Baugh, 2020/11/21
- [PATCH v2 13/16] Get rid of buffer_permanent_local_flags array, Spencer Baugh, 2020/11/21
- Re: [PATCH v2 13/16] Get rid of buffer_permanent_local_flags array, Eli Zaretskii, 2020/11/22
- [PATCH v2 12/16] Rearrange set_internal for buffer forwarded symbols, Spencer Baugh, 2020/11/21
- [PATCH v2 15/16] Remove local_flags array in struct buffer, Spencer Baugh, 2020/11/21
- Re: [PATCH v2 15/16] Remove local_flags array in struct buffer, Stefan Monnier, 2020/11/22