emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [patch] add TTL as defcustom to ox-icalendar
@ 2021-12-30 21:59 Detlef Steuer
  2022-01-02 13:28 ` [patch] improved: " Detlef Steuer
  0 siblings, 1 reply; 6+ messages in thread
From: Detlef Steuer @ 2021-12-30 21:59 UTC (permalink / raw)
  To: emacs-orgmode

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

This is my first try ever to contribute anything in elisp.

The nextcloud calendar app supports the X-PUBLISHED-TTL 
option if subscribing to an ics file. Nextcloud defaults
to a TTL of 1 week, what is much too long for my use case.

When exporting to such a file from org I did not find any way
to set this option during export. So I tried to add a defcustom
in ox-icalendar.el.

The default TTL in this patch is 1 hour.

I think this qualifies as an tiny patch, as it is mostly a docstring
:-), in case anybody finds this an useful addition.

The patch is relative to 9.5.1 from elpa.

All comments very much appreciated.

And a happy new year to you all
Detlef

[-- Attachment #2: patch.ttl --]
[-- Type: text/turtle, Size: 1619 bytes --]

267a268,280
> (defcustom org-icalendar-ttl "PT1H"
>   "The time to life for the exported calendar.
> Subscribing clients to the exported ics file can derive the time interval
> to read the file again from the server. One example of such a client is
> the nextcloud calendar, which respects the setting of
> X-PUBLISHED-TTL, i.e. X-PUBLISHED-TTL:PT1H .
> 
> See https://icalendar.org/iCalendar-RFC-5545/3-8-2-5-duration.html
> for a complete description of possiblee values of this option. I.e.
> PT1H stands for 1 hour, PT0H27M34S for 0 hours, 27 minutes and 34 seconds."
>   :group 'org-export-icalendar
>   :type 'string)
> 
303c316,317
<     (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled))
---
>     (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled)
>     (:icalendar-ttl nil nil org-icalendar-ttl))
833c847
< (defun org-icalendar--vcalendar (name owner tz description contents)
---
> (defun org-icalendar--vcalendar (name owner tz description ttl contents)
835c849
< NAME, OWNER, TZ, DESCRIPTION and CONTENTS are all strings giving,
---
> NAME, OWNER, TZ, DESCRIPTION, TTL and CONTENTS are all strings giving,
837c851,852
< used, a short description and the other components included."
---
> used, a short description, the time-to-live resp. refresh period and 
> the other components included."
843a859
> X-PUBLISHED-TTL:%s
848c864,865
< 		  (org-icalendar-cleanup-string description))
---
> 		  (org-icalendar-cleanup-string description)
> 		  (org-icalendar-cleanup-string ttl))
976a994
> 	org-icalendar-ttl
1000a1019,1020
> 	      ;; TTL (Refresh period)
> 	      org-icalendar-ttl

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

* Re: [patch] improved: add TTL as defcustom to ox-icalendar
  2021-12-30 21:59 [patch] add TTL as defcustom to ox-icalendar Detlef Steuer
@ 2022-01-02 13:28 ` Detlef Steuer
  2022-01-03  6:08   ` Max Nikulin
  0 siblings, 1 reply; 6+ messages in thread
From: Detlef Steuer @ 2022-01-02 13:28 UTC (permalink / raw)
  To: emacs-orgmode

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

Improved patch since org-icalendar-template needed to use
the new variable, too.

And now based on 9.5.2 from elpa.

Detlef


Am Thu, 30 Dec 2021 22:59:19 +0100
schrieb Detlef Steuer <steuer@hsu-hh.de>:

> This is my first try ever to contribute anything in elisp.
> 
> The nextcloud calendar app supports the X-PUBLISHED-TTL 
> option if subscribing to an ics file. Nextcloud defaults
> to a TTL of 1 week, what is much too long for my use case.
> 
> When exporting to such a file from org I did not find any way
> to set this option during export. So I tried to add a defcustom
> in ox-icalendar.el.
> 
> The default TTL in this patch is 1 hour.
> 
> I think this qualifies as an tiny patch, as it is mostly a docstring
> :-), in case anybody finds this an useful addition.
> 
> The patch is relative to 9.5.1 from elpa.
> 
> All comments very much appreciated.
> 
> And a happy new year to you all
> Detlef


[-- Attachment #2: addttl.patch --]
[-- Type: text/x-patch, Size: 1666 bytes --]

267a268,280
> (defcustom org-icalendar-ttl "PT1H"
>   "The time to life for the exported calendar.
> Subscribing clients to the exported ics file can derive the time interval
> to read the file again from the server. One example of such a client is
> the nextcloud calendar, which respects the setting of
> X-PUBLISHED-TTL, i.e. X-PUBLISHED-TTL:PT1H .
> 
> See https://icalendar.org/iCalendar-RFC-5545/3-8-2-5-duration.html
> for a complete description of possiblee values of this option. I.e.
> PT1H stands for 1 hour, PT0H27M34S for 0 hours, 27 minutes and 34 seconds."
>   :group 'org-export-icalendar
>   :type 'string)
> 
303c316,317
<     (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled))
---
>     (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled)
>     (:icalendar-ttl nil nil org-icalendar-ttl))
830a845,846
>    ;; TTL
>    org-icalendar-ttl
833c849
< (defun org-icalendar--vcalendar (name owner tz description contents)
---
> (defun org-icalendar--vcalendar (name owner tz description ttl contents)
835c851
< NAME, OWNER, TZ, DESCRIPTION and CONTENTS are all strings giving,
---
> NAME, OWNER, TZ, DESCRIPTION, TTL and CONTENTS are all strings giving,
837c853,854
< used, a short description and the other components included."
---
> used, a short description, the time-to-live resp. refresh period and 
> the other components included."
843a861
> X-PUBLISHED-TTL:%s
848c866,867
< 		  (org-icalendar-cleanup-string description))
---
> 		  (org-icalendar-cleanup-string description)
> 		  (org-icalendar-cleanup-string ttl))
976a996
> 	org-icalendar-ttl
1000a1021,1022
> 	      ;; TTL (Refresh period)
> 	      org-icalendar-ttl

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

* Re: [patch] improved: add TTL as defcustom to ox-icalendar
  2022-01-02 13:28 ` [patch] improved: " Detlef Steuer
