emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 10/16] Add and use KILL_PER_BUFFER_VALUE


From: Spencer Baugh
Subject: [PATCH v2 10/16] Add and use KILL_PER_BUFFER_VALUE
Date: Sat, 21 Nov 2020 21:34:39 -0500

This improves clarity and removes usage of idx.
---
 src/buffer.c |  5 +----
 src/buffer.h | 10 ++++++++++
 src/data.c   |  8 +-------
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index 47a40a4284..b05fdbd9b2 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1085,10 +1085,7 @@ reset_buffer_local_variables (struct buffer *b, bool 
permanent_too)
       if ((BUFFER_DEFAULT_VALUE_P (offset)
           && (permanent_too
               || buffer_permanent_local_flags[idx] == 0)))
-        {
-          SET_PER_BUFFER_VALUE_P (b, idx, 0);
-          set_per_buffer_value (b, offset, per_buffer_default (offset));
-        }
+        KILL_PER_BUFFER_VALUE (b, offset);
     }
 }
 
diff --git a/src/buffer.h b/src/buffer.h
index 16a5f223f8..b95379db82 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1507,6 +1507,16 @@ PER_BUFFER_VALUE_P (struct buffer *b, int offset)
   return idx == -1 || b->local_flags[idx];
 }
 
+/* Kill the per-buffer binding for this value, if there is one. */
+
+INLINE void
+KILL_PER_BUFFER_VALUE (struct buffer *b, int offset)
+{
+  int idx = PER_BUFFER_IDX (offset);
+  SET_PER_BUFFER_VALUE_P (b, idx, 0);
+  set_per_buffer_value (b, offset, per_buffer_default (offset));
+}
+
 /* Downcase a character C, or make no change if that cannot be done.  */
 INLINE int
 downcase (int c)
diff --git a/src/data.c b/src/data.c
index bfb7decc09..b7ad4ef1db 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1993,14 +1993,8 @@ From now on the default value will apply in this buffer. 
 Return VARIABLE.  */)
        if (BUFFER_OBJFWDP (valcontents))
          {
            int offset = XBUFFER_OBJFWD (valcontents)->offset;
-           int idx = PER_BUFFER_IDX (offset);
-
            if (BUFFER_DEFAULT_VALUE_P (offset))
-             {
-               SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0);
-               set_per_buffer_value (current_buffer, offset,
-                                     per_buffer_default (offset));
-             }
+              KILL_PER_BUFFER_VALUE (current_buffer, offset);
          }
        return variable;
       }
-- 
2.28.0




reply via email to

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