aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2000-10-25 05:18:10 +0000
committerMiles Bader2000-10-25 05:18:10 +0000
commit7ae1c032031cde96d276c7f3b785e5ce5d0fb6fb (patch)
treee6b0d9ed3f59762c2dbd40183a94a97b25a9601b /src
parent8d41abc445741cb74d059e78f56f999f5215c4e1 (diff)
downloademacs-7ae1c032031cde96d276c7f3b785e5ce5d0fb6fb.tar.gz
emacs-7ae1c032031cde96d276c7f3b785e5ce5d0fb6fb.zip
(find_field):
Set the field stickiness correctly from overlay fields. Use renamed `text_property_stickiness'. (text_property_stickiness): Renamed from `char_property_stickiness'.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/editfns.c53
2 files changed, 55 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index cc5cfd86b1c..4255dfc59e0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12000-10-25 Miles Bader <miles@lsi.nec.co.jp>
2
3 * editfns.c (find_field): Set the field stickiness correctly from
4 overlay fields. Use renamed `text_property_stickiness'.
5 (text_property_stickiness): Renamed from `char_property_stickiness'.
6 * textprop.c (get_char_property_and_overlay): New function.
7 (Fget_char_property): Use it.
8 * intervals.h (get_char_property_and_overlay): Add declaration.
9
12000-10-25 Stefan Monnier <monnier@cs.yale.edu> 102000-10-25 Stefan Monnier <monnier@cs.yale.edu>
2 11
3 * keymap.c: Use AREF, ASET and ASIZE macros. 12 * keymap.c: Use AREF, ASET and ASIZE macros.
diff --git a/src/editfns.c b/src/editfns.c
index 57dbdaae0cc..dcc64455b3c 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -330,13 +330,13 @@ char_property_eq (prop, pos1, pos2)
330 return EQ (pval1, pval2); 330 return EQ (pval1, pval2);
331} 331}
332 332
333/* Return the direction from which the char-property PROP would be 333/* Return the direction from which the text-property PROP would be
334 inherited by any new text inserted at POS: 1 if it would be 334 inherited by any new text inserted at POS: 1 if it would be
335 inherited from the char after POS, -1 if it would be inherited from 335 inherited from the char after POS, -1 if it would be inherited from
336 the char before POS, and 0 if from neither. */ 336 the char before POS, and 0 if from neither. */
337 337
338static int 338static int
339char_property_stickiness (prop, pos) 339text_property_stickiness (prop, pos)
340 Lisp_Object prop; 340 Lisp_Object prop;
341 Lisp_Object pos; 341 Lisp_Object pos;
342{ 342{
@@ -348,7 +348,7 @@ char_property_stickiness (prop, pos)
348 Lisp_Object prev_pos, rear_non_sticky; 348 Lisp_Object prev_pos, rear_non_sticky;
349 349
350 prev_pos = make_number (XINT (pos) - 1); 350 prev_pos = make_number (XINT (pos) - 1);
351 rear_non_sticky = Fget_char_property (prev_pos, Qrear_nonsticky, Qnil); 351 rear_non_sticky = Fget_text_property (prev_pos, Qrear_nonsticky, Qnil);
352 352
353 if (EQ (rear_non_sticky, Qnil) 353 if (EQ (rear_non_sticky, Qnil)
354 || (CONSP (rear_non_sticky) 354 || (CONSP (rear_non_sticky)
@@ -359,7 +359,7 @@ char_property_stickiness (prop, pos)
359 } 359 }
360 360
361 /* Consider following character. */ 361 /* Consider following character. */
362 front_sticky = Fget_char_property (pos, Qfront_sticky, Qnil); 362 front_sticky = Fget_text_property (pos, Qfront_sticky, Qnil);
363 363
364 if (EQ (front_sticky, Qt) 364 if (EQ (front_sticky, Qt)
365 || (CONSP (front_sticky) 365 || (CONSP (front_sticky)
@@ -397,6 +397,9 @@ find_field (pos, merge_at_boundary, beg, end)
397{ 397{
398 /* Fields right before and after the point. */ 398 /* Fields right before and after the point. */
399 Lisp_Object before_field, after_field; 399 Lisp_Object before_field, after_field;
400 /* If the fields came from overlays, the associated overlays.
401 Qnil means they came from text-properties. */
402 Lisp_Object before_overlay = Qnil, after_overlay = Qnil;
400 /* 1 if POS counts as the start of a field. */ 403 /* 1 if POS counts as the start of a field. */
401 int at_field_start = 0; 404 int at_field_start = 0;
402 /* 1 if POS counts as the end of a field. */ 405 /* 1 if POS counts as the end of a field. */
@@ -408,10 +411,12 @@ find_field (pos, merge_at_boundary, beg, end)
408 CHECK_NUMBER_COERCE_MARKER (pos, 0); 411 CHECK_NUMBER_COERCE_MARKER (pos, 0);
409 412
410 after_field 413 after_field
411 = Fget_char_property (pos, Qfield, Qnil); 414 = get_char_property_and_overlay (pos, Qfield, Qnil, &after_overlay);
412 before_field 415 before_field
413 = (XFASTINT (pos) > BEGV 416 = (XFASTINT (pos) > BEGV
414 ? Fget_char_property (make_number (XINT (pos) - 1), Qfield, Qnil) 417 ? get_char_property_and_overlay (make_number (XINT (pos) - 1),
418 Qfield, Qnil,
419 &before_overlay)
415 : Qnil); 420 : Qnil);
416 421
417 /* See if we need to handle the case where MERGE_AT_BOUNDARY is nil 422 /* See if we need to handle the case where MERGE_AT_BOUNDARY is nil
@@ -424,7 +429,41 @@ find_field (pos, merge_at_boundary, beg, end)
424 /* We are at a boundary, see which direction is inclusive. We 429 /* We are at a boundary, see which direction is inclusive. We
425 decide by seeing which field the `field' property sticks to. */ 430 decide by seeing which field the `field' property sticks to. */
426 { 431 {
427 int stickiness = char_property_stickiness (Qfield, pos); 432 /* -1 means insertions go into before_field, 1 means they go
433 into after_field, 0 means neither. */
434 int stickiness;
435 /* Whether the before/after_field come from overlays. */
436 int bop = !NILP (before_overlay);
437 int aop = !NILP (after_overlay);
438
439 if (bop && XMARKER (OVERLAY_END (before_overlay))->insertion_type == 1)
440 /* before_field is from an overlay, which expands upon
441 end-insertions. Note that it's possible for after_overlay to
442 also eat insertions here, but then they will overlap, and
443 there's not much we can do. */
444 stickiness = -1;
445 else if (aop && XMARKER(OVERLAY_END(after_overlay))->insertion_type == 0)
446 /* after_field is from an overlay, which expand to contain
447 start-insertions. */
448 stickiness = 1;
449 else if (bop && aop)
450 /* Both fields come from overlays, but neither will contain any
451 insertion here. */
452 stickiness = 0;
453 else if (bop)
454 /* before_field is an overlay that won't eat any insertion, but
455 after_field is from a text-property. Assume that the
456 text-property continues underneath the overlay, and so will
457 be inherited by any insertion, regardless of any stickiness
458 settings. */
459 stickiness = 1;
460 else if (aop)
461 /* Similarly, when after_field is the overlay. */
462 stickiness = -1;
463 else
464 /* Both fields come from text-properties. Look for explicit
465 stickiness properties. */
466 stickiness = text_property_stickiness (Qfield, pos);
428 467
429 if (stickiness > 0) 468 if (stickiness > 0)
430 at_field_start = 1; 469 at_field_start = 1;