]> code.delx.au - gnu-emacs/blob - lisp/calendar/cal-menu.el
(date, event): Don't declare as dynamic-var.
[gnu-emacs] / lisp / calendar / cal-menu.el
1 ;;; cal-menu.el --- calendar functions for menu bar and popup menu support
2
3 ;; Copyright (C) 1994, 1995, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
4
5 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
6 ;; Lara Rios <lrios@coewl.cen.uiuc.edu>
7 ;; Maintainer: Glenn Morris <rgm@gnu.org>
8 ;; Keywords: calendar
9 ;; Human-Keywords: calendar, popup menus, menu bar
10
11 ;; This file is part of GNU Emacs.
12
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
17
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
27
28 ;;; Commentary:
29
30 ;; This collection of functions implements menu bar and popup menu support for
31 ;; calendar.el.
32
33 ;; Comments, corrections, and improvements should be sent to
34 ;; Edward M. Reingold Department of Computer Science
35 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
36 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
37 ;; Urbana, Illinois 61801
38
39 ;;; Code:
40
41 (defvar displayed-month)
42 (defvar displayed-year)
43
44 (eval-when-compile (require 'calendar))
45
46 (define-key calendar-mode-map [menu-bar edit] 'undefined)
47 (define-key calendar-mode-map [menu-bar search] 'undefined)
48
49 (define-key calendar-mode-map [down-mouse-2] 'calendar-mouse-2-date-menu)
50 (define-key calendar-mode-map [mouse-2] 'ignore)
51
52 (defvar calendar-mouse-3-map (make-sparse-keymap "Calendar"))
53 (define-key calendar-mode-map [down-mouse-3] calendar-mouse-3-map)
54
55 (define-key calendar-mode-map [menu-bar moon]
56 (cons "Moon" (make-sparse-keymap "Moon")))
57
58 (define-key calendar-mode-map [menu-bar moon moon]
59 '("Lunar Phases" . calendar-phases-of-moon))
60
61 (define-key calendar-mode-map [menu-bar diary]
62 (cons "Diary" (make-sparse-keymap "Diary")))
63
64 (define-key calendar-mode-map [menu-bar diary heb]
65 '("Insert Hebrew" . calendar-mouse-insert-hebrew-diary-entry))
66 (define-key calendar-mode-map [menu-bar diary isl]
67 '("Insert Islamic" . calendar-mouse-insert-islamic-diary-entry))
68 (define-key calendar-mode-map [menu-bar diary baha]
69 '("Insert Baha'i" . calendar-mouse-insert-bahai-diary-entry))
70 (define-key calendar-mode-map [menu-bar diary cyc]
71 '("Insert Cyclic" . insert-cyclic-diary-entry))
72 (define-key calendar-mode-map [menu-bar diary blk]
73 '("Insert Block" . insert-block-diary-entry))
74 (define-key calendar-mode-map [menu-bar diary ann]
75 '("Insert Anniversary" . insert-anniversary-diary-entry))
76 (define-key calendar-mode-map [menu-bar diary yr]
77 '("Insert Yearly" . insert-yearly-diary-entry))
78 (define-key calendar-mode-map [menu-bar diary mon]
79 '("Insert Monthly" . insert-monthly-diary-entry))
80 (define-key calendar-mode-map [menu-bar diary wk]
81 '("Insert Weekly" . insert-weekly-diary-entry))
82 (define-key calendar-mode-map [menu-bar diary ent]
83 '("Insert Diary Entry" . insert-diary-entry))
84 (define-key calendar-mode-map [menu-bar diary all]
85 '("Show All" . show-all-diary-entries))
86 (define-key calendar-mode-map [menu-bar diary mark]
87 '("Mark All" . mark-diary-entries))
88 (define-key calendar-mode-map [menu-bar diary view]
89 '("Cursor Date" . view-diary-entries))
90 (define-key calendar-mode-map [menu-bar diary view]
91 '("Other File" . view-other-diary-entries))
92
93 (define-key calendar-mode-map [menu-bar Holidays]
94 (cons "Holidays" (make-sparse-keymap "Holidays")))
95
96 (define-key calendar-mode-map [menu-bar goto]
97 (cons "Goto" (make-sparse-keymap "Goto")))
98
99 (define-key calendar-mode-map [menu-bar goto french]
100 '("French Date" . calendar-goto-french-date))
101 (define-key calendar-mode-map [menu-bar goto mayan]
102 (cons "Mayan Date" (make-sparse-keymap "Mayan")))
103 (define-key calendar-mode-map [menu-bar goto ethiopic]
104 '("Ethiopic Date" . calendar-goto-ethiopic-date))
105 (define-key calendar-mode-map [menu-bar goto coptic]
106 '("Coptic Date" . calendar-goto-coptic-date))
107 (define-key calendar-mode-map [menu-bar goto chinese]
108 '("Chinese Date" . calendar-goto-chinese-date))
109 (define-key calendar-mode-map [menu-bar goto julian]
110 '("Julian Date" . calendar-goto-julian-date))
111 (define-key calendar-mode-map [menu-bar goto islamic]
112 '("Islamic Date" . calendar-goto-islamic-date))
113 (define-key calendar-mode-map [menu-bar goto persian]
114 '("Baha'i Date" . calendar-goto-bahai-date))
115 (define-key calendar-mode-map [menu-bar goto persian]
116 '("Persian Date" . calendar-goto-persian-date))
117 (define-key calendar-mode-map [menu-bar goto hebrew]
118 '("Hebrew Date" . calendar-goto-hebrew-date))
119 (define-key calendar-mode-map [menu-bar goto astro]
120 '("Astronomical Date" . calendar-goto-astro-day-number))
121 (define-key calendar-mode-map [menu-bar goto iso]
122 '("ISO Date" . calendar-goto-iso-date))
123 (define-key calendar-mode-map [menu-bar goto iso-week]
124 '("ISO Week" . calendar-goto-iso-week))
125 (define-key calendar-mode-map [menu-bar goto day-of-year]
126 '("Day of Year" . calendar-goto-day-of-year))
127 (define-key calendar-mode-map [menu-bar goto gregorian]
128 '("Other Date" . calendar-goto-date))
129 (define-key calendar-mode-map [menu-bar goto end-of-year]
130 '("End of Year" . calendar-end-of-year))
131 (define-key calendar-mode-map [menu-bar goto beginning-of-year]
132 '("Beginning of Year" . calendar-beginning-of-year))
133 (define-key calendar-mode-map [menu-bar goto end-of-month]
134 '("End of Month" . calendar-end-of-month))
135 (define-key calendar-mode-map [menu-bar goto beginning-of-month]
136 '("Beginning of Month" . calendar-beginning-of-month))
137 (define-key calendar-mode-map [menu-bar goto end-of-week]
138 '("End of Week" . calendar-end-of-week))
139 (define-key calendar-mode-map [menu-bar goto beginning-of-week]
140 '("Beginning of Week" . calendar-beginning-of-week))
141 (define-key calendar-mode-map [menu-bar goto today]
142 '("Today" . calendar-goto-today))
143
144
145 (define-key calendar-mode-map [menu-bar goto mayan prev-rnd]
146 '("Previous Round" . calendar-previous-calendar-round-date))
147 (define-key calendar-mode-map [menu-bar goto mayan nxt-rnd]
148 '("Next Round" . calendar-next-calendar-round-date))
149 (define-key calendar-mode-map [menu-bar goto mayan prev-haab]
150 '("Previous Haab" . calendar-previous-haab-date))
151 (define-key calendar-mode-map [menu-bar goto mayan next-haab]
152 '("Next Haab" . calendar-next-haab-date))
153 (define-key calendar-mode-map [menu-bar goto mayan prev-tzol]
154 '("Previous Tzolkin" . calendar-previous-tzolkin-date))
155 (define-key calendar-mode-map [menu-bar goto mayan next-tzol]
156 '("Next Tzolkin" . calendar-next-tzolkin-date))
157
158 (define-key calendar-mode-map [menu-bar scroll]
159 (cons "Scroll" (make-sparse-keymap "Scroll")))
160
161 (define-key calendar-mode-map [menu-bar scroll bk-12]
162 '("Backward 1 Year" . "4\ev"))
163 (define-key calendar-mode-map [menu-bar scroll bk-3]
164 '("Backward 3 Months" . scroll-calendar-right-three-months))
165 (define-key calendar-mode-map [menu-bar scroll bk-1]
166 '("Backward 1 Month" . scroll-calendar-right))
167 (define-key calendar-mode-map [menu-bar scroll fwd-12]
168 '("Forward 1 Year" . "4\C-v"))
169 (define-key calendar-mode-map [menu-bar scroll fwd-3]
170 '("Forward 3 Months" . scroll-calendar-left-three-months))
171 (define-key calendar-mode-map [menu-bar scroll fwd-1]
172 '("Forward 1 Month" . scroll-calendar-left))
173
174 (defun calendar-flatten (list)
175 "Flatten LIST eliminating sublists structure; result is a list of atoms.
176 This is the same as the preorder list of leaves in a rooted forest."
177 (if (atom list)
178 (list list)
179 (if (cdr list)
180 (append (calendar-flatten (car list)) (calendar-flatten (cdr list)))
181 (calendar-flatten (car list)))))
182
183 (defun cal-menu-x-popup-menu (position menu)
184 "Like `x-popup-menu', but prints an error message if popup menus are
185 not available."
186 (if (display-popup-menus-p)
187 (x-popup-menu position menu)
188 (error "Popup menus are not available on this system")))
189
190 (defun cal-menu-list-holidays-year ()
191 "Display a list of the holidays of the selected date's year."
192 (interactive)
193 (let ((year (extract-calendar-year (calendar-cursor-to-date))))
194 (list-holidays year year)))
195
196 (defun cal-menu-list-holidays-following-year ()
197 "Display a list of the holidays of the following year."
198 (interactive)
199 (let ((year (1+ (extract-calendar-year (calendar-cursor-to-date)))))
200 (list-holidays year year)))
201
202 (defun cal-menu-list-holidays-previous-year ()
203 "Display a list of the holidays of the previous year."
204 (interactive)
205 (let ((year (1- (extract-calendar-year (calendar-cursor-to-date)))))
206 (list-holidays year year)))
207
208 (defun cal-menu-update ()
209 ;; Update the holiday part of calendar menu bar for the current display.
210 (condition-case nil
211 (if (eq major-mode 'calendar-mode)
212 (let ((l))
213 (calendar-for-loop;; Show 11 years--5 before, 5 after year of
214 ;; middle month
215 i from (- displayed-year 5) to (+ displayed-year 5) do
216 (setq l (cons (vector (format "For Year %s" i)
217 (list (list 'lambda 'nil '(interactive)
218 (list 'list-holidays i i)))
219 t)
220 l)))
221 (setq l (cons ["Mark Holidays" mark-calendar-holidays t]
222 (cons ["Unmark Calendar" calendar-unmark t]
223 (cons "--" l))))
224 (define-key calendar-mode-map [menu-bar Holidays]
225 (cons "Holidays" (easy-menu-create-menu "Holidays" (nreverse l))))
226 (define-key calendar-mode-map [menu-bar Holidays separator]
227 '("--"))
228 (define-key calendar-mode-map [menu-bar Holidays today]
229 `(,(format "For Today (%s)"
230 (calendar-date-string (calendar-current-date) t t))
231 . cal-menu-today-holidays))
232 (let ((title
233 (let ((m1 displayed-month)
234 (y1 displayed-year)
235 (m2 displayed-month)
236 (y2 displayed-year))
237 (increment-calendar-month m1 y1 -1)
238 (increment-calendar-month m2 y2 1)
239 (if (= y1 y2)
240 (format "%s-%s, %d"
241 (calendar-month-name m1 'abbrev)
242 (calendar-month-name m2 'abbrev)
243 y2)
244 (format "%s, %d-%s, %d"
245 (calendar-month-name m1 'abbrev)
246 y1
247 (calendar-month-name m2 'abbrev)
248 y2)))))
249 (define-key calendar-mode-map [menu-bar Holidays 3-month]
250 `(,(format "For Window (%s)" title)
251 . list-calendar-holidays)))
252 (let ((date (calendar-cursor-to-date)))
253 (if date
254 (define-key calendar-mode-map [menu-bar Holidays 1-day]
255 `(,(format "For Cursor Date (%s)"
256 (calendar-date-string date t t))
257 . calendar-cursor-holidays))))))
258 ;; Try to avoid entering infinite beep mode in case of errors.
259 (error (ding))))
260
261 (defun calendar-event-to-date (&optional error)
262 "Date of last event.
263 If event is not on a specific date, signals an error if optional parameter
264 ERROR is t, otherwise just returns nil."
265 (save-excursion
266 (set-buffer (window-buffer (posn-window (event-start last-input-event))))
267 (goto-char (posn-point (event-start last-input-event)))
268 (calendar-cursor-to-date error)))
269
270 (defun calendar-mouse-insert-hebrew-diary-entry (event)
271 "Pop up menu to insert a Hebrew-date diary entry."
272 (interactive "e")
273 (let ((hebrew-selection
274 (cal-menu-x-popup-menu
275 event
276 (list "Hebrew insert menu"
277 (list (calendar-hebrew-date-string (calendar-cursor-to-date))
278 '("One time" . insert-hebrew-diary-entry)
279 '("Monthly" . insert-monthly-hebrew-diary-entry)
280 '("Yearly" . insert-yearly-hebrew-diary-entry))))))
281 (and hebrew-selection (call-interactively hebrew-selection))))
282
283 (defun calendar-mouse-insert-islamic-diary-entry (event)
284 "Pop up menu to insert an Islamic-date diary entry."
285 (interactive "e")
286 (let ((islamic-selection
287 (cal-menu-x-popup-menu
288 event
289 (list "Islamic insert menu"
290 (list (calendar-islamic-date-string (calendar-cursor-to-date))
291 '("One time" . insert-islamic-diary-entry)
292 '("Monthly" . insert-monthly-islamic-diary-entry)
293 '("Yearly" . insert-yearly-islamic-diary-entry))))))
294 (and islamic-selection (call-interactively islamic-selection))))
295
296 (defun calendar-mouse-insert-bahai-diary-entry (event)
297 "Pop up menu to insert an Baha'i-date diary entry."
298 (interactive "e")
299 (let ((bahai-selection
300 (x-popup-menu
301 event
302 (list "Baha'i insert menu"
303 (list (calendar-bahai-date-string (calendar-cursor-to-date))
304 '("One time" . insert-bahai-diary-entry)
305 '("Monthly" . insert-monthly-bahai-diary-entry)
306 '("Yearly" . insert-yearly-bahai-diary-entry))))))
307 (and bahai-selection (call-interactively bahai-selection))))
308
309 (defun calendar-mouse-sunrise/sunset ()
310 "Show sunrise/sunset times for mouse-selected date."
311 (interactive)
312 (save-excursion
313 (calendar-mouse-goto-date (calendar-event-to-date))
314 (calendar-sunrise-sunset)))
315
316 (defun cal-menu-today-holidays ()
317 "Show holidays for today's date."
318 (interactive)
319 (save-excursion
320 (calendar-cursor-to-date (calendar-current-date))
321 (calendar-cursor-holidays)))
322
323 (autoload 'check-calendar-holidays "holidays")
324 (autoload 'diary-list-entries "diary-lib")
325
326 (defun calendar-mouse-holidays (&optional event)
327 "Pop up menu of holidays for mouse selected date."
328 (interactive "e")
329 (let* ((date (calendar-event-to-date))
330 (l (mapcar 'list (check-calendar-holidays date)))
331 (selection
332 (cal-menu-x-popup-menu
333 event
334 (list
335 (format "Holidays for %s" (calendar-date-string date))
336 (append
337 (list (format "Holidays for %s" (calendar-date-string date)))
338 (if l l '("None")))))))
339 (and selection (call-interactively selection))))
340
341 (defun calendar-mouse-view-diary-entries (&optional date diary event)
342 "Pop up menu of diary entries for mouse-selected date.
343 Use optional DATE and alternative file DIARY.
344
345 Any holidays are shown if `holidays-in-diary-buffer' is t."
346 (interactive "i\ni\ne")
347 (let* ((date (if date date (calendar-event-to-date)))
348 (diary-file (if diary diary diary-file))
349 (diary-list-include-blanks nil)
350 (diary-display-hook 'ignore)
351 (diary-entries
352 (mapcar (lambda (x) (split-string (car (cdr x)) "\^M\\|\n"))
353 (diary-list-entries date 1 'list-only)))
354 (holidays (if holidays-in-diary-buffer
355 (check-calendar-holidays date)))
356 (title (concat "Diary entries "
357 (if diary (format "from %s " diary) "")
358 "for "
359 (calendar-date-string date)))
360 (selection
361 (cal-menu-x-popup-menu
362 event
363 (list title
364 (append
365 (list title)
366 (mapcar (lambda (x) (list (concat " " x))) holidays)
367 (if holidays
368 (list "--shadow-etched-in" "--shadow-etched-in"))
369 (if diary-entries
370 (mapcar 'list (calendar-flatten diary-entries))
371 '("None")))))))
372 (and selection (call-interactively selection))))
373
374 (defun calendar-mouse-view-other-diary-entries ()
375 "Pop up menu of diary entries from alternative file on mouse-selected date."
376 (interactive)
377 (calendar-mouse-view-diary-entries
378 (calendar-event-to-date)
379 (read-file-name "Enter diary file name: " default-directory nil t)))
380
381 (defun calendar-mouse-insert-diary-entry ()
382 "Insert diary entry for mouse-selected date."
383 (interactive)
384 (save-excursion
385 (calendar-mouse-goto-date (calendar-event-to-date))
386 (insert-diary-entry nil)))
387
388 (defun calendar-mouse-set-mark ()
389 "Mark the date under the cursor."
390 (interactive)
391 (save-excursion
392 (calendar-mouse-goto-date (calendar-event-to-date))
393 (calendar-set-mark nil)))
394
395 (defun cal-tex-mouse-day ()
396 "Make a buffer with LaTeX commands for the day mouse is on."
397 (interactive)
398 (save-excursion
399 (calendar-mouse-goto-date (calendar-event-to-date))
400 (cal-tex-cursor-day nil)))
401
402 (defun cal-tex-mouse-week ()
403 "One page calendar for week indicated by cursor.
404 Holidays are included if `cal-tex-holidays' is t."
405 (interactive)
406 (save-excursion
407 (calendar-mouse-goto-date (calendar-event-to-date))
408 (cal-tex-cursor-week nil)))
409
410 (defun cal-tex-mouse-week2 ()
411 "Make a buffer with LaTeX commands for the week cursor is on.
412 The printed output will be on two pages."
413 (interactive)
414 (save-excursion
415 (calendar-mouse-goto-date (calendar-event-to-date))
416 (cal-tex-cursor-week2 nil)))
417
418 (defun cal-tex-mouse-week-iso ()
419 "One page calendar for week indicated by cursor.
420 Holidays are included if `cal-tex-holidays' is t."
421 (interactive)
422 (save-excursion
423 (calendar-mouse-goto-date (calendar-event-to-date))
424 (cal-tex-cursor-week-iso nil)))
425
426 (defun cal-tex-mouse-week-monday ()
427 "One page calendar for week indicated by cursor."
428 (interactive)
429 (save-excursion
430 (calendar-mouse-goto-date (calendar-event-to-date))
431 (cal-tex-cursor-week-monday nil)))
432
433 (defun cal-tex-mouse-filofax-daily ()
434 "Day-per-page Filofax calendar for week indicated by cursor."
435 (interactive)
436 (save-excursion
437 (calendar-mouse-goto-date (calendar-event-to-date))
438 (cal-tex-cursor-filofax-daily nil)))
439
440 (defun cal-tex-mouse-filofax-2week ()
441 "One page Filofax calendar for week indicated by cursor."
442 (interactive)
443 (save-excursion
444 (calendar-mouse-goto-date (calendar-event-to-date))
445 (cal-tex-cursor-filofax-2week nil)))
446
447 (defun cal-tex-mouse-filofax-week ()
448 "Two page Filofax calendar for week indicated by cursor."
449 (interactive)
450 (save-excursion
451 (calendar-mouse-goto-date (calendar-event-to-date))
452 (cal-tex-cursor-filofax-week nil)))
453
454 (defun cal-tex-mouse-month ()
455 "Make a buffer with LaTeX commands for the month cursor is on.
456 Calendar is condensed onto one page."
457 (interactive)
458 (save-excursion
459 (calendar-mouse-goto-date (calendar-event-to-date))
460 (cal-tex-cursor-month nil)))
461
462 (defun cal-tex-mouse-month-landscape ()
463 "Make a buffer with LaTeX commands for the month cursor is on.
464 The output is in landscape format, one month to a page."
465 (interactive)
466 (save-excursion
467 (calendar-mouse-goto-date (calendar-event-to-date))
468 (cal-tex-cursor-month-landscape nil)))
469
470 (defun cal-tex-mouse-year ()
471 "Make a buffer with LaTeX commands for the year cursor is on."
472 (interactive)
473 (save-excursion
474 (calendar-mouse-goto-date (calendar-event-to-date))
475 (cal-tex-cursor-year nil)))
476
477 (defun cal-tex-mouse-filofax-year ()
478 "Make a buffer with LaTeX commands for Filofax calendar of year cursor is on."
479 (interactive)
480 (save-excursion
481 (calendar-mouse-goto-date (calendar-event-to-date))
482 (cal-tex-cursor-filofax-year nil)))
483
484 (defun cal-tex-mouse-year-landscape ()
485 "Make a buffer with LaTeX commands for the year cursor is on."
486 (interactive)
487 (save-excursion
488 (calendar-mouse-goto-date (calendar-event-to-date))
489 (cal-tex-cursor-year-landscape nil)))
490
491 (defun calendar-mouse-print-dates (&optional event)
492 "Pop up menu of equivalent dates to mouse selected date."
493 (interactive "e")
494 (let* ((date (calendar-event-to-date))
495 (selection
496 (cal-menu-x-popup-menu
497 event
498 (list
499 (concat (calendar-date-string date) " (Gregorian)")
500 (append
501 (list
502 (concat (calendar-date-string date) " (Gregorian)")
503 (list (calendar-day-of-year-string date))
504 (list (format "ISO date: %s" (calendar-iso-date-string date)))
505 (list (format "Julian date: %s"
506 (calendar-julian-date-string date)))
507 (list
508 (format "Astronomical (Julian) day number (at noon UTC): %s.0"
509 (calendar-astro-date-string date)))
510 (list
511 (format "Fixed (RD) date: %s"
512 (calendar-absolute-from-gregorian date)))
513 (list (format "Hebrew date (before sunset): %s"
514 (calendar-hebrew-date-string date)))
515 (list (format "Persian date: %s"
516 (calendar-persian-date-string date)))
517 (list (format "Baha'i date (before sunset): %s"
518 (calendar-bahai-date-string date))))
519 (let ((i (calendar-islamic-date-string date)))
520 (if (not (string-equal i ""))
521 (list (list (format "Islamic date (before sunset): %s" i)))))
522 (list
523 (list (format "Chinese date: %s"
524 (calendar-chinese-date-string date))))
525 ;; (list '("Chinese date (select to echo Chinese date)"
526 ;; . calendar-mouse-chinese-date))
527 (let ((c (calendar-coptic-date-string date)))
528 (if (not (string-equal c ""))
529 (list (list (format "Coptic date: %s" c)))))
530 (let ((e (calendar-ethiopic-date-string date)))
531 (if (not (string-equal e ""))
532 (list (list (format "Ethiopic date: %s" e)))))
533 (let ((f (calendar-french-date-string date)))
534 (if (not (string-equal f ""))
535 (list (list (format "French Revolutionary date: %s" f)))))
536 (list
537 (list
538 (format "Mayan date: %s"
539 (calendar-mayan-date-string date)))))))))
540 (and selection (call-interactively selection))))
541
542 (defun calendar-mouse-chinese-date ()
543 "Show Chinese equivalent for mouse-selected date."
544 (interactive)
545 (save-excursion
546 (calendar-mouse-goto-date (calendar-event-to-date))
547 (calendar-print-chinese-date)))
548
549 (defun calendar-mouse-goto-date (date)
550 (set-buffer (window-buffer (posn-window (event-start last-input-event))))
551 (calendar-goto-date date))
552
553 (defun calendar-mouse-2-date-menu (event)
554 "Pop up menu for Mouse-2 for selected date in the calendar window."
555 (interactive "e")
556 (let* ((date (calendar-event-to-date t))
557 (selection
558 (cal-menu-x-popup-menu
559 event
560 (list (calendar-date-string date t nil)
561 (list
562 ""
563 '("Holidays" . calendar-mouse-holidays)
564 '("Mark date" . calendar-mouse-set-mark)
565 '("Sunrise/sunset" . calendar-mouse-sunrise/sunset)
566 '("Other calendars" . calendar-mouse-print-dates)
567 '("Prepare LaTeX buffer" . calendar-mouse-cal-tex-menu)
568 '("Diary entries" . calendar-mouse-view-diary-entries)
569 '("Insert diary entry" . calendar-mouse-insert-diary-entry)
570 '("Other diary file entries"
571 . calendar-mouse-view-other-diary-entries)
572 )))))
573 (and selection (call-interactively selection))))
574
575 (defun calendar-mouse-cal-tex-menu (event)
576 "Pop up submenu for Mouse-2 for cal-tex commands for selected date in the calendar window."
577 (interactive "e")
578 (let* ((selection
579 (cal-menu-x-popup-menu
580 event
581 (list (calendar-date-string (calendar-event-to-date t) t nil)
582 (list
583 ""
584 '("Daily (1 page)" . cal-tex-mouse-day)
585 '("Weekly (1 page)" . cal-tex-mouse-week)
586 '("Weekly (2 pages)" . cal-tex-mouse-week2)
587 '("Weekly (other style; 1 page)" . cal-tex-mouse-week-iso)
588 '("Weekly (yet another style; 1 page)" .
589 cal-tex-mouse-week-monday)
590 '("Monthly" . cal-tex-mouse-month)
591 '("Monthly (landscape)" . cal-tex-mouse-month-landscape)
592 '("Yearly" . cal-tex-mouse-year)
593 '("Yearly (landscape)" . cal-tex-mouse-year-landscape)
594 '("Filofax styles" . cal-tex-mouse-filofax)
595 )))))
596 (and selection (call-interactively selection))))
597
598 (defun cal-tex-mouse-filofax (event)
599 "Pop up sub-submenu for Mouse-2 for Filofax cal-tex commands for selected date."
600 (interactive "e")
601 (let* ((selection
602 (cal-menu-x-popup-menu
603 event
604 (list (calendar-date-string (calendar-event-to-date t) t nil)
605 (list
606 ""
607 '("Filofax Daily (one-day-per-page)" .
608 cal-tex-mouse-filofax-daily)
609 '("Filofax Weekly (2-weeks-at-a-glance)" .
610 cal-tex-mouse-filofax-2week)
611 '("Filofax Weekly (week-at-a-glance)" .
612 cal-tex-mouse-filofax-week)
613 '("Filofax Yearly" . cal-tex-mouse-filofax-year)
614 )))))
615 (and selection (call-interactively selection))))
616
617 (define-key calendar-mouse-3-map [exit-calendar]
618 '("Exit calendar" . exit-calendar))
619 (define-key calendar-mouse-3-map [show-diary]
620 '("Show diary" . show-all-diary-entries))
621 (define-key calendar-mouse-3-map [lunar-phases]
622 '("Lunar phases" . calendar-phases-of-moon))
623 (define-key calendar-mouse-3-map [unmark]
624 '("Unmark" . calendar-unmark))
625 (define-key calendar-mouse-3-map [mark-holidays]
626 '("Mark holidays" . mark-calendar-holidays))
627 (define-key calendar-mouse-3-map [list-holidays]
628 '("List holidays" . list-calendar-holidays))
629 (define-key calendar-mouse-3-map [mark-diary-entries]
630 '("Mark diary entries" . mark-diary-entries))
631 (define-key calendar-mouse-3-map [scroll-backward]
632 '("Scroll backward" . scroll-calendar-right-three-months))
633 (define-key calendar-mouse-3-map [scroll-forward]
634 '("Scroll forward" . scroll-calendar-left-three-months))
635
636 (run-hooks 'cal-menu-load-hook)
637
638 (provide 'cal-menu)
639
640 ;; arch-tag: aa81cf73-ce89-48a4-97ec-9ef861e87fe9
641 ;;; cal-menu.el ends here