emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Patch that enables visibility settings in org-mode iCalendar export
@ 2017-08-14 18:49 Tobias Schlemmer
  2017-08-17 16:09 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Tobias Schlemmer @ 2017-08-14 18:49 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

for some reasons I need to control the visibility of individual entries
of my caldav calendars. I have implemented a small patch that passes the
`CLASS' propery to the iCalendar export:

https://github.com/keinstein/org-mode/pull/1

I'd like to have this patch integrated in the short term. It is mostly
done by cut and paste from the same file.

For long term I think a configurable framework would be more useful:

• It would be helpful to have a configuration variable that tells which
properties are passed more or less verbatim as iCalendar fields
• It would be helpful to save some/all other fields with some prefix
(X-ORG-MODE-…) in the calendar file/service. The prefix should be
configurable as well as the list of saved properties.
• A mapping between org-mode properties and iCalendar fields could be
helpful. Together with some default action all of the above could be
realized with only two variables.

I'm not familiar enough with Lisp to do the work by myself. So this is a
pure feature request.

Tobias

P.S.: Please add me to CC for all discussions as I'm not on the mailing
list.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch that enables visibility settings in org-mode iCalendar export
  2017-08-14 18:49 Patch that enables visibility settings in org-mode iCalendar export Tobias Schlemmer
@ 2017-08-17 16:09 ` Nicolas Goaziou
  2017-08-17 19:39   ` Eric Abrahamsen
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2017-08-17 16:09 UTC (permalink / raw)
  To: Tobias Schlemmer; +Cc: emacs-orgmode

Hello,

Tobias Schlemmer <keinstein.junior@gmail.com> writes:

> for some reasons I need to control the visibility of individual entries
> of my caldav calendars. I have implemented a small patch that passes the
> `CLASS' propery to the iCalendar export:
>
> https://github.com/keinstein/org-mode/pull/1
>
> I'd like to have this patch integrated in the short term. It is mostly
> done by cut and paste from the same file.

Thank you!

Could you send a patch on this mailing list using git's "format-patch"
sub-command?

Also, could you document the feature in org.texi.

> For long term I think a configurable framework would be more useful:
>
> • It would be helpful to have a configuration variable that tells which
> properties are passed more or less verbatim as iCalendar fields

This doesn't sound too hard, if you have a list of such properties and
are willing to document them.

> • It would be helpful to save some/all other fields with some prefix
> (X-ORG-MODE-…) in the calendar file/service. The prefix should be
> configurable as well as the list of saved properties.

What use-case do you have in mind ?

> • A mapping between org-mode properties and iCalendar fields could be
> helpful. Together with some default action all of the above could be
> realized with only two variables.

