X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/b347b3fd3fbbdd5f009294edd406696889f34329..b3561514f631090ea1af4b6a04aaa8790654595d:/src/undo.c diff --git a/src/undo.c b/src/undo.c index 49dc4453d1..ec6f9d6b1d 100644 --- a/src/undo.c +++ b/src/undo.c @@ -1,5 +1,5 @@ /* undo handling for GNU Emacs. - Copyright (C) 1990, 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1990, 1993, 1994, 2000 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -73,7 +73,7 @@ record_insert (beg, length) && INTEGERP (XCDR (elt)) && XINT (XCDR (elt)) == beg) { - XSETINT (XCDR (elt), beg + length); + XSETCDR (elt, make_number (beg + length)); return; } } @@ -102,7 +102,8 @@ record_delete (beg, string) if (NILP (pending_boundary)) pending_boundary = Fcons (Qnil, Qnil); - if (current_buffer != XBUFFER (last_undo_buffer)) + if (BUFFERP (last_undo_buffer) + && current_buffer != XBUFFER (last_undo_buffer)) Fundo_boundary (); XSETBUFFER (last_undo_buffer, current_buffer); @@ -167,7 +168,8 @@ record_marker_adjustment (marker, adjustment) if (NILP (pending_boundary)) pending_boundary = Fcons (Qnil, Qnil); - if (current_buffer != XBUFFER (last_undo_buffer)) + if (!BUFFERP (last_undo_buffer) + || current_buffer != XBUFFER (last_undo_buffer)) Fundo_boundary (); XSETBUFFER (last_undo_buffer, current_buffer); @@ -201,7 +203,8 @@ record_first_change () if (EQ (current_buffer->undo_list, Qt)) return; - if (current_buffer != XBUFFER (last_undo_buffer)) + if (!BUFFERP (last_undo_buffer) + || current_buffer != XBUFFER (last_undo_buffer)) Fundo_boundary (); XSETBUFFER (last_undo_buffer, current_buffer); @@ -254,10 +257,10 @@ record_property_change (beg, length, prop, value, buffer) } DEFUN ("undo-boundary", Fundo_boundary, Sundo_boundary, 0, 0, 0, - "Mark a boundary between units of undo.\n\ -An undo command will stop at this point,\n\ -but another undo command will undo to the previous boundary.") - () + doc: /* Mark a boundary between units of undo. +An undo command will stop at this point, +but another undo command will undo to the previous boundary. */) + () { Lisp_Object tem; if (EQ (current_buffer->undo_list, Qt)) @@ -270,7 +273,7 @@ but another undo command will undo to the previous boundary.") { /* If we have preallocated the cons cell to use here, use that one. */ - XCDR (pending_boundary) = current_buffer->undo_list; + XSETCDR (pending_boundary, current_buffer->undo_list); current_buffer->undo_list = pending_boundary; pending_boundary = Qnil; } @@ -375,7 +378,7 @@ truncate_undo_list (list, minsize, maxsize) /* Truncate at the boundary where we decided to truncate. */ if (!NILP (last_boundary)) { - XCDR (last_boundary) = Qnil; + XSETCDR (last_boundary, Qnil); return list; } else @@ -383,15 +386,16 @@ truncate_undo_list (list, minsize, maxsize) } DEFUN ("primitive-undo", Fprimitive_undo, Sprimitive_undo, 2, 2, 0, - "Undo N records from the front of the list LIST.\n\ -Return what remains of the list.") - (n, list) + doc: /* Undo N records from the front of the list LIST. +Return what remains of the list. */) + (n, list) Lisp_Object n, list; { struct gcpro gcpro1, gcpro2; Lisp_Object next; - int count = specpdl_ptr - specpdl; + int count = BINDING_STACK_SIZE (); register int arg; + #if 0 /* This is a good feature, but would make undo-start unable to do what is expected. */ Lisp_Object tem; @@ -403,21 +407,25 @@ Return what remains of the list.") list = Fcdr (list); #endif - CHECK_NUMBER (n, 0); + CHECK_NUMBER (n); arg = XINT (n); next = Qnil; GCPRO2 (next, list); - /* Don't let read-only properties interfere with undo. */ + /* In a writable buffer, enable undoing read-only text that is so + because of text properties. */ if (NILP (current_buffer->read_only)) specbind (Qinhibit_read_only, Qt); + /* Don't let `intangible' properties interfere with undo. */ + specbind (Qinhibit_point_motion_hooks, Qt); + while (arg > 0) { - while (1) + while (CONSP (list)) { - next = Fcar (list); - list = Fcdr (list); + next = XCAR (list); + list = XCDR (list); /* Exit inner loop at undo boundary. */ if (NILP (next)) break; @@ -428,8 +436,8 @@ Return what remains of the list.") { Lisp_Object car, cdr; - car = Fcar (next); - cdr = Fcdr (next); + car = XCAR (next); + cdr = XCDR (next); if (EQ (car, Qt)) { /* Element (t high . low) records previous modtime. */ @@ -471,7 +479,6 @@ Return what remains of the list.") else if (INTEGERP (car) && INTEGERP (cdr)) { /* Element (BEG . END) means range was inserted. */ - Lisp_Object end; if (XINT (car) < BEGV || XINT (cdr) > ZV)