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); run_undoable_change (); 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))); }
/* Record point, if necessary, as it was at beginning of this command. BEG is the position of point that will naturally occur as a result of the undo record that will be added just after this command terminates. */ static void record_point (ptrdiff_t beg) { /* Don't record position of pt when undo_inhibit_record_point holds. */ if (undo_inhibit_record_point) return; bool at_boundary; /* Check whether we are at a boundary now, in case we record the first change. FIXME: This check is currently dependent on being called before record_first_change, but could be made not to by ignoring timestamp undo entries */ at_boundary = ! CONSP (BVAR (current_buffer, undo_list)) || NILP (XCAR (BVAR (current_buffer, undo_list))); /* If this is the first change since save, then record this.*/ if (MODIFF <= SAVE_MODIFF) record_first_change (); /* We may need to record point if we are immediately after a boundary, so that this will be restored correctly after undo. We do not need to do this if point is at the start of a change region since it will be restored there anyway, and we must not do this if the buffer has changed since the last command, since the value of point that we have will be for that buffer, not this.*/ if (at_boundary && point_before_last_command_or_undo != beg && buffer_before_last_command_or_undo == current_buffer ) bset_undo_list (current_buffer, Fcons (make_number (point_before_last_command_or_undo), 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); 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); /* Switch temporarily to the buffer that was changed. */ set_buffer_internal (buf); run_undoable_change (); 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))); /* Reset the buffer */ set_buffer_internal (obuf); }
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)); }
/* Record point as it was at beginning of this command (if necessary) and prepare the undo info for recording a change. Prepare the undo info for recording a change. */ static void prepare_record (void) { /* Allocate a cons cell to be the undo boundary after this command. */ if (NILP (pending_boundary)) pending_boundary = Fcons (Qnil, Qnil); if (MODIFF <= SAVE_MODIFF) record_first_change (); }
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 *buf = XBUFFER (buffer); if (EQ (BVAR (buf, undo_list), Qt)) return; prepare_record(); 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))); }
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 (EMACS_INT beg, EMACS_INT length, Lisp_Object prop, Lisp_Object value, Lisp_Object buffer) { Lisp_Object lbeg, lend, entry; struct buffer *obuf = current_buffer, *buf = XBUFFER (buffer); int 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)))); BVAR (current_buffer, undo_list) = Fcons (entry, BVAR (current_buffer, undo_list)); current_buffer = obuf; }