Function: diary-icalendar--vevent-to-legacy-alist

diary-icalendar--vevent-to-legacy-alist is a byte-compiled function defined in diary-icalendar.el.gz.

This function is obsolete since 31.1.

Signature

(diary-icalendar--vevent-to-legacy-alist VEVENT)

Documentation

Convert an icalendar-vevent to an alist of the kind used by icalendar.el.

This function is for backward compatibility; please do not rely on it in new code.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/diary-icalendar.el.gz
(defun di:-vevent-to-legacy-alist (vevent)
  "Convert an `icalendar-vevent' to an alist of the kind used by icalendar.el.
This function is for backward compatibility; please do not rely on it in
new code."
  (declare (obsolete nil "31.1"))
  ;; function values of `icalendar-import-format' expect a list like:
  ;; ((VEVENT nil
  ;;   ((PROP1 params val)
  ;;    (PROP2 params val)
  ;;    ...)))
  (let ((vevent-children (ical:ast-node-children vevent))
        children)
    (dolist (p vevent-children)
      (let* ((type (ical:ast-node-type p))
             (list-sep (get type 'ical:list-sep))
             (name (intern (car (rassq type ical:property-types))))
             ;; icalendar.el did not interpret values when parsing, so we
             ;; convert back to string representation:
             (value (ical:ast-node-value p))
             (value-str
              (or (ical:ast-node-meta-get :original-value p)
                  (if list-sep
                      (string-join (mapcar #'ical:default-value-printer value)
                                   list-sep)
                    (ical:default-value-printer value))))
             params)
        (when (ical:ast-node-children p)
          (dolist (param (ical:ast-node-children p))
            (let* ((par-str (ical:print-param-node param))
                   (split (string-split par-str "[;=]"))
                   (parname (intern (nth 1 split)))
                   (parval (nth 2 split)))
              (push `(,parname nil ,parval) params)))
          (setq params (nreverse params)))
        (push `(,name ,params ,value-str) children)))
    (setq children (nreverse children))
    ;; Return the legacy alist:
    `((VEVENT nil ,children))))