emacs-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]