Skip to content

Commit

Permalink
Fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
telotortium committed Feb 22, 2022
1 parent cfde24a commit 064e483
Showing 1 changed file with 37 additions and 17 deletions.
54 changes: 37 additions & 17 deletions org-gcal.el
Original file line number Diff line number Diff line change
Expand Up @@ -1489,8 +1489,8 @@ AIO version: see ‘org-gcal--sync-buffer-inner-aio’."
nil skip-export
(org-gcal--sync-get-update-existing)))))
(error
(message "org-gcal-sync-buffer: event %S: error: %S"
time-desc err)))
(message "org-gcal-sync-buffer: at %S event %S: error: %s"
marker-for-post time-desc err)))
marker)))
nil)))))
nil)
Expand Down Expand Up @@ -1908,8 +1908,8 @@ For valid values of EXISTING-MODE see
Returns a promise to wait for completion."
(interactive)
(let ((marker (point-marker)))
(org-gcal--aio-wait-for-background-interactive
(aio-iter2-with-async
(org-gcal--aio-wait-for-background-interactive
(aio-iter2-with-async
(aio-await (org-gcal--ensure-token-aio))
(org-with-point-at marker
;; Post entry at point in org-agenda buffer.
Expand All @@ -1923,9 +1923,17 @@ Returns a promise to wait for completion."
(let* ((skip-import skip-import)
(skip-export skip-export)
(elem (org-element-headline-parser (point-max) t))
(smry (substring-no-properties
(org-get-heading 'no-tags 'no-todo 'no-priority 'no-comment)))
(smry (org-gcal--headline))
(loc (org-entry-get (point) "LOCATION"))
(source
(when-let ((link-string
(or (org-entry-get (point) "link")
(nth 0
(org-entry-get-multivalued-property
(point) "ROAM_REFS")))))
(org-gcal--source-from-link-string link-string)))
(transparency (or (org-entry-get (point) "TRANSPARENCY")
org-gcal-default-transparency))
(recurrence (org-entry-get (point) "recurrence"))
(event-id (org-gcal--get-id (point)))
(etag (org-entry-get (point) org-gcal-etag-property))
Expand All @@ -1943,8 +1951,15 @@ Returns a promise to wait for completion."
;; Fill in Calendar ID if not already present.
(unless calendar-id
(setq calendar-id
(completing-read "Calendar ID: "
(mapcar #'car org-gcal-file-alist)))
;; Completes read with prompts like "CALENDAR-FILE (CALENDAR-ID)",
;; and then uses ‘replace-regexp-in-string’ to extract just
;; CALENDAR-ID.
(replace-regexp-in-string
".*(\\(.*?\\))$" "\\1"
(completing-read "Calendar ID: "
(mapcar
(lambda (x) (format "%s (%s)" (cdr x) (car x)))
org-gcal-fetch-file-alist))))
(org-entry-put (point) org-gcal-calendar-id-property calendar-id))
(when (equal managed "gcal")
(unless existing-mode
Expand Down Expand Up @@ -1996,8 +2011,8 @@ Returns a promise to wait for completion."
(setq start nil end nil))
(aio-await
(org-gcal--post-event-aio
start end smry loc desc
calendar-id marker etag event-id
start end smry loc source desc
calendar-id marker transparency etag event-id
nil skip-import skip-export)))))
nil))))

Expand Down Expand Up @@ -2799,9 +2814,12 @@ Returns an ‘aio-promise’ for a ‘request-response' object."
((not (eq error-thrown nil))
(org-gcal--notify
(concat "Status code: " (number-to-string status-code))
(pp-to-string error-thrown))
(error "org-gcal--get-event: Got error %S for %s %s: %S"
status-code calendar-id event-id error-thrown))
(format "%s %s: %s"
calendar-id
event-id
(pp-to-string error-thrown)))
(error "org-gcal--get-event-aio: Got error %S for %s %s: %S"
status-code calendar-id event-id error-thrown))
;; Fetch was successful.
(t response))))

Expand Down Expand Up @@ -2966,7 +2984,7 @@ Returns a ‘aio-promise’ object that can be used to wait for completion."
(concat
(org-gcal-events-url calendar-id)
(when event-id
(concat "/" event-id)))
(concat "/" (url-hexify-string event-id))))
:type (cond
(skip-export "GET")
(event-id "PATCH")
Expand All @@ -2978,7 +2996,9 @@ Returns a ‘aio-promise’ object that can be used to wait for completion."
(cond
((null etag) nil)
((null event-id)
(error "Event cannot have ETag set when event ID absent"))
(error "org-gcal--post-event-aio: %s %s %s: %s"
(point-marker) calendar-id event-id
"Event cannot have ETag set when event ID absent"))
(t
`(("If-Match" . ,etag)))))
:parser 'org-gcal--json-read
Expand Down Expand Up @@ -3017,8 +3037,8 @@ Returns a ‘aio-promise’ object that can be used to wait for completion."
"Received HTTP 401"
"OAuth token expired. Now trying to refresh-token")
(aio-await (org-gcal--refresh-token-aio))
(aio-await (org-gcal--post-event-aio start end smry loc desc calendar-id
marker etag event-id nil
(aio-await (org-gcal--post-event-aio start end smry loc source desc calendar-id
marker etag transparency event-id nil
skip-import skip-export)))
;; ETag on current entry is stale. This means the event on the
;; server has been updated. In that case, update the event using
Expand Down

0 comments on commit 064e483

Please sign in to comment.