aboutsummaryrefslogtreecommitdiffstats
path: root/src/undo.c
diff options
context:
space:
mode:
authorRichard M. Stallman1994-03-08 16:33:28 +0000
committerRichard M. Stallman1994-03-08 16:33:28 +0000
commitc58632fc81146eb6bb03bf85c43128884179fc05 (patch)
tree7633987613e0e2bd55064c44ce6c0add519b62a0 /src/undo.c
parent5d694741264de50c7eda86c8c9467946c18dd96c (diff)
downloademacs-c58632fc81146eb6bb03bf85c43128884179fc05.tar.gz
emacs-c58632fc81146eb6bb03bf85c43128884179fc05.zip
(syms_of_undo): staticpro pending_boundary.
(pending_boundary): New variable. (syms_of_undo): Initialize it. (Fundo_boundary): Use pending_boundary. (record_insert, record_delete, record_property_change): Set pending_boundary.
Diffstat (limited to 'src/undo.c')
-rw-r--r--src/undo.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/undo.c b/src/undo.c
index 64f773d62c8..683fa66b89a 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -29,6 +29,13 @@ Lisp_Object last_undo_buffer;
29 29
30Lisp_Object Qinhibit_read_only; 30Lisp_Object Qinhibit_read_only;
31 31
32/* The first time a command records something for undo.
33 it also allocates the undo-boundary object
34 which will be added to the list at the end of the command.
35 This ensures we can't run out of space while trying to make
36 an undo-boundary. */
37Lisp_Object pending_boundary;
38
32/* Record an insertion that just happened or is about to happen, 39/* Record an insertion that just happened or is about to happen,
33 for LENGTH characters at position BEG. 40 for LENGTH characters at position BEG.
34 (It is possible to record an insertion before or after the fact 41 (It is possible to record an insertion before or after the fact
@@ -42,6 +49,10 @@ record_insert (beg, length)
42 if (EQ (current_buffer->undo_list, Qt)) 49 if (EQ (current_buffer->undo_list, Qt))
43 return; 50 return;
44 51
52 /* Allocate a cons cell to be the undo boundary after this command. */
53 if (NILP (pending_boundary))
54 pending_boundary = Fcons (Qnil, Qnil);
55
45 if (current_buffer != XBUFFER (last_undo_buffer)) 56 if (current_buffer != XBUFFER (last_undo_buffer))
46 Fundo_boundary (); 57 Fundo_boundary ();
47 XSET (last_undo_buffer, Lisp_Buffer, current_buffer); 58 XSET (last_undo_buffer, Lisp_Buffer, current_buffer);
@@ -82,6 +93,10 @@ record_delete (beg, length)
82 if (EQ (current_buffer->undo_list, Qt)) 93 if (EQ (current_buffer->undo_list, Qt))
83 return; 94 return;
84 95
96 /* Allocate a cons cell to be the undo boundary after this command. */
97 if (NILP (pending_boundary))
98 pending_boundary = Fcons (Qnil, Qnil);
99
85 if (current_buffer != XBUFFER (last_undo_buffer)) 100 if (current_buffer != XBUFFER (last_undo_buffer))
86 Fundo_boundary (); 101 Fundo_boundary ();
87 XSET (last_undo_buffer, Lisp_Buffer, current_buffer); 102 XSET (last_undo_buffer, Lisp_Buffer, current_buffer);
@@ -151,6 +166,10 @@ record_property_change (beg, length, prop, value, buffer)
151 if (EQ (XBUFFER (buffer)->undo_list, Qt)) 166 if (EQ (XBUFFER (buffer)->undo_list, Qt))
152 return; 167 return;
153 168
169 /* Allocate a cons cell to be the undo boundary after this command. */
170 if (NILP (pending_boundary))
171 pending_boundary = Fcons (Qnil, Qnil);
172
154 if (!EQ (buffer, last_undo_buffer)) 173 if (!EQ (buffer, last_undo_buffer))
155 boundary = 1; 174 boundary = 1;
156 last_undo_buffer = buffer; 175 last_undo_buffer = buffer;
@@ -183,7 +202,19 @@ but another undo command will undo to the previous boundary.")
183 return Qnil; 202 return Qnil;
184 tem = Fcar (current_buffer->undo_list); 203 tem = Fcar (current_buffer->undo_list);
185 if (!NILP (tem)) 204 if (!NILP (tem))
186 current_buffer->undo_list = Fcons (Qnil, current_buffer->undo_list); 205 {
206 /* One way or another, cons nil onto the front of the undo list. */
207 if (!NILP (pending_boundary))
208 {
209 /* If we have preallocated the cons cell to use here,
210 use that one. */
211 XCONS (pending_boundary)->cdr = current_buffer->undo_list;
212 current_buffer->undo_list = pending_boundary;
213 pending_boundary = Qnil;
214 }
215 else
216 current_buffer->undo_list = Fcons (Qnil, current_buffer->undo_list);
217 }
187 return Qnil; 218 return Qnil;
188} 219}
189 220
@@ -425,6 +456,9 @@ syms_of_undo ()
425 Qinhibit_read_only = intern ("inhibit-read-only"); 456 Qinhibit_read_only = intern ("inhibit-read-only");
426 staticpro (&Qinhibit_read_only); 457 staticpro (&Qinhibit_read_only);
427 458
459 pending_boundary = Qnil;
460 staticpro (&pending_boundary);
461
428 defsubr (&Sprimitive_undo); 462 defsubr (&Sprimitive_undo);
429 defsubr (&Sundo_boundary); 463 defsubr (&Sundo_boundary);
430} 464}