anchor.diff:                                  end-linum)
       disp-lines))
   
  +(defun check-read-only (buffer)
  +  (when (buffer-read-only-p buffer)
  +    (error 'readonly)))
  +
  +(defun buffer-modify (buffer)
  +  (setf (buffer-modified-p buffer)
  +        (if (buffer-modified-p buffer)
  +            (1+ (mod (buffer-modified-p buffer)
  +                     #.(floor most-positive-fixnum 2)))
  +            0)))
  +
  +(defmacro with-buffer-modify (buffer &body body)
  +  `(progn
  +     (check-read-only ,buffer)
  +     (prog1 (progn ,@body)
  +       (buffer-modify ,buffer))))
  +
   (defun buffer-insert-char (buffer linum pos c)
     (cond ((char= c #\newline)
            (buffer-insert-newline buffer linum pos))
           (t
  -         (check-read-only buffer)
  -         (with-push-undo (buffer)
  -           (buffer-delete-char buffer linum pos 1)
  -           (make-point linum pos))
  -         (buffer-modify buffer)
  -         (let ((line (buffer-get-line buffer linum)))
  +         (with-buffer-modify buffer
  +           (with-push-undo (buffer)
  +             (buffer-delete-char buffer linum pos 1)
  +             (make-point linum pos))
  +           (let ((line (buffer-get-line buffer linum)))
  +             (dolist (marker (buffer-markers buffer))
  +               (when (and (= linum (marker-linum marker))
  +                          (if (marker-insertion-type marker)
  +                              (<= pos (marker-charpos marker))
  +                              (< pos (marker-charpos marker))))
  +                 (incf (marker-charpos marker))))
  +             (setf (line-fatstr line)
  +                   (fat-concat (fat-substring (line-fatstr line) 0 pos)
  +                               (string c)
  +                               (fat-substring (line-fatstr line) pos)))))))
  +  t)
  +
  +(defun buffer-insert-newline (buffer linum pos)
  +  (with-buffer-modify buffer
  +    (with-push-undo (buffer)
  +      (buffer-delete-char buffer linum pos 1)
  +      (make-point linum pos))
  +    (dolist (marker (buffer-markers buffer))
  +      (cond
  +        ((and (= (marker-linum marker) linum)
  +              (if (marker-insertion-type marker)
  +                  (<= pos (marker-charpos marker))
  +                  (< pos (marker-charpos marker))))
  +         (incf (marker-linum marker))
  +         (decf (marker-charpos marker) pos))
  +        ((< linum (marker-linum marker))
  +         (incf (marker-linum marker)))))
  +    (let ((line (buffer-get-line buffer linum)))
  +      (let ((newline
  +              (make-line line
  +                         (line-next line)
  +                         (fat-substring (line-fatstr line) pos))))
  +        (when (eq line (buffer-tail-line buffer))
  +          (setf (buffer-tail-line buffer) newline))
  +        (setf (line-fatstr line)
  +              (fat-substring (line-fatstr line) 0 pos))))
  +    (incf (buffer-nlines buffer)))
  +  t)
  +
  +(defun buffer-insert-line (buffer linum pos str)
  +  (with-buffer-modify buffer
  +    (let ((line (buffer-get-line buffer linum)))
  +      (with-push-undo (buffer)
  +        (buffer-delete-char buffer linum pos (fat-length str))
  +        (make-point linum pos))
  +      (dolist (marker (buffer-markers buffer))
  +        (when (and (= linum (marker-linum marker))
  +                   (if (marker-insertion-type marker)
  +                       (<= pos (marker-charpos marker))
  +                       (< pos (marker-charpos marker))))
  +          (incf (marker-charpos marker) (fat-length str))))
  +      (setf (line-fatstr line)
  +            (fat-concat (fat-substring (line-fatstr line) 0 pos)
  +                        str
  +                        (fat-substring (line-fatstr line) pos)))))
  +  t)
  +
  +(defun buffer-delete-char (buffer linum pos n)
  +  (with-buffer-modify buffer
  +    (let ((line (buffer-get-line buffer linum))
  +          (del-lines (list (make-fatstring "" 0))))
  +      (loop while (or (eq n t) (plusp n)) do
  +        (cond
  +          ((and (not (eq n t))
  +                (<= n (- (fat-length (line-fatstr line)) pos)))
              (dolist (marker (buffer-markers buffer))
                (when (and (= linum (marker-linum marker))
  -                        (if (marker-insertion-type marker)
  -                            (<= pos (marker-charpos marker))
  -                            (< pos (marker-charpos marker))))
  -               (incf (marker-charpos marker))))
  +                        (< pos (marker-charpos marker)))
  +               (setf (marker-charpos marker)
  +                     (if (> pos (- (marker-charpos marker) n))
  +                         pos
  +                         (- (marker-charpos marker) n)))))
  +           (setf (car del-lines)
  +                 (fat-concat (car del-lines)
  +                             (fat-substring (line-fatstr line) pos (+ pos n))))
              (setf (line-fatstr line)
                    (fat-concat (fat-substring (line-fatstr line) 0 pos)
  -                             (string c)
  -                             (fat-substring (line-fatstr line) pos))))))
  -  t)
  -
  -(defun buffer-insert-newline (buffer linum pos)
  -  (check-read-only buffer)
  -  (with-push-undo (buffer)
  -    (buffer-delete-char buffer linum pos 1)
  -    (make-point linum pos))
  -  (buffer-modify buffer)
  -  (dolist (marker (buffer-markers buffer))
  -    (cond
  -     ((and (= (marker-linum marker) linum)
  -           (if (marker-insertion-type marker)
  -               (<= pos (marker-charpos marker))
  -               (< pos (marker-charpos marker))))
  -      (incf (marker-linum marker))
  -      (decf (marker-charpos marker) pos))
  -     ((< linum (marker-linum marker))
  -      (incf (marker-linum marker)))))
  -  (let ((line (buffer-get-line buffer linum)))
  -    (let ((newline
  -           (make-line line
  -                      (line-next line)
  -                      (fat-substring (line-fatstr line) pos))))
  -      (when (eq line (buffer-tail-line buffer))
  -        (setf (buffer-tail-line buffer) newline))
  -      (setf (line-fatstr line)
  -            (fat-substring (line-fatstr line) 0 pos))))
  -  (incf (buffer-nlines buffer))
  -  t)
  -
  -(defun buffer-insert-line (buffer linum pos str)
  -  (check-read-only buffer)
  -  (let ((line (buffer-get-line buffer linum)))
  -    (with-push-undo (buffer)
  -      (buffer-delete-char buffer linum pos (fat-length str))
  -      (make-point linum pos))
  -    (buffer-modify buffer)
  -    (dolist (marker (buffer-markers buffer))
  -      (when (and (= linum (marker-linum marker))
  -                 (if (marker-insertion-type marker)
  -                     (<= pos (marker-charpos marker))
  -                     (< pos (marker-charpos marker))))
  -        (incf (marker-charpos marker) (fat-length str))))
  -    (setf (line-fatstr line)
  -          (fat-concat (fat-substring (line-fatstr line) 0 pos)
  -                      str
  -                      (fat-substring (line-fatstr line) pos))))
  -  t)
  -
  -(defun buffer-delete-char (buffer linum pos n)
  -  (check-read-only buffer)
  -  (let ((line (buffer-get-line buffer linum))
  -        (del-lines (list (make-fatstring "" 0))))
  -    (loop while (or (eq n t) (plusp n)) do
  -      (cond
  -       ((and (not (eq n t))
  -             (<= n (- (fat-length (line-fatstr line)) pos)))
  -        (dolist (marker (buffer-markers buffer))
  -          (when (and (= linum (marker-linum marker))
  +                             (fat-substring (line-fatstr line) (+ pos n))))
  +           (return))
  +          (t
  +           (dolist (marker (buffer-markers buffer))
  +             (cond
  +               ((and (= linum (marker-linum marker))
                        (< pos (marker-charpos marker)))
  -            (setf (marker-charpos marker)
  -                  (if (> pos (- (marker-charpos marker) n))
  -                      pos
  -                      (- (marker-charpos marker) n)))))
  -        (buffer-modify buffer)
  -        (setf (car del-lines)
  -              (fat-concat (car del-lines)
  -                          (fat-substring (line-fatstr line) pos (+ pos n))))
  -        (setf (line-fatstr line)
  -              (fat-concat (fat-substring (line-fatstr line) 0 pos)
  -                          (fat-substring (line-fatstr line) (+ pos n))))
  -        (setq n 0))
  -       (t
  -        (dolist (marker (buffer-markers buffer))
  -          (cond
  -           ((and (= linum (marker-linum marker))
  -                 (< pos (marker-charpos marker)))
  -            (setf (marker-charpos marker) pos))
  -           ((< linum (marker-linum marker))
  -            (decf (marker-linum marker)))))
  -        (setf (car del-lines)
  -              (fat-concat (car del-lines)
  -                          (fat-substring (line-fatstr line) pos)))
  -        (unless (line-next line)
  -          (return nil))
  -        (push (make-fatstring "" 0) del-lines)
  -        (unless (eq n t)
  -          (decf n (1+ (- (fat-length (line-fatstr line)) pos))))
  -        (decf (buffer-nlines buffer))
  -        (buffer-modify buffer)
  -        (setf (line-fatstr line)
  -              (fat-concat (fat-substring (line-fatstr line) 0 pos)
  -                          (line-fatstr (line-next line))))
  -        (when (eq (line-next line)
  -                  (buffer-tail-line buffer))
  -          (setf (buffer-tail-line buffer) line))
  -        (line-free (line-next line)))))
  -    (setq del-lines
  -          (mapcar #'fat-string
  -                  (nreverse del-lines)))
  -    (with-push-undo (buffer)
  -      (let ((linum linum)
  -            (pos pos))
  -        (do ((rest del-lines (cdr rest)))
  -            ((null rest))
  -          (buffer-insert-line buffer linum pos (car rest))
  -          (when (cdr rest)
  -            (buffer-insert-newline buffer linum
  -                                   (+ pos (length (car rest))))
  -            (incf linum)
  -            (setq pos 0)))
  -        (make-point linum pos)))
  -    del-lines))
  +                (setf (marker-charpos marker) pos))
  +               ((< linum (marker-linum marker))
  +                (decf (marker-linum marker)))))
  +           (setf (car del-lines)
  +                 (fat-concat (car del-lines)
  +                             (fat-substring (line-fatstr line) pos)))
  +           (unless (line-next line)
  +             (return))
  +           (push (make-fatstring "" 0) del-lines)
  +           (unless (eq n t)
  +             (decf n (1+ (- (fat-length (line-fatstr line)) pos))))
  +           (decf (buffer-nlines buffer))
  +           (setf (line-fatstr line)
  +                 (fat-concat (fat-substring (line-fatstr line) 0 pos)
  +                             (line-fatstr (line-next line))))
  +           (when (eq (line-next line)
  +                     (buffer-tail-line buffer))
  +             (setf (buffer-tail-line buffer) line))
  +           (line-free (line-next line)))))
  +      (setq del-lines
  +            (mapcar #'fat-string
  +                    (nreverse del-lines)))
  +      (with-push-undo (buffer)
  +        (let ((linum linum)
  +              (pos pos))
  +          (do ((rest del-lines (cdr rest)))
  +              ((null rest))
  +            (buffer-insert-line buffer linum pos (car rest))
  +            (when (cdr rest)
  +              (buffer-insert-newline buffer linum
  +                                     (+ pos (length (car rest))))
  +              (incf linum)
  +              (setq pos 0)))
  +          (make-point linum pos)))
  +      del-lines)))
   
   (defun buffer-erase (buffer)
     (buffer-delete-char buffer 1 0 t)
  
positive.code:   (setf (buffer-saved-node buffer) 0)
    nil)
  
  (defun buffer-modify (buffer)
    (setf (buffer-modified-p buffer)
          (if (buffer-modified-p buffer)
              (1+ (mod (buffer-modified-p buffer)
                       #.(floor most-positive-fixnum 2)))
              0)))
  
  (defun buffer-save-node (buffer)
    (setf (buffer-saved-node buffer)
          (buffer-undo-node buffer)))
  
negative.code:               (push-undo-stack ,buffer elt))
               (:undo
                (push-redo-stack ,buffer elt))))))))
  
  (defun buffer-line-set-attribute (line-set-fn buffer attr linum
                                    &optional start-charpos end-charpos)
  