emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Improving Emacs' iCalendar support


From: Richard Lawrence
Subject: Re: Improving Emacs' iCalendar support
Date: Wed, 23 Oct 2024 11:01:26 +0200

Hi Ihor,

Ihor Radchenko <yantar92@posteo.net> writes:

> Some kind of icalendar parser could be useful.

Great to know you'd be interested in this!

> In Org mode, we currently do icalendar export by hand-writing iCalendar
> entries as strings and need to be careful about things like line endings
> and special symbols.

Yes. 

> What could be done instead is some kind of Elisp API similar to
> `xml-parse-region' and `xml-print', so that things like escaping
> symbols, exact literals, newlines, etc are handled behind the scenes, and
> we could instead just define an AST and "print" it into a valid
> iCalendar file.
>
> So, my suggestion would be something akin xml.el and maybe (optionally)
> https://github.com/ndwarshuis/org-ml - to manipulate the AST.

Thank you, this is a very useful suggestion. I wasn't aware that xml.el
had an API like this -- I will take a look.

At the moment, I am drafting a set of data structures that the parser
will produce, and the printer will consume. Following Adam's suggestion,
I've been basing these on cl-structs (except for simple atomic values). So
eventually you should be able to write code that's something like this:

(icalendar-make-vevent
  ;; properties:
  (list (icalendar-make-property "DTSTART"
           (icalendar-datetime-from-timestamp some-lisp-timestamp))
        (icalendar-make-property "DTEND"
           (icalendar-datetime-from-timestamp some-other-timestamp)))
  ;; subcomponents:
  (list (icalendar-make-valarm ...))
  ...)
           

and get a struct back that you could then send directly to a function
like 'icalendar-print-component' or similar. Does that seem like a
reasonable approach, or is it already too cumbersome? (Would you prefer
e.g. to just be able to write the appropriate data structure as a
backquoted (p)list?)

Best,
Richard



reply via email to

[Prev in Thread] Current Thread [Next in Thread]