Function: icalendar-parse
icalendar-parse is a byte-compiled function defined in
icalendar-parser.el.gz.
Signature
(icalendar-parse &optional BUFFER)
Documentation
Parse an iCalendar VCALENDAR object in BUFFER (default: current buffer).
An unfolded copy of BUFFER (see icalendar-unfolded-buffer-from-buffer)
will first be obtained if necessary. Parsing will begin at the first
occurrence of "BEGIN:VCALENDAR" in the unfolded buffer.
The buffer may be tidied up by user functions before parsing begins; see
icalendar-pre-unfolding-hook and icalendar-pre-parsing-hook.
If parsing is successful, an icalendar-vcalendar object is returned.
Otherwise, nil is returned, a warning is issued, and errors are logged
in the buffer returned by icalendar-error-buffer.
Other relevant functions are documented in the icalendar group.
Shortdoc
;; icalendar
(icalendar-parse)
-> [it depends]
=> (icalendar-vcalendar ...)
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar-parser.el.gz
;;; High-level parsing and printing functions.
(defun ical:parse (&optional buffer)
"Parse an iCalendar VCALENDAR object in BUFFER (default: current buffer).
An unfolded copy of BUFFER (see `icalendar-unfolded-buffer-from-buffer')
will first be obtained if necessary. Parsing will begin at the first
occurrence of \"BEGIN:VCALENDAR\" in the unfolded buffer.
The buffer may be tidied up by user functions before parsing begins; see
`icalendar-pre-unfolding-hook' and `icalendar-pre-parsing-hook'.
If parsing is successful, an `icalendar-vcalendar' object is returned.
Otherwise, nil is returned, a warning is issued, and errors are logged
in the buffer returned by `icalendar-error-buffer'."
(let* ((buf (or buffer (current-buffer)))
(unfolded (cond ((ical:unfolded-p buf) buf)
((buffer-file-name buf)
(ical:unfolded-buffer-from-file (buffer-file-name buf)))
(t (ical:unfolded-buffer-from-buffer buf)))))
(ical:init-error-buffer)
(with-current-buffer unfolded
(run-hooks 'ical:pre-parsing-hook)
(let ((cal-start (ical:contains-vcalendar-p))
vcalendar)
(unless cal-start
(ical:signal-parse-error "Buffer does not contain \"BEGIN:VCALENDAR\""))
(save-excursion
(goto-char cal-start)
(ical:condition-case err
(setq vcalendar (ical:parse-calendar (point-max)))
(ical:parse-error
(ical:handle-parse-error err)
(warn "Errors while parsing %s; see buffer %s"
buffer (buffer-name (ical:error-buffer))))))
vcalendar))))