summary refs log tree commit diff
path: root/mew.scm
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-12-01 21:03:45 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-12-01 22:56:31 +0100
commitf690959ef59004ba00d2d54073c9b8265e5b6d57 (patch)
treed8dd2698ae088bfe321fd40e3724cf376bfd68af /mew.scm
parent73b23b27998906ec479a995434ca5b664f0c0912 (diff)
downloadmew-f690959ef59004ba00d2d54073c9b8265e5b6d57.tar.gz
mew-f690959ef59004ba00d2d54073c9b8265e5b6d57.tar.xz
mew-f690959ef59004ba00d2d54073c9b8265e5b6d57.zip
add lines
Diffstat (limited to 'mew.scm')
-rw-r--r--mew.scm18
1 files changed, 17 insertions, 1 deletions
diff --git a/mew.scm b/mew.scm
index 7f491b9..4caebd1 100644
--- a/mew.scm
+++ b/mew.scm
@@ -11,7 +11,7 @@
      imp inc inject into
      juxt
      keys
-     len loc
+     len lines loc
      mod
      negate
      odometer one-of op op*
@@ -823,6 +823,22 @@
                                  (read-string #f (current-input-port)))))
           (else              (error "no slurp defined"))))
 
+  (define lines
+    (case-lambda
+      (() read-line)
+      ((x) (cond ((input-port? x)
+                  (lambda ()
+                    (read-line x)))
+                 ((string? x)
+                  (let ((file (open-input-file x)))
+                    (lambda ()
+                      (let ((line (read-line file)))
+                        (when (eof-object? line)
+                          (close-input-port file))
+                        line))))
+                 (else
+                  (error "can't read lines"))))))
+
   (define (hash-table->generator h)
     (make-for-each-generator (lambda (f t)
                                (hash-table-for-each t (lambda (k v)