diff options
author | Griffin Smith <grfn@gws.fyi> | 2020-06-22T14·03-0400 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2020-06-22T14·06+0000 |
commit | c7e0d962f0db1aeda96995d52c5c83546345fa05 (patch) | |
tree | 6388d5bfd358262f40dc7be9f2aae198aec01902 | |
parent | 5f018172eec4d7f831eca3f1122a25f2d0e65702 (diff) |
fix(org-gcal): Don't render LOCATION if there isn't one r/1063
previously it'd just render: :LOCATION: key not found: location Change-Id: I6454c1ef8c6c1096773978add1243097116d1e68 Reviewed-on: https://cl.tvl.fyi/c/depot/+/558 Reviewed-by: glittershark <grfn@gws.fyi>
-rw-r--r-- | users/glittershark/emacs.d/org-gcal.el | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/users/glittershark/emacs.d/org-gcal.el b/users/glittershark/emacs.d/org-gcal.el index d31e705269a4..183dfbd5a725 100644 --- a/users/glittershark/emacs.d/org-gcal.el +++ b/users/glittershark/emacs.d/org-gcal.el @@ -68,32 +68,40 @@ (defun event->org-headline (event level) (cl-flet ((make-time - (key) - (when-let ((raw-time (->> event (alist-get key) (alist-get 'dateTime)))) - (format-time-string - (org-time-stamp-format t) - (parse-iso8601-time-string raw-time))))) - (if-let ((start-time (make-time 'start)) - (end-time (make-time 'end))) - (s-format - "${headline} [[${htmlLink}][${summary}]] :event: + (key) + (when-let ((raw-time (->> event (alist-get key) (alist-get 'dateTime)))) + (format-time-string + (org-time-stamp-format t) + (parse-iso8601-time-string raw-time))))) + (if-let ((start-time (make-time 'start)) + (end-time (make-time 'end))) + (s-format + "${headline} [[${htmlLink}][${summary}]] :event: ${startTime}--${endTime} :PROPERTIES: -:LOCATION: ${location} +${location-prop} :EVENT: ${htmlLink} :END: ${description}" - (function - (lambda (k m) - (or (alist-get (intern k) m) - (format "key not found: %s" k)))) - (append - event - `((headline . ,(make-string level ?*)) - (startTime . ,start-time) - (endTime . ,end-time)))) - ""))) + (function + (lambda (k m) + (or (alist-get (intern k) m) + (format "key not found: %s" k)))) + (append + event + `((headline . ,(make-string level ?*)) + (startTime . ,start-time) + (endTime . ,end-time) + (location-prop + . ,(if-let ((location (alist-get 'location event))) + (s-lex-format ":LOCATION: ${location}") + ""))))) + ""))) + +(comment + (alist-get 'foo nil) + ) (defun write-events (events) (with-current-buffer (find-file-noselect events-file) |