all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Detlef Steuer <steuer@hsu-hh.de>
To: emacs-orgmode@gnu.org
Subject: Re: [patch] improved: add TTL as defcustom to ox-icalendar
Date: Fri, 3 Feb 2023 14:25:08 +0100	[thread overview]
Message-ID: <20230203142508.4140679f@linux.fritz.box> (raw)
In-Reply-To: <87a62hihcg.fsf@localhost>

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

Am Tue, 17 Jan 2023 10:30:07 +0000
schrieb Ihor Radchenko <yantar92@posteo.net>:

> Detlef Steuer <steuer@hsu-hh.de> writes:
> 
> >> The patch only allows to the TTL globally for all the calendars.
> >> However, it would make sense to specify TTL on per-file basis.
> >> WDYT? 
> >
> > Hmm. Surely it would be useful to have the option to use different
> > TTL settings for different calendar exports, yes.
> >
> > The next question would be, if org-icalendar-combine-agenda-files is
> > called and the files have different per-file settings, which will be
> > used?  
> 
> The only sane way would be using the global default.
> 
> > May be single file org-icalendar-export-to-ics and
> > org-icalender-export-agenda-files use an existing per-file setting,
> > global setting otherwise, but org-icalendar-combine-agenda-files
> > always uses the global setting?  
> 
> Agree.
> 
> To achieve this you just need to update the export option settings:
> 
>     (:icalendar-ttl nil nil org-icalendar-ttl)
> 
> adding a file keyword to be used.
> See `org-export-options-alist' docstring.
> 

Hi Ihor, 

I hope I understood your advice and the docstring and examples in other
exporters correctly. Is it really that easy?

Next iteration of the patch.

Detlef


[-- Attachment #2: 0001-Add-TTL-to-icalendar-export-options.patch --]
[-- Type: text/x-patch, Size: 3398 bytes --]

From 0af9cf3d1e742271531f047f2ed0a690a81261c7 Mon Sep 17 00:00:00 2001
From: Detlef Steuer <detlef.steuer@hsu-hh.de>
Date: Fri, 3 Feb 2023 14:11:00 +0100
Subject: [PATCH 1/2] Add TTL to icalendar export options

---
 lisp/ox-icalendar.el | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
index 81a77a770..600eaae24 100644
--- a/lisp/ox-icalendar.el
+++ b/lisp/ox-icalendar.el
@@ -297,6 +297,21 @@ Interesting value are:
 	  (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.
+
+This option can also be set with the ICAL-TTL keyword."
+  :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
@@ -333,6 +348,7 @@ re-read the iCalendar file.")
     (: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-ttl "ICAL-TTL" nil org-icalendar-ttl)
     (:icalendar-scheduled-summary-prefix nil nil org-icalendar-scheduled-summary-prefix)
     (:icalendar-deadline-summary-prefix nil nil org-icalendar-deadline-summary-prefix))
   :filters-alist
@@ -872,13 +888,16 @@ as a communication channel."
    (or (org-string-nw-p org-icalendar-timezone) (format-time-string "%Z"))
    ;; 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
@@ -1018,6 +1037,7 @@ This function assumes major mode for current buffer is
 	user-full-name
 	(or (org-string-nw-p org-icalendar-timezone) (format-time-string "%Z"))
 	org-icalendar-combined-description
+	org-icalendar-ttl
 	contents)))
     (run-hook-with-args 'org-icalendar-after-save-hook file)))
 
@@ -1042,6 +1062,8 @@ FILES is a list of files to build the calendar from."
 		  (format-time-string "%Z"))
 	      ;; Description.
 	      org-icalendar-combined-description
+	      ;; TTL (Refresh period)
+	      org-icalendar-ttl
 	      ;; Contents.
 	      (concat
 	       ;; Agenda contents.
-- 
2.39.1


[-- Attachment #3: 0002-Add-entry-for-new-org-icalendar-ttl-option-to-ORG-NE.patch --]
[-- Type: text/x-patch, Size: 1363 bytes --]

From 2a1376457a7d09b6586bea55061aa0aa99509106 Mon Sep 17 00:00:00 2001
From: Detlef Steuer <detlef.steuer@hsu-hh.de>
Date: Fri, 3 Feb 2023 14:20:52 +0100
Subject: [PATCH 2/2] Add entry for new org-icalendar-ttl option to ORG-NEWS

---
 etc/ORG-NEWS | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 40477e73f..c10f95d67 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -24,6 +24,23 @@ consider [[https://gitlab.com/jackkamm/ob-python-mode-mode][ob-python-mode-mode]
 has been ported to.
 
 ** New and changed options
+*** New custom setting ~org-icalendar-ttl~ for the ~ox-icalendar~ backend
+
+The option ~org-icalendar-ttl~ allows to advise a subscriber to the
+exported ~.ics~ file to reload after the given time interval.
+
+This is useful i.e. if a calendar server subscribes to your exported
+file and that file is updated regularly.
+
+See IETF RFC 5545, Section 3.3.6 Duration, and
+https://en.wikipedia.org/wiki/ICalendar#Other_component_types for
+details.
+
+Default for ~org-icalendar-ttl~ is nil.  In that case the setting will
+not be used in the exported ICS file.
+
+The option may also be set using the ICAL-TTL keyword.
+
 *** ~org-clock-x11idle-program-name~ now defaults to =xprintidle=, when available
 
 When =xprintidle= executable is available at =org-clock= load time, it
-- 
2.39.1


  reply	other threads:[~2023-02-03 13:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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
2022-11-09  6:57           ` Ihor Radchenko
     [not found]             ` <20221109082520.066dc4c6@linux.fritz.box>
2022-11-09  7:58               ` Ihor Radchenko
2022-11-09  8:32                 ` Bastien Guerry
     [not found]               ` <20230113181035.1469ab37@hsu-hh.de>
     [not found]                 ` <878ri52z06.fsf@localhost>
2023-01-16 22:42                   ` Detlef Steuer
2023-01-17  9:43                     ` Ihor Radchenko
2023-01-17 10:03                       ` Detlef Steuer
2023-01-17 10:30                         ` Ihor Radchenko
2023-02-03 13:25                           ` Detlef Steuer [this message]
2023-02-04 11:09                             ` Ihor Radchenko
2023-02-04 21:01                               ` Detlef Steuer
2023-02-05 11:09                                 ` Ihor Radchenko
2024-01-27  5:00                                   ` Jack Kamm
2024-01-28 13:42                                     ` Ihor Radchenko
2024-01-28 21:50                                       ` Jack Kamm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230203142508.4140679f@linux.fritz.box \
    --to=steuer@hsu-hh.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.