diff options
author | Edward M. Reingold <reingold@emr.cs.iit.edu> | 1998-05-11 14:56:37 +0000 |
---|---|---|
committer | Edward M. Reingold <reingold@emr.cs.iit.edu> | 1998-05-11 14:56:37 +0000 |
commit | b5305eb0516c217caba18b37ff8c993acaa7cfc0 (patch) | |
tree | f9b32ee66027b066c40b1e21f6a424877475cd0e /lisp/calendar | |
parent | 0516edee5f13a1589df2aa2e316e6f4e9ab5f36c (diff) | |
download | emacs-b5305eb0516c217caba18b37ff8c993acaa7cfc0.tar.gz |
Made holiday button on menu bar related to current calendar display.
Diffstat (limited to 'lisp/calendar')
-rw-r--r-- | lisp/calendar/cal-menu.el | 61 | ||||
-rw-r--r-- | lisp/calendar/calendar.el | 2 |
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 @@ ;;; Code: (eval-when-compile (require 'calendar)) +(require 'easymenu) (define-key calendar-mode-map [menu-bar edit] 'undefined) (define-key calendar-mode-map [menu-bar search] 'undefined) @@ -88,21 +89,6 @@ (define-key calendar-mode-map [menu-bar holidays] (cons "Holidays" (make-sparse-keymap "Holidays"))) -(define-key calendar-mode-map [menu-bar holidays unmark] - '("Unmark" . calendar-unmark)) -(define-key calendar-mode-map [menu-bar holidays mark] - '("Mark" . mark-calendar-holidays)) -(define-key calendar-mode-map [menu-bar holidays previous-year] - '("Previous year" . cal-menu-list-holidays-previous-year)) -(define-key calendar-mode-map [menu-bar holidays following-year] - '("Following year" . cal-menu-list-holidays-following-year)) -(define-key calendar-mode-map [menu-bar holidays year] - '("Year" . cal-menu-list-holidays-year)) -(define-key calendar-mode-map [menu-bar holidays 3-mon] - '("3 Months" . list-calendar-holidays)) -(define-key calendar-mode-map [menu-bar holidays 1-day] - '("One Day" . calendar-cursor-holidays)) - (define-key calendar-mode-map [menu-bar goto] (cons "Goto" (make-sparse-keymap "Goto"))) @@ -193,6 +179,51 @@ (let ((year (1- (extract-calendar-year (calendar-cursor-to-date))))) (list-holidays year year))) +(defun cal-menu-update () + ;; Update the holiday part of calendar menu bar for the current display. + (condition-case nil + (if (eq major-mode 'calendar-mode) + (let ((l)) + (calendar-for-loop;; Show 11 years--5 before, 5 after year of + ;; middle month + i from (- displayed-year 5) to (+ displayed-year 5) do + (setq l (cons (vector (format "For Year %s" i) + (list (list 'lambda 'nil '(interactive) + (list 'list-holidays i i))) + t) + l))) + (setq l (cons ["Mark Holidays" mark-calendar-holidays t] + (cons ["Unmark Calendar" calendar-unmark t] l))) + (easy-menu-change nil "holidays" (nreverse l)) + (let ((title + (let ((m1 displayed-month) + (y1 displayed-year) + (m2 displayed-month) + (y2 displayed-year)) + (increment-calendar-month m1 y1 -1) + (increment-calendar-month m2 y2 1) + (if (= y1 y2) + (format "%s-%s, %d" + (calendar-month-name m1 3) + (calendar-month-name m2 3) + y2) + (format "%s, %d-%s, %d" + (calendar-month-name m1 3) + y1 + (calendar-month-name m2 3) + y2))))) + (define-key calendar-mode-map [menu-bar holidays 3-day] + `(,(format "For Current Window (%s)" title) + . list-calendar-holidays))) + (let ((date (calendar-cursor-to-date))) + (if date + (define-key calendar-mode-map [menu-bar holidays 1-day] + `(,(format "For Cursor Date (%s)" + (calendar-date-string date t t)) + . calendar-cursor-holidays)))))) + ;; Try to avoid entering infinite beep mode in case of errors. + (error (ding)))) + (defun calendar-event-to-date (&optional error) "Date of last event. If 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 \ (setq buffer-read-only t) (setq indent-tabs-mode nil) (update-calendar-mode-line) + (make-local-hook 'activate-menubar-hook) + (add-hook 'activate-menubar-hook 'cal-menu-update nil t) (make-local-variable 'calendar-mark-ring) (make-local-variable 'displayed-month);; Month in middle of window. (make-local-variable 'displayed-year));; Year in middle of window. |