Could you elaborate a bit?


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Patch that enables visibility settings in org-mode iCalendar export
  2017-08-17 16:09 ` Nicolas Goaziou
@ 2017-08-17 19:39   ` Eric Abrahamsen
  2017-08-18  9:13     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Abrahamsen @ 2017-08-17 19:39 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1610 bytes --]

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Hello,
>
> Tobias Schlemmer <keinstein.junior@gmail.com> writes:
>
>> for some reasons I need to control the visibility of individual entries
>> of my caldav calendars. I have implemented a small patch that passes the
>> `CLASS' propery to the iCalendar export:
>>
>> https://github.com/keinstein/org-mode/pull/1
>>
>> I'd like to have this patch integrated in the short term. It is mostly
>> done by cut and paste from the same file.
>
> Thank you!
>
> Could you send a patch on this mailing list using git's "format-patch"
> sub-command?
>
> Also, could you document the feature in org.texi.
>
>> For long term I think a configurable framework would be more useful:
>>
>> • It would be helpful to have a configuration variable that tells which
>> properties are passed more or less verbatim as iCalendar fields
>
> This doesn't sound too hard, if you have a list of such properties and
> are willing to document them.

Hey, now's the time to bring up something I've wanted to do for a while:
adding support for per-entry timezones to the ical export. I've attached
a draft patch that shows what I mean. Basically you give an entry a
TIMEZONE property in the tz database format (eg "Europe/London") and it
will pass that on to the DTSTART/DTEND properties.

I suppose it would also be possible to have separate properties for
start and end timezones, then we could do plane trips!

Further work would be necessary to pass this through org-caldav
correctly, but it's a first step.

If this works out, I'll do a proper commit with docs and all that.

Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ox-ical-timezones.patch --]
[-- Type: text/x-diff, Size: 5311 bytes --]

diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
index ba7a62f8b..a955469b5 100644
--- a/lisp/ox-icalendar.el
+++ b/lisp/ox-icalendar.el
@@ -341,7 +341,7 @@ A headline is blocked when either
 		   (1- (length org-icalendar-date-time-format))) ?Z))
 
 (defvar org-agenda-default-appointment-duration) ; From org-agenda.el.
-(defun org-icalendar-convert-timestamp (timestamp keyword &optional end utc)
+(defun org-icalendar-convert-timestamp (timestamp keyword &optional end tz)
   "Convert TIMESTAMP to iCalendar format.
 
 TIMESTAMP is a timestamp object.  KEYWORD is added in front of
@@ -352,8 +352,11 @@ Also increase the hour by two (if time string contains a time),
 or the day by one (if it does not contain a time) when no
 explicit ending time is specified.
 
-When optional argument UTC is non-nil, time will be expressed in
-Universal Time, ignoring `org-icalendar-date-time-format'."
+When optional argument TZ is non-nil, timezone data time will be
+added to the timestamp.  It can be the string \"UTC\", to use UTC
+time, or a string in the IANA TZ database
+format (e.g. \"Europe/London\").  In either case, the value of
+`org-icalendar-date-time-format' will be ignored."
   (let* ((year-start (org-element-property :year-start timestamp))
 	 (year-end (org-element-property :year-end timestamp))
 	 (month-start (org-element-property :month-start timestamp))
@@ -387,8 +390,9 @@ Universal Time, ignoring `org-icalendar-date-time-format'."
     (concat
      keyword
      (format-time-string
-      (cond (utc ":%Y%m%dT%H%M%SZ")
+      (cond ((string-equal tz "UTC") ":%Y%m%dT%H%M%SZ")
 	    ((not with-time-p) ";VALUE=DATE:%Y%m%d")
+	    ((stringp tz) (concat ";TZID=" tz ":%Y%m%dT%H%M%S"))
 	    (t (replace-regexp-in-string "%Z"
 					 org-icalendar-timezone
 					 org-icalendar-date-time-format
@@ -396,7 +400,10 @@ Universal Time, ignoring `org-icalendar-date-time-format'."
       ;; Convert timestamp into internal time in order to use
       ;; `format-time-string' and fix any mistake (i.e. MI >= 60).
       (encode-time 0 mi h d m y)
-      (and (or utc (and with-time-p (org-icalendar-use-UTC-date-time-p)))
+      (and (or (string-equal tz "UTC")
+	       (and (null tz)
+		    with-time-p
+		    (org-icalendar-use-UTC-date-time-p)))
 	   t)))))
 
 (defun org-icalendar-dtstamp ()
@@ -545,7 +552,8 @@ inlinetask within the section."
 			  contents 0 (min (length contents)
 					  org-icalendar-include-body))))
 		      (org-icalendar-include-body (org-trim contents)))))))
