Inline functions to examine and change buffer overlays.
[bpt/emacs.git] / src / buffer.h
index 9618fc6..a52ca71 100644 (file)
@@ -193,9 +193,6 @@ INLINE_HEADER_BEGIN
 /* FIXME: should we move this into ->text->auto_save_modiff?  */
 #define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified)
 
-/* Interval tree of buffer.  */
-#define BUF_INTERVALS(buf) ((buf)->text->intervals)
-
 /* Marker chain of buffer.  */
 #define BUF_MARKERS(buf) ((buf)->text->markers)
 
@@ -948,10 +945,74 @@ extern void mmap_set_vars (int);
       }                                                                        \
   } while (0)
 
+enum overlay_type
+{
+  OV_BEFORE,
+  OV_AFTER
+};
+
+/* Get overlay list of type T and belonging to B.  */
+
+BUFFER_INLINE struct Lisp_Overlay *
+buffer_get_overlays (struct buffer *b, enum overlay_type t)
+{
+  if (!b)
+    b = current_buffer;
+  if (t == OV_BEFORE)
+    return b->overlays_before;
+  else if (t == OV_AFTER)
+    return b->overlays_after;
+  else
+    abort ();
+}
+
+/* Set overlay list of type T as belonging to B.  */
+
+BUFFER_INLINE void
+buffer_set_overlays (struct buffer *b, struct Lisp_Overlay *o,
+                    enum overlay_type t)
+{
+  if (!b)
+    b = current_buffer;
+  if (t == OV_BEFORE)
+    b->overlays_before = o;
+  else if (t == OV_AFTER)
+    b->overlays_after = o;
+  else
+    abort ();
+}
+
+/* Non-zero if current buffer has overlays.  */
+
+BUFFER_INLINE int
+buffer_has_overlays (void)
+{
+  return buffer_get_overlays (current_buffer, OV_BEFORE)
+    || buffer_get_overlays (current_buffer, OV_AFTER);
+}
+
 extern Lisp_Object Qbefore_change_functions;
 extern Lisp_Object Qafter_change_functions;
 extern Lisp_Object Qfirst_change_hook;
-\f
+
+/* Get text properties of B.  */
+
+BUFFER_INLINE INTERVAL
+buffer_get_intervals (struct buffer *b)
+{
+  eassert (b->text != NULL);
+  return b->text->intervals;
+}
+
+/* Set text properties of B to I.  */
+
+BUFFER_INLINE void
+buffer_set_intervals (struct buffer *b, INTERVAL i)
+{
+  eassert (b->text != NULL);
+  b->text->intervals = i;
+}
+
 /* Return character code of multi-byte form at byte position POS.  If POS
    doesn't point the head of valid multi-byte form, only the byte at
    POS is returned.  No range checking.