comparison src/editfns.c @ 30244:bfc202f38a22

(char_property_eq, char_property_stickiness): Renamed from `text_property_eq' and `text_property_stickiness', respectively. (find_field, Fconstrain_to_field, char_property_eq, char_property_stickiness): Changed to call char-property functions instead of text-property-only ones.
author Miles Bader <miles@gnu.org>
date Sat, 15 Jul 2000 15:18:35 +0000
parents ec25786e4705
children c084f49c2a7f
comparison
equal deleted inserted replaced
30243:c56062542bae 30244:bfc202f38a22
279 279
280 /* Return nonzero if POS1 and POS2 have the same value 280 /* Return nonzero if POS1 and POS2 have the same value
281 for the text property PROP. */ 281 for the text property PROP. */
282 282
283 static int 283 static int
284 text_property_eq (prop, pos1, pos2) 284 char_property_eq (prop, pos1, pos2)
285 Lisp_Object prop; 285 Lisp_Object prop;
286 Lisp_Object pos1, pos2; 286 Lisp_Object pos1, pos2;
287 { 287 {
288 Lisp_Object pval1, pval2; 288 Lisp_Object pval1, pval2;
289 289
290 pval1 = Fget_text_property (pos1, prop, Qnil); 290 pval1 = Fget_char_property (pos1, prop, Qnil);
291 pval2 = Fget_text_property (pos2, prop, Qnil); 291 pval2 = Fget_char_property (pos2, prop, Qnil);
292 292
293 return EQ (pval1, pval2); 293 return EQ (pval1, pval2);
294 } 294 }
295 295
296 /* Return the direction from which the text-property PROP would be 296 /* Return the direction from which the char-property PROP would be
297 inherited by any new text inserted at POS: 1 if it would be 297 inherited by any new text inserted at POS: 1 if it would be
298 inherited from the char after POS, -1 if it would be inherited from 298 inherited from the char after POS, -1 if it would be inherited from
299 the char before POS, and 0 if from neither. */ 299 the char before POS, and 0 if from neither. */
300 300
301 static int 301 static int
302 text_property_stickiness (prop, pos) 302 char_property_stickiness (prop, pos)
303 Lisp_Object prop; 303 Lisp_Object prop;
304 Lisp_Object pos; 304 Lisp_Object pos;
305 { 305 {
306 Lisp_Object front_sticky; 306 Lisp_Object front_sticky;
307 307
309 /* Consider previous character. */ 309 /* Consider previous character. */
310 { 310 {
311 Lisp_Object prev_pos, rear_non_sticky; 311 Lisp_Object prev_pos, rear_non_sticky;
312 312
313 prev_pos = make_number (XINT (pos) - 1); 313 prev_pos = make_number (XINT (pos) - 1);
314 rear_non_sticky = Fget_text_property (prev_pos, Qrear_nonsticky, Qnil); 314 rear_non_sticky = Fget_char_property (prev_pos, Qrear_nonsticky, Qnil);
315 315
316 if (EQ (rear_non_sticky, Qnil) 316 if (EQ (rear_non_sticky, Qnil)
317 || (CONSP (rear_non_sticky) 317 || (CONSP (rear_non_sticky)
318 && NILP (Fmemq (prop, rear_non_sticky)))) 318 && NILP (Fmemq (prop, rear_non_sticky))))
319 /* PROP is not rear-non-sticky, and since this takes precedence over 319 /* PROP is not rear-non-sticky, and since this takes precedence over
320 any front-stickiness, PROP is inherited from before. */ 320 any front-stickiness, PROP is inherited from before. */
321 return -1; 321 return -1;
322 } 322 }
323 323
324 /* Consider following character. */ 324 /* Consider following character. */
325 front_sticky = Fget_text_property (pos, Qfront_sticky, Qnil); 325 front_sticky = Fget_char_property (pos, Qfront_sticky, Qnil);
326 326
327 if (EQ (front_sticky, Qt) 327 if (EQ (front_sticky, Qt)
328 || (CONSP (front_sticky) 328 || (CONSP (front_sticky)
329 && !NILP (Fmemq (prop, front_sticky)))) 329 && !NILP (Fmemq (prop, front_sticky))))
330 /* PROP is inherited from after. */ 330 /* PROP is inherited from after. */
374 then we avoid treating the beginning of a field specially. */ 374 then we avoid treating the beginning of a field specially. */
375 { 375 {
376 /* First see if POS is actually *at* a boundary. */ 376 /* First see if POS is actually *at* a boundary. */
377 Lisp_Object after_field, before_field; 377 Lisp_Object after_field, before_field;
378 378
379 after_field = Fget_text_property (pos, Qfield, Qnil); 379 after_field = Fget_char_property (pos, Qfield, Qnil);
380 before_field = Fget_text_property (make_number (XINT (pos) - 1), 380 before_field = Fget_char_property (make_number (XINT (pos) - 1),
381 Qfield, Qnil); 381 Qfield, Qnil);
382 382
383 if (! EQ (after_field, before_field)) 383 if (! EQ (after_field, before_field))
384 /* We are at a boundary, see which direction is inclusive. */ 384 /* We are at a boundary, see which direction is inclusive. */
385 { 385 {
386 int stickiness = text_property_stickiness (Qfield, pos); 386 int stickiness = char_property_stickiness (Qfield, pos);
387 387
388 if (stickiness > 0) 388 if (stickiness > 0)
389 at_field_start = 1; 389 at_field_start = 1;
390 else if (stickiness < 0) 390 else if (stickiness < 0)
391 at_field_end = 1; 391 at_field_end = 1;
392 else 392 else
393 /* STICKINESS == 0 means that any inserted text will get a 393 /* STICKINESS == 0 means that any inserted text will get a
394 `field' text-property of nil, so check to see if that 394 `field' char-property of nil, so check to see if that
395 matches either of the adjacent characters (this being a 395 matches either of the adjacent characters (this being a
396 kind of "stickiness by default"). */ 396 kind of "stickiness by default"). */
397 { 397 {
398 if (NILP (before_field)) 398 if (NILP (before_field))
399 at_field_end = 1; /* Sticks to the left. */ 399 at_field_end = 1; /* Sticks to the left. */
411 *beg = XFASTINT (pos); 411 *beg = XFASTINT (pos);
412 else 412 else
413 /* Find the previous field boundary. */ 413 /* Find the previous field boundary. */
414 { 414 {
415 Lisp_Object prev; 415 Lisp_Object prev;
416 prev = Fprevious_single_property_change (pos, Qfield, Qnil, Qnil); 416 prev =
417 Fprevious_single_char_property_change (pos, Qfield, Qnil, Qnil);
417 *beg = NILP (prev) ? BEGV : XFASTINT (prev); 418 *beg = NILP (prev) ? BEGV : XFASTINT (prev);
418 } 419 }
419 } 420 }
420 421
421 if (end) 422 if (end)
426 *end = XFASTINT (pos); 427 *end = XFASTINT (pos);
427 else 428 else
428 /* Find the next field boundary. */ 429 /* Find the next field boundary. */
429 { 430 {
430 Lisp_Object next; 431 Lisp_Object next;
431 next = Fnext_single_property_change (pos, Qfield, Qnil, Qnil); 432 next = Fnext_single_char_property_change (pos, Qfield, Qnil, Qnil);
432 *end = NILP (next) ? ZV : XFASTINT (next); 433 *end = NILP (next) ? ZV : XFASTINT (next);
433 } 434 }
434 } 435 }
435 } 436 }
436 437
507 constrained position if that is is different.\n\ 508 constrained position if that is is different.\n\
508 \n\ 509 \n\
509 If OLD-POS is at the boundary of two fields, then the allowable\n\ 510 If OLD-POS is at the boundary of two fields, then the allowable\n\
510 positions for NEW-POS depends on the value of the optional argument\n\ 511 positions for NEW-POS depends on the value of the optional argument\n\
511 ESCAPE-FROM-EDGE: If ESCAPE-FROM-EDGE is nil, then NEW-POS is\n\ 512 ESCAPE-FROM-EDGE: If ESCAPE-FROM-EDGE is nil, then NEW-POS is\n\
512 constrained to the field that has the same `field' text-property\n\ 513 constrained to the field that has the same `field' char-property\n\
513 as any new characters inserted at OLD-POS, whereas if ESCAPE-FROM-EDGE\n\ 514 as any new characters inserted at OLD-POS, whereas if ESCAPE-FROM-EDGE\n\
514 is non-nil, NEW-POS is constrained to the union of the two adjacent\n\ 515 is non-nil, NEW-POS is constrained to the union of the two adjacent\n\
515 fields.\n\ 516 fields.\n\
516 \n\ 517 \n\
517 If the optional argument ONLY-IN-LINE is non-nil and constraining\n\ 518 If the optional argument ONLY-IN-LINE is non-nil and constraining\n\
534 XSETFASTINT (new_pos, PT); 535 XSETFASTINT (new_pos, PT);
535 } 536 }
536 537
537 if (NILP (Vinhibit_field_text_motion) 538 if (NILP (Vinhibit_field_text_motion)
538 && !EQ (new_pos, old_pos) 539 && !EQ (new_pos, old_pos)
539 && !text_property_eq (Qfield, new_pos, old_pos)) 540 && !char_property_eq (Qfield, new_pos, old_pos))
540 /* NEW_POS is not within the same field as OLD_POS; try to 541 /* NEW_POS is not within the same field as OLD_POS; try to
541 move NEW_POS so that it is. */ 542 move NEW_POS so that it is. */
542 { 543 {
543 int fwd; 544 int fwd;
544 Lisp_Object field_bound; 545 Lisp_Object field_bound;