anchor.diff:    ;;             entered.  The current address is set  to  the  last  line
     ;;             printed.
     (with-addresses (buffer (curr from 1) (last to 1))
  -    (DO-PRINT-LINES BUFFER curr last
  -                    (LAMBDA (LINUM LINE)
  -                      (DECLARE (IGNORE LINUM))
  -                      (FORMAT *TERMINAL-IO* "~A~%" LINE))))
  -  ) ;;CMD-PRINT-LINES
  -
  -
  -(DEFUN CMD-PRINT-LINES-AND-NUMBERS (BUFFER FROM TO ARG)
  +    (do-print-lines buffer curr last
  +                    (lambda (linum line)
  +                      (declare (ignore linum))
  +                      (format *terminal-io* "~A~%" line)))))
  +
  +
  +(defun cmd-print-lines-and-numbers (buffer from to arg)
     (declare (ignore arg))
  -  (DBG (FORMAT T "CMD-PRINT-LINES-AND-NUMBERS: ~%"))
  +  (dbg (format t "CMD-PRINT-LINES-AND-NUMBERS: ~%"))
     ;;     (.,.)n  Prints the addressed lines along with their line numbers.
     ;;             The current address is set to the last line printed.
     ;;
     (with-addresses (buffer (curr from 1) (last to 1))
  -    (DO-PRINT-LINES BUFFER curr last
  -                    (LAMBDA (LINUM LINE)
  -                      (FORMAT *TERMINAL-IO* "~6D  ~A~%" LINUM LINE))))
  -  ) ;;CMD-PRINT-LINES-AND-NUMBERS
  +    (do-print-lines buffer curr last
  +                    (lambda (linum line)
  +                      (format *terminal-io* "~6D  ~A~%" linum line)))))
   
      
  -(DEFUN CMD-PRINT-LINES-UNAMBIGUOUSLY (BUFFER FROM TO ARG)
  +(defun cmd-print-lines-unambiguously (buffer from to arg)
     (declare (ignore arg))
  -  (DBG (FORMAT T "CMD-PRINT-LINES-UNAMBIGUOUSLY: ~%"))
  +  (dbg (format t "CMD-PRINT-LINES-UNAMBIGUOUSLY: ~%"))
     ;;     (.,.)l  Prints  the  addressed  lines  unambiguously.  If invoked
     ;;             from a terminal, ed pauses at the end of each page  until
     ;;             a  newline is entered.  The current address is set to the
     ;;             last line printed.
     (with-addresses (buffer (curr from 1) (last to 1))
  -    (DO-PRINT-LINES
  -        BUFFER curr last
  -        (LAMBDA (LINUM LINE)
  -          (DECLARE (IGNORE LINUM))
  -          (DO ((I 0 (1+ I))
  -               (CH))
  -              ((>= I (LENGTH LINE)) (FORMAT *TERMINAL-IO* "$~%"))
  -            (SETQ CH (CHAR LINE I))
  -            (IF (GRAPHIC-CHAR-P CH)
  -                (format *TERMINAL-IO* "~C" ch)
  -                (LET ((ASS (ASSOC (CHAR-CODE CH)
  +    (do-print-lines
  +        buffer curr last
  +        (lambda (linum line)
  +          (declare (ignore linum))
  +          (do ((i 0 (1+ i))
  +               (ch))
  +              ((>= i (length line)) (format *terminal-io* "$~%"))
  +            (setq ch (char line i))
  +            (if (graphic-char-p ch)
  +                (format *terminal-io* "~C" ch)
  +                (let ((ass (assoc (char-code ch)
                                     '((7 . "a") (8 . "b") (9 . "t")
                                       (10 . "l") (11 . "v") (12 . "f")
                                       (13 . "r")))))
  -                  (IF ASS
  -                      (FORMAT *TERMINAL-IO* "\\~A" (CDR ASS))
  -                      (FORMAT *TERMINAL-IO* "\\~3,'0O" (CHAR-CODE CH)))))))))
  -  ) ;;CMD-PRINT-LINES-UNAMBIGUOUSLY
  -
  -
  -(DEFUN CMD-SUBSTITUTE (BUFFER FROM TO ARG)
  +                  (if ass
  +                      (format *terminal-io* "\\~A" (cdr ass))
  +                      (format *terminal-io* "\\~3,'0O" (char-code ch))))))))))
  +
  +
  +(defun cmd-substitute (buffer from to arg)
     (declare (ignore buffer from to arg)) ;; TODO: implement this function.
  -  (DBG (FORMAT T "CMD-SUBSTITUTE: ~%"))
  +  (dbg (format t "CMD-SUBSTITUTE: ~%"))
     ;; (.,.)s/re/replacement/
     ;; (.,.)s/re/replacement/g
     ;; (.,.)s/re/replacement/n
  
positive.code:            :input (subseq (buffer-lines buffer) curr (1+ last))))
          ((:invalid) (buffer-set-error buffer path))
          (otherwise
           (buffer-set-error buffer "Internal error: FILE-OR-COMMAND-ARG")))))
    ) ;;cmd-write-or-append
  
  
  (DEFUN CMD-APPEND-FILE (BUFFER FROM TO ARG)
    (DBG (FORMAT T "CMD-APPEND-FILE: ~%"))
    ;; (1,$)W file
    ;;         Appends  the addressed lines to the end of file.  This is
    ;;         similar to the `w' command, expect that the previous con-
    ;;         tents  of  file is not clobbered.  The current address is
    ;;         unchanged.
    (cmd-write-or-append buffer from to arg :append)
    ) ;;CMD-APPEND-FILE
  
  
  (DEFUN CMD-WRITE-FILE (BUFFER FROM TO ARG)
    (DBG (FORMAT T "CMD-WRITE-FILE: ~%"))
    ;; (1,$)w file
    ;;         Writes  the  addressed  lines to file.  Any previous con-
    ;;         tents of file is lost without warning.  If  there  is  no
  
negative.code:          (setf (buffer-modified ,buffer) nil)
           (buffer-set-error ,buffer "Warning: file modified"))
         (progn
           ,@body)))
  
  
  ;; (progn (PJB-CL+INDENT with-addresses 1)(PJB-CL+INDENT unless-modified 1))
  
  (defun do-insert (buffer linum)
    (dbg (format t "DO-INSERT(~S ~S) ~%" "buffer" linum))
    (do ((place (buffer-line-cons buffer linum) (cdr place))
         (line  (read-line *terminal-io* nil ".")
                (read-line *terminal-io* nil "."))
         (curr  linum (1+ curr)))
        ((string= line ".")
         (progn
           (setf (buffer-current-linum buffer) curr)
           (buffer-offset-marks buffer linum (- curr linum))))
      (setf (cdr place) (cons line (cdr place)))))
  
  
  (defun do-paste (buffer linum new-lines)
    (dbg (format t "DO-PASTE(~S ~S [~D lines]) ~%"
                 "buffer" linum (length new-lines)))
    (let* ((insert-point (buffer-line-cons buffer linum))
           (after        (cdr insert-point)))
      (setf (buffer-current-linum buffer) (+ linum (length new-lines)))
      (setf (cdr insert-point) new-lines)
      (setf (cdr (last new-lines)) after)))
  
  
  (defun do-cut (buffer from last)
    "
  RETURN: The list of cut lines.
  "
    (dbg (format t "DO-CUT(~S ~S ~S) ~%" "buffer" from last))
    (let* ((delete-point (buffer-line-cons buffer (1- from)))
           (after-point  (buffer-line-cons buffer  last))
           (result       (cdr delete-point)))
      (setf (buffer-current-linum buffer)
            (if (null (cdr after-point)) from (1+ from)))
      (setf (cdr delete-point) (cdr after-point)
            (cdr after-point) nil)
      (buffer-offset-marks buffer from (- last from -1))
      result))
  
  
  (defun do-print-lines (buffer curr last func)
    (dbg (format t " DO-PRINT-LINES(~S ~S ~S [a function]) ~%" "buffer" curr last))
    (setf (buffer-print buffer) nil)
    (do* ((curr curr (1+ curr))
          (lines (buffer-line-cons buffer curr) (cdr lines)))
         ((> curr last)
          (setf (buffer-current-linum buffer) last))
      (funcall func curr (car lines))))
  
  
  (defun do-write (buffer path mode from last)
    (dbg (format t "DO-WRITE(~S ~S ~S ~S ~S) ~%" "buffer" path mode from last))
    (handler-case
        (with-open-file (output path :direction :output :if-exists mode
                                :if-does-not-exist :create)
  