2

I write my org-mode entries like this:

*** Some Event <2015-10-11 Sun 18:30-19:30>

    Some description

icalendar export used to automatically use "Some Event" as the icalendar item's SUMMARY, but now (somewhere between versions 7 and 8.2.10) it uses all of "Some Event <2015-10-11 Sun 18:30-19:30>" as the SUMMARY string, which is just wrong (it knows that last part is a date and uses it to create the icalendar .

The only way I have found to fix this is to create a SUMMARY property, like so:

*** Some Event <2015-10-11 Sun 18:30-19:30>
    :PROPERTIES:
    :SUMMARY:  Some Event
    :END:
    Some description

This is, however, awful for maintenance, because now I have to write and/or edit "Some Event" in two places.

Is there a way to have the date automatically excluded from the summary?

1
  • If it's OK to include the timestamp in the DESCRIPTION field, then you can move it to the line after the headline. The agenda recognizes it in either place. OTOH, if you don't want it in the DESCRIPTION field either, then filtering is indicated as shown in @Robert's answer.
    – NickD
    Jul 2, 2021 at 18:02

2 Answers 2

1

One, albeit not perfect, option would be to filter the heading text using a function like this:

(defun my-filter-timestamps (text backend info)
  "Remove timestamps from headings."
  (when (org-export-derived-backend-p backend 'icalendar)
    (replace-regexp-in-string org-stamp-time-of-day-regexp "" text)))

(add-to-list 'org-export-filter-headline-functions
             'my-filter-timestamps)

Unfortunately, for time ranges a "--" remains but that's could likely be fixed by a more sophisticated regex.

0

Building on Robert's answer, I had to make a few edits to make it work for me, and additionally with use-package (placing it in a :config block).

;; change ical export, remove timestamp with regex
(require 'ox-latex)

(defun my-filter-timestamps (text backend info)
    "Remove timestamps from headings."
    (when (org-export-derived-backend-p backend 'icalendar)
      (replace-regexp-in-string "<[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^>]*>" " " text)))  

(add-to-list 'org-export-filter-headline-functions
               'my-filter-timestamps)

And with my version I am not getting any "--" remaining. It looks great for me now in ical, but the export is much much slower. Glacial.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.