comparison src/undo.c @ 1968:de0a0ed7318e

(record_property_change): Typo in last change. (Fprimitive_undo): Handle property-change undo entry. (record_property_change): New function.
author Richard M. Stallman <rms@gnu.org>
date Mon, 01 Mar 1993 09:01:13 +0000
parents 3e9dadf2d13c
children 886a69457557
comparison
equal deleted inserted replaced
1967:239a8c1cb40f 1968:de0a0ed7318e
120 { 120 {
121 Lisp_Object high, low; 121 Lisp_Object high, low;
122 XFASTINT (high) = (current_buffer->modtime >> 16) & 0xffff; 122 XFASTINT (high) = (current_buffer->modtime >> 16) & 0xffff;
123 XFASTINT (low) = current_buffer->modtime & 0xffff; 123 XFASTINT (low) = current_buffer->modtime & 0xffff;
124 current_buffer->undo_list = Fcons (Fcons (Qt, Fcons (high, low)), current_buffer->undo_list); 124 current_buffer->undo_list = Fcons (Fcons (Qt, Fcons (high, low)), current_buffer->undo_list);
125 }
126
127 /* Record a change in property PROP (whose old value was VAL)
128 for LENGTH characters starting at position BEG in BUFFER. */
129
130 record_property_change (beg, length, prop, value, buffer)
131 int beg, length;
132 Lisp_Object prop, value, buffer;
133 {
134 Lisp_Object lbeg, lend, entry;
135 struct buffer *obuf = current_buffer;
136 int boundary = 0;
137
138 if (!EQ (buffer, last_undo_buffer))
139 boundary = 1;
140 last_undo_buffer = buffer;
141
142 if (EQ (current_buffer->undo_list, Qt))
143 return;
144
145 /* Switch temporarily to the buffer that was changed. */
146 current_buffer = XBUFFER (buffer);
147
148 if (boundary)
149 Fundo_boundary ();
150
151 if (MODIFF <= current_buffer->save_modified)
152 record_first_change ();
153
154 XSET (lbeg, Lisp_Int, beg);
155 XSET (lend, Lisp_Int, beg + length);
156 entry = Fcons (Qnil, Fcons (prop, Fcons (value, Fcons (lbeg, lend))));
157 current_buffer->undo_list = Fcons (entry, current_buffer->undo_list);
158
159 current_buffer = obuf;
125 } 160 }
126 161
127 DEFUN ("undo-boundary", Fundo_boundary, Sundo_boundary, 0, 0, 0, 162 DEFUN ("undo-boundary", Fundo_boundary, Sundo_boundary, 0, 0, 0,
128 "Mark a boundary between units of undo.\n\ 163 "Mark a boundary between units of undo.\n\
129 An undo command will stop at this point,\n\ 164 An undo command will stop at this point,\n\
297 #ifdef CLASH_DETECTION 332 #ifdef CLASH_DETECTION
298 Funlock_buffer (); 333 Funlock_buffer ();
299 #endif /* CLASH_DETECTION */ 334 #endif /* CLASH_DETECTION */
300 Fset_buffer_modified_p (Qnil); 335 Fset_buffer_modified_p (Qnil);
301 } 336 }
337 if (EQ (car, Qnil))
338 {
339 /* Element (t prop val beg . end) records property change. */
340 Lisp_Object beg, end, prop, val;
341
342 prop = Fcar (cdr);
343 cdr = Fcdr (cdr);
344 val = Fcar (cdr);
345 cdr = Fcdr (cdr);
346 beg = Fcar (cdr);
347 end = Fcdr (cdr);
348
349 Fput_text_property (beg, end, prop, val, Qnil);
350 }
302 else if (XTYPE (car) == Lisp_Int && XTYPE (cdr) == Lisp_Int) 351 else if (XTYPE (car) == Lisp_Int && XTYPE (cdr) == Lisp_Int)
303 { 352 {
304 /* Element (BEG . END) means range was inserted. */ 353 /* Element (BEG . END) means range was inserted. */
305 Lisp_Object end; 354 Lisp_Object end;
306 355