X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/699c782b7668c44d0fa4446331b0590a6d5dac82..05ecb497393551e8bb65fb07fbdc4bbb5f61765a:/src/undo.c diff --git a/src/undo.c b/src/undo.c index 4041a2adac..9b763984d7 100644 --- a/src/undo.c +++ b/src/undo.c @@ -30,7 +30,7 @@ static struct buffer *last_undo_buffer; /* Position of point last time we inserted a boundary. */ static struct buffer *last_boundary_buffer; -static EMACS_INT last_boundary_position; +static ptrdiff_t last_boundary_position; Lisp_Object Qinhibit_read_only; @@ -51,7 +51,7 @@ static Lisp_Object pending_boundary; undo record that will be added just after this command terminates. */ static void -record_point (EMACS_INT pt) +record_point (ptrdiff_t pt) { int at_boundary; @@ -113,7 +113,7 @@ record_point (EMACS_INT pt) because we don't need to record the contents.) */ void -record_insert (EMACS_INT beg, EMACS_INT length) +record_insert (ptrdiff_t beg, ptrdiff_t length) { Lisp_Object lbeg, lend; @@ -148,7 +148,7 @@ record_insert (EMACS_INT beg, EMACS_INT length) of the characters in STRING, at location BEG. */ void -record_delete (EMACS_INT beg, Lisp_Object string) +record_delete (ptrdiff_t beg, Lisp_Object string) { Lisp_Object sbeg; @@ -176,7 +176,7 @@ record_delete (EMACS_INT beg, Lisp_Object string) won't be inverted automatically by undoing the buffer modification. */ void -record_marker_adjustment (Lisp_Object marker, EMACS_INT adjustment) +record_marker_adjustment (Lisp_Object marker, ptrdiff_t adjustment) { if (EQ (BVAR (current_buffer, undo_list), Qt)) return; @@ -199,7 +199,7 @@ record_marker_adjustment (Lisp_Object marker, EMACS_INT adjustment) The replacement must not change the number of characters. */ void -record_change (EMACS_INT beg, EMACS_INT length) +record_change (ptrdiff_t beg, ptrdiff_t length) { record_delete (beg, make_buffer_string (beg, beg + length, 1)); record_insert (beg, length); @@ -233,7 +233,7 @@ record_first_change (void) for LENGTH characters starting at position BEG in BUFFER. */ void -record_property_change (EMACS_INT beg, EMACS_INT length, +record_property_change (ptrdiff_t beg, ptrdiff_t length, Lisp_Object prop, Lisp_Object value, Lisp_Object buffer) { @@ -308,11 +308,11 @@ truncate_undo_list (struct buffer *b) { Lisp_Object list; Lisp_Object prev, next, last_boundary; - int size_so_far = 0; + EMACS_INT size_so_far = 0; /* Make sure that calling undo-outer-limit-function won't cause another GC. */ - int count = inhibit_garbage_collection (); + ptrdiff_t count = inhibit_garbage_collection (); /* Make the buffer current to get its local values of variables such as undo_limit. Also so that Vundo_outer_limit_function can @@ -436,6 +436,13 @@ truncate_undo_list (struct buffer *b) unbind_to (count, Qnil); } + +static void user_error (const char*) NO_RETURN; +static void user_error (const char *msg) +{ + xsignal1 (Quser_error, build_string (msg)); +} + DEFUN ("primitive-undo", Fprimitive_undo, Sprimitive_undo, 2, 2, 0, doc: /* Undo N records from the front of the list LIST. @@ -444,8 +451,8 @@ Return what remains of the list. */) { struct gcpro gcpro1, gcpro2; Lisp_Object next; - int count = SPECPDL_INDEX (); - register int arg; + ptrdiff_t count = SPECPDL_INDEX (); + register EMACS_INT arg; Lisp_Object oldlist; int did_apply = 0; @@ -528,7 +535,7 @@ Return what remains of the list. */) end = Fcdr (cdr); if (XINT (beg) < BEGV || XINT (end) > ZV) - error ("Changes to be undone are outside visible portion of buffer"); + user_error ("Changes to be undone are outside visible portion of buffer"); Fput_text_property (beg, end, prop, val, Qnil); } else if (INTEGERP (car) && INTEGERP (cdr)) @@ -537,7 +544,7 @@ Return what remains of the list. */) if (XINT (car) < BEGV || XINT (cdr) > ZV) - error ("Changes to be undone are outside visible portion of buffer"); + user_error ("Changes to be undone are outside visible portion of buffer"); /* Set point first thing, so that undoing this undo does not send point back to where it is now. */ Fgoto_char (car); @@ -588,14 +595,14 @@ Return what remains of the list. */) if (pos < 0) { if (-pos < BEGV || -pos > ZV) - error ("Changes to be undone are outside visible portion of buffer"); + user_error ("Changes to be undone are outside visible portion of buffer"); SET_PT (-pos); Finsert (1, &membuf); } else { if (pos < BEGV || pos > ZV) - error ("Changes to be undone are outside visible portion of buffer"); + user_error ("Changes to be undone are outside visible portion of buffer"); SET_PT (pos); /* Now that we record marker adjustments