Commit | Line | Data |
---|---|---|
aef1a243 RS |
1 | ;;; cal-menu.el --- calendar functions for menu bar and popup menu support |
2 | ||
5bb7a2d5 | 3 | ;; Copyright (C) 1994, 1995, 2001, 2003 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 | ||
5bb7a2d5 GM |
40 | (defvar displayed-month) |
41 | (defvar displayed-year) | |
42 | ||
dce5c916 | 43 | (eval-when-compile (require 'calendar)) |
b5305eb0 | 44 | (require 'easymenu) |
20eff799 | 45 | |
7c77d665 | 46 | (define-key calendar-mode-map [menu-bar edit] 'undefined) |
bc83970d | 47 | (define-key calendar-mode-map [menu-bar search] 'undefined) |
7c77d665 | 48 | |
89e14386 | 49 | (define-key calendar-mode-map [down-mouse-2] 'calendar-mouse-2-date-menu) |
982f12d0 | 50 | (define-key calendar-mode-map [mouse-2] 'ignore) |
89e14386 RS |
51 | |
52 | (defvar calendar-mouse-3-map (make-sparse-keymap "Calendar")) | |
53 | (define-key calendar-mode-map [down-mouse-3] calendar-mouse-3-map) | |
5c51b72e | 54 | (define-key calendar-mode-map [C-down-mouse-3] calendar-mouse-3-map) |
aef1a243 | 55 | |
48b29ac0 ER |
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] | |
0e520d74 | 60 | '("Lunar Phases" . calendar-phases-of-moon)) |
48b29ac0 | 61 | |
aef1a243 RS |
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] | |
0e520d74 | 70 | '("Insert Cyclic" . insert-cyclic-diary-entry)) |
aef1a243 | 71 | (define-key calendar-mode-map [menu-bar diary blk] |
0e520d74 | 72 | '("Insert Block" . insert-block-diary-entry)) |
aef1a243 | 73 | (define-key calendar-mode-map [menu-bar diary ann] |
0e520d74 | 74 | '("Insert Anniversary" . insert-anniversary-diary-entry)) |
aef1a243 | 75 | (define-key calendar-mode-map [menu-bar diary yr] |
0e520d74 | 76 | '("Insert Yearly" . insert-yearly-diary-entry)) |
aef1a243 | 77 | (define-key calendar-mode-map [menu-bar diary mon] |
0e520d74 | 78 | '("Insert Monthly" . insert-monthly-diary-entry)) |
aef1a243 | 79 | (define-key calendar-mode-map [menu-bar diary wk] |
0e520d74 | 80 | '("Insert Weekly" . insert-weekly-diary-entry)) |
aef1a243 | 81 | (define-key calendar-mode-map [menu-bar diary ent] |
9a8e2a10 | 82 | '("Insert Diary Entry" . insert-diary-entry)) |
aef1a243 | 83 | (define-key calendar-mode-map [menu-bar diary all] |
0e520d74 | 84 | '("Show All" . show-all-diary-entries)) |
aef1a243 | 85 | (define-key calendar-mode-map [menu-bar diary mark] |
0e520d74 | 86 | '("Mark All" . mark-diary-entries)) |
aef1a243 | 87 | (define-key calendar-mode-map [menu-bar diary view] |
0e520d74 | 88 | '("Cursor Date" . view-diary-entries)) |
95436630 | 89 | (define-key calendar-mode-map [menu-bar diary view] |
0e520d74 | 90 | '("Other File" . view-other-diary-entries)) |
aef1a243 | 91 | |
f8cac35a | 92 | (define-key calendar-mode-map [menu-bar Holidays] |
aef1a243 RS |
93 | (cons "Holidays" (make-sparse-keymap "Holidays"))) |
94 | ||
aef1a243 RS |
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] | |
0e520d74 | 99 | '("French Date" . calendar-goto-french-date)) |
aef1a243 | 100 | (define-key calendar-mode-map [menu-bar goto mayan] |
0e520d74 | 101 | (cons "Mayan Date" (make-sparse-keymap "Mayan"))) |
c29681e1 ER |
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)) | |
aef1a243 | 108 | (define-key calendar-mode-map [menu-bar goto julian] |
0e520d74 | 109 | '("Julian Date" . calendar-goto-julian-date)) |
aef1a243 | 110 | (define-key calendar-mode-map [menu-bar goto islamic] |
0e520d74 | 111 | '("Islamic Date" . calendar-goto-islamic-date)) |
c21eb13d ER |
112 | (define-key calendar-mode-map [menu-bar goto persian] |
113 | '("Persian Date" . calendar-goto-persian-date)) | |
aef1a243 | 114 | (define-key calendar-mode-map [menu-bar goto hebrew] |
0e520d74 | 115 | '("Hebrew Date" . calendar-goto-hebrew-date)) |
aef1a243 | 116 | (define-key calendar-mode-map [menu-bar goto astro] |
0e520d74 | 117 | '("Astronomical Date" . calendar-goto-astro-day-number)) |
aef1a243 | 118 | (define-key calendar-mode-map [menu-bar goto iso] |
0e520d74 | 119 | '("ISO Date" . calendar-goto-iso-date)) |
f9df0ca0 GM |
120 | (define-key calendar-mode-map [menu-bar goto day-of-year] |
121 | '("Day of Year" . calendar-goto-day-of-year)) | |
aef1a243 | 122 | (define-key calendar-mode-map [menu-bar goto gregorian] |
0e520d74 | 123 | '("Other Date" . calendar-goto-date)) |
aef1a243 | 124 | (define-key calendar-mode-map [menu-bar goto end-of-year] |
0e520d74 | 125 | '("End of Year" . calendar-end-of-year)) |
aef1a243 | 126 | (define-key calendar-mode-map [menu-bar goto beginning-of-year] |
0e520d74 | 127 | '("Beginning of Year" . calendar-beginning-of-year)) |
aef1a243 | 128 | (define-key calendar-mode-map [menu-bar goto end-of-month] |
0e520d74 | 129 | '("End of Month" . calendar-end-of-month)) |
aef1a243 | 130 | (define-key calendar-mode-map [menu-bar goto beginning-of-month] |
0e520d74 | 131 | '("Beginning of Month" . calendar-beginning-of-month)) |
aef1a243 | 132 | (define-key calendar-mode-map [menu-bar goto end-of-week] |
0e520d74 | 133 | '("End of Week" . calendar-end-of-week)) |
aef1a243 | 134 | (define-key calendar-mode-map [menu-bar goto beginning-of-week] |
0e520d74 | 135 | '("Beginning of Week" . calendar-beginning-of-week)) |
aef1a243 | 136 | (define-key calendar-mode-map [menu-bar goto today] |
e8cf82e8 | 137 | '("Today" . calendar-goto-today)) |
aef1a243 RS |
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 | ||
f9df0ca0 GM |
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 | ||
87671c25 EZ |
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) | |
3f3410a9 | 183 | (error "Popup menus are not available on this system"))) |
87671c25 | 184 | |
f10cbb4c RS |
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 | ||
b5305eb0 ER |
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] | |
b67c85e9 | 217 | (cons ["Unmark Calendar" calendar-unmark t] |
4cb54652 | 218 | (cons ["--" '("--") t] l)))) |
d5b213cc RS |
219 | (define-key calendar-mode-map [menu-bar Holidays] |
220 | (cons "Holidays" (easy-menu-create-menu "Holidays" (nreverse l)))) | |
4cb54652 | 221 | (define-key calendar-mode-map [menu-bar Holidays separator] |
b67c85e9 | 222 | '("--")) |
f8cac35a | 223 | (define-key calendar-mode-map [menu-bar Holidays today] |
07342a64 ER |
224 | `(,(format "For Today (%s)" |
225 | (calendar-date-string (calendar-current-date) t t)) | |
226 | . cal-menu-today-holidays)) | |
b5305eb0 ER |
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" | |
5bb7a2d5 GM |
236 | (calendar-month-name m1 'abbrev) |
237 | (calendar-month-name m2 'abbrev) | |
b5305eb0 ER |
238 | y2) |
239 | (format "%s, %d-%s, %d" | |
5bb7a2d5 | 240 | (calendar-month-name m1 'abbrev) |
b5305eb0 | 241 | y1 |
5bb7a2d5 | 242 | (calendar-month-name m2 'abbrev) |
b5305eb0 | 243 | y2))))) |
f8cac35a RS |
244 | (define-key calendar-mode-map [menu-bar Holidays 3-month] |
245 | `(,(format "For Window (%s)" title) | |
b5305eb0 ER |
246 | . list-calendar-holidays))) |
247 | (let ((date (calendar-cursor-to-date))) | |
248 | (if date | |
f8cac35a | 249 | (define-key calendar-mode-map [menu-bar Holidays 1-day] |
3f0855d5 | 250 | `(,(format "For Cursor Date (%s)" |
b5305eb0 ER |
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 | ||
a6ee0a2f ER |
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." | |
aef1a243 | 260 | (save-excursion |
a0e06fd0 | 261 | (set-buffer (window-buffer (posn-window (event-start last-input-event)))) |
aef1a243 | 262 | (goto-char (posn-point (event-start last-input-event))) |
a6ee0a2f | 263 | (calendar-cursor-to-date error))) |
aef1a243 RS |
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 | |
87671c25 | 269 | (cal-menu-x-popup-menu |
aef1a243 RS |
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 | |
87671c25 | 282 | (cal-menu-x-popup-menu |
aef1a243 RS |
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 | |
a0e06fd0 | 295 | (calendar-mouse-goto-date (calendar-event-to-date)) |
aef1a243 RS |
296 | (calendar-sunrise-sunset))) |
297 | ||
07342a64 ER |
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 | ||
aef1a243 | 305 | (defun calendar-mouse-holidays () |
6c8a48a6 | 306 | "Pop up menu of holidays for mouse selected date." |
aef1a243 | 307 | (interactive) |
6c8a48a6 ER |
308 | (let* ((date (calendar-event-to-date)) |
309 | (l (mapcar '(lambda (x) (list x)) | |
310 | (check-calendar-holidays date))) | |
311 | (selection | |
87671c25 | 312 | (cal-menu-x-popup-menu |
6c8a48a6 ER |
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)))) | |
aef1a243 | 320 | |
f9df0ca0 GM |
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." | |
aef1a243 | 326 | (interactive) |
f9df0ca0 GM |
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))) | |
6c8a48a6 | 341 | (selection |
87671c25 | 342 | (cal-menu-x-popup-menu |
6c8a48a6 | 343 | event |
f9df0ca0 GM |
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"))))))) | |
6c8a48a6 | 355 | (and selection (call-interactively selection)))) |
aef1a243 | 356 | |
95436630 | 357 | (defun calendar-mouse-view-other-diary-entries () |
6c8a48a6 | 358 | "Pop up menu of diary entries from alternative file on mouse-selected date." |
95436630 | 359 | (interactive) |
f9df0ca0 GM |
360 | (calendar-mouse-view-diary-entries |
361 | (calendar-event-to-date) | |
362 | (read-file-name "Enter diary file name: " default-directory nil t))) | |
95436630 | 363 | |
d960f279 ER |
364 | (defun calendar-mouse-insert-diary-entry () |
365 | "Insert diary entry for mouse-selected date." | |
366 | (interactive) | |
367 | (save-excursion | |
a0e06fd0 | 368 | (calendar-mouse-goto-date (calendar-event-to-date)) |
d960f279 ER |
369 | (insert-diary-entry nil))) |
370 | ||
b61631a7 RS |
371 | (defun calendar-mouse-set-mark () |
372 | "Mark the date under the cursor." | |
373 | (interactive) | |
374 | (save-excursion | |
a0e06fd0 | 375 | (calendar-mouse-goto-date (calendar-event-to-date)) |
b61631a7 RS |
376 | (calendar-set-mark nil))) |
377 | ||
e519449d ER |
378 | (defun cal-tex-mouse-day () |
379 | "Make a buffer with LaTeX commands for the day mouse is on." | |
380 | (interactive) | |
381 | (save-excursion | |
a0e06fd0 | 382 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
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 | |
a0e06fd0 | 390 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
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 | |
a0e06fd0 | 398 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
399 | (cal-tex-cursor-week2 nil))) |
400 | ||
bc83970d | 401 | (defun cal-tex-mouse-week-iso () |
e519449d ER |
402 | "One page calendar for week indicated by cursor. |
403 | Holidays are included if `cal-tex-holidays' is t." | |
404 | (interactive) | |
405 | (save-excursion | |
a0e06fd0 | 406 | (calendar-mouse-goto-date (calendar-event-to-date)) |
bc83970d | 407 | (cal-tex-cursor-week-iso nil))) |
e519449d | 408 | |
bc83970d | 409 | (defun cal-tex-mouse-week-monday () |
e519449d ER |
410 | "One page calendar for week indicated by cursor." |
411 | (interactive) | |
412 | (save-excursion | |
a0e06fd0 | 413 | (calendar-mouse-goto-date (calendar-event-to-date)) |
bc83970d | 414 | (cal-tex-cursor-week-monday nil))) |
e519449d | 415 | |
a137e62c KH |
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 | ||
610d0966 | 423 | (defun cal-tex-mouse-filofax-2week () |
e519449d ER |
424 | "One page Filofax calendar for week indicated by cursor." |
425 | (interactive) | |
426 | (save-excursion | |
a0e06fd0 | 427 | (calendar-mouse-goto-date (calendar-event-to-date)) |
610d0966 | 428 | (cal-tex-cursor-filofax-2week nil))) |
e519449d | 429 | |
610d0966 | 430 | (defun cal-tex-mouse-filofax-week () |
e519449d ER |
431 | "Two page Filofax calendar for week indicated by cursor." |
432 | (interactive) | |
433 | (save-excursion | |
a0e06fd0 | 434 | (calendar-mouse-goto-date (calendar-event-to-date)) |
610d0966 | 435 | (cal-tex-cursor-filofax-week nil))) |
e519449d ER |
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 | |
a0e06fd0 | 442 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
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 | |
a0e06fd0 | 450 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
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 | |
a0e06fd0 | 457 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
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 | |
a0e06fd0 | 464 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
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 | |
a0e06fd0 | 471 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
472 | (cal-tex-cursor-year-landscape nil))) |
473 | ||
aef1a243 RS |
474 | (defun calendar-mouse-print-dates () |
475 | "Pop up menu of equivalent dates to mouse selected date." | |
476 | (interactive) | |
c29681e1 ER |
477 | (let ((date (calendar-event-to-date)) |
478 | (selection | |
87671c25 | 479 | (cal-menu-x-popup-menu |
c29681e1 ER |
480 | event |
481 | (list | |
ebf90a0f | 482 | (concat (calendar-date-string date) " (Gregorian)") |
c29681e1 ER |
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 | |
33a07d62 | 491 | (format "Astronomical (Julian) day number (at noon UTC): %s.0" |
c29681e1 | 492 | (calendar-astro-date-string date))) |
ee3bb32f | 493 | (list |
20f92f7b | 494 | (format "Fixed (RD) date: %s" |
ee3bb32f | 495 | (calendar-absolute-from-gregorian date))) |
c29681e1 | 496 | (list (format "Hebrew date (before sunset): %s" |
c21eb13d ER |
497 | (calendar-hebrew-date-string date))) |
498 | (list (format "Persian date: %s" | |
b0e6051a | 499 | (calendar-persian-date-string date)))) |
c29681e1 ER |
500 | (let ((i (calendar-islamic-date-string date))) |
501 | (if (not (string-equal i "")) | |
502 | (list (list (format "Islamic date (before sunset): %s" i))))) | |
78627296 ER |
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)) | |
c29681e1 ER |
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 | ||
92da8c78 ER |
523 | (defun calendar-mouse-chinese-date () |
524 | "Show Chinese equivalent for mouse-selected date." | |
525 | (interactive) | |
526 | (save-excursion | |
a0e06fd0 | 527 | (calendar-mouse-goto-date (calendar-event-to-date)) |
92da8c78 | 528 | (calendar-print-chinese-date))) |
aef1a243 | 529 | |
a0e06fd0 RS |
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 | ||
a6ee0a2f ER |
534 | (defun calendar-mouse-2-date-menu (event) |
535 | "Pop up menu for Mouse-2 for selected date in the calendar window." | |
aef1a243 | 536 | (interactive "e") |
a6ee0a2f ER |
537 | (let* ((date (calendar-event-to-date t)) |
538 | (selection | |
87671c25 | 539 | (cal-menu-x-popup-menu |
a6ee0a2f | 540 | event |
610d0966 | 541 | (list (calendar-date-string date t nil) |
a6ee0a2f | 542 | (list |
610d0966 | 543 | "" |
a6ee0a2f ER |
544 | '("Holidays" . calendar-mouse-holidays) |
545 | '("Mark date" . calendar-mouse-set-mark) | |
546 | '("Sunrise/sunset" . calendar-mouse-sunrise/sunset) | |
95436630 | 547 | '("Other calendars" . calendar-mouse-print-dates) |
e519449d | 548 | '("Prepare LaTeX buffer" . calendar-mouse-cal-tex-menu) |
95436630 ER |
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 | ))))) | |
a6ee0a2f ER |
554 | (and selection (call-interactively selection)))) |
555 | ||
e519449d ER |
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 | |
87671c25 | 560 | (cal-menu-x-popup-menu |
e519449d | 561 | event |
610d0966 | 562 | (list (calendar-date-string date t nil) |
e519449d | 563 | (list |
610d0966 | 564 | "" |
e519449d ER |
565 | '("Daily (1 page)" . cal-tex-mouse-day) |
566 | '("Weekly (1 page)" . cal-tex-mouse-week) | |
567 | '("Weekly (2 pages)" . cal-tex-mouse-week2) | |
610d0966 ER |
568 | '("Weekly (other style; 1 page)" . cal-tex-mouse-week-iso) |
569 | '("Weekly (yet another style; 1 page)" . | |
570 | cal-tex-mouse-week-monday) | |
e519449d ER |
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 | |
87671c25 | 583 | (cal-menu-x-popup-menu |
e519449d | 584 | event |
610d0966 | 585 | (list (calendar-date-string date t nil) |
e519449d | 586 | (list |
610d0966 | 587 | "" |
a137e62c KH |
588 | '("Filofax Daily (one-day-per-page)" . |
589 | cal-tex-mouse-filofax-daily) | |
610d0966 ER |
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) | |
e519449d ER |
594 | '("Filofax Yearly" . cal-tex-mouse-filofax-year) |
595 | ))))) | |
596 | (and selection (call-interactively selection)))) | |
597 | ||
89e14386 RS |
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)) | |
aef1a243 RS |
616 | |
617 | (run-hooks 'cal-menu-load-hook) | |
618 | ||
619 | (provide 'cal-menu) | |
620 | ||
ab5796a9 | 621 | ;;; arch-tag: aa81cf73-ce89-48a4-97ec-9ef861e87fe9 |
aef1a243 | 622 | ;;; cal-menu.el ends here |