Subject: bug#56241: [PATCH] icalendar doesn't correctly process arbitrary diary sexp entries

From: Brendan O'Dea <[email-masked]>
Date: Tue, 4 Jul 2023 20:29:03 +1000

On Wed, Nov 23, 2022 at 09:24:45PM +0100, Ulf Jasper wrote:
>I added a test to icalendar-tests.el that verifies that patch
>0001-Fix-detecting-dotted-pairs.patch works as expected.

Note that this test is failing on both the current 'master' and
'emacs-29' branch (excerpt, full log attached):

  "Error in line 0 -- (error Could not parse date): `%%(icalendar-tests--diary-float 7 0 1) First Sunday in July 2'\n"
  FAILED  25/42  icalendar-export-bug-56241-dotted-pair (0.003671 sec) at lisp/calendar/icalendar-tests.el:1000

>From what I can tell, the problem is that while these calls look like
they should be identical:

  (diary-float 7 0 1)
  (icalendar-tests--diary-float 7 0 1)  ;; calls diary-float

in practice, they are handled by different code paths:

  icalendar--convert-float-to-ical
  icalendar--convert-sexp-to-ical

resp.  The key difference being that the first one sets 'date' and
'entry' with calendar-dlet when calling diary-float*, and the latter
does not.  diary-float is documented as requiring those to be set.†

I'm not sure of the fix here: if the expectation is that some arbitrary
sexp should be able to indirectly call some of the diary-*‡ functions,
then it may be that icalendar--convert-sexp-to-ical may need to
similarly set those values.  Alternately, if that is not supported, then
maybe disable/remove the test.

--bod

* https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/calendar/icalendar.el?id=b42cd524b46a4f29ef13e9d03be9d3df917f9aa3#n1787
† https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/calendar/diary-lib.el?id=b42cd524b46a4f29ef13e9d03be9d3df917f9aa3#n1891
‡ diary-date, diary-block, diary-float, diary-anniversary, diary-cyclic,
  and diary-offset (there may be others, those were the ones with
  an explicit comment)