static void record_point (EMACS_INT pt) { int at_boundary; /* Don't record position of pt when undo_inhibit_record_point holds. */ if (undo_inhibit_record_point) return; /* Allocate a cons cell to be the undo boundary after this command. */ if (NILP (pending_boundary)) pending_boundary = Fcons (Qnil, Qnil); if ((current_buffer != last_undo_buffer) /* Don't call Fundo_boundary for the first change. Otherwise we risk overwriting last_boundary_position in Fundo_boundary with PT of the current buffer and as a consequence not insert an undo boundary because last_boundary_position will equal pt in the test at the end of the present function (Bug#731). */ && (MODIFF > SAVE_MODIFF)) Fundo_boundary (); last_undo_buffer = current_buffer; if (CONSP (BVAR (current_buffer, undo_list))) { /* Set AT_BOUNDARY to 1 only when we have nothing other than marker adjustment before undo boundary. */ Lisp_Object tail = BVAR (current_buffer, undo_list), elt; while (1) { if (NILP (tail)) elt = Qnil; else elt = XCAR (tail); if (NILP (elt) || ! (CONSP (elt) && MARKERP (XCAR (elt)))) break; tail = XCDR (tail); } at_boundary = NILP (elt); } else at_boundary = 1; if (MODIFF <= SAVE_MODIFF) record_first_change (); /* If we are just after an undo boundary, and point wasn't at start of deleted range, record where it was. */ if (at_boundary && current_buffer == last_boundary_buffer && last_boundary_position != pt) BVAR (current_buffer, undo_list) = Fcons (make_number (last_boundary_position), BVAR (current_buffer, undo_list)); }
void record_marker_adjustment (Lisp_Object marker, EMACS_INT adjustment) { if (EQ (BVAR (current_buffer, undo_list), Qt)) return; /* Allocate a cons cell to be the undo boundary after this command. */ if (NILP (pending_boundary)) pending_boundary = Fcons (Qnil, Qnil); if (current_buffer != last_undo_buffer) Fundo_boundary (); last_undo_buffer = current_buffer; BVAR (current_buffer, undo_list) = Fcons (Fcons (marker, make_number (adjustment)), BVAR (current_buffer, undo_list)); }
void record_first_change (void) { struct buffer *base_buffer = current_buffer; if (EQ (BVAR (current_buffer, undo_list), Qt)) return; if (current_buffer != last_undo_buffer) Fundo_boundary (); last_undo_buffer = current_buffer; if (base_buffer->base_buffer) base_buffer = base_buffer->base_buffer; bset_undo_list (current_buffer, Fcons (Fcons (Qt, Fvisited_file_modtime ()), BVAR (current_buffer, undo_list))); }
void record_first_change (void) { struct buffer *base_buffer = current_buffer; if (EQ (BVAR (current_buffer, undo_list), Qt)) return; if (current_buffer != last_undo_buffer) Fundo_boundary (); last_undo_buffer = current_buffer; if (base_buffer->base_buffer) base_buffer = base_buffer->base_buffer; BVAR (current_buffer, undo_list) = Fcons (Fcons (Qt, INTEGER_TO_CONS (base_buffer->modtime)), BVAR (current_buffer, undo_list)); }
static void record_marker_adjustments (ptrdiff_t from, ptrdiff_t to) { Lisp_Object marker; register struct Lisp_Marker *m; register ptrdiff_t charpos, adjustment; /* Allocate a cons cell to be the undo boundary after this command. */ if (NILP (pending_boundary)) pending_boundary = Fcons (Qnil, Qnil); if (current_buffer != last_undo_buffer) Fundo_boundary (); last_undo_buffer = current_buffer; for (m = BUF_MARKERS (current_buffer); m; m = m->next) { charpos = m->charpos; eassert (charpos <= Z); if (from <= charpos && charpos <= to) { /* insertion_type nil markers will end up at the beginning of the re-inserted text after undoing a deletion, and must be adjusted to move them to the correct place. insertion_type t markers will automatically move forward upon re-inserting the deleted text, so we have to arrange for them to move backward to the correct position. */ adjustment = (m->insertion_type ? to : from) - charpos; if (adjustment) { XSETMISC (marker, m); bset_undo_list (current_buffer, Fcons (Fcons (marker, make_number (adjustment)), BVAR (current_buffer, undo_list))); } } } }
static void record_point (ptrdiff_t pt) { bool at_boundary; /* Don't record position of pt when undo_inhibit_record_point holds. */ if (undo_inhibit_record_point) return; /* Allocate a cons cell to be the undo boundary after this command. */ if (NILP (pending_boundary)) pending_boundary = Fcons (Qnil, Qnil); if ((current_buffer != last_undo_buffer) /* Don't call Fundo_boundary for the first change. Otherwise we risk overwriting last_boundary_position in Fundo_boundary with PT of the current buffer and as a consequence not insert an undo boundary because last_boundary_position will equal pt in the test at the end of the present function (Bug#731). */ && (MODIFF > SAVE_MODIFF)) Fundo_boundary (); last_undo_buffer = current_buffer; at_boundary = ! CONSP (BVAR (current_buffer, undo_list)) || NILP (XCAR (BVAR (current_buffer, undo_list))); if (MODIFF <= SAVE_MODIFF) record_first_change (); /* If we are just after an undo boundary, and point wasn't at start of deleted range, record where it was. */ if (at_boundary && current_buffer == last_boundary_buffer && last_boundary_position != pt) bset_undo_list (current_buffer, Fcons (make_number (last_boundary_position), BVAR (current_buffer, undo_list))); }
void record_property_change (ptrdiff_t beg, ptrdiff_t length, Lisp_Object prop, Lisp_Object value, Lisp_Object buffer) { Lisp_Object lbeg, lend, entry; struct buffer *obuf = current_buffer, *buf = XBUFFER (buffer); bool boundary = 0; if (EQ (BVAR (buf, undo_list), Qt)) return; /* Allocate a cons cell to be the undo boundary after this command. */ if (NILP (pending_boundary)) pending_boundary = Fcons (Qnil, Qnil); if (buf != last_undo_buffer) boundary = 1; last_undo_buffer = buf; /* Switch temporarily to the buffer that was changed. */ current_buffer = buf; if (boundary) Fundo_boundary (); if (MODIFF <= SAVE_MODIFF) record_first_change (); XSETINT (lbeg, beg); XSETINT (lend, beg + length); entry = Fcons (Qnil, Fcons (prop, Fcons (value, Fcons (lbeg, lend)))); bset_undo_list (current_buffer, Fcons (entry, BVAR (current_buffer, undo_list))); current_buffer = obuf; }