aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2023-12-07 22:21:50 -0800
committerGravatar Tom Willemse2023-12-07 22:21:50 -0800
commitcf761c40a52d07500ed0b9d0307d5e01e29f553d (patch)
tree03dc6f6d6501901268810eb89092bcdd4681699b
parent8bd0ba25e46f0398c30b2e84c26dc7913c52b35f (diff)
downloadtekuti-el-cf761c40a52d07500ed0b9d0307d5e01e29f553d.tar.gz
tekuti-el-cf761c40a52d07500ed0b9d0307d5e01e29f553d.zip
Extract data parsing into separate function
-rw-r--r--tekuti.el21
1 files changed, 12 insertions, 9 deletions
diff --git a/tekuti.el b/tekuti.el
index c859396..9fbbbf9 100644
--- a/tekuti.el
+++ b/tekuti.el
@@ -56,6 +56,17 @@ with a ‘/’.")
(date-to-time date))
t))
+(defun tekuti--parse-data-keyword (pair)
+ "Ensure that both the key and value in PAIR match what tekuti needs."
+ (pcase pair
+ (`("DATE" ,date)
+ (list "DATE" (tekuti--format-date date)))
+ (`("COMMENTS_DATE" ,date)
+ (list "COMMENTS-CLOSED-DATE"
+ (and (not (string-empty-p date))
+ (tekuti--format-date date))))
+ (_ pair)))
+
(defun tekuti-build-data-from-org ()
"Parse the current org buffer to collect the necessary metadata."
(let ((defaults `(("TITLE")
@@ -67,15 +78,7 @@ with a ‘/’.")
("BODY")))
(data (append
(mapcar
- (lambda (pair)
- (pcase pair
- (`("DATE" ,date)
- (list "DATE" (tekuti--format-date date)))
- (`("COMMENTS_DATE" ,date)
- (list "COMMENTS-CLOSED-DATE"
- (and (not (string-empty-p date))
- (tekuti--format-date date))))
- (_ pair)))
+ #'tekuti--parse-data-keyword
(org-collect-keywords '("TITLE" "TAGS" "STATUS" "COMMENT_STATUS" "DATE" "COMMENTS_DATE")))
(list
(list "BODY"