Function: icalendar--convert-sexp-to-ical

icalendar--convert-sexp-to-ical is a byte-compiled function defined in icalendar.el.gz.

Signature

(icalendar--convert-sexp-to-ical NONMARKER ENTRY-MAIN &optional START)

Documentation

Convert sexp diary entry to iCalendar format.

Enumerate the evaluated sexp entry for the next icalendar-export-sexp-enumeration-days days. NONMARKER is a regular expression matching the start of non-marking entries. ENTRY-MAIN is the first line of the diary entry.

Optional argument START determines the first day of the enumeration, given as a Lisp time value -- used for test purposes.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar.el.gz
(defun icalendar--convert-sexp-to-ical (nonmarker entry-main &optional start)
  "Convert sexp diary entry to iCalendar format.
Enumerate the evaluated sexp entry for the next
`icalendar-export-sexp-enumeration-days' days.  NONMARKER is a
regular expression matching the start of non-marking entries.
ENTRY-MAIN is the first line of the diary entry.

Optional argument START determines the first day of the
enumeration, given as a Lisp time value -- used for test purposes."
  (cond ((string-match (concat nonmarker
                               "%%(and \\(([^)]+)\\))\\(\\s-*.*?\\) ?$")
                       entry-main)
         ;; simple sexp entry as generated by icalendar.el: strip off the
         ;; unnecessary (and)
         (icalendar--dmsg "diary-sexp from icalendar.el %s" entry-main)
         (icalendar--convert-to-ical
          nonmarker
          (concat "%%"
                  (substring entry-main (match-beginning 1) (match-end 1))
                  (substring entry-main (match-beginning 2) (match-end 2)))))
        ((string-match (concat nonmarker
                               "%%\\(([^)]+)\\)\\s-*\\(.*\\)")
                       entry-main)
         ;; regular sexp entry
         (icalendar--dmsg "diary-sexp %s" entry-main)
         (let ((p1 (substring entry-main (match-beginning 1) (match-end 1)))
               (p2 (substring entry-main (match-beginning 2) (match-end 2)))
               (now (or start (current-time))))
           (delete nil
                   (mapcar
                    (lambda (offset)
                      (let* ((day (decode-time (time-add now
							 (* 60 60 24 offset))))
                             (d (decoded-time-day day))
                             (m (decoded-time-month day))
                             (y (decoded-time-year day))
                             (se (diary-sexp-entry p1 p2 (list m d y)))
                             (see (cond ((stringp se) se)
                                        ((consp se) (cdr se))
                                        (t nil))))
                        (cond ((null see)
                               nil)
                              ((stringp see)
                               (let ((calendar-date-style 'iso))
                                 (icalendar--convert-ordinary-to-ical
                                  nonmarker (format "%4d/%02d/%02d %s" y m d see))))
                             (;TODO:
                              (error "Unsupported Sexp-entry: %s"
                                     entry-main)))))
                    (number-sequence
                     0 (- icalendar-export-sexp-enumeration-days 1))))))
        (t
         ;; no match
         nil)))