aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2001-11-15 08:05:45 +0000
committerMiles Bader2001-11-15 08:05:45 +0000
commit9ac741c5e8ff590e468046aadcc60d0c24bc9062 (patch)
treed05e11c3b7d751b88ec031767c84b266b472f039 /src
parente29f823e0d54b05ee30b66b286589e4b465b3ac4 (diff)
downloademacs-9ac741c5e8ff590e468046aadcc60d0c24bc9062.tar.gz
emacs-9ac741c5e8ff590e468046aadcc60d0c24bc9062.zip
(find_field): Add BEG_LIMIT and END_LIMIT parameters.
(Fdelete_field, Ffield_string, Ffield_string_no_properties): Update arguments to find_field. (Ffield_beginning, Ffield_end): Add LIMIT param, pass to find_field. (Fconstrain_to_field): Use LIMIT arg to shorten search time.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/src/editfns.c b/src/editfns.c
index abecfa94466..f8edbadc05a 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -64,7 +64,7 @@ extern Lisp_Object make_time P_ ((time_t));
64extern size_t emacs_strftimeu P_ ((char *, size_t, const char *, 64extern size_t emacs_strftimeu P_ ((char *, size_t, const char *,
65 const struct tm *, int)); 65 const struct tm *, int));
66static int tm_diff P_ ((struct tm *, struct tm *)); 66static int tm_diff P_ ((struct tm *, struct tm *));
67static void find_field P_ ((Lisp_Object, Lisp_Object, int *, int *)); 67static void find_field P_ ((Lisp_Object, Lisp_Object, Lisp_Object, int *, Lisp_Object, int *));
68static void update_buffer_properties P_ ((int, int)); 68static void update_buffer_properties P_ ((int, int));
69static Lisp_Object region_limit P_ ((int)); 69static Lisp_Object region_limit P_ ((int));
70static int lisp_time_argument P_ ((Lisp_Object, time_t *, int *)); 70static int lisp_time_argument P_ ((Lisp_Object, time_t *, int *));
@@ -404,6 +404,9 @@ text_property_stickiness (prop, pos)
404 the value of point is used instead. If BEG or END null, 404 the value of point is used instead. If BEG or END null,
405 means don't store the beginning or end of the field. 405 means don't store the beginning or end of the field.
406 406
407 BEG_LIMIT and END_LIMIT serve to limit the ranged of the returned
408 results; they do not effect boundary behavior.
409
407 If MERGE_AT_BOUNDARY is nonzero, then if POS is at the very first 410 If MERGE_AT_BOUNDARY is nonzero, then if POS is at the very first
408 position of a field, then the beginning of the previous field is 411 position of a field, then the beginning of the previous field is
409 returned instead of the beginning of POS's field (since the end of a 412 returned instead of the beginning of POS's field (since the end of a
@@ -418,9 +421,10 @@ text_property_stickiness (prop, pos)
418 is not stored. */ 421 is not stored. */
419 422
420static void 423static void
421find_field (pos, merge_at_boundary, beg, end) 424find_field (pos, merge_at_boundary, beg_limit, beg, end_limit, end)
422 Lisp_Object pos; 425 Lisp_Object pos;
423 Lisp_Object merge_at_boundary; 426 Lisp_Object merge_at_boundary;
427 Lisp_Object beg_limit, end_limit;
424 int *beg, *end; 428 int *beg, *end;
425{ 429{
426 /* Fields right before and after the point. */ 430 /* Fields right before and after the point. */
@@ -544,9 +548,11 @@ find_field (pos, merge_at_boundary, beg, end)
544 { 548 {
545 if (!NILP (merge_at_boundary) && EQ (before_field, Qboundary)) 549 if (!NILP (merge_at_boundary) && EQ (before_field, Qboundary))
546 /* Skip a `boundary' field. */ 550 /* Skip a `boundary' field. */
547 pos = Fprevious_single_char_property_change (pos, Qfield, Qnil,Qnil); 551 pos = Fprevious_single_char_property_change (pos, Qfield, Qnil,
552 beg_limit);
548 553
549 pos = Fprevious_single_char_property_change (pos, Qfield, Qnil, Qnil); 554 pos = Fprevious_single_char_property_change (pos, Qfield, Qnil,
555 beg_limit);
550 *beg = NILP (pos) ? BEGV : XFASTINT (pos); 556 *beg = NILP (pos) ? BEGV : XFASTINT (pos);
551 } 557 }
552 } 558 }
@@ -562,9 +568,11 @@ find_field (pos, merge_at_boundary, beg, end)
562 { 568 {
563 if (!NILP (merge_at_boundary) && EQ (after_field, Qboundary)) 569 if (!NILP (merge_at_boundary) && EQ (after_field, Qboundary))
564 /* Skip a `boundary' field. */ 570 /* Skip a `boundary' field. */
565 pos = Fnext_single_char_property_change (pos, Qfield, Qnil, Qnil); 571 pos = Fnext_single_char_property_change (pos, Qfield, Qnil,
572 end_limit);
566 573
567 pos = Fnext_single_char_property_change (pos, Qfield, Qnil, Qnil); 574 pos = Fnext_single_char_property_change (pos, Qfield, Qnil,
575 end_limit);
568 *end = NILP (pos) ? ZV : XFASTINT (pos); 576 *end = NILP (pos) ? ZV : XFASTINT (pos);
569 } 577 }
570 } 578 }
@@ -579,7 +587,7 @@ If POS is nil, the value of point is used for POS. */)
579 Lisp_Object pos; 587 Lisp_Object pos;
580{ 588{
581 int beg, end; 589 int beg, end;
582 find_field (pos, Qnil, &beg, &end); 590 find_field (pos, Qnil, Qnil, &beg, Qnil, &end);
583 if (beg != end) 591 if (beg != end)
584 del_range (beg, end); 592 del_range (beg, end);
585 return Qnil; 593 return Qnil;
@@ -593,7 +601,7 @@ If POS is nil, the value of point is used for POS. */)
593 Lisp_Object pos; 601 Lisp_Object pos;
594{ 602{
595 int beg, end; 603 int beg, end;
596 find_field (pos, Qnil, &beg, &end); 604 find_field (pos, Qnil, Qnil, &beg, Qnil, &end);
597 return make_buffer_string (beg, end, 1); 605 return make_buffer_string (beg, end, 1);
598} 606}
599 607
@@ -605,35 +613,39 @@ If POS is nil, the value of point is used for POS. */)
605 Lisp_Object pos; 613 Lisp_Object pos;
606{ 614{
607 int beg, end; 615 int beg, end;
608 find_field (pos, Qnil, &beg, &end); 616 find_field (pos, Qnil, Qnil, &beg, Qnil, &end);
609 return make_buffer_string (beg, end, 0); 617 return make_buffer_string (beg, end, 0);
610} 618}
611 619
612DEFUN ("field-beginning", Ffield_beginning, Sfield_beginning, 0, 2, 0, 620DEFUN ("field-beginning", Ffield_beginning, Sfield_beginning, 0, 3, 0,
613 doc: /* Return the beginning of the field surrounding POS. 621 doc: /* Return the beginning of the field surrounding POS.
614A field is a region of text with the same `field' property. 622A field is a region of text with the same `field' property.
615If POS is nil, the value of point is used for POS. 623If POS is nil, the value of point is used for POS.
616If ESCAPE-FROM-EDGE is non-nil and POS is at the beginning of its 624If ESCAPE-FROM-EDGE is non-nil and POS is at the beginning of its
617field, then the beginning of the *previous* field is returned. */) 625field, then the beginning of the *previous* field is returned.
618 (pos, escape_from_edge) 626If LIMIT is non-nil, it is a buffer position; if the beginning of the field
619 Lisp_Object pos, escape_from_edge; 627is before LIMIT, then LIMIT will be returned instead. */)
628 (pos, escape_from_edge, limit)
629 Lisp_Object pos, escape_from_edge, limit;
620{ 630{
621 int beg; 631 int beg;
622 find_field (pos, escape_from_edge, &beg, 0); 632 find_field (pos, escape_from_edge, limit, &beg, Qnil, 0);
623 return make_number (beg); 633 return make_number (beg);
624} 634}
625 635
626DEFUN ("field-end", Ffield_end, Sfield_end, 0, 2, 0, 636DEFUN ("field-end", Ffield_end, Sfield_end, 0, 3, 0,
627 doc: /* Return the end of the field surrounding POS. 637 doc: /* Return the end of the field surrounding POS.
628A field is a region of text with the same `field' property. 638A field is a region of text with the same `field' property.
629If POS is nil, the value of point is used for POS. 639If POS is nil, the value of point is used for POS.
630If ESCAPE-FROM-EDGE is non-nil and POS is at the end of its field, 640If ESCAPE-FROM-EDGE is non-nil and POS is at the end of its field,
631then the end of the *following* field is returned. */) 641then the end of the *following* field is returned.
632 (pos, escape_from_edge) 642If LIMIT is non-nil, it is a buffer position; if the end of the field
633 Lisp_Object pos, escape_from_edge; 643is after LIMIT, then LIMIT will be returned instead. */)
644 (pos, escape_from_edge, limit)
645 Lisp_Object pos, escape_from_edge, limit;
634{ 646{
635 int end; 647 int end;
636 find_field (pos, escape_from_edge, 0, &end); 648 find_field (pos, escape_from_edge, Qnil, 0, limit, &end);
637 return make_number (end); 649 return make_number (end);
638} 650}
639 651
@@ -696,9 +708,9 @@ Field boundaries are not noticed if `inhibit-field-text-motion' is non-nil. */)
696 fwd = (XFASTINT (new_pos) > XFASTINT (old_pos)); 708 fwd = (XFASTINT (new_pos) > XFASTINT (old_pos));
697 709
698 if (fwd) 710 if (fwd)
699 field_bound = Ffield_end (old_pos, escape_from_edge); 711 field_bound = Ffield_end (old_pos, escape_from_edge, new_pos);
700 else 712 else
701 field_bound = Ffield_beginning (old_pos, escape_from_edge); 713 field_bound = Ffield_beginning (old_pos, escape_from_edge, new_pos);
702 714
703 if (/* See if ESCAPE_FROM_EDGE caused FIELD_BOUND to jump to the 715 if (/* See if ESCAPE_FROM_EDGE caused FIELD_BOUND to jump to the
704 other side of NEW_POS, which would mean that NEW_POS is 716 other side of NEW_POS, which would mean that NEW_POS is