Function: diary-icalendar-mark-entries
diary-icalendar-mark-entries is a byte-compiled function defined in
diary-icalendar.el.gz.
Signature
(diary-icalendar-mark-entries)
Documentation
Mark calendar dates for iCalendar data from a file.
This function allows you to mark the dates in an iCalendar-formatted
file in the calendar without importing it. The data is read directly
from the current value of diary-file (which is dynamically bound by
the diary when this function is called).
To use this function, add an '#include "FILE"' entry in your diary
file for each iCalendar file you want to display (see
diary-include-string). Then add diary-mark-included-diary-files to
diary-mark-entries-hook. Finally, add this function to
diary-nongregorian-marking-hook, so that it is called once for each
included file when dates are marked in the calendar.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/diary-icalendar.el.gz
(defun di:mark-entries ()
"Mark calendar dates for iCalendar data from a file.
This function allows you to mark the dates in an iCalendar-formatted
file in the calendar without importing it. The data is read directly
from the current value of `diary-file' (which is dynamically bound by
the diary when this function is called).
To use this function, add an '#include \"FILE\"' entry in your diary
file for each iCalendar file you want to display (see
`diary-include-string'). Then add `diary-mark-included-diary-files' to
`diary-mark-entries-hook'. Finally, add this function to
`diary-nongregorian-marking-hook', so that it is called once for each
included file when dates are marked in the calendar."
(with-no-warnings (defvar diary-file)) ; dyn. bound to included file name
(let ((diary-buffer (or (find-buffer-visiting diary-file)
(find-file-noselect diary-file))))
(when (ical:contains-vcalendar-p diary-buffer)
(let ((vcal/idx (ical:parse-and-index diary-buffer)))
(when vcal/idx
(let* ((index (cadr vcal/idx))
(vcalendar (car vcal/idx))
(to-mark
(append (ical:ast-node-children-of 'ical:vevent vcalendar)
(ical:ast-node-children-of 'ical:vjournal vcalendar)
(ical:ast-node-children-of 'ical:vtodo vcalendar)))
(all-dates (mapcan (lambda (c) (di:marking-dates-of c index))
to-mark))
(dates (seq-uniq
(sort all-dates :lessp #'ical:date< :in-place t))))
(dolist (date dates)
(let ((month (calendar-extract-month date))
(year (calendar-extract-year date)))
;; avoid marking outside the displayed months,
;; to speed things up:
(with-current-buffer calendar-buffer
(with-suppressed-warnings
((free-vars displayed-year
displayed-month))
(when (and (= year displayed-year)
(<= (1- displayed-month) month)
(<= month (1+ displayed-month)))
(calendar-mark-visible-date date))))))))))))