(define-options (gemrefinder) `((my-posts "Gemini URL to a page with links to your own posts, to watch" (single-char #\p) (value #t)) (limit "Only check this many lines. Defaults to 20." (single-char #\m) (value (required "limit") (transformer ,string->number)) (default 20)) (cert "Trust certificates once or always? Default once." (single-char #\j) (value #t) (default 'once)))) (define (url->lines url) (string-split (run/string (gmni -j ,cert ,url)) "\n")) (define ((take-up-to lim) lis) (take lis (min lim (length lis)))) (define starts (call-key*)) (define matching (call-key*)) (for-each (fn (strse x (: bos "=>" (+ space) (+ graph) (+ space) (? (: (= 4 num) #\- (= 2 num) #\- (= 2 num) (+ space) (? "-") (* space))) (? (w/nocase "Re: ")) ($ (+ (~ "\n\r")))) (then (starts ((as-list (take-up-to 15)) (m 1)))))) ((take-up-to limit) (url->lines my-posts))) (define (string-append-tree str) (list str)) (define (string-append-tree (prefix . strings)) (map (c string-append prefix) (append-map string-append-tree strings))) (define pages (map url->lines (string-append-tree '("gemini://" "warmedal.se/~antenna/" "nytpu.com/feed.gmi" "calcuode.com/gmisub-aggregate.gmi" "gemini.circumlunar.space/capcom/" ("nightfall.city/" "main-street/" "dusks-end/" "writers-lane/"))))) (do-ec (: startre ((over `(w/nocase (: bos "=>" (+ space) (+ graph) (+ space) (*? nonl) "Re: " ,x (* nonl)))) (starts))) (: page pages) ;; TODO: if "pages" is inlined, do-ec borks. prints whitespace. (: line page) (strse line startre (then (matching (m 0))))) (eif (delete-duplicates (matching) (bi-each string=? (fn (strse x (: bos "=>" (+ space) (=> url (+ graph)) (+ space)) url 0)))) (begin (print "# What's that buzz?\n") (for-each print it)) (print "No matches"))