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