anchor.diff:       nil)))
   
   (defun buffer-undo-1 (buffer)
  -  (let ((tlist (buffer-undo-stack buffer)))
  -    (unless (tlist-empty-p tlist)
  +  (let ((elt (pop (buffer-undo-stack buffer))))
  +    (when elt
         (decf (buffer-undo-size buffer))
  -      (let ((elt (tlist-right tlist))
  -            (*use-redo-stack* t))
  -        (setf (car tlist) (butlast (car tlist)))
  -        (tlist-update tlist)
  +      (let ((*use-redo-stack* t))
           (unless (eq elt :undo-separator)
             (funcall elt))))))
   
   (defun buffer-undo (buffer)
  -  (do ((res #1=(buffer-undo-1 buffer) #1#)
  -       (pres nil res))
  -      ((not res) pres)))
  +  (when (eq :undo-separator (car (buffer-undo-stack buffer)))
  +    (pop (buffer-undo-stack buffer)))
  +  (prog1
  +      (do ((res #1=(buffer-undo-1 buffer) #1#)
  +           (pres nil res))
  +          ((not res) pres))
  +    (push :undo-separator (buffer-redo-stack buffer))))
  +
  +(defun buffer-redo-1 (buffer)
  +  (let ((elt (pop (buffer-redo-stack buffer))))
  +    (when elt
  +      (let ((*use-undo-stack* t))
  +        (unless (eq elt :undo-separator)
  +          (funcall elt))))))
   
   (defun buffer-redo (buffer)
  -  (let ((f (pop (buffer-redo-stack buffer))))
  -    (when f
  -      (let ((*use-undo-stack* t))
  -        (funcall f)))))
  +  (when (eq :undo-separator (car (buffer-redo-stack buffer)))
  +    (pop (buffer-redo-stack buffer)))
  +  (prog1 (do ((res #1=(buffer-redo-1 buffer) #1#)
  +              (pres nil res))
  +             ((not res) pres))
  +    (push :undo-separator (buffer-undo-stack buffer))))
   
   (defclass buffer-output-stream (sb-gray:fundamental-output-stream)
     ((buffer
  
positive.code:     (setf (buffer-mark-col buffer) 0)
      (setf (buffer-nlines buffer) 1)
      (setf (buffer-undo-size buffer) 0)
      (setf (buffer-undo-stack buffer) (make-tlist))
      (setf (buffer-redo-stack buffer) nil)
      (push buffer *buffer-list*)
      buffer))
  
negative.code: 
  (defun push-undo-stack (buffer elt)
    (cond ((<= *undo-limit* (buffer-undo-size buffer))
           )
          (t
           (incf (buffer-undo-size buffer))))
    (when-interrupted-flag 
     undo
     (push :undo-separator (buffer-undo-stack buffer)))
    (push elt (buffer-undo-stack buffer)))
  
  (defun push-redo-stack (buffer elt)
    (push elt (buffer-redo-stack buffer)))
  