aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-06-25 22:35:48 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-06-25 22:35:48 +0200
commitb9ce4240a4d729b051acab17896f4102e0fbf123 (patch)
treec0d5ca30f5563a2302a7b055b46e084c60e50787
parentAdd minor todo. (diff)
downloadcalp-b9ce4240a4d729b051acab17896f4102e0fbf123.tar.gz
calp-b9ce4240a4d729b051acab17896f4102e0fbf123.tar.xz
Move stuff from output/ical to output/common./
-rw-r--r--module/output/common.scm42
-rw-r--r--module/output/ical.scm23
2 files changed, 43 insertions, 22 deletions
diff --git a/module/output/common.scm b/module/output/common.scm
new file mode 100644
index 00000000..c501bcae
--- /dev/null
+++ b/module/output/common.scm
@@ -0,0 +1,42 @@
+;;; Commentary:
+;; Common code between all serializers.
+;; (ical and xcal). Not for graphical output stuff.
+;;; Code:
+
+(define-module (output common)
+ :use-module (util)
+ )
+
+;; TODO this is also defined @ (vcomponent parse component)
+(define-public (x-property? symb)
+ (string=? "X-" (string-take (symbol->string symb) 2)))
+
+;; TODO this is also defined twice
+(define (generate-uuid)
+ ((@ (rnrs io ports) call-with-port)
+ ((@ (ice-9 popen) open-input-pipe) "uuidgen")
+ (@ (ice-9 rdelim) read-line)))
+
+(define*-public (internal-field? symbol optional: (prefix "X-HNH-"))
+ (string=? prefix
+ (string-take-to (symbol->string symbol)
+ (string-length prefix))))
+
+(define-public (->string a)
+ (with-output-to-string (lambda () (display a))))
+
+(define-public (get-tz-names events)
+ (lset-difference
+ equal? (lset-union
+ equal? '("dummy")
+ (filter-map
+ (lambda (vline) (and=> (prop vline 'TZID) car))
+ (filter-map (extract* 'DTSTART)
+ events)))
+ '("dummy" "local")))
+
+(define-public (downcase-symbol symb)
+ (-> symb
+ symbol->string
+ string-downcase
+ string->symbol))
diff --git a/module/output/ical.scm b/module/output/ical.scm
index 7773cce7..013de5fb 100644
--- a/module/output/ical.scm
+++ b/module/output/ical.scm
@@ -15,11 +15,9 @@
:use-module (glob)
:use-module (vcomponent recurrence)
:use-module (output types)
+ :use-module (output common)
)
-;; TODO this is also defined @ (vcomponent parse component)
-(define (x-property? symb)
- (string=? "X-" (string-take (symbol->string symb) 2)))
;; Format value depending on key type.
;; Should NOT emit the key.
@@ -94,10 +92,6 @@
fallback-string)
fallback-string)))
-(define (generate-uuid)
- ((@ (rnrs io ports) call-with-port)
- ((@ (ice-9 popen) open-input-pipe) "uuidgen")
- (@ (ice-9 rdelim) read-line)))
;; Fold long lines to limit width.
;; Since this works in characters, but ics works in bytes
@@ -113,13 +107,7 @@
(ical-line-fold (string-drop string wrap-len)))]
[else string]))
-(define* (internal-field? symbol optional: (prefix "X-HNH-"))
- (string=? prefix
- (string-take-to (symbol->string symbol)
- (string-length prefix))))
-(define (->string a)
- (with-output-to-string (lambda () (display a))))
(define (vline->string vline)
(define key (vline-key vline))
@@ -206,15 +194,6 @@ CALSCALE:GREGORIAN\r
(format #t "END:VCALENDAR\r\n"))
-(define (get-tz-names events)
- (lset-difference
- equal? (lset-union
- equal? '("dummy")
- (filter-map
- (lambda (vline) (and=> (prop vline 'TZID) car))
- (filter-map (extract* 'DTSTART)
- events)))
- '("dummy" "local")))
(define-public (print-components-with-fake-parent events)