[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#48264: [PATCH v3 06/15] Rearrange set_internal for buffer forwarded
From: |
Spencer Baugh |
Subject: |
bug#48264: [PATCH v3 06/15] Rearrange set_internal for buffer forwarded symbols |
Date: |
Thu, 6 May 2021 17:33:37 -0400 |
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
- bug#48264: [PATCH v3 03/15] Add and use BUFFER_DEFAULT_VALUE_P, (continued)
- 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
bug#48264: [PATCH v3 06/15] Rearrange set_internal for buffer forwarded symbols,
Spencer Baugh <=
bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound, Spencer Baugh, 2021/05/06
- bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound, Eli Zaretskii, 2021/05/07
- bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound, Eli Zaretskii, 2021/05/07
- bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound, Eli Zaretskii, 2021/05/07
- bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound, Spencer Baugh, 2021/05/07
- bug#48264: [PATCH v3 12/15] Set buffer_defaults fields without a default to Qunbound, Eli Zaretskii, 2021/05/08