summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2021-09-23 00:46:21 +0530
committerArun Isaac2021-09-23 14:16:47 +0530
commitf7ed0ce8a3c9f23c31c71b47f344c9b90cfc30fb (patch)
tree6abd9c8055bd81651eacd737bbd6bd1930e474c3
parentae4a4bb349ccc2d609f59b02d530adf0051b15ca (diff)
downloadgn-gemtext-f7ed0ce8a3c9f23c31c71b47f344c9b90cfc30fb.tar.gz
gnbug: Abstract out hashtable-append!.
* gnbug (hashtable-append!): New function. (file-details): Use hashtable-append!.
-rwxr-xr-xgnbug20
1 files 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)