Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions org-caldav.el
Original file line number Diff line number Diff line change
Expand Up @@ -1404,10 +1404,11 @@ Do nothing if LEVEL is larger than `org-caldav-debug-level'."
(point-min))))

(defun org-caldav-insert-org-entry (start-d start-t end-d end-t
summary description location e-type
summary description location e-type freq
&optional uid level)
"Insert org block from given data at current position.
START/END-D: Start/End date. START/END-T: Start/End time.
FREQ: Start org datetime with recursive option.
SUMMARY, DESCRIPTION, LOCATION, UID: obvious.
Dates must be given in a format `org-read-date' can parse.

Expand All @@ -1418,7 +1419,7 @@ If LEVEL is nil, it defaults to 1.
Returns MD5 from entry."
(insert (make-string (or level 1) ?*) " " summary "\n")
(insert (if org-adapt-indentation " " "")
(org-caldav-create-time-range start-d start-t end-d end-t e-type) "\n")
(org-caldav-create-time-range start-d start-t end-d end-t e-type freq) "\n")
(when (> (length description) 0)
(insert " " description "\n"))
(forward-line -1)
Expand All @@ -1431,8 +1432,8 @@ Returns MD5 from entry."
(org-entry-beginning-position)
(org-entry-end-position))))

(defun org-caldav-create-time-range (start-d start-t end-d end-t e-type)
"Creeate an Org timestamp range from START-D/T, END-D/T."
(defun org-caldav-create-time-range (start-d start-t end-d end-t e-type freq)
"Create an Org timestamp range from START-D/T, END-D/T."
(with-temp-buffer
(cond
((string= "S" e-type) (insert "SCHEDULED: "))
Expand All @@ -1448,6 +1449,8 @@ Returns MD5 from entry."
;; Same day, different time.
(backward-char 1)
(insert "-" end-t)))
(when freq
(insert " " freq))
(buffer-string)))

(defun org-caldav-insert-org-time-stamp (date &optional time)
Expand Down Expand Up @@ -1614,7 +1617,7 @@ If COMPLEMENT is non-nil, return all item without errors."
;; The LOCATION property is added the extracted list
(defun org-caldav-convert-event ()
"Convert icalendar event in current buffer.
Returns a list '(start-d start-t end-d end-t summary description location)'
Returns a list '(start-d start-t end-d end-t summary description location freq)'
which can be fed into `org-caldav-insert-org-entry'."
(let ((decoded (decode-coding-region (point-min) (point-max) 'utf-8 t)))
(erase-buffer)
Expand Down Expand Up @@ -1651,14 +1654,21 @@ which can be fed into `org-caldav-insert-org-entry'."
(summary (icalendar--convert-string-for-import
(or (icalendar--get-event-property e 'SUMMARY)
"No Title")))
e-type
e-type
(description (icalendar--convert-string-for-import
(or (icalendar--get-event-property e 'DESCRIPTION)
"")))
(location (icalendar--convert-string-for-import
(or (icalendar--get-event-property e 'LOCATION)
"")))
(rrule (icalendar--get-event-property e 'RRULE))
(freq (when (and rrule (string-match ".*FREQ=\\(.*\\);" rrule))
(concat "+" (save-match-data
(if (string-match ".*INTERVAL=\\(.*\\);.*" rrule)
(match-string 1 rrule) "1"))
(save-match-data
(and (string-match ".*FREQ=\\(.*\\);.*" rrule)
(downcase (substring (match-string 1 rrule) 0 1)))))))
(rdate (icalendar--get-event-property e 'RDATE))
(duration (icalendar--get-event-property e 'DURATION)))
(if (string-match "^\\(?:\\(DL\\|S\\):\s+\\)?\\(.*\\)$" summary)
Expand Down Expand Up @@ -1703,7 +1713,7 @@ which can be fed into `org-caldav-insert-org-entry'."
;; Return result
(list start-d start-t
(if end-t end-d end-1-d)
end-t summary description location e-type)))
end-t summary description location e-type freq)))

;; This is adapted from url-dav.el, written by Bill Perry.
;; This does more error checking on the headers and retries
Expand Down