summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-07-09 00:17:19 +0530
committerArun Isaac2022-07-09 00:19:46 +0530
commit7e4ae17f1c12269e8c468ef8278150cbf1c621eb (patch)
tree0bcb3098ad0a3cbdb1955d0a3448edb8e5aa12f3
parent4a39e49241c57f5f44ea298d022cdaa812ef42f7 (diff)
downloadtissue-7e4ae17f1c12269e8c468ef8278150cbf1c621eb.tar.gz
tissue-7e4ae17f1c12269e8c468ef8278150cbf1c621eb.tar.lz
tissue-7e4ae17f1c12269e8c468ef8278150cbf1c621eb.zip
tissue: Delay index-documents field.
* tissue/tissue.scm: Import (ice-9 match). (<tissue-configuration>)[indexed-documents]: Rename getter to delayed-tissue-configuration-indexed-documents. (tissue-configuration-indexed-documents): New function. (pairify): New function. (tissue-configuration): Delay #:indexed-documents argument too. * tests/tissue.scm: New file.
-rw-r--r--tests/tissue.scm30
-rw-r--r--tissue/tissue.scm47
2 files changed, 60 insertions, 17 deletions
diff --git a/tests/tissue.scm b/tests/tissue.scm
new file mode 100644
index 0000000..6fb01fa
--- /dev/null
+++ b/tests/tissue.scm
@@ -0,0 +1,30 @@
+;;; tissue --- Text based issue tracker
+;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; This file is part of tissue.
+;;;
+;;; tissue is free software: you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; tissue is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with tissue. If not, see <https://www.gnu.org/licenses/>.
+
+(import (srfi srfi-64))
+
+(define pairify
+ (@@ (tissue tissue) pairify))
+
+(test-begin "tissue")
+
+(test-equal "pairify"
+ '((1 . 2) (3 . 4) (5 . 6))
+ (pairify (list 1 2 3 4 5 6)))
+
+(test-end "tissue")
diff --git a/tissue/tissue.scm b/tissue/tissue.scm
index 2fdd2ac..e7637b4 100644
--- a/tissue/tissue.scm
+++ b/tissue/tissue.scm
@@ -20,6 +20,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-71)
+ #:use-module (ice-9 match)
#:use-module (tissue git)
#:export (tissue-configuration
tissue-configuration?
@@ -36,10 +37,13 @@
tissue-configuration?
(project tissue-configuration-project)
(aliases tissue-configuration-aliases)
- (indexed-documents tissue-configuration-indexed-documents)
+ (indexed-documents delayed-tissue-configuration-indexed-documents)
(web-css tissue-configuration-web-css)
(web-files delayed-tissue-configuration-web-files))
+(define tissue-configuration-indexed-documents
+ (compose force delayed-tissue-configuration-indexed-documents))
+
(define tissue-configuration-web-files
(compose force delayed-tissue-configuration-web-files))
@@ -54,19 +58,26 @@ which directory they are in."
(string-suffix? ".gmi" filename)))
(git-tracked-files (current-git-repository))))
+(define (pairify lst)
+ "Return a list of pairs of successive elements of LST. For example,
+
+(pairify (list 1 2 3 4 5 6))
+=> ((1 . 2) (3 . 4) (5 . 6))"
+ (match lst
+ (() '())
+ ((first second tail ...)
+ (cons (cons first second)
+ (pairify tail)))))
+
(define-syntax tissue-configuration
(lambda (x)
(syntax-case x ()
((_ args ...)
- (let ((before after (break (lambda (arg)
- (eq? (syntax->datum arg)
- #:web-files))
- #'(args ...))))
- #`(apply (lambda* (#:key project (aliases '())
- (indexed-documents '())
- web-css (web-files (delay '())))
- "PROJECT is the name of the project. It is used in
-the title of the generated web pages, among other places.
+ #`((lambda* (#:key project (aliases '())
+ (indexed-documents (delay '()))
+ web-css (web-files (delay '())))
+ "PROJECT is the name of the project. It is used in the title of the
+generated web pages, among other places.
ALIASES is a list of aliases used to refer to authors in the
repository. Each element is in turn a list of aliases an author goes
@@ -81,10 +92,12 @@ used in the generated web pages.
WEB-FILES is a list of <file> objects representing files to be written
to the web output."
- (make-tissue-configuration project aliases indexed-documents web-css web-files))
- (list #,@(append before
- (syntax-case after ()
- ((web-files-key web-files rest ...)
- #`(web-files-key (delay web-files)
- rest ...))
- (() #'()))))))))))
+ (make-tissue-configuration project aliases
+ indexed-documents web-css web-files))
+ #,@(append-map (match-lambda
+ ((key . value)
+ (if (memq (syntax->datum key)
+ (list #:indexed-documents #:web-files))
+ #`(#,key (delay #,value))
+ #`(#,key #,value))))
+ (pairify #'(args ...))))))))