Ihor Radchenko <yanta...@gmail.com> writes:

>> I have noticed that properties that stretch over multiple lines using 
>> the :value+: syntax are ignored by org-element-property and therefore 
>> also by e.g. org-export-get-node-property when exporting to ics via 
>> ox-icalendar.el (see example below). I was wondering now whether this is 
>> intentional and to be expected or a bug?

> 3. Change ox-icalendar to consider :LOCATION+ properties and merge them
>    during export.

I went with this approach.
See the attached tentative patch.

CCing Jack - you expressed interest in ox-icalendar in the past.

P.S. We need a maintainer for ox-icalendar ;)

>From 84fb56dcbccc2c99be4fed172184c25cfe2a3395 Mon Sep 17 00:00:00 2001
Message-ID: <84fb56dcbccc2c99be4fed172184c25cfe2a3395.1705922024.git.yanta...@posteo.net>
From: Ihor Radchenko <yanta...@posteo.net>
Date: Mon, 22 Jan 2024 12:12:16 +0100
Subject: [PATCH] ox-icalendar: Add support for multi-line SUMMARY, LOCATION,
 and DESCRIPTION

* lisp/ox-icalendar.el (org-icalendar-entry): Use `org-entry-get' to
account for both PROP and PROP+ in SUMMARY, LOCATION, and DESCRIPTION
properties.  Use newline as accumulated value separator.
* etc/ORG-NEWS (iCalendar export now supports multiline =SUMMARY=,
=LOCATION=, and =DESCRIPTION= properties): Announce the breaking
change.

Reported-by: Hanno Perrey <ha...@hoowl.se>
Link: https://orgmode.org/list/87o821dv7o.fsf@localhost
---
 etc/ORG-NEWS         | 26 ++++++++++++++++++++++++++
 lisp/ox-icalendar.el | 19 +++++++++++--------
 2 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 847ddf614..dc6886318 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -13,6 +13,32 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
 
 * Version 9.7 (not released yet)
 ** Important announcements and breaking changes
+*** iCalendar export now supports multiline =SUMMARY=, =LOCATION=, and =DESCRIPTION= properties
+
+Previously, it was not possible to specify multi-line location,
+summary, or description when exporting to iCalendar.
+
+In the following example, =LOCATION= was exported as "Someplace",
+ignoring the other lines.
+
+#+begin_src org
+,* heading with multi-line property
+:PROPERTIES:
+:LOCATION: Someplace
+:LOCATION+: Some Street 5
+:LOCATION+: 12345 Small Town
+:END:
+#+end_src
+
+Now, =SUMMARY+=, =LOCATION+=, and =DESCRIPTION+= properties can be
+used to create multi-line values.
+
+In the above example, =LOCATION= is now exported as
+
+: Someplace
+: Some Street 5
+: 12345 Small Town
+
 *** ~org-agenda-search-headline-for-time~ now ignores all the timestamp in headings
 
 Previously, ~org-agenda-search-headline-for-time~ made Org agenda
diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
index 3dd2c88d8..f6513563d 100644
--- a/lisp/ox-icalendar.el
+++ b/lisp/ox-icalendar.el
@@ -643,13 +643,15 @@ (defun org-icalendar-entry (entry contents info)
        (let ((todo-type (org-element-property :todo-type entry))
 	     (uid (or (org-element-property :ID entry) (org-id-new)))
 	     (summary (org-icalendar-cleanup-string
-		       (or (org-element-property :SUMMARY entry)
-			   (org-export-data
-			    (org-element-property :title entry) info))))
-	     (loc (org-icalendar-cleanup-string
-		   (org-export-get-node-property
-		    :LOCATION entry
-		    (org-property-inherit-p "LOCATION"))))
+		       (or
+                        (let ((org-property-separators '(("SUMMARY" . "\n"))))
+                          (org-entry-get entry "SUMMARY"))
+			(org-export-data
+			 (org-element-property :title entry) info))))
+	     (loc
+              (let ((org-property-separators '(("LOCATION" . "\n"))))
+                (org-icalendar-cleanup-string
+                 (org-entry-get entry "LOCATION" 'selective))))
 	     (class (org-icalendar-cleanup-string
 		     (org-export-get-node-property
 		      :CLASS entry
@@ -658,7 +660,8 @@ (defun org-icalendar-entry (entry contents info)
 	     ;; (headline) or contents (inlinetask).
 	     (desc
 	      (org-icalendar-cleanup-string
-	       (or (org-element-property :DESCRIPTION entry)
+	       (or (let ((org-property-separators '(("DESCRIPTION" . "\n"))))
+                     (org-entry-get entry "DESCRIPTION"))
 		   (let ((contents (org-export-data inside info)))
 		     (cond
 		      ((not (org-string-nw-p contents)) nil)
-- 
2.43.0

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to