@ 2022-01-03  6:08   ` Max Nikulin
  2022-01-03  7:41     ` Detlef Steuer
  0 siblings, 1 reply; 6+ messages in thread
From: Max Nikulin @ 2022-01-03  6:08 UTC (permalink / raw)
  To: emacs-orgmode

On 02/01/2022 20:28, Detlef Steuer wrote:
> 
>> This is my first try ever to contribute anything in elisp.

Thanks for the patch. It is tracked on https://updates.orgmode.org/

It is easier to review and to apply a patch when it it is prepared in 
context format ("-u" option of diff). Several additional lines of code 
above and below changed ones makes the patch more tolerate to unrelated 
changes in the same file. It is a hint for humans as well.

See info "(diffutils) Tips for Patch Producers" 
https://www.gnu.org/software/diffutils/manual/html_node/Tips-for-Patch-Producers.html 
or "NOTES FOR PATCH SENDERS" section in "man patch".

If you have never used git (or other VCS) before then it is likely an 
overkill for a single patch, diff output with manually added description 
is OK. However you may find such tool rather convenient as number of 
changes will grow. See https://orgmode.org/worg/org-contribute.html for 
some hints addressed to contributors.

I am not a nextcloud or org-icalendar user, so while I expect that 
suggested change is an improvement, I can say nothing concerning the code.



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