-	     (cat (org-icalendar-get-categories entry info)))
+	     (cat (org-icalendar-get-categories entry info))
+	     (tz (org-element-property :TIMEZONE entry)))
 	 (concat
 	  ;; Events: Delegate to `org-icalendar--vevent' to generate
 	  ;; "VEVENT" component from scheduled, deadline, or any
@@ -556,14 +564,14 @@ inlinetask within the section."
 		       org-icalendar-use-deadline)
 		 (org-icalendar--vevent
 		  entry deadline (concat "DL-" uid)
-		  (concat "DL: " summary) loc desc cat)))
+		  (concat "DL: " summary) loc desc cat tz)))
 	  (let ((scheduled (org-element-property :scheduled entry)))
 	    (and scheduled
 		 (memq (if todo-type 'event-if-todo 'event-if-not-todo)
 		       org-icalendar-use-scheduled)
 		 (org-icalendar--vevent
 		  entry scheduled (concat "SC-" uid)
-		  (concat "S: " summary) loc desc cat)))
+		  (concat "S: " summary) loc desc cat tz)))
 	  ;; When collecting plain timestamps from a headline and its
 	  ;; title, skip inlinetasks since collection will happen once
 	  ;; ENTRY is one of them.
@@ -581,7 +589,7 @@ inlinetask within the section."
 			   ((t) t)))
 		   (let ((uid (format "TS%d-%s" (cl-incf counter) uid)))
 		     (org-icalendar--vevent
-		      entry ts uid summary loc desc cat))))
+		      entry ts uid summary loc desc cat tz))))
 	       info nil (and (eq type 'headline) 'inlinetask))
 	     ""))
 	  ;; Task: First check if it is appropriate to export it.  If
@@ -626,7 +634,7 @@ inlinetask within the section."
        contents))))
 
 (defun org-icalendar--vevent
-    (entry timestamp uid summary location description categories)
+    (entry timestamp uid summary location description categories timezone)
   "Create a VEVENT component.
 
 ENTRY is either a headline or an inlinetask element.  TIMESTAMP
@@ -635,7 +643,8 @@ is the unique identifier for the event.  SUMMARY defines a short
 summary or subject for the event.  LOCATION defines the intended
 venue for the event.  DESCRIPTION provides the complete
 description of the event.  CATEGORIES defines the categories the
-event belongs to.
+event belongs to.  If TIMEZONE is non-nil, use the specified
+timezone for this event only.
 
 Return VEVENT component as a string."
   (org-icalendar-fold-string
@@ -645,8 +654,8 @@ Return VEVENT component as a string."
      (concat "BEGIN:VEVENT\n"
 	     (org-icalendar-dtstamp) "\n"
 	     "UID:" uid "\n"
-	     (org-icalendar-convert-timestamp timestamp "DTSTART") "\n"
-	     (org-icalendar-convert-timestamp timestamp "DTEND" t) "\n"
+	     (org-icalendar-convert-timestamp timestamp "DTSTART" nil timezone) "\n"
+	     (org-icalendar-convert-timestamp timestamp "DTEND" t timezone) "\n"
 	     ;; RRULE.
 	     (when (org-element-property :repeater-type timestamp)
 	       (format "RRULE:FREQ=%s;INTERVAL=%d\n"

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Patch that enables visibility settings in org-mode iCalendar export
  2017-08-17 19:39   ` Eric Abrahamsen
@ 2017-08-18  9:13     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2017-08-18  9:13 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-orgmode

Hello,

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Hey, now's the time to bring up something I've wanted to do for
> a while:

I think this deserves its own thread.

> adding support for per-entry timezones to the ical export. 

It sounds good.

> I've attached a draft patch that shows what I mean. Basically you give
> an entry a TIMEZONE property in the tz database format (eg
> "Europe/London") and it will pass that on to the DTSTART/DTEND
> properties.
>
> I suppose it would also be possible to have separate properties for
> start and end timezones, then we could do plane trips!

Right. But since Org doesn't support time zones, the usefulness may be
limited.

> +When optional argument TZ is non-nil, timezone data time will be
> +added to the timestamp.  It can be the string \"UTC\", to use UTC
> +time, or a string in the IANA TZ database
> +format (e.g. \"Europe/London\").  In either case, the value of
> +`org-icalendar-date-time-format' will be ignored."

I suggest to have symbol t as an equivalent to "UTC", for compatibility
with, e.g., ZONE in `format-time-string'.

Thank you for the work.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-18  9:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-14 18:49 Patch that enables visibility settings in org-mode iCalendar export Tobias Schlemmer
2017-08-17 16:09 ` Nicolas Goaziou
2017-08-17 19:39   ` Eric Abrahamsen
2017-08-18  9:13     ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).