From a38d033f0e3f8b936e450e91afd1736ab263454f Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 23 Sep 2021 01:02:35 +0530 Subject: gnbug: Abstract out splitting on commas. * gnbug (comma-split): New function. (file-details): Use comma-split. --- gnbug | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gnbug b/gnbug index 7e86438..acf02af 100755 --- a/gnbug +++ b/gnbug @@ -90,6 +90,12 @@ it is associated to the empty list." (hashtable-update! hashtable key (cut append <> new-values) '())) +(define (comma-split str) + "Split string at commas, trim whitespace from both ends of the split +strings, and return them as a list." + (map (cut string-trim-both <>) + (string-split str #\,))) + (define (file-details file) "Return a hashtable of details extracted from gemini FILE." (let ((result (make-eq-hashtable))) @@ -101,10 +107,8 @@ it is associated to the empty list." ;; specify assignees. ((string-prefix? "* assigned:" line) (hashtable-append! result 'assigned - (map (cut string-trim-both <>) - (string-split - (substring line (string-length "* assigned:")) - #\,)))))) + (comma-split + (substring line (string-length "* assigned:"))))) ;; The first level one heading is the ;; title. ((string-prefix? "# " line) -- cgit v1.2.3