anchor.diff:                         (vector-push-extend ch (buffer stream))
                          (write-char ch stream)
                          (incf (cursor-position stream))
  -                       (setf (line-end-position stream) (multiple-value-list (sys.int::stream-cursor-pos stream))))
  +                       (setf (line-end-position stream) (multiple-value-list (sys.int::stream-cursor-pos stream)))
  +                       (setf (last-command stream) ch))
                         (t ;; Writing into the middle of the line requires a redraw.
                          ;; Ensure space.
                          (vector-push-extend ch (buffer stream))
  
positive.code:                                       :adjustable t)
            (cursor-position stream) (length data))))
  
  (define-command previous-history (stream (#\M-P #\Up-Arrow))
    (cond ((history-position stream)
           (let ((prev (history-previous (history-table stream) (history-position stream))))
             (when prev
               (setf (history-position stream) prev)
               (set-from-history stream))))
          (t (setf (history-position stream) (history-newest (history-table stream)))
             (when (history-position stream)
               (set-from-history stream)))))
  
  (define-command next-history (stream (#\M-N #\Down-Arrow))
    (cond ((history-position stream)
           (let ((next (history-next (history-table stream) (history-position stream))))
             (cond (next
                    (setf (history-position stream) next)
                    (set-from-history stream))
                   (t (setf (history-position stream) nil
                            (fill-pointer (buffer stream)) 0
                            (cursor-position stream) 0)))))
          (t (history-add (history-table stream) (make-array (length (buffer stream))
                                                             :element-type 'character
                                                             :initial-contents (buffer stream)))
             (setf (history-position stream) nil
                   (fill-pointer (buffer stream)) 0
                   (cursor-position stream) 0))))
  
  (define-command forward-delete-char (stream (#\Delete #\C-D))
    "Delete one character forward."
  
negative.code:                        ;; Advance cursor.
                         (incf (cursor-position stream))
                         ;; Redraw.
                         (redraw-line stream)
                         (setf (last-command stream) ch))))))))
  