/[emacs]/emacs/src/undo.c
ViewVC logotype

Diff of /emacs/src/undo.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.55.2.2 by miles, Tue Oct 14 23:22:47 2003 UTC revision 1.55.2.3 by miles, Tue Jul 6 09:31:32 2004 UTC
# Line 292  but another undo command will undo to th Line 292  but another undo command will undo to th
292    
293  /* At garbage collection time, make an undo list shorter at the end,  /* At garbage collection time, make an undo list shorter at the end,
294     returning the truncated list.     returning the truncated list.
295     MINSIZE and MAXSIZE are the limits on size allowed, as described below.     MINSIZE, MAXSIZE and LIMITSIZE are the limits on size allowed,
296     In practice, these are the values of undo-limit and     as described below.
297     undo-strong-limit.  */     In practice, these are the values of undo-limit,
298       undo-strong-limit, and undo-outer-limit.  */
299    
300  Lisp_Object  Lisp_Object
301  truncate_undo_list (list, minsize, maxsize)  truncate_undo_list (list, minsize, maxsize, limitsize)
302       Lisp_Object list;       Lisp_Object list;
303       int minsize, maxsize;       int minsize, maxsize, limitsize;
304  {  {
305    Lisp_Object prev, next, last_boundary;    Lisp_Object prev, next, last_boundary;
306    int size_so_far = 0;    int size_so_far = 0;
# Line 308  truncate_undo_list (list, minsize, maxsi Line 309  truncate_undo_list (list, minsize, maxsi
309    next = list;    next = list;
310    last_boundary = Qnil;    last_boundary = Qnil;
311    
312    /* Always preserve at least the most recent undo record.    /* Always preserve at least the most recent undo record
313         unless it is really horribly big.
314       If the first element is an undo boundary, skip past it.       If the first element is an undo boundary, skip past it.
315    
316       Skip, skip, skip the undo, skip, skip, skip the undo,       Skip, skip, skip the undo, skip, skip, skip the undo,
# Line 323  truncate_undo_list (list, minsize, maxsi Line 325  truncate_undo_list (list, minsize, maxsi
325        prev = next;        prev = next;
326        next = XCDR (next);        next = XCDR (next);
327      }      }
328    
329    while (CONSP (next) && ! NILP (XCAR (next)))    while (CONSP (next) && ! NILP (XCAR (next)))
330      {      {
331        Lisp_Object elt;        Lisp_Object elt;
# Line 338  truncate_undo_list (list, minsize, maxsi Line 341  truncate_undo_list (list, minsize, maxsi
341                              + SCHARS (XCAR (elt)));                              + SCHARS (XCAR (elt)));
342          }          }
343    
344          /* If we reach LIMITSIZE before the first boundary,
345             we're heading for memory full, so truncate the list to nothing.  */
346          if (size_so_far > limitsize)
347            return Qnil;
348    
349        /* Advance to next element.  */        /* Advance to next element.  */
350        prev = next;        prev = next;
351        next = XCDR (next);        next = XCDR (next);
352      }      }
353    
354    if (CONSP (next))    if (CONSP (next))
355      last_boundary = prev;      last_boundary = prev;
356    
357      /* Keep more if it fits.  */
358    while (CONSP (next))    while (CONSP (next))
359      {      {
360        Lisp_Object elt;        Lisp_Object elt;

Legend:
Removed from v.1.55.2.2  
changed lines
  Added in v.1.55.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26