;;; cal-menu.el --- calendar functions for menu bar and popup menu support
-;; Copyright (C) 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
;; Lara Rios <lrios@coewl.cen.uiuc.edu>
;;; Code:
+(define-key calendar-mode-map [menu-bar edit] 'undefined)
+(define-key calendar-mode-map [menu-bar search] 'undefined)
+
(define-key calendar-mode-map [down-mouse-2] 'calendar-mouse-2-date-menu)
(define-key calendar-mode-map [mouse-2] 'ignore)
(defvar calendar-mouse-3-map (make-sparse-keymap "Calendar"))
(define-key calendar-mode-map [down-mouse-3] calendar-mouse-3-map)
+(define-key calendar-mode-map [C-down-mouse-3] calendar-mouse-3-map)
+
+(define-key calendar-mode-map [menu-bar moon]
+ (cons "Moon" (make-sparse-keymap "Moon")))
+
+(define-key calendar-mode-map [menu-bar moon moon]
+ '("Lunar Phases" . calendar-phases-of-moon))
(define-key calendar-mode-map [menu-bar diary]
(cons "Diary" (make-sparse-keymap "Diary")))
(define-key calendar-mode-map [menu-bar diary isl]
'("Insert Islamic" . calendar-mouse-insert-islamic-diary-entry))
(define-key calendar-mode-map [menu-bar diary cyc]
- '("Insert cyclic" . insert-cyclic-diary-entry))
+ '("Insert Cyclic" . insert-cyclic-diary-entry))
(define-key calendar-mode-map [menu-bar diary blk]
- '("Insert block" . insert-block-diary-entry))
+ '("Insert Block" . insert-block-diary-entry))
(define-key calendar-mode-map [menu-bar diary ann]
- '("Insert anniversary" . insert-anniversary-diary-entry))
+ '("Insert Anniversary" . insert-anniversary-diary-entry))
(define-key calendar-mode-map [menu-bar diary yr]
- '("Insert yearly" . insert-yearly-diary-entry))
+ '("Insert Yearly" . insert-yearly-diary-entry))
(define-key calendar-mode-map [menu-bar diary mon]
- '("Insert monthly" . insert-monthly-diary-entry))
+ '("Insert Monthly" . insert-monthly-diary-entry))
(define-key calendar-mode-map [menu-bar diary wk]
- '("Insert weekly" . insert-weekly-diary-entry))
+ '("Insert Weekly" . insert-weekly-diary-entry))
(define-key calendar-mode-map [menu-bar diary ent]
- '("Insert daily". insert-diary-entry))
+ '("Insert Daily". insert-diary-entry))
(define-key calendar-mode-map [menu-bar diary all]
- '("Show all" . show-all-diary-entries))
+ '("Show All" . show-all-diary-entries))
(define-key calendar-mode-map [menu-bar diary mark]
- '("Mark all" . mark-diary-entries))
+ '("Mark All" . mark-diary-entries))
(define-key calendar-mode-map [menu-bar diary view]
- '("Cursor date" . view-diary-entries))
+ '("Cursor Date" . view-diary-entries))
+(define-key calendar-mode-map [menu-bar diary view]
+ '("Other File" . view-other-diary-entries))
(define-key calendar-mode-map [menu-bar holidays]
(cons "Holidays" (make-sparse-keymap "Holidays")))
(define-key calendar-mode-map [menu-bar holidays mark]
'("Mark" . mark-calendar-holidays))
(define-key calendar-mode-map [menu-bar holidays 3-mon]
- '("3 months" . list-calendar-holidays))
+ '("3 Months" . list-calendar-holidays))
(define-key calendar-mode-map [menu-bar holidays 1-day]
- '("One day" . calendar-cursor-holidays))
+ '("One Day" . calendar-cursor-holidays))
(define-key calendar-mode-map [menu-bar goto]
(cons "Goto" (make-sparse-keymap "Goto")))
(define-key calendar-mode-map [menu-bar goto french]
- '("French date" . calendar-goto-french-date))
+ '("French Date" . calendar-goto-french-date))
(define-key calendar-mode-map [menu-bar goto mayan]
- (cons "Mayan date" (make-sparse-keymap "Mayan")))
+ (cons "Mayan Date" (make-sparse-keymap "Mayan")))
+(define-key calendar-mode-map [menu-bar goto ethiopic]
+ '("Ethiopic Date" . calendar-goto-ethiopic-date))
+(define-key calendar-mode-map [menu-bar goto coptic]
+ '("Coptic Date" . calendar-goto-coptic-date))
+(define-key calendar-mode-map [menu-bar goto chinese]
+ '("Chinese Date" . calendar-goto-chinese-date))
(define-key calendar-mode-map [menu-bar goto julian]
- '("Julian date" . calendar-goto-julian-date))
+ '("Julian Date" . calendar-goto-julian-date))
(define-key calendar-mode-map [menu-bar goto islamic]
- '("Islamic date" . calendar-goto-islamic-date))
+ '("Islamic Date" . calendar-goto-islamic-date))
(define-key calendar-mode-map [menu-bar goto hebrew]
- '("Hebrew date" . calendar-goto-hebrew-date))
+ '("Hebrew Date" . calendar-goto-hebrew-date))
(define-key calendar-mode-map [menu-bar goto astro]
- '("Astronomical date" . calendar-goto-astro-day-number))
+ '("Astronomical Date" . calendar-goto-astro-day-number))
(define-key calendar-mode-map [menu-bar goto iso]
- '("ISO date" . calendar-goto-iso-date))
+ '("ISO Date" . calendar-goto-iso-date))
(define-key calendar-mode-map [menu-bar goto gregorian]
- '("Other date" . calendar-goto-date))
+ '("Other Date" . calendar-goto-date))
(define-key calendar-mode-map [menu-bar goto end-of-year]
- '("End of year" . calendar-end-of-year))
+ '("End of Year" . calendar-end-of-year))
(define-key calendar-mode-map [menu-bar goto beginning-of-year]
- '("Beginning of year" . calendar-beginning-of-year))
+ '("Beginning of Year" . calendar-beginning-of-year))
(define-key calendar-mode-map [menu-bar goto end-of-month]
- '("End of month" . calendar-end-of-month))
+ '("End of Month" . calendar-end-of-month))
(define-key calendar-mode-map [menu-bar goto beginning-of-month]
- '("Beginning of month" . calendar-beginning-of-month))
+ '("Beginning of Month" . calendar-beginning-of-month))
(define-key calendar-mode-map [menu-bar goto end-of-week]
- '("End of week" . calendar-end-of-week))
+ '("End of Week" . calendar-end-of-week))
(define-key calendar-mode-map [menu-bar goto beginning-of-week]
- '("Beginning of week" . calendar-beginning-of-week))
+ '("Beginning of Week" . calendar-beginning-of-week))
(define-key calendar-mode-map [menu-bar goto today]
- '("Today" . calendar-current-month))
+ '("Today" . calendar-goto-today))
(define-key calendar-mode-map [menu-bar goto mayan prev-rnd]
(put 'calendar-sunrise-sunset 'menu-enable '(calendar-event-to-date))
(put 'calendar-cursor-holidays 'menu-enable '(calendar-cursor-to-date))
(put 'view-diary-entries 'menu-enable '(calendar-cursor-to-date))
+(put 'view-other-diary-entries 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-mouse-insert-hebrew-diary-entry
'menu-enable
'(calendar-cursor-to-date))
(put 'insert-yearly-diary-entry 'menu-enable '(calendar-cursor-to-date))
(put 'insert-monthly-diary-entry 'menu-enable '(calendar-cursor-to-date))
(put 'insert-weekly-diary-entry 'menu-enable '(calendar-cursor-to-date))
+(put 'cal-tex-cursor-day 'menu-enable '(calendar-cursor-to-date))
+(put 'cal-tex-cursor-week 'menu-enable '(calendar-cursor-to-date))
+(put 'cal-tex-cursor-week2 'menu-enable '(calendar-cursor-to-date))
+(put 'cal-tex-cursor-week-iso 'menu-enable '(calendar-cursor-to-date))
+(put 'cal-tex-cursor-week-monday 'menu-enable '(calendar-cursor-to-date))
+(put 'cal-tex-cursor-filofax-2week
+ 'menu-enable '(calendar-cursor-to-date))
+(put 'cal-tex-cursor-filofax-week 'menu-enable '(calendar-cursor-to-date))
+(put 'cal-tex-cursor-month 'menu-enable '(calendar-cursor-to-date))
+(put 'cal-tex-cursor-month-landscape 'menu-enable '(calendar-cursor-to-date))
+(put 'cal-tex-cursor-year 'menu-enable '(calendar-cursor-to-date))
+(put 'cal-tex-cursor-filofax-year 'menu-enable '(calendar-cursor-to-date))
+(put 'cal-tex-cursor-year-landscape 'menu-enable '(calendar-cursor-to-date))
(defun calendar-event-to-date (&optional error)
"Date of last event.
(calendar-goto-date (calendar-event-to-date))
(view-diary-entries 1)))
+(defun calendar-mouse-view-other-diary-entries ()
+ "View diary entries from alternative file on mouse-selected date."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (call-interactively 'view-other-diary-entries)))
+
+(defun calendar-mouse-insert-diary-entry ()
+ "Insert diary entry for mouse-selected date."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (insert-diary-entry nil)))
+
(defun calendar-mouse-set-mark ()
"Mark the date under the cursor."
(interactive)
(calendar-goto-date (calendar-event-to-date))
(calendar-set-mark nil)))
+(defun cal-tex-mouse-day ()
+ "Make a buffer with LaTeX commands for the day mouse is on."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (cal-tex-cursor-day nil)))
+
+(defun cal-tex-mouse-week ()
+ "One page calendar for week indicated by cursor.
+Holidays are included if `cal-tex-holidays' is t."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (cal-tex-cursor-week nil)))
+
+(defun cal-tex-mouse-week2 ()
+ "Make a buffer with LaTeX commands for the week cursor is on.
+The printed output will be on two pages."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (cal-tex-cursor-week2 nil)))
+
+(defun cal-tex-mouse-week-iso ()
+ "One page calendar for week indicated by cursor.
+Holidays are included if `cal-tex-holidays' is t."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (cal-tex-cursor-week-iso nil)))
+
+(defun cal-tex-mouse-week-monday ()
+ "One page calendar for week indicated by cursor."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (cal-tex-cursor-week-monday nil)))
+
+(defun cal-tex-mouse-filofax-2week ()
+ "One page Filofax calendar for week indicated by cursor."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (cal-tex-cursor-filofax-2week nil)))
+
+(defun cal-tex-mouse-filofax-week ()
+ "Two page Filofax calendar for week indicated by cursor."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (cal-tex-cursor-filofax-week nil)))
+
+(defun cal-tex-mouse-month ()
+ "Make a buffer with LaTeX commands for the month cursor is on.
+Calendar is condensed onto one page."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (cal-tex-cursor-month nil)))
+
+(defun cal-tex-mouse-month-landscape ()
+ "Make a buffer with LaTeX commands for the month cursor is on.
+The output is in landscape format, one month to a page."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (cal-tex-cursor-month-landscape nil)))
+
+(defun cal-tex-mouse-year ()
+ "Make a buffer with LaTeX commands for the year cursor is on."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (cal-tex-cursor-year nil)))
+
+(defun cal-tex-mouse-filofax-year ()
+ "Make a buffer with LaTeX commands for Filofax calendar of year cursor is on."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (cal-tex-cursor-filofax-year nil)))
+
+(defun cal-tex-mouse-year-landscape ()
+ "Make a buffer with LaTeX commands for the year cursor is on."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (cal-tex-cursor-year-landscape nil)))
+
(defun calendar-mouse-print-dates ()
"Pop up menu of equivalent dates to mouse selected date."
(interactive)
- (let ((date (calendar-event-to-date)))
- (x-popup-menu
- event
- (list
- "Date Menu"
- (append
- (list
- (concat (calendar-date-string date) " (Gregorian)")
- (list (calendar-day-of-year-string date))
- (list (format "ISO date: %s" (calendar-iso-date-string date)))
- (list (format "Julian date: %s" (calendar-julian-date-string date)))
- (list (format "Astronomical (Julian) date (before noon): %s"
- (calendar-astro-date-string date)))
- (list (format "Hebrew date (before sunset): %s"
- (calendar-hebrew-date-string date))))
- (let ((i (calendar-islamic-date-string date)))
- (if (not (string-equal i ""))
- (list (list (format "Islamic date (before sunset): %s" i)))))
- (let ((f (calendar-french-date-string date)))
- (if (not (string-equal f ""))
- (list (list (format "French Revolutionary date: %s" f)))))
- (list
- (list
- (format "Mayan date: %s" (calendar-mayan-date-string date)))))))))
+ (let ((date (calendar-event-to-date))
+ (selection
+ (x-popup-menu
+ event
+ (list
+ (concat (calendar-date-string date) " (Gregorian)")
+ (append
+ (list
+ (concat (calendar-date-string date) " (Gregorian)")
+ (list (calendar-day-of-year-string date))
+ (list (format "ISO date: %s" (calendar-iso-date-string date)))
+ (list (format "Julian date: %s"
+ (calendar-julian-date-string date)))
+ (list
+ (format "Astronomical (Julian) day number (after noon UTC): %s"
+ (calendar-astro-date-string date)))
+ (list (format "Hebrew date (before sunset): %s"
+ (calendar-hebrew-date-string date))))
+ (let ((i (calendar-islamic-date-string date)))
+ (if (not (string-equal i ""))
+ (list (list (format "Islamic date (before sunset): %s" i)))))
+ (list
+ (list (format "Chinese date: %s"
+ (calendar-chinese-date-string date))))
+; (list '("Chinese date (select to echo Chinese date)"
+; . calendar-mouse-chinese-date))
+ (let ((c (calendar-coptic-date-string date)))
+ (if (not (string-equal c ""))
+ (list (list (format "Coptic date: %s" c)))))
+ (let ((e (calendar-ethiopic-date-string date)))
+ (if (not (string-equal e ""))
+ (list (list (format "Ethiopic date: %s" e)))))
+ (let ((f (calendar-french-date-string date)))
+ (if (not (string-equal f ""))
+ (list (list (format "French Revolutionary date: %s" f)))))
+ (list
+ (list
+ (format "Mayan date: %s"
+ (calendar-mayan-date-string date)))))))))
+ (and selection (call-interactively selection))))
+
+(defun calendar-mouse-chinese-date ()
+ "Show Chinese equivalent for mouse-selected date."
+ (interactive)
+ (save-excursion
+ (calendar-goto-date (calendar-event-to-date))
+ (calendar-print-chinese-date)))
(defun calendar-mouse-2-date-menu (event)
"Pop up menu for Mouse-2 for selected date in the calendar window."
(selection
(x-popup-menu
event
- (list "Menu"
+ (list (calendar-date-string date t nil)
(list
- (calendar-date-string date t t)
- '("Moon phase" . calendar-phases-of-moon)
- '("Diary entries" . calendar-mouse-view-diary-entries)
+ ""
'("Holidays" . calendar-mouse-holidays)
'("Mark date" . calendar-mouse-set-mark)
'("Sunrise/sunset" . calendar-mouse-sunrise/sunset)
- '("Other calendars" . calendar-mouse-print-dates))))))
+ '("Other calendars" . calendar-mouse-print-dates)
+ '("Prepare LaTeX buffer" . calendar-mouse-cal-tex-menu)
+ '("Diary entries" . calendar-mouse-view-diary-entries)
+ '("Insert diary entry" . calendar-mouse-insert-diary-entry)
+ '("Other diary file entries"
+ . calendar-mouse-view-other-diary-entries)
+ )))))
+ (and selection (call-interactively selection))))
+
+(defun calendar-mouse-cal-tex-menu (event)
+ "Pop up submenu for Mouse-2 for cal-tex commands for selected date in the calendar window."
+ (interactive "e")
+ (let* ((selection
+ (x-popup-menu
+ event
+ (list (calendar-date-string date t nil)
+ (list
+ ""
+ '("Daily (1 page)" . cal-tex-mouse-day)
+ '("Weekly (1 page)" . cal-tex-mouse-week)
+ '("Weekly (2 pages)" . cal-tex-mouse-week2)
+ '("Weekly (other style; 1 page)" . cal-tex-mouse-week-iso)
+ '("Weekly (yet another style; 1 page)" .
+ cal-tex-mouse-week-monday)
+ '("Monthly" . cal-tex-mouse-month)
+ '("Monthly (landscape)" . cal-tex-mouse-month-landscape)
+ '("Yearly" . cal-tex-mouse-year)
+ '("Yearly (landscape)" . cal-tex-mouse-year-landscape)
+ '("Filofax styles" . cal-tex-mouse-filofax)
+ )))))
+ (and selection (call-interactively selection))))
+
+(defun cal-tex-mouse-filofax (event)
+ "Pop up sub-submenu for Mouse-2 for Filofax cal-tex commands for selected date."
+ (interactive "e")
+ (let* ((selection
+ (x-popup-menu
+ event
+ (list (calendar-date-string date t nil)
+ (list
+ ""
+ '("Filofax Weekly (2-weeks-at-a-glance)" .
+ cal-tex-mouse-filofax-2week)
+ '("Filofax Weekly (week-at-a-glance)" .
+ cal-tex-mouse-filofax-week)
+ '("Filofax Yearly" . cal-tex-mouse-filofax-year)
+ )))))
(and selection (call-interactively selection))))
(define-key calendar-mouse-3-map [exit-calendar]