aboutsummaryrefslogtreecommitdiffstats
path: root/src/editfns.c
diff options
context:
space:
mode:
authorStefan Monnier2022-10-28 17:44:44 -0400
committerStefan Monnier2022-10-28 17:44:44 -0400
commit71589b101ccbec67fa2741856ee0add5752dea72 (patch)
tree63aeb9f5617c3e7e9b87c04f10bfa938f495736c /src/editfns.c
parent69121c33e4a11805bf6438131c8aec72411a0e5d (diff)
parent9d7ba2b1998afc3664c37d9d1b6f6ca2d68356e9 (diff)
downloademacs-71589b101ccbec67fa2741856ee0add5752dea72.tar.gz
emacs-71589b101ccbec67fa2741856ee0add5752dea72.zip
Merge remote-tracking branch 'origin/feature/noverlay'
Diffstat (limited to 'src/editfns.c')
-rw-r--r--src/editfns.c67
1 files changed, 18 insertions, 49 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 3f9618edb08..17dca4708ed 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1,6 +1,6 @@
1/* Lisp functions pertaining to editing. -*- coding: utf-8 -*- 1/* Lisp functions pertaining to editing. -*- coding: utf-8 -*-
2 2
3Copyright (C) 1985-1987, 1989, 1993-2022 Free Software Foundation, Inc. 3Copyright (C) 1985-2022 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -265,51 +265,20 @@ If you set the marker not to point anywhere, the buffer will have no mark. */)
265 265
266/* Find all the overlays in the current buffer that touch position POS. 266/* Find all the overlays in the current buffer that touch position POS.
267 Return the number found, and store them in a vector in VEC 267 Return the number found, and store them in a vector in VEC
268 of length LEN. */ 268 of length LEN.
269
270 Note: this can return overlays that do not touch POS. The caller
271 should filter these out. */
269 272
270static ptrdiff_t 273static ptrdiff_t
271overlays_around (EMACS_INT pos, Lisp_Object *vec, ptrdiff_t len) 274overlays_around (ptrdiff_t pos, Lisp_Object *vec, ptrdiff_t len)
272{ 275{
273 ptrdiff_t idx = 0; 276 /* Find all potentially rear-advance overlays at (POS - 1). Find
274 277 all overlays at POS, so end at (POS + 1). Find even empty
275 for (struct Lisp_Overlay *tail = current_buffer->overlays_before; 278 overlays, which due to the way 'overlays-in' works implies that
276 tail; tail = tail->next) 279 we might also fetch empty overlays starting at (POS + 1). */
277 { 280 return overlays_in (pos - 1, pos + 1, false, &vec, &len,
278 Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); 281 true, false, NULL);
279 Lisp_Object end = OVERLAY_END (overlay);
280 ptrdiff_t endpos = OVERLAY_POSITION (end);
281 if (endpos < pos)
282 break;
283 Lisp_Object start = OVERLAY_START (overlay);
284 ptrdiff_t startpos = OVERLAY_POSITION (start);
285 if (startpos <= pos)
286 {
287 if (idx < len)
288 vec[idx] = overlay;
289 /* Keep counting overlays even if we can't return them all. */
290 idx++;
291 }
292 }
293
294 for (struct Lisp_Overlay *tail = current_buffer->overlays_after;
295 tail; tail = tail->next)
296 {
297 Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike);
298 Lisp_Object start = OVERLAY_START (overlay);
299 ptrdiff_t startpos = OVERLAY_POSITION (start);
300 if (pos < startpos)
301 break;
302 Lisp_Object end = OVERLAY_END (overlay);
303 ptrdiff_t endpos = OVERLAY_POSITION (end);
304 if (pos <= endpos)
305 {
306 if (idx < len)
307 vec[idx] = overlay;
308 idx++;
309 }
310 }
311
312 return idx;
313} 282}
314 283
315DEFUN ("get-pos-property", Fget_pos_property, Sget_pos_property, 2, 3, 0, 284DEFUN ("get-pos-property", Fget_pos_property, Sget_pos_property, 2, 3, 0,
@@ -369,11 +338,12 @@ at POSITION. */)
369 if (!NILP (tem)) 338 if (!NILP (tem))
370 { 339 {
371 /* Check the overlay is indeed active at point. */ 340 /* Check the overlay is indeed active at point. */
372 Lisp_Object start = OVERLAY_START (ol), finish = OVERLAY_END (ol); 341 if ((OVERLAY_START (ol) == posn
373 if ((OVERLAY_POSITION (start) == posn 342 && OVERLAY_FRONT_ADVANCE_P (ol))
374 && XMARKER (start)->insertion_type == 1) 343 || (OVERLAY_END (ol) == posn
375 || (OVERLAY_POSITION (finish) == posn 344 && ! OVERLAY_REAR_ADVANCE_P (ol))
376 && XMARKER (finish)->insertion_type == 0)) 345 || OVERLAY_START (ol) > posn
346 || OVERLAY_END (ol) < posn)
377 ; /* The overlay will not cover a char inserted at point. */ 347 ; /* The overlay will not cover a char inserted at point. */
378 else 348 else
379 { 349 {
@@ -4526,7 +4496,6 @@ ring. */)
4526 transpose_markers (start1, end1, start2, end2, 4496 transpose_markers (start1, end1, start2, end2,
4527 start1_byte, start1_byte + len1_byte, 4497 start1_byte, start1_byte + len1_byte,
4528 start2_byte, start2_byte + len2_byte); 4498 start2_byte, start2_byte + len2_byte);
4529 fix_start_end_in_overlays (start1, end2);
4530 } 4499 }
4531 else 4500 else
4532 { 4501 {