/* Header file for the buffer manipulation primitives.
-Copyright (C) 1985-1986, 1993-1995, 1997-2012
- Free Software Foundation, Inc.
+Copyright (C) 1985-1986, 1993-1995, 1997-2013 Free Software Foundation,
+Inc.
This file is part of GNU Emacs.
/* Usually 0. Temporarily set to 1 in decode_coding_gap to
prevent Fgarbage_collect from shrinking the gap and losing
not-yet-decoded bytes. */
- int inhibit_shrinking;
+ bool inhibit_shrinking;
};
/* Most code should use this macro to access Lisp fields in struct buffer. */
b->INTERNAL_FIELD (width_table) = val;
}
-\f
+/* Convenient check whether buffer B is live. */
+
+#define BUFFER_LIVE_P(b) (!NILP (BVAR (b, name)))
+
+/* Verify indirection counters. */
+
+#define BUFFER_CHECK_INDIRECTION(b) \
+ do { \
+ if (BUFFER_LIVE_P (b)) \
+ { \
+ if (b->base_buffer) \
+ { \
+ eassert (b->indirections == -1); \
+ eassert (b->base_buffer->indirections > 0); \
+ } \
+ else \
+ eassert (b->indirections >= 0); \
+ } \
+ } while (0)
+
/* Chain of all buffers, including killed ones. */
extern struct buffer *all_buffers;
\f
extern void delete_all_overlays (struct buffer *);
extern void reset_buffer (struct buffer *);
-extern int compact_buffer (struct buffer *);
+extern void compact_buffer (struct buffer *);
extern void evaporate_overlays (ptrdiff_t);
-extern ptrdiff_t overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr,
- ptrdiff_t *len_ptr, ptrdiff_t *next_ptr,
- ptrdiff_t *prev_ptr, int change_req);
+extern ptrdiff_t overlays_at (EMACS_INT, bool, Lisp_Object **,
+ ptrdiff_t *, ptrdiff_t *, ptrdiff_t *, bool);
extern ptrdiff_t sort_overlays (Lisp_Object *, ptrdiff_t, struct window *);
extern void recenter_overlay_lists (struct buffer *, ptrdiff_t);
extern ptrdiff_t overlay_strings (ptrdiff_t, struct window *, unsigned char **);
extern void validate_region (Lisp_Object *, Lisp_Object *);
-extern void set_buffer_internal (struct buffer *);
extern void set_buffer_internal_1 (struct buffer *);
extern void set_buffer_temp (struct buffer *);
extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object);
extern void record_buffer (Lisp_Object);
extern _Noreturn void buffer_slot_type_mismatch (Lisp_Object, int);
extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t);
-extern void mmap_set_vars (int);
+extern void mmap_set_vars (bool);
+
+/* Set the current buffer to B.
+
+ We previously set windows_or_buffers_changed here to invalidate
+ global unchanged information in beg_unchanged and end_unchanged.
+ This is no longer necessary because we now compute unchanged
+ information on a buffer-basis. Every action affecting other
+ windows than the selected one requires a select_window at some
+ time, and that increments windows_or_buffers_changed. */
+
+BUFFER_INLINE void
+set_buffer_internal (struct buffer *b)
+{
+ if (current_buffer != b)
+ set_buffer_internal_1 (b);
+}
+
+/* Arrange to go back to the original buffer after the next
+ call to unbind_to if the original buffer is still alive. */
+
+BUFFER_INLINE void
+record_unwind_current_buffer (void)
+{
+ record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ());
+}
/* Get overlays at POSN into array OVERLAYS with NOVERLAYS elements.
If NEXTP is non-NULL, return next overlay there.
/* Non-zero if current buffer has overlays. */
-BUFFER_INLINE int
+BUFFER_INLINE bool
buffer_has_overlays (void)
{
return current_buffer->overlays_before || current_buffer->overlays_after;
We assume you know which buffer it's pointing into. */
#define OVERLAY_POSITION(P) \
- (MARKERP (P) ? marker_position (P) : (abort (), 0))
+ (MARKERP (P) ? marker_position (P) : (emacs_abort (), 0))
\f
/***********************************************************************
#define PER_BUFFER_VALUE_P(B, IDX) \
(((IDX) < 0 || IDX >= last_per_buffer_idx) \
- ? (abort (), 0) \
+ ? (emacs_abort (), 0) \
: ((B)->local_flags[IDX] != 0))
/* Set whether per-buffer variable with index IDX has a buffer-local
#define SET_PER_BUFFER_VALUE_P(B, IDX, VAL) \
do { \
if ((IDX) < 0 || (IDX) >= last_per_buffer_idx) \
- abort (); \
+ emacs_abort (); \
(B)->local_flags[IDX] = (VAL); \
} while (0)
#define PER_BUFFER_IDX(OFFSET) \
XINT (*(Lisp_Object *)((OFFSET) + (char *) &buffer_local_flags))
-/* Return the default value of the per-buffer variable at offset
- OFFSET in the buffer structure. */
+/* Functions to get and set default value of the per-buffer
+ variable at offset OFFSET in the buffer structure. */
-#define PER_BUFFER_DEFAULT(OFFSET) \
- (*(Lisp_Object *)((OFFSET) + (char *) &buffer_defaults))
+BUFFER_INLINE Lisp_Object
+per_buffer_default (int offset)
+{
+ return *(Lisp_Object *)(offset + (char *) &buffer_defaults);
+}
-/* Return the buffer-local value of the per-buffer variable at offset
- OFFSET in the buffer structure. */
+BUFFER_INLINE void
+set_per_buffer_default (int offset, Lisp_Object value)
+{
+ *(Lisp_Object *)(offset + (char *) &buffer_defaults) = value;
+}
+
+/* Functions to get and set buffer-local value of the per-buffer
+ variable at offset OFFSET in the buffer structure. */
+
+BUFFER_INLINE Lisp_Object
+per_buffer_value (struct buffer *b, int offset)
+{
+ return *(Lisp_Object *)(offset + (char *) b);
+}
+
+BUFFER_INLINE void
+set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value)
+{
+ *(Lisp_Object *)(offset + (char *) b) = value;
+}
-#define PER_BUFFER_VALUE(BUFFER, OFFSET) \
- (*(Lisp_Object *)((OFFSET) + (char *) (BUFFER)))
-\f
/* Downcase a character C, or make no change if that cannot be done. */
BUFFER_INLINE int
downcase (int c)
}
/* 1 if C is upper case. */
-BUFFER_INLINE int uppercasep (int c) { return downcase (c) != c; }
+BUFFER_INLINE bool uppercasep (int c) { return downcase (c) != c; }
/* Upcase a character C known to be not upper case. */
BUFFER_INLINE int
}
/* 1 if C is lower case. */
-BUFFER_INLINE int lowercasep (int c)
-{ return !uppercasep (c) && upcase1 (c) != c; }
+BUFFER_INLINE bool
+lowercasep (int c)
+{
+ return !uppercasep (c) && upcase1 (c) != c;
+}
/* Upcase a character C, or make no change if that cannot be done. */
BUFFER_INLINE int upcase (int c) { return uppercasep (c) ? c : upcase1 (c); }