summary refs log tree commit diff
path: root/gnbug
diff options
context:
space:
mode:
authorArun Isaac2021-09-19 12:08:08 +0530
committerBonfaceKilz2021-09-20 10:31:42 +0300
commit3670a06746387e245d13b78d4014c610e5d9a9ce (patch)
tree3db97f4444ff57069ed8874203981387362c19e6 /gnbug
parentb7cbc9b95cc86439834fb4b1ca0a8ce8c141ddfd (diff)
downloadgn-gemtext-3670a06746387e245d13b78d4014c610e5d9a9ce.tar.gz
gnbug: Sort issues by creation date, newest first.
* gnbug (issues): Sort issues by creation date, newest first.
Diffstat (limited to 'gnbug')
-rwxr-xr-xgnbug39
1 files changed, 21 insertions, 18 deletions
diff --git a/gnbug b/gnbug
index fd9d8d1..b814477 100755
--- a/gnbug
+++ b/gnbug
@@ -57,27 +57,30 @@ even if it exits non-locally. Return the value returned by PROC."
   (assigned issue-assigned))
 
 (define (issues)
-  "Return a list of all issues."
+  "Return a list of all issues, sorted newest first."
   ;; Get all gemini files except README.gmi and hidden files. Text
   ;; editors tend to create hidden files while editing, and we want to
   ;; avoid them.
-  (map (lambda (file)
-         (let ((file-details (file-details file))
-               (creation-details (creation-details file)))
-           (issue file
-                  ;; Fallback to filename if title has no alphabetic
-                  ;; characters.
-                  (let ((title (hashtable-ref file-details 'title "")))
-                    (if (string-any char-set:letter title) title file))
-                  (assq-ref creation-details 'creator)
-                  (assq-ref creation-details 'created-date)
-                  (assq-ref creation-details 'created-relative-date)
-                  (hashtable-ref file-details 'assigned '()))))
-       (find-files "."
-                   (lambda (name _)
-                     (and (string-suffix? ".gmi" name)
-                          (not (string=? (basename name) "README.gmi"))
-                          (not (string-prefix? "." (basename name))))))))
+  (sort (map (lambda (file)
+               (let ((file-details (file-details file))
+                     (creation-details (creation-details file)))
+                 (issue file
+                        ;; Fallback to filename if title has no alphabetic
+                        ;; characters.
+                        (let ((title (hashtable-ref file-details 'title "")))
+                          (if (string-any char-set:letter title) title file))
+                        (assq-ref creation-details 'creator)
+                        (assq-ref creation-details 'created-date)
+                        (assq-ref creation-details 'created-relative-date)
+                        (hashtable-ref file-details 'assigned '()))))
+             (find-files "."
+                         (lambda (name _)
+                           (and (string-suffix? ".gmi" name)
+                                (not (string=? (basename name) "README.gmi"))
+                                (not (string-prefix? "." (basename name)))))))
+        (lambda (issue1 issue2)
+          (> (issue-created-date issue1)
+             (issue-created-date issue2)))))
 
 (define (file-details file)
   "Return a hashtable of details extracted from gemini FILE."