;;; calendar.el --- calendar functions
;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997,
-;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
;; Free Software Foundation, Inc.
;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
;;; Code:
-(require 'cal-loaddefs)
+(load "cal-loaddefs" nil t)
;; Avoid recursive load of calendar when loading cal-menu. Yuck.
(provide 'calendar)
:version "22.1"
:group 'calendar)
+;; See discussion in bug#1806.
+(defcustom calendar-split-width-threshold nil
+ "Value to use for `split-width-threshold' when creating a calendar.
+This only affects frames wider than the default value of
+`split-width-threshold'."
+ :type '(choice (const nil)
+ (integer))
+ :version "23.2"
+ :group 'calendar)
+
(defcustom calendar-week-start-day 0
"The day of the week on which a week in the calendar begins.
0 means Sunday (default), 1 means Monday, and so on.
(defcustom diary-iso-date-forms
'((month "[-/]" day "[^-/0-9]")
(year "[-/]" month "[-/]" day "[^0-9]")
- (monthname "-" day "[^-0-9]")
- (year "-" monthname "-" day "[^0-9]")
+ ;; Cannot allow [-/] as separators here, since it would also match
+ ;; the first element (bug#7377).
+ (monthname " *" day "[^-0-9]")
+ (year " *" monthname " *" day "[^0-9]")
(dayname "\\W"))
"List of pseudo-patterns describing the ISO style of dates.
-The defaults are: MONTH[-/]DAY; YEAR[-/]MONTH[-/]DAY; MONTHNAME-DAY;
-YEAR-MONTHNAME-DAY; DAYNAME. Normally you should not customize this,
+The defaults are: MONTH[-/]DAY; YEAR[-/]MONTH[-/]DAY; MONTHNAME DAY;
+YEAR MONTHNAME DAY; DAYNAME. Normally you should not customize this,
but `diary-date-forms' (which see)."
- :version "23.1"
+ :version "23.3" ; bug#7377
:type '(repeat (choice (cons :tag "Backup"
:value (backup . nil)
(const backup)
and year, else uses the current date. If NODISPLAY is non-nil, don't
display the generated calendar."
(interactive "P")
- (set-buffer (get-buffer-create calendar-buffer))
- (calendar-mode)
- (let* ((pop-up-windows t)
- ;; Not really needed now, but means we use exactly the same
- ;; behavior as before in the non-wide case (see below).
- (split-height-threshold 1000)
- (date (if arg (calendar-read-date t)
- (calendar-current-date)))
- (month (calendar-extract-month date))
- (year (calendar-extract-year date)))
- (calendar-increment-month month year (- calendar-offset))
- ;; Display the buffer before calling calendar-generate-window so that it
- ;; can get a chance to adjust the window sizes to the frame size.
- (unless nodisplay
- ;; We want a window configuration that looks something like
- ;; X X | Y
- ;; - -----
- ;; C Z | C
- ;; where C is the calendar, and the LHS is the traditional,
- ;; non-wide frame, and the RHS is the wide frame case.
- ;; We should end up in the same state regardless of whether the
- ;; windows were initially split or not.
- ;; Previously, we only thought about the non-wide case.
- ;; We could just set split-height-threshold to 1000, relying on
- ;; the fact that the window splitting treated a single window as
- ;; a special case and would always split it (vertically). The
- ;; same thing does not work in the wide-frame case, so now we do
- ;; the splitting by hand.
- ;; See discussion in bug#1806.
- ;; Actually, this still does not do quite the right thing in the
- ;; wide frame case if started from a configuration like the LHS.
- ;; Eg if you start with a non-wide frame, call calendar, then
- ;; make the frame wider. This one is problematic because you
- ;; might need to split a totally unrelated window. Oh well, it
- ;; seems unlikely, and perhaps respecting the original layout is
- ;; the right thing in that case.
- ;;
- ;; Is this a wide frame? If so, split it horizontally.
- (if (window-splittable-p t) (split-window-horizontally))
- (pop-to-buffer calendar-buffer)
- ;; Has the window already been split vertically? (See bug#4543)
- (when (= (window-height) (window-height (frame-root-window)))
- (let ((win (split-window-vertically)))
- ;; Show something else in the upper window.
- (switch-to-buffer (other-buffer))
- ;; Switch to the lower window with the calendar buffer.
- (select-window win))))
- (calendar-generate-window month year)
- (if (and calendar-view-diary-initially-flag
- (calendar-date-is-visible-p date))
- (diary-view-entries)))
+ (let ((buff (current-buffer)))
+ (set-buffer (get-buffer-create calendar-buffer))
+ (calendar-mode)
+ (let* ((pop-up-windows t)
+ ;; Not really needed now, but means we use exactly the same
+ ;; behavior as before in the non-wide case (see below).
+ (split-height-threshold 1000)
+ (split-width-threshold calendar-split-width-threshold)
+ (date (if arg (calendar-read-date t)
+ (calendar-current-date)))
+ (month (calendar-extract-month date))
+ (year (calendar-extract-year date)))
+ (calendar-increment-month month year (- calendar-offset))
+ ;; Display the buffer before calling calendar-generate-window so that it
+ ;; can get a chance to adjust the window sizes to the frame size.
+ (unless nodisplay
+ ;; We want a window configuration that looks something like
+ ;; X X | Y
+ ;; - -----
+ ;; C Z | C
+ ;; where C is the calendar, and the LHS is the traditional,
+ ;; non-wide frame, and the RHS is the wide frame case.
+ ;; We should end up in the same state regardless of whether the
+ ;; windows were initially split or not.
+ ;; Previously, we only thought about the non-wide case.
+ ;; We could just set split-height-threshold to 1000, relying on
+ ;; the fact that the window splitting treated a single window as
+ ;; a special case and would always split it (vertically). The
+ ;; same thing does not work in the wide-frame case, so now we do
+ ;; the splitting by hand.
+ ;; See discussion in bug#1806.
+ ;; Actually, this still does not do quite the right thing in the
+ ;; wide frame case if started from a configuration like the LHS.
+ ;; Eg if you start with a non-wide frame, call calendar, then
+ ;; make the frame wider. This one is problematic because you
+ ;; might need to split a totally unrelated window. Oh well, it
+ ;; seems unlikely, and perhaps respecting the original layout is
+ ;; the right thing in that case.
+ ;;
+ ;; Is this a wide frame? If so, split it horizontally.
+ (if (window-splittable-p t) (split-window-horizontally))
+ (pop-to-buffer calendar-buffer)
+ ;; Has the window already been split vertically?
+ (when (and (not (window-dedicated-p))
+ (window-full-height-p))
+ (let ((win (split-window-vertically)))
+ ;; In the upper window, show whatever was visible before.
+ ;; This looks better than using other-buffer.
+ (switch-to-buffer buff)
+ ;; Switch to the lower window with the calendar buffer.
+ (select-window win))))
+ (calendar-generate-window month year)
+ (if (and calendar-view-diary-initially-flag
+ (calendar-date-is-visible-p date))
+ (diary-view-entries))))
(if calendar-view-holidays-initially-flag
(let* ((diary-buffer (get-file-buffer diary-file))
(diary-window (if diary-buffer (get-buffer-window diary-buffer)))
interpreted as BC; -1 being 1 BC, and so on."
(mod (calendar-absolute-from-gregorian date) 7))
+(defun calendar-week-end-day ()
+ "Return the index (0 for Sunday, etc.) of the last day of the week."
+ (mod (+ calendar-week-start-day 6) 7))
+
(defun calendar-unmark ()
"Delete all diary/holiday marks/highlighting from the calendar."
(interactive)
(format "Mayan date: %s"
(calendar-mayan-date-string date))))))
-(declare-function x-popup-menu "xmenu.c" (position menu))
+(declare-function x-popup-menu "menu.c" (position menu))
(defun calendar-print-other-dates (&optional event)
"Show dates on other calendars for date under the cursor.
;; byte-compile-dynamic: t
;; End:
-;; arch-tag: 19c61596-c8fb-4c69-bcf1-7dd739919cd8
;;; calendar.el ends here