diff options
| author | Richard M. Stallman | 1993-11-20 09:44:27 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-11-20 09:44:27 +0000 |
| commit | 111b637db62231033258dc3aefed6c1418b7f067 (patch) | |
| tree | 45a6cae59d98043d1896bca3e43fba8a283f4436 /src | |
| parent | f75c0f8aae1ab21ee2155fa0b6664212a53f52e3 (diff) | |
| download | emacs-111b637db62231033258dc3aefed6c1418b7f067.tar.gz emacs-111b637db62231033258dc3aefed6c1418b7f067.zip | |
(Ftext_property_not_all): Swap t and nil values in
the case where there are no intervals.
(Fprevious_single_property_change, Fprevious_property_change)
Extra arg LIMIT. Return value was off by 1.
(Fnext_single_property_change, Fnext_property_change):
Extra arg LIMIT.
(Fnext_single_property_change): Require at least 2 args.
Diffstat (limited to 'src')
| -rw-r--r-- | src/textprop.c | 86 |
1 files changed, 55 insertions, 31 deletions
diff --git a/src/textprop.c b/src/textprop.c index f4adb23b31b..a95b9a9af5d 100644 --- a/src/textprop.c +++ b/src/textprop.c | |||
| @@ -520,15 +520,17 @@ If POSITION is at the end of OBJECT, the value is nil.") | |||
| 520 | } | 520 | } |
| 521 | 521 | ||
| 522 | DEFUN ("next-property-change", Fnext_property_change, | 522 | DEFUN ("next-property-change", Fnext_property_change, |
| 523 | Snext_property_change, 1, 2, 0, | 523 | Snext_property_change, 1, 3, 0, |
| 524 | "Return the position of next property change.\n\ | 524 | "Return the position of next property change.\n\ |
| 525 | Scans characters forward from POS in OBJECT till it finds\n\ | 525 | Scans characters forward from POS in OBJECT till it finds\n\ |
| 526 | a change in some text property, then returns the position of the change.\n\ | 526 | a change in some text property, then returns the position of the change.\n\ |
| 527 | The optional second argument OBJECT is the string or buffer to scan.\n\ | 527 | The optional second argument OBJECT is the string or buffer to scan.\n\ |
| 528 | Return nil if the property is constant all the way to the end of OBJECT.\n\ | 528 | Return nil if the property is constant all the way to the end of OBJECT.\n\ |
| 529 | If the value is non-nil, it is a position greater than POS, never equal.") | 529 | If the value is non-nil, it is a position greater than POS, never equal.\n\n\ |
| 530 | (pos, object) | 530 | If the optional third argument LIMIT is non-nil, don't search\n\ |
| 531 | Lisp_Object pos, object; | 531 | past position LIMIT; return LIMIT if nothing is found before LIMIT.") |
| 532 | (pos, object, limit) | ||
| 533 | Lisp_Object pos, object, limit; | ||
| 532 | { | 534 | { |
| 533 | register INTERVAL i, next; | 535 | register INTERVAL i, next; |
| 534 | 536 | ||
| @@ -537,14 +539,17 @@ If the value is non-nil, it is a position greater than POS, never equal.") | |||
| 537 | 539 | ||
| 538 | i = validate_interval_range (object, &pos, &pos, soft); | 540 | i = validate_interval_range (object, &pos, &pos, soft); |
| 539 | if (NULL_INTERVAL_P (i)) | 541 | if (NULL_INTERVAL_P (i)) |
| 540 | return Qnil; | 542 | return limit; |
| 541 | 543 | ||
| 542 | next = next_interval (i); | 544 | next = next_interval (i); |
| 543 | while (! NULL_INTERVAL_P (next) && intervals_equal (i, next)) | 545 | while (! NULL_INTERVAL_P (next) && intervals_equal (i, next) |
| 546 | && (NILP (limit) || next->position < XFASTINT (limit))) | ||
| 544 | next = next_interval (next); | 547 | next = next_interval (next); |
| 545 | 548 | ||
| 546 | if (NULL_INTERVAL_P (next)) | 549 | if (NULL_INTERVAL_P (next)) |
| 547 | return Qnil; | 550 | return limit; |
| 551 | if (! NILP (limit) && !(next->position < XFASTINT (limit))) | ||
| 552 | return limit; | ||
| 548 | 553 | ||
| 549 | return next->position - (XTYPE (object) == Lisp_String); | 554 | return next->position - (XTYPE (object) == Lisp_String); |
| 550 | } | 555 | } |
| @@ -582,16 +587,18 @@ property_change_between_p (beg, end) | |||
| 582 | } | 587 | } |
| 583 | 588 | ||
| 584 | DEFUN ("next-single-property-change", Fnext_single_property_change, | 589 | DEFUN ("next-single-property-change", Fnext_single_property_change, |
| 585 | Snext_single_property_change, 1, 3, 0, | 590 | Snext_single_property_change, 2, 4, 0, |
| 586 | "Return the position of next property change for a specific property.\n\ | 591 | "Return the position of next property change for a specific property.\n\ |
| 587 | Scans characters forward from POS till it finds\n\ | 592 | Scans characters forward from POS till it finds\n\ |
| 588 | a change in the PROP property, then returns the position of the change.\n\ | 593 | a change in the PROP property, then returns the position of the change.\n\ |
| 589 | The optional third argument OBJECT is the string or buffer to scan.\n\ | 594 | The optional third argument OBJECT is the string or buffer to scan.\n\ |
| 590 | The property values are compared with `eq'.\n\ | 595 | The property values are compared with `eq'.\n\ |
| 591 | Return nil if the property is constant all the way to the end of OBJECT.\n\ | 596 | Return nil if the property is constant all the way to the end of OBJECT.\n\ |
| 592 | If the value is non-nil, it is a position greater than POS, never equal.") | 597 | If the value is non-nil, it is a position greater than POS, never equal.\n\n\ |
| 593 | (pos, prop, object) | 598 | If the optional fourth argument LIMIT is non-nil, don't search\n\ |
| 594 | Lisp_Object pos, prop, object; | 599 | past position LIMIT; fail if nothing is found before LIMIT.") |
| 600 | (pos, prop, object, limit) | ||
| 601 | Lisp_Object pos, prop, object, limit; | ||
| 595 | { | 602 | { |
| 596 | register INTERVAL i, next; | 603 | register INTERVAL i, next; |
| 597 | register Lisp_Object here_val; | 604 | register Lisp_Object here_val; |
| @@ -601,30 +608,35 @@ If the value is non-nil, it is a position greater than POS, never equal.") | |||
| 601 | 608 | ||
| 602 | i = validate_interval_range (object, &pos, &pos, soft); | 609 | i = validate_interval_range (object, &pos, &pos, soft); |
| 603 | if (NULL_INTERVAL_P (i)) | 610 | if (NULL_INTERVAL_P (i)) |
| 604 | return Qnil; | 611 | return limit; |
| 605 | 612 | ||
| 606 | here_val = textget (i->plist, prop); | 613 | here_val = textget (i->plist, prop); |
| 607 | next = next_interval (i); | 614 | next = next_interval (i); |
| 608 | while (! NULL_INTERVAL_P (next) | 615 | while (! NULL_INTERVAL_P (next) |
| 609 | && EQ (here_val, textget (next->plist, prop))) | 616 | && EQ (here_val, textget (next->plist, prop)) |
| 617 | && (NILP (limit) || next->position < XFASTINT (limit))) | ||
| 610 | next = next_interval (next); | 618 | next = next_interval (next); |
| 611 | 619 | ||
| 612 | if (NULL_INTERVAL_P (next)) | 620 | if (NULL_INTERVAL_P (next)) |
| 613 | return Qnil; | 621 | return limit; |
| 622 | if (! NILP (limit) && !(next->position < XFASTINT (limit))) | ||
| 623 | return limit; | ||
| 614 | 624 | ||
| 615 | return next->position - (XTYPE (object) == Lisp_String); | 625 | return next->position - (XTYPE (object) == Lisp_String); |
| 616 | } | 626 | } |
| 617 | 627 | ||
| 618 | DEFUN ("previous-property-change", Fprevious_property_change, | 628 | DEFUN ("previous-property-change", Fprevious_property_change, |
| 619 | Sprevious_property_change, 1, 2, 0, | 629 | Sprevious_property_change, 1, 3, 0, |
| 620 | "Return the position of previous property change.\n\ | 630 | "Return the position of previous property change.\n\ |
| 621 | Scans characters backwards from POS in OBJECT till it finds\n\ | 631 | Scans characters backwards from POS in OBJECT till it finds\n\ |
| 622 | a change in some text property, then returns the position of the change.\n\ | 632 | a change in some text property, then returns the position of the change.\n\ |
| 623 | The optional second argument OBJECT is the string or buffer to scan.\n\ | 633 | The optional second argument OBJECT is the string or buffer to scan.\n\ |
| 624 | Return nil if the property is constant all the way to the start of OBJECT.\n\ | 634 | Return nil if the property is constant all the way to the start of OBJECT.\n\ |
| 625 | If the value is non-nil, it is a position less than POS, never equal.") | 635 | If the value is non-nil, it is a position less than POS, never equal.\n\n\ |
| 626 | (pos, object) | 636 | If the optional third argument LIMIT is non-nil, don't search\n\ |
| 627 | Lisp_Object pos, object; | 637 | back past position LIMIT; fail if nothing is found before LIMIT.") |
| 638 | (pos, object, limit) | ||
| 639 | Lisp_Object pos, object, limit; | ||
| 628 | { | 640 | { |
| 629 | register INTERVAL i, previous; | 641 | register INTERVAL i, previous; |
| 630 | 642 | ||
| @@ -633,29 +645,36 @@ If the value is non-nil, it is a position less than POS, never equal.") | |||
| 633 | 645 | ||
| 634 | i = validate_interval_range (object, &pos, &pos, soft); | 646 | i = validate_interval_range (object, &pos, &pos, soft); |
| 635 | if (NULL_INTERVAL_P (i)) | 647 | if (NULL_INTERVAL_P (i)) |
| 636 | return Qnil; | 648 | return limit; |
| 637 | 649 | ||
| 638 | previous = previous_interval (i); | 650 | previous = previous_interval (i); |
| 639 | while (! NULL_INTERVAL_P (previous) && intervals_equal (previous, i)) | 651 | while (! NULL_INTERVAL_P (previous) && intervals_equal (previous, i) |
| 652 | && (NILP (limit) | ||
| 653 | || previous->position + LENGTH (previous) > XFASTINT (limit))) | ||
| 640 | previous = previous_interval (previous); | 654 | previous = previous_interval (previous); |
| 641 | if (NULL_INTERVAL_P (previous)) | 655 | if (NULL_INTERVAL_P (previous)) |
| 642 | return Qnil; | 656 | return limit; |
| 657 | if (!NILP (limit) | ||
| 658 | && !(previous->position + LENGTH (previous) > XFASTINT (limit))) | ||
| 659 | return limit; | ||
| 643 | 660 | ||
| 644 | return (previous->position + LENGTH (previous) - 1 | 661 | return (previous->position + LENGTH (previous) |
| 645 | - (XTYPE (object) == Lisp_String)); | 662 | - (XTYPE (object) == Lisp_String)); |
| 646 | } | 663 | } |
| 647 | 664 | ||
| 648 | DEFUN ("previous-single-property-change", Fprevious_single_property_change, | 665 | DEFUN ("previous-single-property-change", Fprevious_single_property_change, |
| 649 | Sprevious_single_property_change, 2, 3, 0, | 666 | Sprevious_single_property_change, 2, 4, 0, |
| 650 | "Return the position of previous property change for a specific property.\n\ | 667 | "Return the position of previous property change for a specific property.\n\ |
| 651 | Scans characters backward from POS till it finds\n\ | 668 | Scans characters backward from POS till it finds\n\ |
| 652 | a change in the PROP property, then returns the position of the change.\n\ | 669 | a change in the PROP property, then returns the position of the change.\n\ |
| 653 | The optional third argument OBJECT is the string or buffer to scan.\n\ | 670 | The optional third argument OBJECT is the string or buffer to scan.\n\ |
| 654 | The property values are compared with `eq'.\n\ | 671 | The property values are compared with `eq'.\n\ |
| 655 | Return nil if the property is constant all the way to the start of OBJECT.\n\ | 672 | Return nil if the property is constant all the way to the start of OBJECT.\n\ |
| 656 | If the value is non-nil, it is a position less than POS, never equal.") | 673 | If the value is non-nil, it is a position less than POS, never equal.\n\n\ |
| 657 | (pos, prop, object) | 674 | If the optional fourth argument LIMIT is non-nil, don't search\n\ |
| 658 | Lisp_Object pos, prop, object; | 675 | back past position LIMIT; fail if nothing is found before LIMIT.") |
| 676 | (pos, prop, object, limit) | ||
| 677 | Lisp_Object pos, prop, object, limit; | ||
| 659 | { | 678 | { |
| 660 | register INTERVAL i, previous; | 679 | register INTERVAL i, previous; |
| 661 | register Lisp_Object here_val; | 680 | register Lisp_Object here_val; |
| @@ -665,17 +684,22 @@ If the value is non-nil, it is a position less than POS, never equal.") | |||
| 665 | 684 | ||
| 666 | i = validate_interval_range (object, &pos, &pos, soft); | 685 | i = validate_interval_range (object, &pos, &pos, soft); |
| 667 | if (NULL_INTERVAL_P (i)) | 686 | if (NULL_INTERVAL_P (i)) |
| 668 | return Qnil; | 687 | return limit; |
| 669 | 688 | ||
| 670 | here_val = textget (i->plist, prop); | 689 | here_val = textget (i->plist, prop); |
| 671 | previous = previous_interval (i); | 690 | previous = previous_interval (i); |
| 672 | while (! NULL_INTERVAL_P (previous) | 691 | while (! NULL_INTERVAL_P (previous) |
| 673 | && EQ (here_val, textget (previous->plist, prop))) | 692 | && EQ (here_val, textget (previous->plist, prop)) |
| 693 | && (NILP (limit) | ||
| 694 | || previous->position + LENGTH (previous) > XFASTINT (limit))) | ||
| 674 | previous = previous_interval (previous); | 695 | previous = previous_interval (previous); |
| 675 | if (NULL_INTERVAL_P (previous)) | 696 | if (NULL_INTERVAL_P (previous)) |
| 676 | return Qnil; | 697 | return limit; |
| 698 | if (!NILP (limit) | ||
| 699 | && !(previous->position + LENGTH (previous) > XFASTINT (limit))) | ||
| 700 | return limit; | ||
| 677 | 701 | ||
| 678 | return (previous->position + LENGTH (previous) - 1 | 702 | return (previous->position + LENGTH (previous) |
| 679 | - (XTYPE (object) == Lisp_String)); | 703 | - (XTYPE (object) == Lisp_String)); |
| 680 | } | 704 | } |
| 681 | 705 | ||
| @@ -986,7 +1010,7 @@ containing the text.") | |||
| 986 | XSET (object, Lisp_Buffer, current_buffer); | 1010 | XSET (object, Lisp_Buffer, current_buffer); |
| 987 | i = validate_interval_range (object, &start, &end, soft); | 1011 | i = validate_interval_range (object, &start, &end, soft); |
| 988 | if (NULL_INTERVAL_P (i)) | 1012 | if (NULL_INTERVAL_P (i)) |
| 989 | return (NILP (value) || EQ (start, end)) ? Qt : Qnil; | 1013 | return (NILP (value) || EQ (start, end)) ? Qnil : Qt; |
| 990 | s = XINT (start); | 1014 | s = XINT (start); |
| 991 | e = XINT (end); | 1015 | e = XINT (end); |
| 992 | 1016 | ||