From f7ed0ce8a3c9f23c31c71b47f344c9b90cfc30fb Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 23 Sep 2021 00:46:21 +0530 Subject: gnbug: Abstract out hashtable-append!. * gnbug (hashtable-append!): New function. (file-details): Use hashtable-append!. --- gnbug | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gnbug b/gnbug index 7bfd828..7e86438 100755 --- a/gnbug +++ b/gnbug @@ -83,6 +83,13 @@ even if it exits non-locally. Return the value returned by PROC." (> (issue-created-date issue1) (issue-created-date issue2))))) +(define (hashtable-append! hashtable key new-values) + "Append NEW-VALUES to the list of values KEY is associated to in +HASHTABLE. If KEY is not associated to any value in HASHTABLE, assume +it is associated to the empty list." + (hashtable-update! + hashtable key (cut append <> new-values) '())) + (define (file-details file) "Return a hashtable of details extracted from gemini FILE." (let ((result (make-eq-hashtable))) @@ -93,14 +100,11 @@ even if it exits non-locally. Return the value returned by PROC." ;; Lists with the assigned: prefix ;; specify assignees. ((string-prefix? "* assigned:" line) - (hashtable-update! result 'assigned - (lambda (previous) - (append (map (cut string-trim-both <>) - (string-split - (substring line (string-length "* assigned:")) - #\,)) - previous)) - '())) + (hashtable-append! result 'assigned + (map (cut string-trim-both <>) + (string-split + (substring line (string-length "* assigned:")) + #\,)))))) ;; The first level one heading is the ;; title. ((string-prefix? "# " line) -- cgit v1.2.3