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