Function: org-diary-to-ical-string

org-diary-to-ical-string is a byte-compiled function defined in org.el.gz.

Signature

(org-diary-to-ical-string FROMBUF)

Documentation

Get iCalendar entries from diary entries in buffer FROMBUF.

This uses the icalendar.el library.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-diary-to-ical-string (frombuf)
  "Get iCalendar entries from diary entries in buffer FROMBUF.
This uses the icalendar.el library."
  (let* ((tmpdir temporary-file-directory)
	 (tmpfile (make-temp-name
		   (expand-file-name "orgics" tmpdir)))
	 buf rtn b e)
    (with-current-buffer frombuf
      (icalendar-export-region (point-min) (point-max) tmpfile)
      (setq buf (find-buffer-visiting tmpfile))
      (set-buffer buf)
      (goto-char (point-min))
      (when (re-search-forward "^BEGIN:VEVENT" nil t)
	(setq b (match-beginning 0)))
      (goto-char (point-max))
      (when (re-search-backward "^END:VEVENT" nil t)
	(setq e (match-end 0)))
      (setq rtn (if (and b e) (concat (buffer-substring b e) "\n") "")))
    (kill-buffer buf)
    (delete-file tmpfile)
    rtn))