aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward M. Reingold1998-05-11 14:56:37 +0000
committerEdward M. Reingold1998-05-11 14:56:37 +0000
commitb5305eb0516c217caba18b37ff8c993acaa7cfc0 (patch)
treef9b32ee66027b066c40b1e21f6a424877475cd0e
parent0516edee5f13a1589df2aa2e316e6f4e9ab5f36c (diff)
downloademacs-b5305eb0516c217caba18b37ff8c993acaa7cfc0.tar.gz
emacs-b5305eb0516c217caba18b37ff8c993acaa7cfc0.zip
Made holiday button on menu bar related to current calendar display.
-rw-r--r--lisp/calendar/cal-menu.el61
-rw-r--r--lisp/calendar/calendar.el2
2 files changed, 48 insertions, 15 deletions
diff --git a/lisp/calendar/cal-menu.el b/lisp/calendar/cal-menu.el
index 2e29be0958a..e6c58109eda 100644
--- a/lisp/calendar/cal-menu.el
+++ b/lisp/calendar/cal-menu.el
@@ -38,6 +38,7 @@
38;;; Code: 38;;; Code:
39 39
40(eval-when-compile (require 'calendar)) 40(eval-when-compile (require 'calendar))
41(require 'easymenu)
41 42
42(define-key calendar-mode-map [menu-bar edit] 'undefined) 43(define-key calendar-mode-map [menu-bar edit] 'undefined)
43(define-key calendar-mode-map [menu-bar search] 'undefined) 44(define-key calendar-mode-map [menu-bar search] 'undefined)
@@ -88,21 +89,6 @@
88(define-key calendar-mode-map [menu-bar holidays] 89(define-key calendar-mode-map [menu-bar holidays]
89 (cons "Holidays" (make-sparse-keymap "Holidays"))) 90 (cons "Holidays" (make-sparse-keymap "Holidays")))
90 91
91(define-key calendar-mode-map [menu-bar holidays unmark]
92 '("Unmark" . calendar-unmark))
93(define-key calendar-mode-map [menu-bar holidays mark]
94 '("Mark" . mark-calendar-holidays))
95(define-key calendar-mode-map [menu-bar holidays previous-year]
96 '("Previous year" . cal-menu-list-holidays-previous-year))
97(define-key calendar-mode-map [menu-bar holidays following-year]
98 '("Following year" . cal-menu-list-holidays-following-year))
99(define-key calendar-mode-map [menu-bar holidays year]
100 '("Year" . cal-menu-list-holidays-year))
101(define-key calendar-mode-map [menu-bar holidays 3-mon]
102 '("3 Months" . list-calendar-holidays))
103(define-key calendar-mode-map [menu-bar holidays 1-day]
104 '("One Day" . calendar-cursor-holidays))
105
106(define-key calendar-mode-map [menu-bar goto] 92(define-key calendar-mode-map [menu-bar goto]
107 (cons "Goto" (make-sparse-keymap "Goto"))) 93 (cons "Goto" (make-sparse-keymap "Goto")))
108 94
@@ -193,6 +179,51 @@
193 (let ((year (1- (extract-calendar-year (calendar-cursor-to-date))))) 179 (let ((year (1- (extract-calendar-year (calendar-cursor-to-date)))))
194 (list-holidays year year))) 180 (list-holidays year year)))
195 181
182(defun cal-menu-update ()
183 ;; Update the holiday part of calendar menu bar for the current display.
184 (condition-case nil
185 (if (eq major-mode 'calendar-mode)
186 (let ((l))
187 (calendar-for-loop;; Show 11 years--5 before, 5 after year of
188 ;; middle month
189 i from (- displayed-year 5) to (+ displayed-year 5) do
190 (setq l (cons (vector (format "For Year %s" i)
191 (list (list 'lambda 'nil '(interactive)
192 (list 'list-holidays i i)))
193 t)
194 l)))
195 (setq l (cons ["Mark Holidays" mark-calendar-holidays t]
196 (cons ["Unmark Calendar" calendar-unmark t] l)))
197 (easy-menu-change nil "holidays" (nreverse l))
198 (let ((title
199 (let ((m1 displayed-month)
200 (y1 displayed-year)
201 (m2 displayed-month)
202 (y2 displayed-year))
203 (increment-calendar-month m1 y1 -1)
204 (increment-calendar-month m2 y2 1)
205 (if (= y1 y2)
206 (format "%s-%s, %d"
207 (calendar-month-name m1 3)
208 (calendar-month-name m2 3)
209 y2)
210 (format "%s, %d-%s, %d"
211 (calendar-month-name m1 3)
212 y1
213 (calendar-month-name m2 3)
214 y2)))))
215 (define-key calendar-mode-map [menu-bar holidays 3-day]
216 `(,(format "For Current Window (%s)" title)
217 . list-calendar-holidays)))
218 (let ((date (calendar-cursor-to-date)))
219 (if date
220 (define-key calendar-mode-map [menu-bar holidays 1-day]
221 `(,(format "For Cursor Date (%s)"
222 (calendar-date-string date t t))
223 . calendar-cursor-holidays))))))
224 ;; Try to avoid entering infinite beep mode in case of errors.
225 (error (ding))))
226
196(defun calendar-event-to-date (&optional error) 227(defun calendar-event-to-date (&optional error)
197 "Date of last event. 228 "Date of last event.
198If event is not on a specific date, signals an error if optional parameter 229If event is not on a specific date, signals an error if optional parameter
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index 821748ad4e3..65e2ace68fc 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -2025,6 +2025,8 @@ For a complete description, type \
2025 (setq buffer-read-only t) 2025 (setq buffer-read-only t)
2026 (setq indent-tabs-mode nil) 2026 (setq indent-tabs-mode nil)
2027 (update-calendar-mode-line) 2027 (update-calendar-mode-line)
2028 (make-local-hook 'activate-menubar-hook)
2029 (add-hook 'activate-menubar-hook 'cal-menu-update nil t)
2028 (make-local-variable 'calendar-mark-ring) 2030 (make-local-variable 'calendar-mark-ring)
2029 (make-local-variable 'displayed-month);; Month in middle of window. 2031 (make-local-variable 'displayed-month);; Month in middle of window.
2030 (make-local-variable 'displayed-year));; Year in middle of window. 2032 (make-local-variable 'displayed-year));; Year in middle of window.