* Re: [patch] improved: add TTL as defcustom to ox-icalendar
  2022-01-03  6:08   ` Max Nikulin
@ 2022-01-03  7:41     ` Detlef Steuer
  2022-01-03 11:23       ` Max Nikulin
  0 siblings, 1 reply; 6+ messages in thread
From: Detlef Steuer @ 2022-01-03  7:41 UTC (permalink / raw)
  To: emacs-orgmode

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

Thank you for the hints.

Attached a diff -u version.

The patch in principle is unrelated to nextcloud. That's just my
use case. The addiditional TTL setting gives a hint to clients
when to reload an imported ics file that was exported from org.

Is there any document how to setup an org-mode developer environment?
Normally I use git, but I even struggled to use org from elpa instead
of the built-in version, so I avoided touching this house of cards :-)

Probably I should use a git clone instead of elpa, if I want to work
on org?

Thx for the feedback!
Detlef



Am Mon, 3 Jan 2022 13:08:54 +0700
schrieb Max Nikulin <manikulin@gmail.com>:

> On 02/01/2022 20:28, Detlef Steuer wrote:
> >   
> >> This is my first try ever to contribute anything in elisp.  
> 
> Thanks for the patch. It is tracked on https://updates.orgmode.org/
> 
> It is easier to review and to apply a patch when it it is prepared in 
> context format ("-u" option of diff). Several additional lines of
> code above and below changed ones makes the patch more tolerate to
> unrelated changes in the same file. It is a hint for humans as well.
> 
> See info "(diffutils) Tips for Patch Producers" 
> https://www.gnu.org/software/diffutils/manual/html_node/Tips-for-Patch-Producers.html 
> or "NOTES FOR PATCH SENDERS" section in "man patch".
> 
> If you have never used git (or other VCS) before then it is likely an 
> overkill for a single patch, diff output with manually added
> description is OK. However you may find such tool rather convenient
> as number of changes will grow. See
> https://orgmode.org/worg/org-contribute.html for some hints addressed
> to contributors.
> 
> I am not a nextcloud or org-icalendar user, so while I expect that 
> suggested change is an improvement, I can say nothing concerning the
> code.
> 
> 


[-- Attachment #2: addttl.patch --]
[-- Type: text/x-patch, Size: 3177 bytes --]

--- ox-icalendar.el.orig	2022-01-02 13:38:17.586027624 +0100
+++ ox-icalendar.el	2022-01-02 14:12:10.446157056 +0100
@@ -265,6 +265,19 @@
 	  (const :tag "Universal time" ":%Y%m%dT%H%M%SZ")
 	  (string :tag "Explicit format")))
 
+(defcustom org-icalendar-ttl "PT1H"
+  "The time to life for the exported calendar.
+Subscribing clients to the exported ics file can derive the time interval
+to read the file again from the server. One example of such a client is
+the nextcloud calendar, which respects the setting of
+X-PUBLISHED-TTL, i.e. X-PUBLISHED-TTL:PT1H .
+
+See https://icalendar.org/iCalendar-RFC-5545/3-8-2-5-duration.html
+for a complete description of possiblee values of this option. I.e.
+PT1H stands for 1 hour, PT0H27M34S for 0 hours, 27 minutes and 34 seconds."
+  :group 'org-export-icalendar
+  :type 'string)
+
 (defvar org-icalendar-after-save-hook nil
   "Hook run after an iCalendar file has been saved.
 This hook is run with the name of the file as argument.  A good
@@ -300,7 +313,8 @@
     (:icalendar-store-UID nil nil org-icalendar-store-UID)
     (:icalendar-timezone nil nil org-icalendar-timezone)
     (:icalendar-use-deadline nil nil org-icalendar-use-deadline)
-    (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled))
+    (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled)
+    (:icalendar-ttl nil nil org-icalendar-ttl))
   :filters-alist
   '((:filter-headline . org-icalendar-clear-blank-lines))
   :menu-entry
@@ -828,24 +842,29 @@
      (cadr (current-time-zone)))
    ;; Description.
    (org-export-data (plist-get info :title) info)
+   ;; TTL
+   org-icalendar-ttl
    contents))
 
-(defun org-icalendar--vcalendar (name owner tz description contents)
+(defun org-icalendar--vcalendar (name owner tz description ttl contents)
   "Create a VCALENDAR component.
-NAME, OWNER, TZ, DESCRIPTION and CONTENTS are all strings giving,
+NAME, OWNER, TZ, DESCRIPTION, TTL and CONTENTS are all strings giving,
 respectively, the name of the calendar, its owner, the timezone
-used, a short description and the other components included."
+used, a short description, the time-to-live resp. refresh period and 
+the other components included."
   (concat (format "BEGIN:VCALENDAR
 VERSION:2.0
 X-WR-CALNAME:%s
 PRODID:-//%s//Emacs with Org mode//EN
 X-WR-TIMEZONE:%s
 X-WR-CALDESC:%s
+X-PUBLISHED-TTL:%s
 CALSCALE:GREGORIAN\n"
 		  (org-icalendar-cleanup-string name)
 		  (org-icalendar-cleanup-string owner)
 		  (org-icalendar-cleanup-string tz)
-		  (org-icalendar-cleanup-string description))
+		  (org-icalendar-cleanup-string description)
+		  (org-icalendar-cleanup-string ttl))
 	  contents
 	  "END:VCALENDAR\n"))
 
@@ -974,6 +993,7 @@
 	user-full-name
 	(or (org-string-nw-p org-icalendar-timezone) (cadr (current-time-zone)))
 	org-icalendar-combined-description
+	org-icalendar-ttl
 	contents)))
     (run-hook-with-args 'org-icalendar-after-save-hook file)))
 
@@ -998,6 +1018,8 @@
 		  (cadr (current-time-zone)))
 	      ;; Description.
 	      org-icalendar-combined-description
+	      ;; TTL (Refresh period)
+	      org-icalendar-ttl
 	      ;; Contents.
 	      (concat
 	       ;; Agenda contents.

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

* Re: [patch] improved: add TTL as defcustom to ox-icalendar
  2022-01-03  7:41     ` Detlef Steuer
