dengste / org-caldav

Caldav sync for Emacs orgmode
GNU General Public License v3.0
719 stars 105 forks source link

Importing cal events with SCHEDULED/DEADLINE labels #300

Open nshan651 opened 4 months ago

nshan651 commented 4 months ago

Hi, I was wondering if there was a way to automatically add SCHEDULED/DEADLINE properties when importing cal events to org mode. I am able to easily do it the other way around, where org mode exports the events and prepends "S:" or "D:" to the event on my nextcloud calendar.

Ideally, it would be nice to be able to add "S:" or "D:" to remote calendar events and then for them to get properly inserted in my inbox.org. For example, if on nextcloud I added the following:

new event -> "TODO Testing nextcloud to org" -> from 05/16/2024 at 6:00 PM to to 05/16/2024 at 8:00 PM

Then after syncing, my inbox.org would show this TODO item:

* TODO Testing nextcloud to org
SCHEDULED: <2024-05-16 Thu 18:00-20:00>
:PROPERTIES:
:ID:       5963df3e-6065-4fa3-bc82-954650ce47c3
:END:

I'm pretty sure this functionality would be handled by org-icalendar, but I'm having trouble finding info on customizing the import behavior. Any suggestions or resources on this would be greatly appreciated :)

Just to be thorough, here's my current config:

  (use-package org-caldav
    :ensure t
    :custom
    ;; URL of the caldav server
    (org-caldav-url "http://me.somedomain.org/remote.php/dav/calendars/me")

    ;; calendar ID on server
    (org-caldav-calendar-id "personal")

    ;; Org filename where new entries from calendar stored
    (org-caldav-inbox "~/org/agenda/inbox.org")

    ;; Additional Org files to check for calendar events
    (org-caldav-files nil)

    ;; Usually a good idea to set the timezone manually
    (org-icalendar-timezone "America/Chicago")

    ;; TODO
    (org-caldav-sync-todo t)
    (org-caldav-todo-deadline-schedule-warning-days t)

    (org-icalendar-include-todo 'all)
    (org-icalendar-use-deadline '(event-if-todo event-if-not-todo todo-due))
    (org-icalendar-use-scheduled '(event-if-todo event-if-not-todo todo-start))
    (org-icalendar-with-timestamps t))

Thanks!

jackkamm commented 4 months ago

Org-caldav does not work with the event-if-todo and event-if-not-todo settings.

The problem is that ox-icalendar will export the Org entry as multiple distinct icalendar entries (separate events for the SCHEDULED and DEADLINE). This is problematic for bidirectional sync. In particular, org-caldav assumes a 1-to-1 mapping between Org and Icalendar IDs, and things will break when this assumption is violated.

See this issue for related discussion: https://github.com/dengste/org-caldav/issues/267

On Org-caldav side, we should document the incompatibility with these settings; issue warnings/errors when they are detected; and implement missing features for todo-due and todo-start (in particular recurring todos) so that users don't resort to the event-if-todo setting.