Function: calendar-generate-window
calendar-generate-window is a byte-compiled function defined in
calendar.el.gz.
Signature
(calendar-generate-window &optional MON YR)
Documentation
Generate the calendar window for the current date.
Optional integers MON and YR are used instead of today's date.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/calendar.el.gz
(defun calendar-generate-window (&optional mon yr)
"Generate the calendar window for the current date.
Optional integers MON and YR are used instead of today's date."
(let* ((inhibit-read-only t)
(today (calendar-current-date))
(month (calendar-extract-month today))
;; (day (calendar-extract-day today))
(year (calendar-extract-year today))
(today-visible (or (not mon)
(<= (abs (calendar-interval mon yr month year)) 1)))
(in-calendar-window (with-current-buffer (window-buffer)
(derived-mode-p 'calendar-mode))))
(calendar-generate (or mon month) (or yr year))
(calendar-cursor-to-visible-date
(if today-visible today (list displayed-month 1 displayed-year)))
(calendar-update-mode-line)
(set-buffer-modified-p nil)
;; Don't do any window-related stuff if we weren't called from a
;; window displaying the calendar.
(when in-calendar-window
(if (window-combined-p)
;; Adjust the window to exactly fit the displayed calendar.
(fit-window-to-buffer nil nil calendar-minimum-window-height)
;; For a full height window or a window that is horizontally
;; combined don't fit height to that of its buffer.
(set-window-vscroll nil 0)))
(and calendar-mark-holidays
;; (calendar-date-is-valid-p today) ; useful for BC dates
(calendar-mark-holidays))
(unwind-protect
(if calendar-mark-diary-entries (diary-mark-entries))
(run-hooks (if today-visible
'calendar-today-visible-hook
'calendar-today-invisible-hook)))))