Mercurial > emacs
annotate lisp/calendar/cal-menu.el @ 7057:7102dd374da4
(special-display-frame-alist): New variable.
(special-display-popup-frame): New function.
(special-display-function): Set it.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 23 Apr 1994 21:38:16 +0000 |
parents | 3e1323443b1a |
children | 494ca99e9517 |
rev | line source |
---|---|
5701 | 1 ;;; cal-menu.el --- calendar functions for menu bar and popup menu support |
2 | |
3 ;; Copyright (C) 1994 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> | |
6 ;; Lara Rios <lrios@coewl.cen.uiuc.edu> | |
7 ;; Keywords: calendar | |
8 ;; Human-Keywords: calendar, popup menus, menu bar | |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5701
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5701
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5701
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5701
diff
changeset
|
15 ;; any later version. |
5701 | 16 |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5701
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5701
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5701
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5701
diff
changeset
|
20 ;; GNU General Public License for more details. |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5701
diff
changeset
|
21 |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5701
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5701
diff
changeset
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5701
diff
changeset
|
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
5701 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; This collection of functions implements menu bar and popup menu support for | |
29 ;; calendar.el. | |
30 | |
31 ;; Comments, corrections, and improvements should be sent to | |
32 ;; Edward M. Reingold Department of Computer Science | |
33 ;; (217) 333-6733 University of Illinois at Urbana-Champaign | |
34 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue | |
35 ;; Urbana, Illinois 61801 | |
36 | |
37 ;;; Code: | |
38 | |
39 (define-key calendar-mode-map [down-mouse-2] 'calendar-mouse-date-menu) | |
40 | |
41 (define-key calendar-mode-map [menu-bar moon] | |
42 '("Moon" . calendar-phases-of-moon)) | |
43 | |
44 (define-key calendar-mode-map [menu-bar diary] | |
45 (cons "Diary" (make-sparse-keymap "Diary"))) | |
46 | |
47 (define-key calendar-mode-map [menu-bar diary heb] | |
48 '("Insert Hebrew" . calendar-mouse-insert-hebrew-diary-entry)) | |
49 (define-key calendar-mode-map [menu-bar diary isl] | |
50 '("Insert Islamic" . calendar-mouse-insert-islamic-diary-entry)) | |
51 (define-key calendar-mode-map [menu-bar diary cyc] | |
52 '("Insert cyclic" . insert-cyclic-diary-entry)) | |
53 (define-key calendar-mode-map [menu-bar diary blk] | |
54 '("Insert block" . insert-block-diary-entry)) | |
55 (define-key calendar-mode-map [menu-bar diary ann] | |
56 '("Insert anniversary" . insert-anniversary-diary-entry)) | |
57 (define-key calendar-mode-map [menu-bar diary yr] | |
58 '("Insert yearly" . insert-yearly-diary-entry)) | |
59 (define-key calendar-mode-map [menu-bar diary mon] | |
60 '("Insert monthly" . insert-monthly-diary-entry)) | |
61 (define-key calendar-mode-map [menu-bar diary wk] | |
62 '("Insert weekly" . insert-weekly-diary-entry)) | |
63 (define-key calendar-mode-map [menu-bar diary ent] | |
64 '("Insert daily". insert-diary-entry)) | |
65 (define-key calendar-mode-map [menu-bar diary all] | |
66 '("Show all" . show-all-diary-entries)) | |
67 (define-key calendar-mode-map [menu-bar diary mark] | |
68 '("Mark all" . mark-diary-entries)) | |
69 (define-key calendar-mode-map [menu-bar diary view] | |
70 '("Cursor date" . view-diary-entries)) | |
71 | |
72 (define-key calendar-mode-map [menu-bar holidays] | |
73 (cons "Holidays" (make-sparse-keymap "Holidays"))) | |
74 | |
75 (define-key calendar-mode-map [menu-bar holidays unmark] | |
76 '("Unmark" . calendar-unmark)) | |
77 (define-key calendar-mode-map [menu-bar holidays mark] | |
78 '("Mark" . mark-calendar-holidays)) | |
79 (define-key calendar-mode-map [menu-bar holidays 3-mon] | |
80 '("3 months" . list-calendar-holidays)) | |
81 (define-key calendar-mode-map [menu-bar holidays 1-day] | |
82 '("One day" . calendar-cursor-holidays)) | |
83 | |
84 (define-key calendar-mode-map [menu-bar goto] | |
85 (cons "Goto" (make-sparse-keymap "Goto"))) | |
86 | |
87 (define-key calendar-mode-map [menu-bar goto french] | |
88 '("French date" . calendar-goto-french-date)) | |
89 (define-key calendar-mode-map [menu-bar goto mayan] | |
90 (cons "Mayan date" (make-sparse-keymap "Mayan"))) | |
91 (define-key calendar-mode-map [menu-bar goto julian] | |
92 '("Julian date" . calendar-goto-julian-date)) | |
93 (define-key calendar-mode-map [menu-bar goto islamic] | |
94 '("Islamic date" . calendar-goto-islamic-date)) | |
95 (define-key calendar-mode-map [menu-bar goto hebrew] | |
96 '("Hebrew date" . calendar-goto-hebrew-date)) | |
97 (define-key calendar-mode-map [menu-bar goto astro] | |
98 '("Astronomical date" . calendar-goto-astro-date)) | |
99 (define-key calendar-mode-map [menu-bar goto iso] | |
100 '("ISO date" . calendar-goto-iso-date)) | |
101 (define-key calendar-mode-map [menu-bar goto gregorian] | |
102 '("Other date" . calendar-goto-date)) | |
103 (define-key calendar-mode-map [menu-bar goto end-of-year] | |
104 '("End of year" . calendar-end-of-year)) | |
105 (define-key calendar-mode-map [menu-bar goto beginning-of-year] | |
106 '("Beginning of year" . calendar-beginning-of-year)) | |
107 (define-key calendar-mode-map [menu-bar goto end-of-month] | |
108 '("End of month" . calendar-end-of-month)) | |
109 (define-key calendar-mode-map [menu-bar goto beginning-of-month] | |
110 '("Beginning of month" . calendar-beginning-of-month)) | |
111 (define-key calendar-mode-map [menu-bar goto end-of-week] | |
112 '("End of week" . calendar-end-of-week)) | |
113 (define-key calendar-mode-map [menu-bar goto beginning-of-week] | |
114 '("Beginning of week" . calendar-beginning-of-week)) | |
115 (define-key calendar-mode-map [menu-bar goto today] | |
116 '("Today" . calendar-current-month)) | |
117 | |
118 | |
119 (define-key calendar-mode-map [menu-bar goto mayan prev-rnd] | |
120 '("Previous Round" . calendar-previous-calendar-round-date)) | |
121 (define-key calendar-mode-map [menu-bar goto mayan nxt-rnd] | |
122 '("Next Round" . calendar-next-calendar-round-date)) | |
123 (define-key calendar-mode-map [menu-bar goto mayan prev-haab] | |
124 '("Previous Haab" . calendar-previous-haab-date)) | |
125 (define-key calendar-mode-map [menu-bar goto mayan next-haab] | |
126 '("Next Haab" . calendar-next-haab-date)) | |
127 (define-key calendar-mode-map [menu-bar goto mayan prev-tzol] | |
128 '("Previous Tzolkin" . calendar-previous-tzolkin-date)) | |
129 (define-key calendar-mode-map [menu-bar goto mayan next-tzol] | |
130 '("Next Tzolkin" . calendar-next-tzolkin-date)) | |
131 | |
132 (define-key calendar-mode-map [menu-bar scroll] | |
133 (cons "Scroll" (make-sparse-keymap "Scroll"))) | |
134 | |
135 (define-key calendar-mode-map [menu-bar scroll bk-12] | |
136 '("Backward 1 Year" . "4\ev")) | |
137 (define-key calendar-mode-map [menu-bar scroll bk-3] | |
138 '("Backward 3 Months" . scroll-calendar-right-three-months)) | |
139 (define-key calendar-mode-map [menu-bar scroll bk-1] | |
140 '("Backward 1 Month" . scroll-calendar-right)) | |
141 (define-key calendar-mode-map [menu-bar scroll fwd-12] | |
142 '("Forward 1 Year" . "4\C-v")) | |
143 (define-key calendar-mode-map [menu-bar scroll fwd-3] | |
144 '("Forward 3 Months" . scroll-calendar-left-three-months)) | |
145 (define-key calendar-mode-map [menu-bar scroll fwd-1] | |
146 '("Forward 1 Month" . scroll-calendar-left)) | |
147 | |
148 (put 'calendar-forward-day 'menu-enable '(calendar-cursor-to-date)) | |
149 (put 'calendar-backward-day 'menu-enable '(calendar-cursor-to-date)) | |
150 (put 'calendar-forward-week 'menu-enable '(calendar-cursor-to-date)) | |
151 (put 'calendar-backward-week 'menu-enable '(calendar-cursor-to-date)) | |
152 (put 'calendar-forward-month 'menu-enable '(calendar-cursor-to-date)) | |
153 (put 'calendar-backward-month 'menu-enable '(calendar-cursor-to-date)) | |
154 (put 'calendar-forward-year 'menu-enable '(calendar-cursor-to-date)) | |
155 (put 'calendar-backward-year 'menu-enable '(calendar-cursor-to-date)) | |
156 (put 'calendar-beginning-of-year 'menu-enable '(calendar-cursor-to-date)) | |
157 (put 'calendar-end-of-year 'menu-enable '(calendar-cursor-to-date)) | |
158 (put 'calendar-beginning-of-month 'menu-enable '(calendar-cursor-to-date)) | |
159 (put 'calendar-end-of-month 'menu-enable '(calendar-cursor-to-date)) | |
160 (put 'calendar-end-of-week 'menu-enable '(calendar-cursor-to-date)) | |
161 (put 'calendar-beginning-of-week 'menu-enable '(calendar-cursor-to-date)) | |
162 (put 'calendar-mouse-print-dates 'menu-enable '(calendar-event-to-date)) | |
163 (put 'calendar-sunrise-sunset 'menu-enable '(calendar-event-to-date)) | |
164 (put 'calendar-cursor-holidays 'menu-enable '(calendar-cursor-to-date)) | |
165 (put 'view-diary-entries 'menu-enable '(calendar-cursor-to-date)) | |
166 (put 'calendar-mouse-insert-hebrew-diary-entry | |
167 'menu-enable | |
168 '(calendar-cursor-to-date)) | |
169 (put 'calendar-mouse-insert-islamic-diary-entry | |
170 'menu-enable | |
171 '(calendar-cursor-to-date)) | |
172 (put 'insert-cyclic-diary-entry 'menu-enable '(calendar-cursor-to-date)) | |
173 (put 'insert-block-diary-entry 'menu-enable '(calendar-cursor-to-date)) | |
174 (put 'insert-anniversary-diary-entry 'menu-enable '(calendar-cursor-to-date)) | |
175 (put 'insert-yearly-diary-entry 'menu-enable '(calendar-cursor-to-date)) | |
176 (put 'insert-monthly-diary-entry 'menu-enable '(calendar-cursor-to-date)) | |
177 (put 'insert-weekly-diary-entry 'menu-enable '(calendar-cursor-to-date)) | |
178 | |
179 (defun calendar-event-to-date () | |
180 "Date of last event. Nil if last event was not done on a date." | |
181 (save-excursion | |
182 (goto-char (posn-point (event-start last-input-event))) | |
183 (calendar-cursor-to-date))) | |
184 | |
185 (defun calendar-mouse-insert-hebrew-diary-entry (event) | |
186 "Pop up menu to insert a Hebrew-date diary entry." | |
187 (interactive "e") | |
188 (let ((hebrew-selection | |
189 (x-popup-menu | |
190 event | |
191 (list "Hebrew insert menu" | |
192 (list (calendar-hebrew-date-string (calendar-cursor-to-date)) | |
193 '("One time" . insert-hebrew-diary-entry) | |
194 '("Monthly" . insert-monthly-hebrew-diary-entry) | |
195 '("Yearly" . insert-yearly-hebrew-diary-entry)))))) | |
196 (and hebrew-selection (call-interactively hebrew-selection)))) | |
197 | |
198 (defun calendar-mouse-insert-islamic-diary-entry (event) | |
199 "Pop up menu to insert an Islamic-date diary entry." | |
200 (interactive "e") | |
201 (let ((islamic-selection | |
202 (x-popup-menu | |
203 event | |
204 (list "Islamic insert menu" | |
205 (list (calendar-islamic-date-string (calendar-cursor-to-date)) | |
206 '("One time" . insert-islamic-diary-entry) | |
207 '("Monthly" . insert-monthly-islamic-diary-entry) | |
208 '("Yearly" . insert-yearly-islamic-diary-entry)))))) | |
209 (and islamic-selection (call-interactively islamic-selection)))) | |
210 | |
211 (defun calendar-mouse-sunrise/sunset () | |
212 "Show sunrise/sunset times for mouse-selected date." | |
213 (interactive) | |
214 (save-excursion | |
215 (calendar-goto-date (calendar-event-to-date)) | |
216 (calendar-sunrise-sunset))) | |
217 | |
218 (defun calendar-mouse-holidays () | |
219 "Show holidays for mouse-selected date." | |
220 (interactive) | |
221 (save-excursion | |
222 (calendar-goto-date (calendar-event-to-date)) | |
223 (calendar-cursor-holidays))) | |
224 | |
225 (defun calendar-mouse-view-diary-entries () | |
226 "View diary entries on mouse-selected date." | |
227 (interactive) | |
228 (save-excursion | |
229 (calendar-goto-date (calendar-event-to-date)) | |
230 (view-diary-entries 1))) | |
231 | |
232 (defun calendar-mouse-print-dates () | |
233 "Pop up menu of equivalent dates to mouse selected date." | |
234 (interactive) | |
235 (let ((date (calendar-event-to-date))) | |
236 (x-popup-menu | |
237 event | |
238 (list | |
239 "Date Menu" | |
240 (append | |
241 (list | |
242 (concat (calendar-date-string date) " (Gregorian)") | |
243 (list (calendar-iso-date-string date)) | |
244 (list (format "ISO date: %s" (calendar-iso-date-string date))) | |
245 (list (format "Julian date: %s" (calendar-julian-date-string date))) | |
246 (list (format "Astronomical (Julian) date (before noon): %s" | |
247 (calendar-astro-date-string date))) | |
248 (list (format "Hebrew date (before sunset): %s" | |
249 (calendar-hebrew-date-string date)))) | |
250 (let ((i (calendar-islamic-date-string date))) | |
251 (if (not (string-equal i "")) | |
252 (list (format "Islamic date (before sunset): %s" i)))) | |
253 (let ((f (calendar-french-date-string date))) | |
254 (if (not (string-equal f "")) | |
255 (list (format "French Revolutionary date: %s" f)))) | |
256 (list | |
257 (format "Mayan date: %s" (calendar-mayan-date-string date)))))))) | |
258 | |
259 (defun calendar-mouse-date-menu (event) | |
260 "Pop up menu for selected date." | |
261 (interactive "e") | |
262 (let ((selection | |
263 (x-popup-menu | |
264 event | |
265 (if (calendar-event-to-date) | |
266 (list "Menu" | |
267 (list | |
268 (calendar-date-string | |
269 (or (calendar-event-to-date) | |
270 (error "Mouse is not on a date!")) | |
271 t t) | |
272 '("Diary entries" . calendar-mouse-view-diary-entries) | |
273 '("Holidays" . calendar-mouse-holidays) | |
274 '("Mark date" . calendar-set-mark) | |
275 '("Sunrise/sunset" . calendar-mouse-sunrise/sunset) | |
276 '("Other calendars" . calendar-mouse-print-dates))) | |
277 (list "Menu" | |
278 (list | |
279 (let ((m1 displayed-month) | |
280 (y1 displayed-year) | |
281 (m2 displayed-month) | |
282 (y2 displayed-year)) | |
283 (increment-calendar-month m1 y1 -1) | |
284 (increment-calendar-month m2 y2 1) | |
285 (if (= y1 y2) | |
286 (format "%s--%s, %d" | |
287 (substring (calendar-month-name m1) 0 3) | |
288 (substring (calendar-month-name m2) 0 3) y2) | |
289 (format "%s, %d--%s, %d" | |
290 (substring (calendar-month-name m1) 0 3) y1 | |
291 (substring (calendar-month-name m2) 0 3) y2))) | |
292 '("Scroll forward" . scroll-calendar-left-three-months) | |
293 '("Scroll backward" . scroll-calendar-right-three-months) | |
294 '("Show diary" . show-all-diary-entries) | |
295 '("Mark diary entries" . mark-diary-entries) | |
296 '("List holidays" . list-calendar-holidays) | |
297 '("Mark holidays" . mark-calendar-holidays) | |
298 '("Unmark" . calendar-unmark) | |
299 '("Lunar phases" . calendar-phases-of-moon) | |
300 '("Exit calendar" . exit-calendar))))))) | |
301 (and selection (call-interactively selection)))) | |
302 | |
303 (run-hooks 'cal-menu-load-hook) | |
304 | |
305 (provide 'cal-menu) | |
306 | |
307 ;;; cal-menu.el ends here |