Commit 4591d6cb authored by Stefan Monnier's avatar Stefan Monnier

(last_boundary_buffer, last_boundary_position): New vars.

(Fundo_boundary): Set them.
(syms_of_undo): Initialize them.
(record_point): Use them instead of last_point_position*.
(last_undo_buffer): Change type.
parent 7c373357
2008-04-04 Stefan Monnier <monnier@iro.umontreal.ca>
* undo.c (last_boundary_buffer, last_boundary_position): New vars.
(Fundo_boundary): Set them.
(syms_of_undo): Initialize them.
(record_point): Use them instead of last_point_position*.
(last_undo_buffer): Change type.
2008-04-04 Jason Rumney <jasonr@gnu.org> 2008-04-04 Jason Rumney <jasonr@gnu.org>
* w32uniscribe.c (uniscribe_check_otf): Fix last change. * w32uniscribe.c (uniscribe_check_otf): Fix last change.
(uniscribe_check_otf): Add GC protection before consing. (uniscribe_check_otf): Add GC protection before consing.
Rearrange loop for counting features. Rearrange loop for counting features.
2008-04-03 Stefan Monnier <monnier@iro.umontreal.ca> 2008-04-03 Stefan Monnier <monnier@iro.umontreal.ca>
...@@ -52,7 +60,7 @@ ...@@ -52,7 +60,7 @@
Handle :otf spec for uniscribe backend. Handle :otf spec for uniscribe backend.
(add_font_entity_to_list): Match truetype fonts in uniscribe backend. (add_font_entity_to_list): Match truetype fonts in uniscribe backend.
(fill_in_logfont): Use DEFAULT_CHARSET when charset not supplied. (fill_in_logfont): Use DEFAULT_CHARSET when charset not supplied.
* w32fns.c (Fx_create_frame): Conditionally register uniscribe * w32fns.c (Fx_create_frame): Conditionally register uniscribe
font backend. font backend.
(globals_of_w32fns): Initialize uniscribe font backend. (globals_of_w32fns): Initialize uniscribe font backend.
......
...@@ -38,7 +38,12 @@ Lisp_Object Vundo_outer_limit; ...@@ -38,7 +38,12 @@ Lisp_Object Vundo_outer_limit;
Lisp_Object Vundo_outer_limit_function; Lisp_Object Vundo_outer_limit_function;
/* Last buffer for which undo information was recorded. */ /* Last buffer for which undo information was recorded. */
Lisp_Object last_undo_buffer; /* BEWARE: This is not traced by the GC, so never dereference it! */
struct buffer *last_undo_buffer;
/* Position of point last time we inserted a boundary. */
struct buffer *last_boundary_buffer;
EMACS_INT last_boundary_position;
Lisp_Object Qinhibit_read_only; Lisp_Object Qinhibit_read_only;
...@@ -68,11 +73,7 @@ record_point (pt) ...@@ -68,11 +73,7 @@ record_point (pt)
{ {
int at_boundary; int at_boundary;
/* Don't record position of pt when undo_inhibit_record_point holds. /* Don't record position of pt when undo_inhibit_record_point holds. */
Needed to avoid inserting a position record in buffer-undo-list
when last_point_position has not been set up correctly by
command_loop_1, for example, when running a repeat-repeat-char
event. */
if (undo_inhibit_record_point) if (undo_inhibit_record_point)
return; return;
...@@ -80,10 +81,9 @@ record_point (pt) ...@@ -80,10 +81,9 @@ record_point (pt)
if (NILP (pending_boundary)) if (NILP (pending_boundary))
pending_boundary = Fcons (Qnil, Qnil); pending_boundary = Fcons (Qnil, Qnil);
if (!BUFFERP (last_undo_buffer) if (current_buffer != last_undo_buffer)
|| current_buffer != XBUFFER (last_undo_buffer))
Fundo_boundary (); Fundo_boundary ();
XSETBUFFER (last_undo_buffer, current_buffer); last_undo_buffer = current_buffer;
if (CONSP (current_buffer->undo_list)) if (CONSP (current_buffer->undo_list))
{ {
...@@ -113,19 +113,10 @@ record_point (pt) ...@@ -113,19 +113,10 @@ record_point (pt)
/* If we are just after an undo boundary, and /* If we are just after an undo boundary, and
point wasn't at start of deleted range, record where it was. */ point wasn't at start of deleted range, record where it was. */
if (at_boundary if (at_boundary
&& BUFFERP (last_point_position_buffer) && current_buffer == last_boundary_buffer
/* If we're called from batch mode, this could be nil. */ && last_boundary_position != pt)
&& current_buffer == XBUFFER (last_point_position_buffer)) current_buffer->undo_list
{ = Fcons (make_number (last_boundary_position), current_buffer->undo_list);
/* If we have switched windows, use the point value
from the window we are in. */
if (! EQ (last_point_position_window, selected_window))
last_point_position = marker_position (XWINDOW (selected_window)->pointm);
if (last_point_position != pt)
current_buffer->undo_list
= Fcons (make_number (last_point_position), current_buffer->undo_list);
}
} }
/* Record an insertion that just happened or is about to happen, /* Record an insertion that just happened or is about to happen,
...@@ -211,10 +202,9 @@ record_marker_adjustment (marker, adjustment) ...@@ -211,10 +202,9 @@ record_marker_adjustment (marker, adjustment)
if (NILP (pending_boundary)) if (NILP (pending_boundary))
pending_boundary = Fcons (Qnil, Qnil); pending_boundary = Fcons (Qnil, Qnil);
if (!BUFFERP (last_undo_buffer) if (current_buffer != last_undo_buffer)
|| current_buffer != XBUFFER (last_undo_buffer))
Fundo_boundary (); Fundo_boundary ();
XSETBUFFER (last_undo_buffer, current_buffer); last_undo_buffer = current_buffer;
current_buffer->undo_list current_buffer->undo_list
= Fcons (Fcons (marker, make_number (adjustment)), = Fcons (Fcons (marker, make_number (adjustment)),
...@@ -246,10 +236,9 @@ record_first_change () ...@@ -246,10 +236,9 @@ record_first_change ()
if (EQ (current_buffer->undo_list, Qt)) if (EQ (current_buffer->undo_list, Qt))
return; return;
if (!BUFFERP (last_undo_buffer) if (current_buffer != last_undo_buffer)
|| current_buffer != XBUFFER (last_undo_buffer))
Fundo_boundary (); Fundo_boundary ();
XSETBUFFER (last_undo_buffer, current_buffer); last_undo_buffer = current_buffer;
if (base_buffer->base_buffer) if (base_buffer->base_buffer)
base_buffer = base_buffer->base_buffer; base_buffer = base_buffer->base_buffer;
...@@ -268,22 +257,22 @@ record_property_change (beg, length, prop, value, buffer) ...@@ -268,22 +257,22 @@ record_property_change (beg, length, prop, value, buffer)
Lisp_Object prop, value, buffer; Lisp_Object prop, value, buffer;
{ {
Lisp_Object lbeg, lend, entry; Lisp_Object lbeg, lend, entry;
struct buffer *obuf = current_buffer; struct buffer *obuf = current_buffer, *buf = XBUFFER (buffer);
int boundary = 0; int boundary = 0;
if (EQ (XBUFFER (buffer)->undo_list, Qt)) if (EQ (buf->undo_list, Qt))
return; return;
/* Allocate a cons cell to be the undo boundary after this command. */ /* Allocate a cons cell to be the undo boundary after this command. */
if (NILP (pending_boundary)) if (NILP (pending_boundary))
pending_boundary = Fcons (Qnil, Qnil); pending_boundary = Fcons (Qnil, Qnil);
if (!EQ (buffer, last_undo_buffer)) if (buf != last_undo_buffer)
boundary = 1; boundary = 1;
last_undo_buffer = buffer; last_undo_buffer = buf;
/* Switch temporarily to the buffer that was changed. */ /* Switch temporarily to the buffer that was changed. */
current_buffer = XBUFFER (buffer); current_buffer = buf;
if (boundary) if (boundary)
Fundo_boundary (); Fundo_boundary ();
...@@ -323,6 +312,8 @@ but another undo command will undo to the previous boundary. */) ...@@ -323,6 +312,8 @@ but another undo command will undo to the previous boundary. */)
else else
current_buffer->undo_list = Fcons (Qnil, current_buffer->undo_list); current_buffer->undo_list = Fcons (Qnil, current_buffer->undo_list);
} }
last_boundary_position = PT;
last_boundary_buffer = current_buffer;
return Qnil; return Qnil;
} }
...@@ -398,7 +389,8 @@ truncate_undo_list (b) ...@@ -398,7 +389,8 @@ truncate_undo_list (b)
&& size_so_far > XINT (Vundo_outer_limit) && size_so_far > XINT (Vundo_outer_limit)
&& !NILP (Vundo_outer_limit_function)) && !NILP (Vundo_outer_limit_function))
{ {
Lisp_Object temp = last_undo_buffer, tem; Lisp_Object tem;
struct buffer *temp = last_undo_buffer;
/* Normally the function this calls is undo-outer-limit-truncate. */ /* Normally the function this calls is undo-outer-limit-truncate. */
tem = call1 (Vundo_outer_limit_function, make_number (size_so_far)); tem = call1 (Vundo_outer_limit_function, make_number (size_so_far));
...@@ -679,6 +671,9 @@ syms_of_undo () ...@@ -679,6 +671,9 @@ syms_of_undo ()
pending_boundary = Qnil; pending_boundary = Qnil;
staticpro (&pending_boundary); staticpro (&pending_boundary);
last_undo_buffer = NULL;
last_boundary_buffer = NULL;
defsubr (&Sprimitive_undo); defsubr (&Sprimitive_undo);
defsubr (&Sundo_boundary); defsubr (&Sundo_boundary);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment