aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2001-10-19 07:45:58 +0000
committerMiles Bader2001-10-19 07:45:58 +0000
commitf8d397ee6b6f9cfa52ba43078b023921d78effa6 (patch)
treec2117251b48c81fb0c68c85c8a80c736b1b3c72f /src
parentb57c2708f0ab0155f7e27cae9d3a42408a947052 (diff)
downloademacs-f8d397ee6b6f9cfa52ba43078b023921d78effa6.tar.gz
emacs-f8d397ee6b6f9cfa52ba43078b023921d78effa6.zip
(text_property_stickiness): Really fix it this time.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/editfns.c b/src/editfns.c
index d0b682ff67e..5161308e6fd 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -352,28 +352,22 @@ text_property_stickiness (prop, pos)
352 Lisp_Object prop; 352 Lisp_Object prop;
353 Lisp_Object pos; 353 Lisp_Object pos;
354{ 354{
355 Lisp_Object front_sticky; 355 Lisp_Object prev_pos, front_sticky;
356 int is_rear_sticky = 1, is_front_sticky = 0; /* defaults */
356 357
357 if (XINT (pos) > BEGV) 358 if (XINT (pos) > BEGV)
358 /* Consider previous character. */ 359 /* Consider previous character. */
359 { 360 {
360 Lisp_Object prev_pos = make_number (XINT (pos) - 1); 361 Lisp_Object rear_non_sticky;
361 362
362 if (! NILP (Fget_text_property (prev_pos, prop, Qnil))) 363 prev_pos = make_number (XINT (pos) - 1);
363 /* Non-rear-non-stickiness only takes precedence if the 364 rear_non_sticky = Fget_text_property (prev_pos, Qrear_nonsticky, Qnil);
364 preceding property value is non-nil. */ 365
365 { 366 if (CONSP (rear_non_sticky)
366 Lisp_Object rear_non_sticky 367 ? Fmemq (prop, rear_non_sticky)
367 = Fget_text_property (prev_pos, Qrear_nonsticky, Qnil); 368 : !NILP (rear_non_sticky))
368 369 /* PROP is rear-non-sticky. */
369 if (EQ (rear_non_sticky, Qnil) 370 is_rear_sticky = 0;
370 || (CONSP (rear_non_sticky)
371 && NILP (Fmemq (prop, rear_non_sticky))))
372 /* PROP is not rear-non-sticky, and since this takes
373 precedence over any front-stickiness, PROP is inherited
374 from before. */
375 return -1;
376 }
377 } 371 }
378 372
379 /* Consider following character. */ 373 /* Consider following character. */
@@ -383,10 +377,24 @@ text_property_stickiness (prop, pos)
383 || (CONSP (front_sticky) 377 || (CONSP (front_sticky)
384 && !NILP (Fmemq (prop, front_sticky)))) 378 && !NILP (Fmemq (prop, front_sticky))))
385 /* PROP is inherited from after. */ 379 /* PROP is inherited from after. */
386 return 1; 380 is_front_sticky = 1;
387 381
388 /* PROP is not inherited from either side. */ 382 /* Simple cases, where the properties are consistent. */
389 return 0; 383 if (is_rear_sticky && !is_front_sticky)
384 return -1;
385 else if (!is_rear_sticky && is_front_sticky)
386 return 1;
387 else if (!is_rear_sticky && !is_front_sticky)
388 return 0;
389
390 /* The stickiness properties are inconsistent, so we have to
391 disambiguate. Basically, rear-sticky wins, _except_ if the
392 property that would be inherited has a value of nil, in which case
393 front-sticky wins. */
394 if (XINT (pos) == BEGV || NILP (Fget_text_property (prev_pos, prop, Qnil)))
395 return 1;
396 else
397 return -1;
390} 398}
391 399
392 400