@ 2022-01-03 11:23       ` Max Nikulin
  2022-01-03 11:32         ` Detlef Steuer
  0 siblings, 1 reply; 6+ messages in thread
From: Max Nikulin @ 2022-01-03 11:23 UTC (permalink / raw)
  To: emacs-orgmode

On 03/01/2022 14:41, Detlef Steuer wrote:
> 
> The patch in principle is unrelated to nextcloud. That's just my
> use case. The addiditional TTL setting gives a hint to clients
> when to reload an imported ics file that was exported from org.

I think, it is better to wait for comments from an ox-icalendar user. I 
am afraid, you will be tired trying to convince me that TTL should be 
overridden for all users (not to say that I am not a maintainer). I 
assume that some of them might have reasonable default in their server 
configuration.

> Is there any document how to setup an org-mode developer environment?
> Normally I use git, but I even struggled to use org from elpa instead
> of the built-in version, so I avoided touching this house of cards :-)

- info "(org) Installation" https://orgmode.org/manual/Installation.html
- info "(org) Feedback" https://orgmode.org/manual/Feedback.html

After "make autoloads" I usually run
     emacs -Q -L ~/src/org-mode/lisp test.org

In addition, I have a LXC container to run tests (and check for compile 
warnings) in an isolated environment.

> Probably I should use a git clone instead of elpa, if I want to work
> on org?

Maintainers prefer patches generated using "git format-patch".

>> https://orgmode.org/worg/org-contribute.html for some hints addressed
>> to contributors.

I am not completely sure, but you patch may exceed "TINYCHANGE" limit, 
so signing FSF copyright papers may be a prerequisite to accept your patch.




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

* Re: [patch] improved: add TTL as defcustom to ox-icalendar
  2022-01-03 11:23       ` Max Nikulin
@ 2022-01-03 11:32         ` Detlef Steuer
  0 siblings, 0 replies; 6+ messages in thread
From: Detlef Steuer @ 2022-01-03 11:32 UTC (permalink / raw)
  To: emacs-orgmode

Am Mon, 3 Jan 2022 18:23:43 +0700
schrieb Max Nikulin <manikulin@gmail.com>:

> On 03/01/2022 14:41, Detlef Steuer wrote:
> > 
> > The patch in principle is unrelated to nextcloud. That's just my
> > use case. The addiditional TTL setting gives a hint to clients
> > when to reload an imported ics file that was exported from org.  
> 
> I think, it is better to wait for comments from an ox-icalendar user.

Sure.

> I am afraid, you will be tired trying to convince me that TTL should
> be overridden for all users (not to say that I am not a maintainer).

No, that wasn't my intention. Just tried to explain.

> I assume that some of them might have reasonable default in their
> server configuration.
> 
> > Is there any document how to setup an org-mode developer
> > environment? Normally I use git, but I even struggled to use org
> > from elpa instead of the built-in version, so I avoided touching
> > this house of cards :-)  
> 
> - info "(org) Installation"
> https://orgmode.org/manual/Installation.html
> - info "(org) Feedback" https://orgmode.org/manual/Feedback.html
> 
> After "make autoloads" I usually run
>      emacs -Q -L ~/src/org-mode/lisp test.org
> 
> In addition, I have a LXC container to run tests (and check for
> compile warnings) in an isolated environment.
> 
> > Probably I should use a git clone instead of elpa, if I want to work
> > on org?  
> 
> Maintainers prefer patches generated using "git format-patch".
>

Ok, thx for the hints.

> >> https://orgmode.org/worg/org-contribute.html for some hints
> >> addressed to contributors.  
> 
> I am not completely sure, but you patch may exceed "TINYCHANGE"
> limit, so signing FSF copyright papers may be a prerequisite to
> accept your patch.
>

Hmm, probably a good idea anyway.

Regards
Detlef


> 
> 



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

end of thread, other threads:[~2022-01-03 11:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-30 21:59 [patch] add TTL as defcustom to ox-icalendar Detlef Steuer
2022-01-02 13:28 ` [patch] improved: " Detlef Steuer
2022-01-03  6:08   ` Max Nikulin
2022-01-03  7:41     ` Detlef Steuer
2022-01-03 11:23       ` Max Nikulin
2022-01-03 11:32         ` Detlef Steuer

Code repositories for project(s) associated with this 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).