aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.h
diff options
context:
space:
mode:
authorGregory Heytings2022-10-30 17:00:35 +0100
committerGregory Heytings2022-10-30 17:00:35 +0100
commitaef803d6c3d61004f15d0bc82fa7bf9952302312 (patch)
tree087c444f788cda27006ddc066ad430f62f5ac02a /src/buffer.h
parent3bf19c417fd39766ee9c7a793c9faadd3bd88478 (diff)
parent3fa4cca3d244f51e471e7779c934278731fc21e9 (diff)
downloademacs-aef803d6c3d61004f15d0bc82fa7bf9952302312.tar.gz
emacs-aef803d6c3d61004f15d0bc82fa7bf9952302312.zip
Merge master into feature/improved-locked-narrowing.
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h114
1 files changed, 83 insertions, 31 deletions
diff --git a/src/buffer.h b/src/buffer.h
index 77f9ea20afa..3ea4125645d 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1,7 +1,6 @@
1/* Header file for the buffer manipulation primitives. 1/* Header file for the buffer manipulation primitives.
2 2
3Copyright (C) 1985-1986, 1993-1995, 1997-2022 Free Software Foundation, 3Copyright (C) 1985-2022 Free Software Foundation, Inc.
4Inc.
5 4
6This file is part of GNU Emacs. 5This file is part of GNU Emacs.
7 6
@@ -26,6 +25,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
26 25
27#include "character.h" 26#include "character.h"
28#include "lisp.h" 27#include "lisp.h"
28#include "itree.h"
29 29
30INLINE_HEADER_BEGIN 30INLINE_HEADER_BEGIN
31 31
@@ -274,7 +274,9 @@ struct buffer_text
274 end_unchanged contain no useful information. */ 274 end_unchanged contain no useful information. */
275 modiff_count overlay_unchanged_modified; 275 modiff_count overlay_unchanged_modified;
276 276
277 /* CHARS_MODIFF as of last redisplay that finished. */ 277 /* CHARS_MODIFF as of last redisplay that finished. It's used
278 when we only care about changes in actual buffer text, not in
279 any other kind of changes, like properties etc. */
278 modiff_count chars_unchanged_modified; 280 modiff_count chars_unchanged_modified;
279 281
280 /* Properties of this buffer's text. */ 282 /* Properties of this buffer's text. */
@@ -695,16 +697,8 @@ struct buffer
695 display optimizations must be used. */ 697 display optimizations must be used. */
696 bool_bf long_line_optimizations_p : 1; 698 bool_bf long_line_optimizations_p : 1;
697 699
698 /* List of overlays that end at or before the current center, 700 /* The inveral tree containing this buffer's overlays. */
699 in order of end-position. */ 701 struct itree_tree *overlays;
700 struct Lisp_Overlay *overlays_before;
701
702 /* List of overlays that end after the current center,
703 in order of start-position. */
704 struct Lisp_Overlay *overlays_after;
705
706 /* Position where the overlay lists are centered. */
707 ptrdiff_t overlay_center;
708 702
709 /* Changes in the buffer are recorded here for undo, and t means 703 /* Changes in the buffer are recorded here for undo, and t means
710 don't record anything. This information belongs to the base 704 don't record anything. This information belongs to the base
@@ -714,6 +708,14 @@ struct buffer
714 Lisp_Object undo_list_; 708 Lisp_Object undo_list_;
715}; 709};
716 710
711struct sortvec
712{
713 Lisp_Object overlay;
714 ptrdiff_t beg, end;
715 EMACS_INT priority;
716 EMACS_INT spriority; /* Secondary priority. */
717};
718
717INLINE bool 719INLINE bool
718BUFFERP (Lisp_Object a) 720BUFFERP (Lisp_Object a)
719{ 721{
@@ -1169,8 +1171,11 @@ extern void delete_all_overlays (struct buffer *);
1169extern void reset_buffer (struct buffer *); 1171extern void reset_buffer (struct buffer *);
1170extern void compact_buffer (struct buffer *); 1172extern void compact_buffer (struct buffer *);
1171extern void evaporate_overlays (ptrdiff_t); 1173extern void evaporate_overlays (ptrdiff_t);
1172extern ptrdiff_t overlays_at (EMACS_INT, bool, Lisp_Object **, 1174extern ptrdiff_t overlays_at (ptrdiff_t, bool, Lisp_Object **, ptrdiff_t *, ptrdiff_t *);
1173 ptrdiff_t *, ptrdiff_t *, ptrdiff_t *, bool); 1175extern ptrdiff_t overlays_in (ptrdiff_t, ptrdiff_t, bool, Lisp_Object **,
1176 ptrdiff_t *, bool, bool, ptrdiff_t *);
1177extern ptrdiff_t previous_overlay_change (ptrdiff_t);
1178extern ptrdiff_t next_overlay_change (ptrdiff_t);
1174extern ptrdiff_t sort_overlays (Lisp_Object *, ptrdiff_t, struct window *); 1179extern ptrdiff_t sort_overlays (Lisp_Object *, ptrdiff_t, struct window *);
1175extern void recenter_overlay_lists (struct buffer *, ptrdiff_t); 1180extern void recenter_overlay_lists (struct buffer *, ptrdiff_t);
1176extern ptrdiff_t overlay_strings (ptrdiff_t, struct window *, unsigned char **); 1181extern ptrdiff_t overlay_strings (ptrdiff_t, struct window *, unsigned char **);
@@ -1184,6 +1189,7 @@ extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t);
1184extern void mmap_set_vars (bool); 1189extern void mmap_set_vars (bool);
1185extern void restore_buffer (Lisp_Object); 1190extern void restore_buffer (Lisp_Object);
1186extern void set_buffer_if_live (Lisp_Object); 1191extern void set_buffer_if_live (Lisp_Object);
1192extern Lisp_Object build_overlay (bool, bool, Lisp_Object);
1187 1193
1188/* Return B as a struct buffer pointer, defaulting to the current buffer. */ 1194/* Return B as a struct buffer pointer, defaulting to the current buffer. */
1189 1195
@@ -1224,18 +1230,16 @@ record_unwind_current_buffer (void)
1224 This macro might evaluate its args multiple times, 1230 This macro might evaluate its args multiple times,
1225 and it treat some args as lvalues. */ 1231 and it treat some args as lvalues. */
1226 1232
1227#define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ 1233#define GET_OVERLAYS_AT(posn, overlays, noverlays, next) \
1228 do { \ 1234 do { \
1229 ptrdiff_t maxlen = 40; \ 1235 ptrdiff_t maxlen = 40; \
1230 SAFE_NALLOCA (overlays, 1, maxlen); \ 1236 SAFE_NALLOCA (overlays, 1, maxlen); \
1231 (noverlays) = overlays_at (posn, false, &(overlays), &maxlen, \ 1237 (noverlays) = overlays_at (posn, false, &(overlays), &maxlen, next); \
1232 nextp, NULL, chrq); \
1233 if ((noverlays) > maxlen) \ 1238 if ((noverlays) > maxlen) \
1234 { \ 1239 { \
1235 maxlen = noverlays; \ 1240 maxlen = noverlays; \
1236 SAFE_NALLOCA (overlays, 1, maxlen); \ 1241 SAFE_NALLOCA (overlays, 1, maxlen); \
1237 (noverlays) = overlays_at (posn, false, &(overlays), &maxlen, \ 1242 (noverlays) = overlays_at (posn, false, &(overlays), &maxlen, next); \
1238 nextp, NULL, chrq); \
1239 } \ 1243 } \
1240 } while (false) 1244 } while (false)
1241 1245
@@ -1270,7 +1274,8 @@ set_buffer_intervals (struct buffer *b, INTERVAL i)
1270INLINE bool 1274INLINE bool
1271buffer_has_overlays (void) 1275buffer_has_overlays (void)
1272{ 1276{
1273 return current_buffer->overlays_before || current_buffer->overlays_after; 1277 return current_buffer->overlays
1278 && (current_buffer->overlays->root != NULL);
1274} 1279}
1275 1280
1276/* Functions for accessing a character or byte, 1281/* Functions for accessing a character or byte,
@@ -1388,25 +1393,69 @@ buffer_window_count (struct buffer *b)
1388 1393
1389/* Overlays */ 1394/* Overlays */
1390 1395
1391/* Return the marker that stands for where OV starts in the buffer. */ 1396INLINE ptrdiff_t
1397overlay_start (struct Lisp_Overlay *ov)
1398{
1399 if (! ov->buffer)
1400 return -1;
1401 return itree_node_begin (ov->buffer->overlays, ov->interval);
1402}
1403
1404INLINE ptrdiff_t
1405overlay_end (struct Lisp_Overlay *ov)
1406{
1407 if (! ov->buffer)
1408 return -1;
1409 return itree_node_end (ov->buffer->overlays, ov->interval);
1410}
1392 1411
1393#define OVERLAY_START(OV) XOVERLAY (OV)->start 1412/* Return the start of OV in its buffer, or -1 if OV is not associated
1413 with any buffer. */
1394 1414
1395/* Return the marker that stands for where OV ends in the buffer. */ 1415INLINE ptrdiff_t
1416OVERLAY_START (Lisp_Object ov)
1417{
1418 return overlay_start (XOVERLAY (ov));
1419}
1396 1420
1397#define OVERLAY_END(OV) XOVERLAY (OV)->end 1421/* Return the end of OV in its buffer, or -1. */
1422
1423INLINE ptrdiff_t
1424OVERLAY_END (Lisp_Object ov)
1425{
1426 return overlay_end (XOVERLAY (ov));
1427}
1398 1428
1399/* Return the plist of overlay OV. */ 1429/* Return the plist of overlay OV. */
1400 1430
1401#define OVERLAY_PLIST(OV) XOVERLAY (OV)->plist 1431INLINE Lisp_Object
1432OVERLAY_PLIST (Lisp_Object ov)
1433{
1434 return XOVERLAY (ov)->plist;
1435}
1402 1436
1403/* Return the actual buffer position for the marker P. 1437/* Return the buffer of overlay OV. */
1404 We assume you know which buffer it's pointing into. */
1405 1438
1406INLINE ptrdiff_t 1439INLINE struct buffer *
1407OVERLAY_POSITION (Lisp_Object p) 1440OVERLAY_BUFFER (Lisp_Object ov)
1408{ 1441{
1409 return marker_position (p); 1442 return XOVERLAY (ov)->buffer;
1443}
1444
1445/* Return true, if OV's rear-advance is set. */
1446
1447INLINE bool
1448OVERLAY_REAR_ADVANCE_P (Lisp_Object ov)
1449{
1450 return XOVERLAY (ov)->interval->rear_advance;
1451}
1452
1453/* Return true, if OV's front-advance is set. */
1454
1455INLINE bool
1456OVERLAY_FRONT_ADVANCE_P (Lisp_Object ov)
1457{
1458 return XOVERLAY (ov)->interval->front_advance;
1410} 1459}
1411 1460
1412 1461
@@ -1690,4 +1739,7 @@ dec_both (ptrdiff_t *charpos, ptrdiff_t *bytepos)
1690 1739
1691INLINE_HEADER_END 1740INLINE_HEADER_END
1692 1741
1742int compare_overlays (const void *v1, const void *v2);
1743void make_sortvec_item (struct sortvec *item, Lisp_Object overlay);
1744
1693#endif /* EMACS_BUFFER_H */ 1745#endif /* EMACS_BUFFER_H */