Commit | Line | Data |
---|---|---|
aef1a243 RS |
1 | ;;; cal-menu.el --- calendar functions for menu bar and popup menu support |
2 | ||
8b72699e | 3 | ;; Copyright (C) 1994, 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
600b6bc9 | 4 | ;; Free Software Foundation, Inc. |
aef1a243 RS |
5 | |
6 | ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> | |
7 | ;; Lara Rios <lrios@coewl.cen.uiuc.edu> | |
aff88519 | 8 | ;; Maintainer: Glenn Morris <rgm@gnu.org> |
aef1a243 RS |
9 | ;; Keywords: calendar |
10 | ;; Human-Keywords: calendar, popup menus, menu bar | |
11 | ||
12 | ;; This file is part of GNU Emacs. | |
13 | ||
59243403 RS |
14 | ;; GNU Emacs is free software; you can redistribute it and/or modify |
15 | ;; it under the terms of the GNU General Public License as published by | |
075969b4 | 16 | ;; the Free Software Foundation; either version 3, or (at your option) |
59243403 RS |
17 | ;; any later version. |
18 | ||
aef1a243 | 19 | ;; GNU Emacs is distributed in the hope that it will be useful, |
59243403 RS |
20 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | ;; GNU General Public License for more details. | |
23 | ||
24 | ;; You should have received a copy of the GNU General Public License | |
b578f267 | 25 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
3a35cf56 LK |
26 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
27 | ;; Boston, MA 02110-1301, USA. | |
aef1a243 RS |
28 | |
29 | ;;; Commentary: | |
30 | ||
31 | ;; This collection of functions implements menu bar and popup menu support for | |
32 | ;; calendar.el. | |
33 | ||
aef1a243 RS |
34 | ;;; Code: |
35 | ||
f086f609 GM |
36 | ;; The code in this file is only called from calendar.el, but can't |
37 | ;; require it (to supress undefined function warnings from compiler) | |
38 | ;; without a recursive require. | |
225ccf92 GM |
39 | ;; All these functions are either autoloaded, or autoloaded or defined |
40 | ;; in calendar.el. | |
41 | (declare-function calendar-increment-month "calendar" (n &optional mon yr)) | |
42 | (declare-function calendar-month-name "calendar" (month &optional abbrev)) | |
43 | (declare-function extract-calendar-year "calendar" (date)) | |
44 | (declare-function calendar-cursor-to-date "calendar" (&optional error)) | |
45 | (declare-function holiday-list "holidays" (y1 y2 &optional l label)) | |
46 | (declare-function calendar-sunrise-sunset "solar" nil) | |
47 | (declare-function calendar-current-date "calendar" nil) | |
48 | (declare-function calendar-cursor-holidays "holidays" nil) | |
49 | (declare-function calendar-date-string "calendar" | |
50 | (date &optional abbreviate nodayname)) | |
51 | (declare-function insert-diary-entry "diary-lib" (arg)) | |
52 | (declare-function calendar-set-mark "calendar" (arg)) | |
53 | (declare-function cal-tex-cursor-day "cal-tex" (&optional arg)) | |
54 | (declare-function cal-tex-cursor-week "cal-tex" (&optional arg)) | |
55 | (declare-function cal-tex-cursor-week2 "cal-tex" (&optional arg)) | |
56 | (declare-function cal-tex-cursor-week-iso "cal-tex" (&optional arg)) | |
57 | (declare-function cal-tex-cursor-week-monday "cal-tex" (&optional arg)) | |
58 | (declare-function cal-tex-cursor-filofax-daily "cal-tex" (&optional arg)) | |
59 | (declare-function cal-tex-cursor-filofax-2week "cal-tex" (&optional arg)) | |
60 | (declare-function cal-tex-cursor-filofax-week "cal-tex" (&optional arg)) | |
61 | (declare-function cal-tex-cursor-month "cal-tex" (arg)) | |
62 | (declare-function cal-tex-cursor-month-landscape "cal-tex" (&optional arg)) | |
63 | (declare-function cal-tex-cursor-year "cal-tex" (&optional arg)) | |
64 | (declare-function cal-tex-cursor-filofax-year "cal-tex" (&optional arg)) | |
65 | (declare-function cal-tex-cursor-year-landscape "cal-tex" (&optional arg)) | |
66 | (declare-function calendar-day-of-year-string "calendar" (&optional date)) | |
67 | (declare-function calendar-iso-date-string "cal-iso" (&optional date)) | |
68 | (declare-function calendar-julian-date-string "cal-julian" (&optional date)) | |
69 | (declare-function calendar-astro-date-string "cal-julian" (&optional date)) | |
70 | (declare-function calendar-absolute-from-gregorian "calendar" (date)) | |
71 | (declare-function calendar-hebrew-date-string "cal-hebrew" (&optional date)) | |
72 | (declare-function calendar-persian-date-string "cal-persia" (&optional date)) | |
73 | (declare-function calendar-bahai-date-string "cal-bahai" (&optional date)) | |
74 | (declare-function calendar-islamic-date-string "cal-islam" (&optional date)) | |
75 | (declare-function calendar-chinese-date-string "cal-china" (&optional date)) | |
76 | (declare-function calendar-coptic-date-string "cal-coptic" (&optional date)) | |
77 | (declare-function calendar-ethiopic-date-string "cal-coptic" (&optional date)) | |
78 | (declare-function calendar-french-date-string "cal-french" (&optional date)) | |
79 | (declare-function calendar-mayan-date-string "cal-mayan" (&optional date)) | |
80 | (declare-function calendar-print-chinese-date "cal-china" nil) | |
81 | (declare-function calendar-goto-date "cal-move" (date)) | |
f086f609 | 82 | |
5bb7a2d5 GM |
83 | (defvar displayed-year) |
84 | ||
05efa389 SM |
85 | (defconst cal-menu-moon-menu |
86 | '("Moon" | |
87 | ["Lunar Phases" calendar-phases-of-moon])) | |
88 | ||
89 | (defconst cal-menu-diary-menu | |
90 | '("Diary" | |
91 | ["Other File" view-other-diary-entries] | |
92 | ["Cursor Date" diary-view-entries] | |
93 | ["Mark All" mark-diary-entries] | |
94 | ["Show All" diary-show-all-entries] | |
95 | ["Insert Diary Entry" insert-diary-entry] | |
96 | ["Insert Weekly" insert-weekly-diary-entry] | |
97 | ["Insert Monthly" insert-monthly-diary-entry] | |
98 | ["Insert Yearly" insert-yearly-diary-entry] | |
99 | ["Insert Anniversary" insert-anniversary-diary-entry] | |
100 | ["Insert Block" insert-block-diary-entry] | |
101 | ["Insert Cyclic" insert-cyclic-diary-entry] | |
102 | ("Insert Baha'i" | |
103 | [" " nil :suffix (calendar-bahai-date-string (calendar-cursor-to-date))] | |
4aefe5e2 GM |
104 | ["One time" diary-bahai-insert-entry] |
105 | ["Monthly" diary-bahai-insert-monthly-entry] | |
106 | ["Yearly" diary-bahai-insert-yearly-entry]) | |
05efa389 SM |
107 | ("Insert Islamic" |
108 | [" " nil :suffix (calendar-islamic-date-string (calendar-cursor-to-date))] | |
109 | ["One time" insert-islamic-diary-entry] | |
110 | ["Monthly" insert-monthly-islamic-diary-entry] | |
111 | ["Yearly" insert-yearly-islamic-diary-entry]) | |
112 | ("Insert Hebrew" | |
113 | [" " nil :suffix (calendar-hebrew-date-string (calendar-cursor-to-date))] | |
114 | ["One time" insert-hebrew-diary-entry] | |
115 | ["Monthly" insert-monthly-hebrew-diary-entry] | |
116 | ["Yearly" insert-yearly-hebrew-diary-entry]))) | |
117 | ||
118 | (defun cal-menu-holiday-window-suffix () | |
119 | (let ((my1 (calendar-increment-month -1)) | |
120 | (my2 (calendar-increment-month 1))) | |
121 | (if (= (cdr my1) (cdr my2)) | |
122 | (format "%s-%s, %d" | |
123 | (calendar-month-name (car my1) 'abbrev) | |
124 | (calendar-month-name (car my2) 'abbrev) | |
125 | (cdr my2)) | |
126 | (format "%s, %d-%s, %d" | |
127 | (calendar-month-name (car my1) 'abbrev) | |
128 | (cdr my1) | |
129 | (calendar-month-name (car my2) 'abbrev) | |
130 | (cdr my2))))) | |
131 | ||
132 | (defconst cal-menu-holidays-menu | |
133 | `("Holidays" | |
134 | ["For Cursor Date -" calendar-cursor-holidays | |
135 | :suffix (calendar-date-string (calendar-cursor-to-date) t t) | |
136 | :visible (calendar-cursor-to-date)] | |
175ede29 | 137 | ["For Window -" calendar-list-holidays |
05efa389 SM |
138 | :suffix (cal-menu-holiday-window-suffix)] |
139 | ["For Today -" cal-menu-today-holidays | |
140 | :suffix (calendar-date-string (calendar-current-date) t t)] | |
141 | "--" | |
142 | ,@(let ((l ())) | |
143 | ;; Show 11 years--5 before, 5 after year of middle month. | |
29ca115f SM |
144 | ;; We used to use :suffix rather than :label and bumped into |
145 | ;; an easymenu bug: | |
60806b73 | 146 | ;; http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01813.html |
29ca115f | 147 | ;; The bug has since been fixed. |
05efa389 | 148 | (dotimes (i 11) |
60806b73 | 149 | (push (vector (format "hol-year-%d" i) |
771e1882 GM |
150 | `(lambda () |
151 | (interactive) | |
152 | (holiday-list (+ displayed-year ,(- i 5)) | |
153 | (+ displayed-year ,(- i 5)))) | |
60806b73 GM |
154 | :label `(format "For Year %d" |
155 | (+ displayed-year ,(- i 5)))) | |
771e1882 | 156 | l)) |
05efa389 SM |
157 | (nreverse l)) |
158 | "--" | |
159 | ["Unmark Calendar" calendar-unmark] | |
160 | ["Mark Holidays" mark-calendar-holidays])) | |
161 | ||
162 | (defconst cal-menu-goto-menu | |
163 | '("Goto" | |
164 | ["Today" calendar-goto-today] | |
165 | ["Beginning of Week" calendar-beginning-of-week] | |
166 | ["End of Week" calendar-end-of-week] | |
167 | ["Beginning of Month" calendar-beginning-of-month] | |
168 | ["End of Month" calendar-end-of-month] | |
169 | ["Beginning of Year" calendar-beginning-of-year] | |
170 | ["End of Year" calendar-end-of-year] | |
171 | ["Other Date" calendar-goto-date] | |
172 | ["Day of Year" calendar-goto-day-of-year] | |
173 | ["ISO Week" calendar-goto-iso-week] | |
174 | ["ISO Date" calendar-goto-iso-date] | |
175 | ["Astronomical Date" calendar-goto-astro-day-number] | |
176 | ["Hebrew Date" calendar-goto-hebrew-date] | |
177 | ["Persian Date" calendar-goto-persian-date] | |
4aefe5e2 | 178 | ["Baha'i Date" calendar-bahai-goto-date] |
05efa389 SM |
179 | ["Islamic Date" calendar-goto-islamic-date] |
180 | ["Julian Date" calendar-goto-julian-date] | |
181 | ["Chinese Date" calendar-goto-chinese-date] | |
182 | ["Coptic Date" calendar-goto-coptic-date] | |
183 | ["Ethiopic Date" calendar-goto-ethiopic-date] | |
184 | ("Mayan Date" | |
185 | ["Next Tzolkin" calendar-next-tzolkin-date] | |
186 | ["Previous Tzolkin" calendar-previous-tzolkin-date] | |
187 | ["Next Haab" calendar-next-haab-date] | |
188 | ["Previous Haab" calendar-previous-haab-date] | |
189 | ["Next Round" calendar-next-calendar-round-date] | |
190 | ["Previous Round" calendar-previous-calendar-round-date]) | |
191 | ["French Date" calendar-goto-french-date])) | |
192 | ||
193 | (defconst cal-menu-scroll-menu | |
194 | '("Scroll" | |
cca1dde0 SM |
195 | ["Forward 1 Month" calendar-scroll-left] |
196 | ["Forward 3 Months" calendar-scroll-left-three-months] | |
05efa389 | 197 | ["Forward 1 Year" "4\C-v"] |
cca1dde0 SM |
198 | ["Backward 1 Month" calendar-scroll-right] |
199 | ["Backward 3 Months" calendar-scroll-right-three-months] | |
05efa389 | 200 | ["Backward 1 Year" "4\ev"])) |
f9df0ca0 | 201 | |
87671c25 EZ |
202 | (defun cal-menu-x-popup-menu (position menu) |
203 | "Like `x-popup-menu', but prints an error message if popup menus are | |
204 | not available." | |
205 | (if (display-popup-menus-p) | |
206 | (x-popup-menu position menu) | |
3f3410a9 | 207 | (error "Popup menus are not available on this system"))) |
87671c25 | 208 | |
f10cbb4c RS |
209 | (defun cal-menu-list-holidays-year () |
210 | "Display a list of the holidays of the selected date's year." | |
211 | (interactive) | |
212 | (let ((year (extract-calendar-year (calendar-cursor-to-date)))) | |
175ede29 | 213 | (holiday-list year year))) |
f10cbb4c RS |
214 | |
215 | (defun cal-menu-list-holidays-following-year () | |
216 | "Display a list of the holidays of the following year." | |
217 | (interactive) | |
218 | (let ((year (1+ (extract-calendar-year (calendar-cursor-to-date))))) | |
175ede29 | 219 | (holiday-list year year))) |
f10cbb4c RS |
220 | |
221 | (defun cal-menu-list-holidays-previous-year () | |
222 | "Display a list of the holidays of the previous year." | |
223 | (interactive) | |
224 | (let ((year (1- (extract-calendar-year (calendar-cursor-to-date))))) | |
175ede29 | 225 | (holiday-list year year))) |
f10cbb4c | 226 | |
a6ee0a2f ER |
227 | (defun calendar-event-to-date (&optional error) |
228 | "Date of last event. | |
229 | If event is not on a specific date, signals an error if optional parameter | |
230 | ERROR is t, otherwise just returns nil." | |
05efa389 SM |
231 | (with-current-buffer |
232 | (window-buffer (posn-window (event-start last-input-event))) | |
aef1a243 | 233 | (goto-char (posn-point (event-start last-input-event))) |
a6ee0a2f | 234 | (calendar-cursor-to-date error))) |
aef1a243 | 235 | |
aef1a243 RS |
236 | (defun calendar-mouse-sunrise/sunset () |
237 | "Show sunrise/sunset times for mouse-selected date." | |
238 | (interactive) | |
239 | (save-excursion | |
a0e06fd0 | 240 | (calendar-mouse-goto-date (calendar-event-to-date)) |
aef1a243 RS |
241 | (calendar-sunrise-sunset))) |
242 | ||
07342a64 ER |
243 | (defun cal-menu-today-holidays () |
244 | "Show holidays for today's date." | |
245 | (interactive) | |
246 | (save-excursion | |
247 | (calendar-cursor-to-date (calendar-current-date)) | |
248 | (calendar-cursor-holidays))) | |
249 | ||
175ede29 | 250 | (autoload 'calendar-check-holidays "holidays") |
ed1cd40c SM |
251 | (autoload 'diary-list-entries "diary-lib") |
252 | ||
e9f8d300 | 253 | (defun calendar-mouse-holidays (&optional event) |
6c8a48a6 | 254 | "Pop up menu of holidays for mouse selected date." |
e9f8d300 | 255 | (interactive "e") |
6c8a48a6 | 256 | (let* ((date (calendar-event-to-date)) |
175ede29 | 257 | (l (mapcar 'list (calendar-check-holidays date))) |
6c8a48a6 | 258 | (selection |
87671c25 | 259 | (cal-menu-x-popup-menu |
6c8a48a6 ER |
260 | event |
261 | (list | |
262 | (format "Holidays for %s" (calendar-date-string date)) | |
263 | (append | |
264 | (list (format "Holidays for %s" (calendar-date-string date))) | |
265 | (if l l '("None"))))))) | |
266 | (and selection (call-interactively selection)))) | |
aef1a243 | 267 | |
f7ae31df GM |
268 | (defvar holidays-in-diary-buffer) ; only called from calendar.el |
269 | ||
e9f8d300 | 270 | (defun calendar-mouse-view-diary-entries (&optional date diary event) |
f9df0ca0 GM |
271 | "Pop up menu of diary entries for mouse-selected date. |
272 | Use optional DATE and alternative file DIARY. | |
273 | ||
274 | Any holidays are shown if `holidays-in-diary-buffer' is t." | |
e9f8d300 | 275 | (interactive "i\ni\ne") |
05efa389 | 276 | (let* ((date (or date (calendar-event-to-date))) |
f9df0ca0 GM |
277 | (diary-file (if diary diary diary-file)) |
278 | (diary-list-include-blanks nil) | |
279 | (diary-display-hook 'ignore) | |
280 | (diary-entries | |
05efa389 | 281 | (mapcar (lambda (x) (split-string (cadr x) "\n")) |
a04b6191 | 282 | (diary-list-entries date 1 'list-only))) |
f9df0ca0 | 283 | (holidays (if holidays-in-diary-buffer |
175ede29 | 284 | (calendar-check-holidays date))) |
f9df0ca0 GM |
285 | (title (concat "Diary entries " |
286 | (if diary (format "from %s " diary) "") | |
287 | "for " | |
288 | (calendar-date-string date))) | |
6c8a48a6 | 289 | (selection |
87671c25 | 290 | (cal-menu-x-popup-menu |
6c8a48a6 | 291 | event |
f9df0ca0 GM |
292 | (list title |
293 | (append | |
294 | (list title) | |
ed1cd40c | 295 | (mapcar (lambda (x) (list (concat " " x))) holidays) |
f9df0ca0 GM |
296 | (if holidays |
297 | (list "--shadow-etched-in" "--shadow-etched-in")) | |
298 | (if diary-entries | |
05efa389 | 299 | (mapcar 'list (apply 'append diary-entries)) |
f9df0ca0 | 300 | '("None"))))))) |
6c8a48a6 | 301 | (and selection (call-interactively selection)))) |
aef1a243 | 302 | |
95436630 | 303 | (defun calendar-mouse-view-other-diary-entries () |
6c8a48a6 | 304 | "Pop up menu of diary entries from alternative file on mouse-selected date." |
95436630 | 305 | (interactive) |
f9df0ca0 GM |
306 | (calendar-mouse-view-diary-entries |
307 | (calendar-event-to-date) | |
308 | (read-file-name "Enter diary file name: " default-directory nil t))) | |
95436630 | 309 | |
d960f279 ER |
310 | (defun calendar-mouse-insert-diary-entry () |
311 | "Insert diary entry for mouse-selected date." | |
312 | (interactive) | |
313 | (save-excursion | |
a0e06fd0 | 314 | (calendar-mouse-goto-date (calendar-event-to-date)) |
d960f279 ER |
315 | (insert-diary-entry nil))) |
316 | ||
b61631a7 RS |
317 | (defun calendar-mouse-set-mark () |
318 | "Mark the date under the cursor." | |
319 | (interactive) | |
320 | (save-excursion | |
a0e06fd0 | 321 | (calendar-mouse-goto-date (calendar-event-to-date)) |
b61631a7 RS |
322 | (calendar-set-mark nil))) |
323 | ||
e519449d ER |
324 | (defun cal-tex-mouse-day () |
325 | "Make a buffer with LaTeX commands for the day mouse is on." | |
326 | (interactive) | |
327 | (save-excursion | |
a0e06fd0 | 328 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
329 | (cal-tex-cursor-day nil))) |
330 | ||
331 | (defun cal-tex-mouse-week () | |
332 | "One page calendar for week indicated by cursor. | |
333 | Holidays are included if `cal-tex-holidays' is t." | |
334 | (interactive) | |
335 | (save-excursion | |
a0e06fd0 | 336 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
337 | (cal-tex-cursor-week nil))) |
338 | ||
339 | (defun cal-tex-mouse-week2 () | |
340 | "Make a buffer with LaTeX commands for the week cursor is on. | |
341 | The printed output will be on two pages." | |
342 | (interactive) | |
343 | (save-excursion | |
a0e06fd0 | 344 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
345 | (cal-tex-cursor-week2 nil))) |
346 | ||
bc83970d | 347 | (defun cal-tex-mouse-week-iso () |
e519449d ER |
348 | "One page calendar for week indicated by cursor. |
349 | Holidays are included if `cal-tex-holidays' is t." | |
350 | (interactive) | |
351 | (save-excursion | |
a0e06fd0 | 352 | (calendar-mouse-goto-date (calendar-event-to-date)) |
bc83970d | 353 | (cal-tex-cursor-week-iso nil))) |
e519449d | 354 | |
bc83970d | 355 | (defun cal-tex-mouse-week-monday () |
e519449d ER |
356 | "One page calendar for week indicated by cursor." |
357 | (interactive) | |
358 | (save-excursion | |
a0e06fd0 | 359 | (calendar-mouse-goto-date (calendar-event-to-date)) |
bc83970d | 360 | (cal-tex-cursor-week-monday nil))) |
e519449d | 361 | |
a137e62c KH |
362 | (defun cal-tex-mouse-filofax-daily () |
363 | "Day-per-page Filofax calendar for week indicated by cursor." | |
364 | (interactive) | |
365 | (save-excursion | |
366 | (calendar-mouse-goto-date (calendar-event-to-date)) | |
367 | (cal-tex-cursor-filofax-daily nil))) | |
368 | ||
610d0966 | 369 | (defun cal-tex-mouse-filofax-2week () |
e519449d ER |
370 | "One page Filofax calendar for week indicated by cursor." |
371 | (interactive) | |
372 | (save-excursion | |
a0e06fd0 | 373 | (calendar-mouse-goto-date (calendar-event-to-date)) |
610d0966 | 374 | (cal-tex-cursor-filofax-2week nil))) |
e519449d | 375 | |
610d0966 | 376 | (defun cal-tex-mouse-filofax-week () |
e519449d ER |
377 | "Two page Filofax calendar for week indicated by cursor." |
378 | (interactive) | |
379 | (save-excursion | |
a0e06fd0 | 380 | (calendar-mouse-goto-date (calendar-event-to-date)) |
610d0966 | 381 | (cal-tex-cursor-filofax-week nil))) |
e519449d ER |
382 | |
383 | (defun cal-tex-mouse-month () | |
384 | "Make a buffer with LaTeX commands for the month cursor is on. | |
385 | Calendar is condensed onto one page." | |
386 | (interactive) | |
387 | (save-excursion | |
a0e06fd0 | 388 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
389 | (cal-tex-cursor-month nil))) |
390 | ||
391 | (defun cal-tex-mouse-month-landscape () | |
392 | "Make a buffer with LaTeX commands for the month cursor is on. | |
393 | The output is in landscape format, one month to a page." | |
394 | (interactive) | |
395 | (save-excursion | |
a0e06fd0 | 396 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
397 | (cal-tex-cursor-month-landscape nil))) |
398 | ||
399 | (defun cal-tex-mouse-year () | |
400 | "Make a buffer with LaTeX commands for the year cursor is on." | |
401 | (interactive) | |
402 | (save-excursion | |
a0e06fd0 | 403 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
404 | (cal-tex-cursor-year nil))) |
405 | ||
406 | (defun cal-tex-mouse-filofax-year () | |
407 | "Make a buffer with LaTeX commands for Filofax calendar of year cursor is on." | |
408 | (interactive) | |
409 | (save-excursion | |
a0e06fd0 | 410 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
411 | (cal-tex-cursor-filofax-year nil))) |
412 | ||
413 | (defun cal-tex-mouse-year-landscape () | |
414 | "Make a buffer with LaTeX commands for the year cursor is on." | |
415 | (interactive) | |
416 | (save-excursion | |
a0e06fd0 | 417 | (calendar-mouse-goto-date (calendar-event-to-date)) |
e519449d ER |
418 | (cal-tex-cursor-year-landscape nil))) |
419 | ||
e9f8d300 | 420 | (defun calendar-mouse-print-dates (&optional event) |
aef1a243 | 421 | "Pop up menu of equivalent dates to mouse selected date." |
e9f8d300 SM |
422 | (interactive "e") |
423 | (let* ((date (calendar-event-to-date)) | |
c29681e1 | 424 | (selection |
87671c25 | 425 | (cal-menu-x-popup-menu |
c29681e1 ER |
426 | event |
427 | (list | |
ebf90a0f | 428 | (concat (calendar-date-string date) " (Gregorian)") |
c29681e1 ER |
429 | (append |
430 | (list | |
431 | (concat (calendar-date-string date) " (Gregorian)") | |
432 | (list (calendar-day-of-year-string date)) | |
433 | (list (format "ISO date: %s" (calendar-iso-date-string date))) | |
434 | (list (format "Julian date: %s" | |
435 | (calendar-julian-date-string date))) | |
436 | (list | |
33a07d62 | 437 | (format "Astronomical (Julian) day number (at noon UTC): %s.0" |
c29681e1 | 438 | (calendar-astro-date-string date))) |
ee3bb32f | 439 | (list |
20f92f7b | 440 | (format "Fixed (RD) date: %s" |
ee3bb32f | 441 | (calendar-absolute-from-gregorian date))) |
c29681e1 | 442 | (list (format "Hebrew date (before sunset): %s" |
c21eb13d ER |
443 | (calendar-hebrew-date-string date))) |
444 | (list (format "Persian date: %s" | |
811a8484 JW |
445 | (calendar-persian-date-string date))) |
446 | (list (format "Baha'i date (before sunset): %s" | |
447 | (calendar-bahai-date-string date)))) | |
c29681e1 ER |
448 | (let ((i (calendar-islamic-date-string date))) |
449 | (if (not (string-equal i "")) | |
450 | (list (list (format "Islamic date (before sunset): %s" i))))) | |
78627296 ER |
451 | (list |
452 | (list (format "Chinese date: %s" | |
453 | (calendar-chinese-date-string date)))) | |
e9f8d300 SM |
454 | ;; (list '("Chinese date (select to echo Chinese date)" |
455 | ;; . calendar-mouse-chinese-date)) | |
c29681e1 ER |
456 | (let ((c (calendar-coptic-date-string date))) |
457 | (if (not (string-equal c "")) | |
458 | (list (list (format "Coptic date: %s" c))))) | |
459 | (let ((e (calendar-ethiopic-date-string date))) | |
460 | (if (not (string-equal e "")) | |
461 | (list (list (format "Ethiopic date: %s" e))))) | |
462 | (let ((f (calendar-french-date-string date))) | |
463 | (if (not (string-equal f "")) | |
464 | (list (list (format "French Revolutionary date: %s" f))))) | |
465 | (list | |
466 | (list | |
467 | (format "Mayan date: %s" | |
468 | (calendar-mayan-date-string date))))))))) | |
469 | (and selection (call-interactively selection)))) | |
470 | ||
92da8c78 ER |
471 | (defun calendar-mouse-chinese-date () |
472 | "Show Chinese equivalent for mouse-selected date." | |
473 | (interactive) | |
474 | (save-excursion | |
a0e06fd0 | 475 | (calendar-mouse-goto-date (calendar-event-to-date)) |
92da8c78 | 476 | (calendar-print-chinese-date))) |
aef1a243 | 477 | |
a0e06fd0 RS |
478 | (defun calendar-mouse-goto-date (date) |
479 | (set-buffer (window-buffer (posn-window (event-start last-input-event)))) | |
480 | (calendar-goto-date date)) | |
481 | ||
05efa389 | 482 | (easy-menu-define cal-menu-context-mouse-menu nil |
a6ee0a2f | 483 | "Pop up menu for Mouse-2 for selected date in the calendar window." |
05efa389 SM |
484 | '("foo" :filter cal-menu-set-date-title |
485 | "--" | |
486 | ["Holidays" calendar-mouse-holidays] | |
487 | ["Mark date" calendar-mouse-set-mark] | |
488 | ["Sunrise/sunset" calendar-mouse-sunrise/sunset] | |
489 | ["Other calendars" calendar-mouse-print-dates] | |
490 | ("Prepare LaTeX buffer" | |
491 | ["Daily (1 page)" cal-tex-mouse-day] | |
492 | ["Weekly (1 page)" cal-tex-mouse-week] | |
493 | ["Weekly (2 pages)" cal-tex-mouse-week2] | |
494 | ["Weekly (other style; 1 page)" cal-tex-mouse-week-iso] | |
495 | ["Weekly (yet another style; 1 page)" cal-tex-mouse-week-monday] | |
496 | ["Monthly" cal-tex-mouse-month] | |
497 | ["Monthly (landscape)" cal-tex-mouse-month-landscape] | |
498 | ["Yearly" cal-tex-mouse-year] | |
499 | ["Yearly (landscape)" cal-tex-mouse-year-landscape] | |
500 | ("Filofax styles" | |
501 | ["Filofax Daily (one-day-per-page)" cal-tex-mouse-filofax-daily] | |
502 | ["Filofax Weekly (2-weeks-at-a-glance)" cal-tex-mouse-filofax-2week] | |
503 | ["Filofax Weekly (week-at-a-glance)" cal-tex-mouse-filofax-week] | |
504 | ["Filofax Yearly" cal-tex-mouse-filofax-year])) | |
505 | ["Diary entries" calendar-mouse-view-diary-entries] | |
506 | ["Insert diary entry" calendar-mouse-insert-diary-entry] | |
507 | ["Other diary file entries" calendar-mouse-view-other-diary-entries])) | |
508 | ||
509 | (defun cal-menu-set-date-title (menu) | |
510 | (easy-menu-filter-return | |
511 | menu (calendar-date-string (calendar-event-to-date t) t nil))) | |
512 | ||
513 | (easy-menu-define cal-menu-global-mouse-menu nil | |
514 | "Menu bound to a mouse event, not specific to the mouse-click location." | |
515 | '("Calendar" | |
cca1dde0 SM |
516 | ["Scroll forward" calendar-scroll-left-three-months] |
517 | ["Scroll backward" calendar-scroll-right-three-months] | |
05efa389 | 518 | ["Mark diary entries" mark-diary-entries] |
175ede29 GM |
519 | ["List holidays" calendar-list-holidays] |
520 | ["Mark holidays" calendar-mark-holidays] | |
05efa389 SM |
521 | ["Unmark" calendar-unmark] |
522 | ["Lunar phases" calendar-phases-of-moon] | |
523 | ["Show diary" diary-show-all-entries] | |
524 | ["Exit calendar" exit-calendar])) | |
aef1a243 RS |
525 | |
526 | (run-hooks 'cal-menu-load-hook) | |
527 | ||
528 | (provide 'cal-menu) | |
529 | ||
e9f8d300 | 530 | ;; arch-tag: aa81cf73-ce89-48a4-97ec-9ef861e87fe9 |
aef1a243 | 531 | ;;; cal-menu.el ends here |