mes: Add with-error-to-file.

* mes/module/mes/guile.mes (with-error-to-file): New function.
This commit is contained in:
Jan Nieuwenhuizen 2018-11-11 10:14:10 +01:00
parent 9da1fd92b6
commit e95c5742be
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 10 additions and 0 deletions

View File

@ -69,6 +69,16 @@
(set-current-output-port save)
r))))
(define (with-error-to-file file thunk)
(let ((port (open-output-file file)))
(if (= port -1)
(error 'cannot-open file)
(let* ((save (current-error-port))
(foo (set-current-error-port port))
(r (thunk)))
(set-current-error-port save)
r))))
(define (with-output-to-port port thunk)
(let* ((save (current-output-port))
(foo (set-current-output-port port))