+#define BUF_GAP_SIZE(buf) ((buf)->text->gap_size)
+
+/* Is this buffer narrowed? */
+#define BUF_NARROWED(buf) ((BUF_BEGV (buf) != BUF_BEG (buf)) \
+ || (BUF_ZV (buf) != BUF_Z (buf)))
+
+/* Modification count. */
+#define BUF_MODIFF(buf) ((buf)->text->modiff)
+
+/* Modification count as of last visit or save. */
+#define BUF_SAVE_MODIFF(buf) ((buf)->text->save_modiff)
+
+/* Overlay modification count. */
+#define BUF_OVERLAY_MODIFF(buf) ((buf)->text->overlay_modiff)
+
+/* Interval tree of buffer. */
+#define BUF_INTERVALS(buf) ((buf)->text->intervals)
+
+/* Marker chain of buffer. */
+#define BUF_MARKERS(buf) ((buf)->text->markers)
+\f
+/* Macros to set PT in the current buffer, or another buffer.. */
+
+#ifdef USE_TEXT_PROPERTIES
+#define SET_PT(position) (set_point (current_buffer, (position)))
+#define TEMP_SET_PT(position) (temp_set_point (current_buffer, (position)))
+
+#define SET_PT_BOTH(position, byte) \
+ (set_point_both (current_buffer, (position), (byte)))
+#define TEMP_SET_PT_BOTH(position, byte) \
+ (temp_set_point_both (current_buffer, (position), (byte)))
+
+#define BUF_SET_PT(buffer, position) \
+ (set_point ((buffer), (position)))
+#define BUF_TEMP_SET_PT(buffer, position) \
+ (temp_set_point ((buffer), (position)))
+
+extern void set_point P_ ((struct buffer *, int));
+extern INLINE void temp_set_point P_ ((struct buffer *, int));
+extern void set_point_both P_ ((struct buffer *, int, int));
+extern INLINE void temp_set_point_both P_ ((struct buffer *, int, int));
+
+#else /* don't support text properties */
+
+#define SET_PT(position) (current_buffer->pt = (position))
+#define TEMP_SET_PT(position) (current_buffer->pt = (position))
+
+#define SET_PT_BOTH(position, byte) \
+ (current_buffer->pt = (position), \
+ current_buffer->pt_byte = (byte))
+
+#define TEMP_SET_PT_BOTH(position, byte) \
+ (current_buffer->pt = (position), \
+ current_buffer->pt_byte = (byte))
+
+#define BUF_SET_PT(buffer, position) (buffer->pt = (position))
+#define BUF_TEMP_SET_PT(buffer, position) (buffer->pt = (position))
+#endif /* don't support text properties */
+\f
+/* Macros for setting the BEGV, ZV or PT of a given buffer.
+
+ SET_BUF_PT* seet to be redundant. Get rid of them?
+
+ The ..._BOTH macros take both a charpos and a bytepos,
+ which must correspond to each other.
+
+ The macros without ..._BOTH take just a charpos,
+ and compute the bytepos from it. */
+
+#define SET_BUF_BEGV(buf, charpos) \
+ ((buf)->begv_byte = buf_charpos_to_bytepos ((buf), (charpos)), \
+ (buf)->begv = (charpos))
+
+#define SET_BUF_ZV(buf, charpos) \
+ ((buf)->zv_byte = buf_charpos_to_bytepos ((buf), (charpos)), \
+ (buf)->zv = (charpos))
+
+#define SET_BUF_BEGV_BOTH(buf, charpos, byte) \
+ ((buf)->begv = (charpos), \
+ (buf)->begv_byte = (byte))
+
+#define SET_BUF_ZV_BOTH(buf, charpos, byte) \
+ ((buf)->zv = (charpos), \
+ (buf)->zv_byte = (byte))
+
+#define SET_BUF_PT_BOTH(buf, charpos, byte) \
+ ((buf)->pt = (charpos), \
+ (buf)->pt_byte = (byte))
+\f
+/* Macros to access a character or byte in the current buffer,
+ or convert between a byte position and an address.
+ These macros do not check that the position is in range. */
+
+/* Access a Lisp position value in POS,
+ and store the charpos in CHARPOS and the bypepos in BYPEPOS. */
+
+#define DECODE_POSITION(charpos, bytepos, pos) \
+if (1) \
+ { \
+ Lisp_Object __pos = (pos); \
+ if (NUMBERP (__pos)) \
+ { \
+ charpos = __pos; \
+ bytepos = buf_charpos_to_bytepos (current_buffer, __pos); \
+ } \
+ else if (MARKERP (__pos)) \
+ { \
+ charpos = marker_position (__pos); \
+ bytepos = marker_byte_position (__pos); \
+ } \
+ else \
+ wrong_type_argument (Qinteger_or_marker_p, __pos); \
+ } \
+else
+
+/* Return the address of byte position N in current buffer. */
+
+#define BYTE_POS_ADDR(n) \
+ (((n) >= GPT_BYTE ? GAP_SIZE : 0) + (n) + BEG_ADDR - 1)
+
+/* Return the address of char position N. */
+
+#define CHAR_POS_ADDR(n) \
+ (((n) >= GPT ? GAP_SIZE : 0) \
+ + buf_charpos_to_bytepos (current_buffer, n) \
+ + BEG_ADDR - 1)
+
+/* Convert a character position to a byte position. */
+
+#define CHAR_TO_BYTE(charpos) \
+ (buf_charpos_to_bytepos (current_buffer, charpos))
+
+/* Convert a byte position to a character position. */
+
+#define BYTE_TO_CHAR(bytepos) \
+ (buf_bytepos_to_charpos (current_buffer, bytepos))
+
+/* Convert PTR, the address of a byte in the buffer, into a byte position. */
+
+#define PTR_BYTE_POS(ptr) \
+((ptr) - (current_buffer)->text->beg \
+ - (ptr - (current_buffer)->text->beg < (unsigned) GPT_BYTE ? 0 : GAP_SIZE) \
+ + 1)
+
+/* Return character at position POS. */
+
+#define FETCH_CHAR(pos) \
+ (!NILP (current_buffer->enable_multibyte_characters) \
+ ? FETCH_MULTIBYTE_CHAR ((pos)) \
+ : FETCH_BYTE ((pos)))
+
+/* Return the byte at byte position N. */
+
+#define FETCH_BYTE(n) *(BYTE_POS_ADDR ((n)))