dengste / org-caldav

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

Sync items with both SCHEDULED and DEADLINE timestamps #121

Open rgemulla opened 7 years ago

rgemulla commented 7 years ago

If a TODO item has a SCHEDULED and a DEADLINE timestamp, I won't be able to see both of them in the calendar due to the design on org-caldav.

When both timestamps are present, org-caldav seems to sync the one that appears earlier. Since org puts DEADLINE before SCHEDULED, the deadline shows up. To me, it would be more usable if my calendar showed the scheduled timestamp instead (and the deadline only when not scheduled).

Is it possible to achieve such a behavior?

grauschnabel commented 7 years ago

Could you provide your config for this behavior?

rgemulla commented 7 years ago

Sure! The relevant part is: ;; sync entries for DEADLINE and SCHEDULED tags (setq 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))

grauschnabel commented 7 years ago

ok, so in this way this seems to be an issue with org-icalendar, the file that org-icalendar creates will be parsed item for item and sent to your remote calendar (when new or changed). To use both, deadline and scheduled would correspond to make 2 calendar entries, but org-icalendar does not create them. So org-caldav does not have the possibility to do that.

In your case, the easiest way would be to create a function that sets the right order of the properties and run it before the export.

Or maybe better see org-export-before-parsing-hook - icalendar export works on a copy of your files. Create a function which just removes the deadline if a scheduled is present and append it to the hook. This might be the easiest way. The hook is used from org-caldav as well, so you could find an example there.

Good luck!

rgemulla commented 7 years ago

org-icalandar does create two events for such a headline: one with summary "S: headline", another one with "D: headline". From this, org-caldav detects a duplicate id and syncs only one of them.

In any case, your suggested fix should work for export and is quick to do. For importing, do you have any idea on what would happen when I "move" such an item in the remote calendar? Would the change be synced back to SCHEDULED as desired? Or would DEADLINE be changed?

grauschnabel commented 7 years ago

Ok, So I was wrong. org-caldav uses org-icalendar for export, but the import is fully done in its code. But I don't think there is any support for todo from outside in.

For me, I decided do use nextcloud and on my phone DAVdroid with opentasks for that I needed to make some changes to the org-caldav code. I don't really know if this works with google in any way, but you could try my fork: https://github.com/grauschnabel/org-caldav (which is also there as a pull request)

With my setting it works great with scheduled and deadline. I just don't have it in the calendar but in an extra widget on my phone. I really recommend any testers for google, so fixes will be fast (at the moment).

rgemulla commented 7 years ago

Yes, that's a sensible approach. For me, however, I'd like scheduled items to show up in my calendar so that I do not overbook.

I can see why org-caldav focuses on only one active timestamp per headline. If there were more, and all of those would be synched, synchronization hell breaks loose when there are any changes.

So for now, I guess I can't sensibly use SCHEDULED and DEADLINE together.

grauschnabel commented 7 years ago

Yes, unless you put your hand on the code...

rgemulla commented 7 years ago

My point is that this is easier said than done.

It's likely easy to implement syncing from org to the remote calender. But when anything is changed on the remote calender, backward synchronization is tough to get right.