Function: diary-icalendar-display-entries

diary-icalendar-display-entries is a byte-compiled function defined in diary-icalendar.el.gz.

Signature

(diary-icalendar-display-entries)

Documentation

Display iCalendar data from a file in the diary.

This function allows you to display the data in an iCalendar-formatted file in the diary without importing it. The data is read directly from the currently value of diary-file. If this file contains iCalendar data, any events, tasks, and journal entries in the file which occur on original-date and number of days after are formatted for display in the diary. (All three of these variables are 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-include-other-diary-files to diary-list-entries-hook. (Consider also adding diary-sort-entries at the end of this hook if you want entries to be displayed in order.) Finally, add this function to diary-nongregorian-listing-hook, so that it is called once for each included file when the diary is displayed.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/diary-icalendar.el.gz
(defun di:display-entries ()
  "Display iCalendar data from a file in the diary.

This function allows you to display the data in an iCalendar-formatted
file in the diary without importing it.  The data is read directly from
the currently value of `diary-file'.  If this file contains iCalendar
data, any events, tasks, and journal entries in the file which occur on
`original-date' and `number' of days after are formatted for display in
the diary.  (All three of these variables are 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-include-other-diary-files' to
`diary-list-entries-hook'.  (Consider also adding `diary-sort-entries' at
the end of this hook if you want entries to be displayed in order.)
Finally, add this function to `diary-nongregorian-listing-hook', so that
it is called once for each included file when the diary is displayed."
  (with-no-warnings (defvar original-date) ; the start date
                    (defvar number) ; number of days to generate entries for
                    (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-file)))
        (when vcal/idx
          (let* ((index (cadr vcal/idx))
                 (absstart (calendar-absolute-from-gregorian original-date))
                 (absend (+ absstart (1- number))))

            (dolist (absdate (number-sequence absstart absend))
              (let* ((date (calendar-gregorian-from-absolute absdate))
                     (to-format (ical:index-get index :date date)))
                (dolist (component to-format)
                  ;; Format the entry, with a pointer back to its location
                  ;; in the parsed buffer:
                  (let ((marker (make-marker)))
                    (set-marker marker
                                (ical:ast-node-meta-get :begin component)
                                (ical:ast-node-meta-get :buffer component))
                    (diary-add-to-list
                     date
                     (di:format-entry component index)
                     ""
                     marker)))))))))))