Function: icalendar-parse-and-index
icalendar-parse-and-index is a byte-compiled function defined in
icalendar-parser.el.gz.
Signature
(icalendar-parse-and-index &optional BUFFER-OR-FILE)
Documentation
Parse and index the first iCalendar VCALENDAR object in BUFFER-OR-FILE.
Returns a list (VCALENDAR INDEX), where VCALENDAR is the parsed
icalendar-vcalendar syntax tree. The index can then be queried to
retrieve components from this calendar by UID, TZID, or date; see
icalendar-index-get.
BUFFER-OR-FILE may be a buffer or a string containing a filename; it
defaults to the current buffer. If it is a filename, an unfolded buffer
containing its data will be found, or created if necessary (see
icalendar-unfolded-buffer-from-file). The resulting buffer must
contain an iCalendar VCALENDAR object, which will be parsed and indexed.
The results of parsing and indexing are cached in buffer-local variables, and subsequent calls with the same BUFFER-OR-FILE will return the cached results as long as the buffer has not been modified in the meantime.
Other relevant functions are documented in the icalendar group.
Shortdoc
;; icalendar
(icalendar-parse-and-index)
-> [it depends]
=> (vcalendar index)
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar-parser.el.gz
(defun ical:parse-and-index (&optional buffer-or-file)
"Parse and index the first iCalendar VCALENDAR object in BUFFER-OR-FILE.
Returns a list (VCALENDAR INDEX), where VCALENDAR is the parsed
`icalendar-vcalendar' syntax tree. The index can then be queried to
retrieve components from this calendar by UID, TZID, or date; see
`icalendar-index-get'.
BUFFER-OR-FILE may be a buffer or a string containing a filename; it
defaults to the current buffer. If it is a filename, an unfolded buffer
containing its data will be found, or created if necessary (see
`icalendar-unfolded-buffer-from-file'). The resulting buffer must
contain an iCalendar VCALENDAR object, which will be parsed and indexed.
The results of parsing and indexing are cached in buffer-local
variables, and subsequent calls with the same BUFFER-OR-FILE will return
the cached results as long as the buffer has not been modified in the
meantime."
(let* ((buffer (cond ((null buffer-or-file) (current-buffer))
((bufferp buffer-or-file) buffer-or-file)
((and (stringp buffer-or-file)
(file-exists-p buffer-or-file))
(find-buffer-visiting buffer-or-file))))
(file-name (cond (buffer (buffer-file-name buffer))
((and (stringp buffer-or-file)
(file-exists-p buffer-or-file))
(expand-file-name buffer-or-file))))
(unfolded (cond ((and buffer (ical:unfolded-p buffer))
buffer)
(file-name
(or (ical:find-unfolded-buffer-visiting file-name)
(ical:unfolded-buffer-from-file file-name)))
(buffer
(ical:unfolded-buffer-from-buffer buffer))
(t
(error "Unable to get unfolded buffer for '%s'"
buffer-or-file)))))
(with-current-buffer unfolded
(when (ical:contains-vcalendar-p)
(if (eql (car ical:-parsed-calendar-and-index) (buffer-modified-tick))
(cdr ical:-parsed-calendar-and-index)
(message "Parsing and indexing iCalendar data in %s..." (buffer-name))
(let ((vcalendar (ical:parse)))
(when vcalendar
(setq ical:-parsed-calendar-and-index
(list
(buffer-modified-tick)
vcalendar
(ical:index-populate-from-calendar (ical:make-index)
vcalendar)))
(message "Parsing and indexing iCalendar data in %s...Done."
(buffer-name))
(cdr ical:-parsed-calendar-and-index))))))))