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