aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2005-02-27 20:25:48 +0000
committerGlenn Morris2005-02-27 20:25:48 +0000
commit0663481f4d13d28704b1ce1fefda4af0f3e30f6d (patch)
treeef0606e21b185369d29d0d38d5af00533fe4690b
parent6e8db3eaf7a985e803898937aedcc5fe2c07109c (diff)
downloademacs-0663481f4d13d28704b1ce1fefda4af0f3e30f6d.tar.gz
emacs-0663481f4d13d28704b1ce1fefda4af0f3e30f6d.zip
From Matt Hodges <MPHodges@member.fsf.org>:
(calendar-buffer): Move above calendar-week-start-day. (calendar-week-start-day): Doc fix. Add :set function. (calendar-minimum-window-height): New variable. (generate-calendar-window): Only resize window if selected-window is displaying the calendar buffer. Use new variable calendar-minimum-window-height. (generate-calendar): Reword error message. (calendar-mode-map): Bind DEL to scroll-other-window-down.
-rw-r--r--lisp/calendar/calendar.el59
1 files changed, 41 insertions, 18 deletions
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index 88d6aee513f..291452db080 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -1,7 +1,7 @@
1;;; calendar.el --- calendar functions 1;;; calendar.el --- calendar functions
2 2
3;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997, 3;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1997,
4;; 2000, 2001, 2003, 2004 Free Software Foundation, Inc. 4;; 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
5 5
6;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> 6;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
7;; Maintainer: Glenn Morris <gmorris@ast.cam.ac.uk> 7;; Maintainer: Glenn Morris <gmorris@ast.cam.ac.uk>
@@ -141,11 +141,25 @@
141 :group 'calendar) 141 :group 'calendar)
142 142
143 143
144(defconst calendar-buffer "*Calendar*"
145 "Name of the buffer used for the calendar.")
146
144;;;###autoload 147;;;###autoload
145(defcustom calendar-week-start-day 0 148(defcustom calendar-week-start-day 0
146 "*The day of the week on which a week in the calendar begins. 149 "*The day of the week on which a week in the calendar begins.
1470 means Sunday (default), 1 means Monday, and so on." 1500 means Sunday (default), 1 means Monday, and so on.
151
152If you change this variable directly (without using customize)
153after starting `calendar', you should call `redraw-calendar' to
154update the calendar display to reflect the change, otherwise
155movement commands will not work correctly."
148 :type 'integer 156 :type 'integer
157 :set (lambda (sym val)
158 (set sym val)
159 (let ((buffer (get-buffer calendar-buffer)))
160 (when (buffer-live-p buffer)
161 (with-current-buffer buffer
162 (redraw-calendar)))))
149 :group 'calendar) 163 :group 'calendar)
150 164
151;;;###autoload 165;;;###autoload
@@ -1303,9 +1317,6 @@ with descriptive strings such as
1303 :type 'sexp 1317 :type 'sexp
1304 :group 'holidays) 1318 :group 'holidays)
1305 1319
1306(defconst calendar-buffer "*Calendar*"
1307 "Name of the buffer used for the calendar.")
1308
1309(defconst holiday-buffer "*Holidays*" 1320(defconst holiday-buffer "*Holidays*"
1310 "Name of the buffer used for the displaying the holidays.") 1321 "Name of the buffer used for the displaying the holidays.")
1311 1322
@@ -1563,7 +1574,7 @@ return negative results."
1563The choices are: `one-frame' (calendar and diary together in one separate, 1574The choices are: `one-frame' (calendar and diary together in one separate,
1564dedicated frame); `two-frames' (calendar and diary in separate, dedicated 1575dedicated frame); `two-frames' (calendar and diary in separate, dedicated
1565frames); `calendar-only' (calendar in a separate, dedicated frame); with 1576frames); `calendar-only' (calendar in a separate, dedicated frame); with
1566any other value the current frame is used. Using any of the first 1577any other value the current frame is used. Using any of the first
1567three options overrides the value of `view-diary-entries-initially'." 1578three options overrides the value of `view-diary-entries-initially'."
1568 :type '(choice 1579 :type '(choice
1569 (const :tag "calendar and diary in separate frame" one-frame) 1580 (const :tag "calendar and diary in separate frame" one-frame)
@@ -1572,6 +1583,12 @@ three options overrides the value of `view-diary-entries-initially'."
1572 (const :tag "use current frame" nil)) 1583 (const :tag "use current frame" nil))
1573 :group 'calendar) 1584 :group 'calendar)
1574 1585
1586(defcustom calendar-minimum-window-height 8
1587 "Minimum height `generate-calendar-window' should use for calendar window."
1588 :type 'integer
1589 :version "22.1"
1590 :group 'calendar)
1591
1575;;;###autoload 1592;;;###autoload
1576(defun calendar (&optional arg) 1593(defun calendar (&optional arg)
1577 "Choose between the one frame, two frame, or basic calendar displays. 1594 "Choose between the one frame, two frame, or basic calendar displays.
@@ -2039,28 +2056,33 @@ Or, for optional MON, YR."
2039 (or (not mon) 2056 (or (not mon)
2040 (let ((offset (calendar-interval mon yr month year))) 2057 (let ((offset (calendar-interval mon yr month year)))
2041 (and (<= offset 1) (>= offset -1))))) 2058 (and (<= offset 1) (>= offset -1)))))
2042 (day-in-week (calendar-day-of-week today))) 2059 (day-in-week (calendar-day-of-week today))
2060 (in-calendar-window (eq (window-buffer (selected-window))
2061 (get-buffer calendar-buffer))))
2043 (update-calendar-mode-line) 2062 (update-calendar-mode-line)
2044 (if mon 2063 (if mon
2045 (generate-calendar mon yr) 2064 (generate-calendar mon yr)
2046 (generate-calendar month year)) 2065 (generate-calendar month year))
2047 (calendar-cursor-to-visible-date 2066 (calendar-cursor-to-visible-date
2048 (if today-visible today (list displayed-month 1 displayed-year))) 2067 (if today-visible today (list displayed-month 1 displayed-year)))
2049 (set-buffer-modified-p nil) 2068 (set-buffer-modified-p nil)
2050 (if (or (one-window-p t) (/= (frame-width) (window-width))) 2069 ;; Don't do any window-related stuff if we weren't called from a
2051 ;; Don't mess with the window size, but ensure that the first 2070 ;; window displaying the calendar
2052 ;; line is fully visible 2071 (when in-calendar-window
2053 (set-window-vscroll nil 0) 2072 (if (or (one-window-p t) (/= (frame-width) (window-width)))
2054 ;; Adjust the window to exactly fit the displayed calendar 2073 ;; Don't mess with the window size, but ensure that the first
2055 (fit-window-to-buffer)) 2074 ;; line is fully visible
2056 (sit-for 0) 2075 (set-window-vscroll nil 0)
2076 ;; Adjust the window to exactly fit the displayed calendar
2077 (fit-window-to-buffer nil nil calendar-minimum-window-height))
2078 (sit-for 0))
2057 (if (and (boundp 'font-lock-mode) 2079 (if (and (boundp 'font-lock-mode)
2058 font-lock-mode) 2080 font-lock-mode)
2059 (font-lock-fontify-buffer)) 2081 (font-lock-fontify-buffer))
2060 (and mark-holidays-in-calendar 2082 (and mark-holidays-in-calendar
2061;;; (calendar-date-is-legal-p today) ; useful for BC dates 2083;;; (calendar-date-is-legal-p today) ; useful for BC dates
2062 (mark-calendar-holidays) 2084 (mark-calendar-holidays)
2063 (sit-for 0)) 2085 (and in-calendar-window (sit-for 0)))
2064 (unwind-protect 2086 (unwind-protect
2065 (if mark-diary-entries-in-calendar (mark-diary-entries)) 2087 (if mark-diary-entries-in-calendar (mark-diary-entries))
2066 (if today-visible 2088 (if today-visible
@@ -2071,10 +2093,10 @@ Or, for optional MON, YR."
2071 "Generate a three-month Gregorian calendar centered around MONTH, YEAR." 2093 "Generate a three-month Gregorian calendar centered around MONTH, YEAR."
2072;;; A negative YEAR is interpreted as BC; -1 being 1 BC, and so on. 2094;;; A negative YEAR is interpreted as BC; -1 being 1 BC, and so on.
2073;;; Note that while calendars for years BC could be displayed as it 2095;;; Note that while calendars for years BC could be displayed as it
2074;;; stands, almost all other calendar functions (eg holidays) would 2096;;; stands, almost all other calendar functions (eg holidays) would
2075;;; at best have unpredictable results for such dates. 2097;;; at best have unpredictable results for such dates.
2076 (if (< (+ month (* 12 (1- year))) 2) 2098 (if (< (+ month (* 12 (1- year))) 2)
2077 (error "Months before February, 1 AD are not available")) 2099 (error "Months before January, 1 AD cannot be displayed"))
2078 (setq displayed-month month 2100 (setq displayed-month month
2079 displayed-year year) 2101 displayed-year year)
2080 (erase-buffer) 2102 (erase-buffer)
@@ -2229,6 +2251,7 @@ the inserted text. Value is always t."
2229 (define-key calendar-mode-map "S" 'calendar-sunrise-sunset) 2251 (define-key calendar-mode-map "S" 'calendar-sunrise-sunset)
2230 (define-key calendar-mode-map "M" 'calendar-phases-of-moon) 2252 (define-key calendar-mode-map "M" 'calendar-phases-of-moon)
2231 (define-key calendar-mode-map " " 'scroll-other-window) 2253 (define-key calendar-mode-map " " 'scroll-other-window)
2254 (define-key calendar-mode-map (kbd "DEL") 'scroll-other-window-down)
2232 (define-key calendar-mode-map "\C-c\C-l" 'redraw-calendar) 2255 (define-key calendar-mode-map "\C-c\C-l" 'redraw-calendar)
2233 (define-key calendar-mode-map "." 'calendar-goto-today) 2256 (define-key calendar-mode-map "." 'calendar-goto-today)
2234 (define-key calendar-mode-map "o" 'calendar-other-month) 2257 (define-key calendar-mode-map "o" 'calendar-other-month)