From e903921f464ab1929063f776074a06093685a140 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 23 Sep 2021 01:03:41 +0530 Subject: gnbug: Abstract out string prefix removal. * gnbug (remove-prefix): New function. (file-details): Use remove-prefix. --- gnbug | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gnbug') diff --git a/gnbug b/gnbug index acf02af..caa474a 100755 --- a/gnbug +++ b/gnbug @@ -96,6 +96,10 @@ strings, and return them as a list." (map (cut string-trim-both <>) (string-split str #\,))) +(define (remove-prefix prefix str) + "Remove PREFIX from STR." + (substring str (string-length prefix))) + (define (file-details file) "Return a hashtable of details extracted from gemini FILE." (let ((result (make-eq-hashtable))) @@ -108,13 +112,13 @@ strings, and return them as a list." ((string-prefix? "* assigned:" line) (hashtable-append! result 'assigned (comma-split - (substring line (string-length "* assigned:"))))) + (remove-prefix "* assigned:" line)))) ;; The first level one heading is the ;; title. ((string-prefix? "# " line) (unless (hashtable-contains? result 'title) (hashtable-set! result 'title - (substring line (string-length "# ")))))))) + (remove-prefix "# " line))))))) (const #t) read-line port))) -- cgit v1.2.3