; edit files in a repl


(define-top-level-value '*editor* "ed")
(define-top-level-value '*edfile* #f)

(define (ed . args)
  (if (pair? args) (set-top-level-value! '*edfile* (car args)))
  (if (not (top-level-value '*edfile*)) (error 'ed "file not found"))
  (system (string-append (top-level-value '*editor*) " " (top-level-value '*edfile*)))
  (load (top-level-value '*edfile*)))