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