mes: Add with-error-to-file.
authorJan Nieuwenhuizen <janneke@gnu.org>
Sun, 11 Nov 2018 09:14:10 +0000 (10:14 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sun, 11 Nov 2018 09:14:10 +0000 (10:14 +0100)
* mes/module/mes/guile.mes (with-error-to-file): New function.

mes/module/mes/guile.mes

index ab1e2455438557b058aa731401d6189bd3c0316f..a730bdd97370ff15a5abbcfaf23c57e1b189cf62 100644 (file)
           (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))