aboutsummaryrefslogtreecommitdiffstats
path: root/src/editfns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/editfns.c')
-rw-r--r--src/editfns.c67
1 files changed, 30 insertions, 37 deletions
diff --git a/src/editfns.c b/src/editfns.c
index aea044db068..c43528c4863 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -629,10 +629,7 @@ find_field (pos, merge_at_boundary, beg_limit, beg, end_limit, end)
629DEFUN ("delete-field", Fdelete_field, Sdelete_field, 0, 1, 0, 629DEFUN ("delete-field", Fdelete_field, Sdelete_field, 0, 1, 0,
630 doc: /* Delete the field surrounding POS. 630 doc: /* Delete the field surrounding POS.
631A field is a region of text with the same `field' property. 631A field is a region of text with the same `field' property.
632If POS is nil, the value of point is used for POS. 632If POS is nil, the value of point is used for POS. */)
633
634An `args-out-of-range' error is signaled if POS is outside the
635buffer's accessible portion. */)
636 (pos) 633 (pos)
637 Lisp_Object pos; 634 Lisp_Object pos;
638{ 635{
@@ -646,10 +643,7 @@ buffer's accessible portion. */)
646DEFUN ("field-string", Ffield_string, Sfield_string, 0, 1, 0, 643DEFUN ("field-string", Ffield_string, Sfield_string, 0, 1, 0,
647 doc: /* Return the contents of the field surrounding POS as a string. 644 doc: /* Return the contents of the field surrounding POS as a string.
648A field is a region of text with the same `field' property. 645A field is a region of text with the same `field' property.
649If POS is nil, the value of point is used for POS. 646If POS is nil, the value of point is used for POS. */)
650
651An `args-out-of-range' error is signaled if POS is outside the
652buffer's accessible portion. */)
653 (pos) 647 (pos)
654 Lisp_Object pos; 648 Lisp_Object pos;
655{ 649{
@@ -661,10 +655,7 @@ buffer's accessible portion. */)
661DEFUN ("field-string-no-properties", Ffield_string_no_properties, Sfield_string_no_properties, 0, 1, 0, 655DEFUN ("field-string-no-properties", Ffield_string_no_properties, Sfield_string_no_properties, 0, 1, 0,
662 doc: /* Return the contents of the field around POS, without text-properties. 656 doc: /* Return the contents of the field around POS, without text-properties.
663A field is a region of text with the same `field' property. 657A field is a region of text with the same `field' property.
664If POS is nil, the value of point is used for POS. 658If POS is nil, the value of point is used for POS. */)
665
666An `args-out-of-range' error is signaled if POS is outside the
667buffer's accessible portion. */)
668 (pos) 659 (pos)
669 Lisp_Object pos; 660 Lisp_Object pos;
670{ 661{
@@ -680,10 +671,7 @@ If POS is nil, the value of point is used for POS.
680If ESCAPE-FROM-EDGE is non-nil and POS is at the beginning of its 671If ESCAPE-FROM-EDGE is non-nil and POS is at the beginning of its
681field, then the beginning of the *previous* field is returned. 672field, then the beginning of the *previous* field is returned.
682If LIMIT is non-nil, it is a buffer position; if the beginning of the field 673If LIMIT is non-nil, it is a buffer position; if the beginning of the field
683is before LIMIT, then LIMIT will be returned instead. 674is before LIMIT, then LIMIT will be returned instead. */)
684
685An `args-out-of-range' error is signaled if POS is outside the
686buffer's accessible portion. */)
687 (pos, escape_from_edge, limit) 675 (pos, escape_from_edge, limit)
688 Lisp_Object pos, escape_from_edge, limit; 676 Lisp_Object pos, escape_from_edge, limit;
689{ 677{
@@ -699,10 +687,7 @@ If POS is nil, the value of point is used for POS.
699If ESCAPE-FROM-EDGE is non-nil and POS is at the end of its field, 687If ESCAPE-FROM-EDGE is non-nil and POS is at the end of its field,
700then the end of the *following* field is returned. 688then the end of the *following* field is returned.
701If LIMIT is non-nil, it is a buffer position; if the end of the field 689If LIMIT is non-nil, it is a buffer position; if the end of the field
702is after LIMIT, then LIMIT will be returned instead. 690is after LIMIT, then LIMIT will be returned instead. */)
703
704An `args-out-of-range' error is signaled if POS is outside the
705buffer's accessible portion. */)
706 (pos, escape_from_edge, limit) 691 (pos, escape_from_edge, limit)
707 Lisp_Object pos, escape_from_edge, limit; 692 Lisp_Object pos, escape_from_edge, limit;
708{ 693{
@@ -1450,14 +1435,11 @@ resolution finer than a second. */)
1450 () 1435 ()
1451{ 1436{
1452 EMACS_TIME t; 1437 EMACS_TIME t;
1453 Lisp_Object result[3];
1454 1438
1455 EMACS_GET_TIME (t); 1439 EMACS_GET_TIME (t);
1456 XSETINT (result[0], (EMACS_SECS (t) >> 16) & 0xffff); 1440 return list3 (make_number ((EMACS_SECS (t) >> 16) & 0xffff),
1457 XSETINT (result[1], (EMACS_SECS (t) >> 0) & 0xffff); 1441 make_number ((EMACS_SECS (t) >> 0) & 0xffff),
1458 XSETINT (result[2], EMACS_USECS (t)); 1442 make_number (EMACS_USECS (t)));
1459
1460 return Flist (3, result);
1461} 1443}
1462 1444
1463DEFUN ("get-internal-run-time", Fget_internal_run_time, Sget_internal_run_time, 1445DEFUN ("get-internal-run-time", Fget_internal_run_time, Sget_internal_run_time,
@@ -1475,7 +1457,6 @@ systems that do not provide resolution finer than a second. */)
1475{ 1457{
1476#ifdef HAVE_GETRUSAGE 1458#ifdef HAVE_GETRUSAGE
1477 struct rusage usage; 1459 struct rusage usage;
1478 Lisp_Object result[3];
1479 int secs, usecs; 1460 int secs, usecs;
1480 1461
1481 if (getrusage (RUSAGE_SELF, &usage) < 0) 1462 if (getrusage (RUSAGE_SELF, &usage) < 0)
@@ -1491,11 +1472,9 @@ systems that do not provide resolution finer than a second. */)
1491 secs++; 1472 secs++;
1492 } 1473 }
1493 1474
1494 XSETINT (result[0], (secs >> 16) & 0xffff); 1475 return list3 (make_number ((secs >> 16) & 0xffff),
1495 XSETINT (result[1], (secs >> 0) & 0xffff); 1476 make_number ((secs >> 0) & 0xffff),
1496 XSETINT (result[2], usecs); 1477 make_number (usecs));
1497
1498 return Flist (3, result);
1499#else 1478#else
1500 return Fcurrent_time (); 1479 return Fcurrent_time ();
1501#endif 1480#endif
@@ -2706,6 +2685,10 @@ Both characters must have the same length of multi-byte form. */)
2706 Lisp_Object start, end, fromchar, tochar, noundo; 2685 Lisp_Object start, end, fromchar, tochar, noundo;
2707{ 2686{
2708 register int pos, pos_byte, stop, i, len, end_byte; 2687 register int pos, pos_byte, stop, i, len, end_byte;
2688 /* Keep track of the first change in the buffer:
2689 if 0 we haven't found it yet.
2690 if < 0 we've found it and we've run the before-change-function.
2691 if > 0 we've actually performed it and the value is its position. */
2709 int changed = 0; 2692 int changed = 0;
2710 unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH]; 2693 unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH];
2711 unsigned char *p; 2694 unsigned char *p;
@@ -2718,6 +2701,8 @@ Both characters must have the same length of multi-byte form. */)
2718 int last_changed = 0; 2701 int last_changed = 0;
2719 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); 2702 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters);
2720 2703
2704 restart:
2705
2721 validate_region (&start, &end); 2706 validate_region (&start, &end);
2722 CHECK_NUMBER (fromchar); 2707 CHECK_NUMBER (fromchar);
2723 CHECK_NUMBER (tochar); 2708 CHECK_NUMBER (tochar);
@@ -2755,7 +2740,7 @@ Both characters must have the same length of multi-byte form. */)
2755 That's faster than getting rid of things, 2740 That's faster than getting rid of things,
2756 and it prevents even the entry for a first change. 2741 and it prevents even the entry for a first change.
2757 Also inhibit locking the file. */ 2742 Also inhibit locking the file. */
2758 if (!NILP (noundo)) 2743 if (!changed && !NILP (noundo))
2759 { 2744 {
2760 record_unwind_protect (subst_char_in_region_unwind, 2745 record_unwind_protect (subst_char_in_region_unwind,
2761 current_buffer->undo_list); 2746 current_buffer->undo_list);
@@ -2789,10 +2774,14 @@ Both characters must have the same length of multi-byte form. */)
2789 && (len == 2 || (p[2] == fromstr[2] 2774 && (len == 2 || (p[2] == fromstr[2]
2790 && (len == 3 || p[3] == fromstr[3])))))) 2775 && (len == 3 || p[3] == fromstr[3]))))))
2791 { 2776 {
2792 if (! changed) 2777 if (changed < 0)
2778 /* We've already seen this and run the before-change-function;
2779 this time we only need to record the actual position. */
2780 changed = pos;
2781 else if (!changed)
2793 { 2782 {
2794 changed = pos; 2783 changed = -1;
2795 modify_region (current_buffer, changed, XINT (end)); 2784 modify_region (current_buffer, pos, XINT (end));
2796 2785
2797 if (! NILP (noundo)) 2786 if (! NILP (noundo))
2798 { 2787 {
@@ -2801,6 +2790,10 @@ Both characters must have the same length of multi-byte form. */)
2801 if (MODIFF - 1 == current_buffer->auto_save_modified) 2790 if (MODIFF - 1 == current_buffer->auto_save_modified)
2802 current_buffer->auto_save_modified++; 2791 current_buffer->auto_save_modified++;
2803 } 2792 }
2793
2794 /* The before-change-function may have moved the gap
2795 or even modified the buffer so we should start over. */
2796 goto restart;
2804 } 2797 }
2805 2798
2806 /* Take care of the case where the new character 2799 /* Take care of the case where the new character
@@ -2853,7 +2846,7 @@ Both characters must have the same length of multi-byte form. */)
2853 pos++; 2846 pos++;
2854 } 2847 }
2855 2848
2856 if (changed) 2849 if (changed > 0)
2857 { 2850 {
2858 signal_after_change (changed, 2851 signal_after_change (changed,
2859 last_changed - changed, last_changed - changed); 2852 last_changed - changed, last_changed - changed);