0

I would like to export my org-agenda to ical, showing any entry as "BUSY" in the export. Since I do not want to add the SUMMARY property to each entry, I'm looking for a way to do it globally. I've tried setting:

#+PROPERTY: SUMMARY "Busy"
#+PROPERTY: CLASS PUBLIC

at the top of my file and set org-use-property-inheritance to t but it does not seem to work (I can still see headlines in the .ics file). What would be the proper way to achieve the result?

Nicolas Rougier
  • 487
  • 3
  • 15

2 Answers2

1

ox.el shows two variables that may be interesting to you:

(defvar org-export-filter-parse-tree-functions nil
  "List of functions applied to the parsed tree.
Each filter is called with three arguments: the parse tree, as
returned by `org-element-parse-buffer', the back-end, as
a symbol, and the communication channel, as a plist.  It must
return the modified parse tree to transcode.")

(defvar org-export-filter-final-output-functions nil
  "List of functions applied to the transcoded string.
Each filter is called with three arguments: the full transcoded
string, the back-end, as a symbol, and the communication channel,
as a plist.  It must return a string that will be used as the
final export output.")

org-export-filter-parse-tree-functions will operate on the org tree itself (and no worries, all of this is done on a copy of the data, not the original file itself), which gives you the power to work with org, but may also be quite slow.

org-export-filter-final-output-functions is called as the last step of org-export-as, so you may be able to run something simple like

(defun my-replace (calendar, backend, channel)
  (replace-regexp-in-string "^SUMMARY:.*$" "SUMMARY:Busy" calendar))

(push 'my-replace org-export-filter-parse-tree-functions)

Mind you, you probably only want this to run when it's the ics export :)

Trevoke
  • 2,375
  • 21
  • 34
0

I've found solution but it is quite slow:

(defun my/org-busy-mode (backend)
  "Set summary to \"Busy\" for all headlines"

  (if (org-export-derived-backend-p backend 'icalendar)
      (org-map-entries
       (lambda ()
         (org-set-property "SUMMARY" "Busy")
         (org-set-property "DESCRIPTION" "")))))

(add-hook 'org-export-before-parsing-hook #'my/org-busy-mode)
Nicolas Rougier
  • 487
  • 3
  • 15