cal-menu.el 21.8 KB
Newer Older
Richard M. Stallman's avatar
Richard M. Stallman committed
1 2
;;; cal-menu.el --- calendar functions for menu bar and popup menu support

3
;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
Richard M. Stallman's avatar
Richard M. Stallman committed
4 5 6 7 8 9 10 11

;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
;;	Lara Rios <lrios@coewl.cen.uiuc.edu>
;; Keywords: calendar
;; Human-Keywords: calendar, popup menus, menu bar

;; This file is part of GNU Emacs.

12 13 14 15 16
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

Richard M. Stallman's avatar
Richard M. Stallman committed
17
;; GNU Emacs is distributed in the hope that it will be useful,
18 19 20 21 22
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
Erik Naggum's avatar
Erik Naggum committed
23 24 25
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
Richard M. Stallman's avatar
Richard M. Stallman committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39

;;; Commentary:

;; This collection of functions implements menu bar and popup menu support for
;; calendar.el.

;; Comments, corrections, and improvements should be sent to
;;  Edward M. Reingold               Department of Computer Science
;;  (217) 333-6733                   University of Illinois at Urbana-Champaign
;;  reingold@cs.uiuc.edu             1304 West Springfield Avenue
;;                                   Urbana, Illinois 61801

;;; Code:

Edward M. Reingold's avatar
Edward M. Reingold committed
40
(define-key calendar-mode-map [menu-bar edit] 'undefined)
41
(define-key calendar-mode-map [menu-bar search] 'undefined)
Edward M. Reingold's avatar
Edward M. Reingold committed
42

43
(define-key calendar-mode-map [down-mouse-2] 'calendar-mouse-2-date-menu)
44
(define-key calendar-mode-map [mouse-2] 'ignore)
45 46 47

(defvar calendar-mouse-3-map (make-sparse-keymap "Calendar"))
(define-key calendar-mode-map [down-mouse-3] calendar-mouse-3-map)
48
(define-key calendar-mode-map [C-down-mouse-3] calendar-mouse-3-map)
Richard M. Stallman's avatar
Richard M. Stallman committed
49

50 51 52 53
(define-key calendar-mode-map [menu-bar moon]
  (cons "Moon" (make-sparse-keymap "Moon")))

(define-key calendar-mode-map [menu-bar moon moon]
Karl Heuer's avatar
Karl Heuer committed
54
  '("Lunar Phases" . calendar-phases-of-moon))
55

Richard M. Stallman's avatar
Richard M. Stallman committed
56 57 58 59 60 61 62 63
(define-key calendar-mode-map [menu-bar diary]
  (cons "Diary" (make-sparse-keymap "Diary")))

(define-key calendar-mode-map [menu-bar diary heb]
  '("Insert Hebrew" . calendar-mouse-insert-hebrew-diary-entry))
(define-key calendar-mode-map [menu-bar diary isl]
  '("Insert Islamic" . calendar-mouse-insert-islamic-diary-entry))
(define-key calendar-mode-map [menu-bar diary cyc]
Karl Heuer's avatar
Karl Heuer committed
64
  '("Insert Cyclic" . insert-cyclic-diary-entry))
Richard M. Stallman's avatar
Richard M. Stallman committed
65
(define-key calendar-mode-map [menu-bar diary blk]
Karl Heuer's avatar
Karl Heuer committed
66
  '("Insert Block" . insert-block-diary-entry))
Richard M. Stallman's avatar
Richard M. Stallman committed
67
(define-key calendar-mode-map [menu-bar diary ann]
Karl Heuer's avatar
Karl Heuer committed
68
  '("Insert Anniversary" . insert-anniversary-diary-entry))
Richard M. Stallman's avatar
Richard M. Stallman committed
69
(define-key calendar-mode-map [menu-bar diary yr]
Karl Heuer's avatar
Karl Heuer committed
70
  '("Insert Yearly" . insert-yearly-diary-entry))
Richard M. Stallman's avatar
Richard M. Stallman committed
71
(define-key calendar-mode-map [menu-bar diary mon]
Karl Heuer's avatar
Karl Heuer committed
72
  '("Insert Monthly" . insert-monthly-diary-entry))
Richard M. Stallman's avatar
Richard M. Stallman committed
73
(define-key calendar-mode-map [menu-bar diary wk]
Karl Heuer's avatar
Karl Heuer committed
74
  '("Insert Weekly" . insert-weekly-diary-entry))
Richard M. Stallman's avatar
Richard M. Stallman committed
75
(define-key calendar-mode-map [menu-bar diary ent]
Karl Heuer's avatar
Karl Heuer committed
76
  '("Insert Daily". insert-diary-entry))
Richard M. Stallman's avatar
Richard M. Stallman committed
77
(define-key calendar-mode-map [menu-bar diary all]
Karl Heuer's avatar
Karl Heuer committed
78
  '("Show All" . show-all-diary-entries))
Richard M. Stallman's avatar
Richard M. Stallman committed
79
(define-key calendar-mode-map [menu-bar diary mark]
Karl Heuer's avatar
Karl Heuer committed
80
 '("Mark All" . mark-diary-entries))
Richard M. Stallman's avatar
Richard M. Stallman committed
81
(define-key calendar-mode-map [menu-bar diary view]
Karl Heuer's avatar
Karl Heuer committed
82
  '("Cursor Date" . view-diary-entries))
83
(define-key calendar-mode-map [menu-bar diary view]
Karl Heuer's avatar
Karl Heuer committed
84
  '("Other File" . view-other-diary-entries))
Richard M. Stallman's avatar
Richard M. Stallman committed
85 86 87 88 89 90 91 92 93

(define-key calendar-mode-map [menu-bar holidays]
  (cons "Holidays" (make-sparse-keymap "Holidays")))

(define-key calendar-mode-map [menu-bar holidays unmark]
  '("Unmark" . calendar-unmark))
(define-key calendar-mode-map [menu-bar holidays mark]
  '("Mark" . mark-calendar-holidays))
(define-key calendar-mode-map [menu-bar holidays 3-mon]
Karl Heuer's avatar
Karl Heuer committed
94
  '("3 Months" . list-calendar-holidays))
Richard M. Stallman's avatar
Richard M. Stallman committed
95
(define-key calendar-mode-map [menu-bar holidays 1-day]
Karl Heuer's avatar
Karl Heuer committed
96
  '("One Day" . calendar-cursor-holidays))
Richard M. Stallman's avatar
Richard M. Stallman committed
97 98 99 100 101

(define-key calendar-mode-map [menu-bar goto]
  (cons "Goto" (make-sparse-keymap "Goto")))

(define-key calendar-mode-map [menu-bar goto french]
Karl Heuer's avatar
Karl Heuer committed
102
  '("French Date" . calendar-goto-french-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
103
(define-key calendar-mode-map [menu-bar goto mayan]
Karl Heuer's avatar
Karl Heuer committed
104
  (cons "Mayan Date" (make-sparse-keymap "Mayan")))
105 106 107 108 109 110
(define-key calendar-mode-map [menu-bar goto ethiopic]
  '("Ethiopic Date" . calendar-goto-ethiopic-date))
(define-key calendar-mode-map [menu-bar goto coptic]
  '("Coptic Date" . calendar-goto-coptic-date))
(define-key calendar-mode-map [menu-bar goto chinese]
  '("Chinese Date" . calendar-goto-chinese-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
111
(define-key calendar-mode-map [menu-bar goto julian]
Karl Heuer's avatar
Karl Heuer committed
112
  '("Julian Date" . calendar-goto-julian-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
113
(define-key calendar-mode-map [menu-bar goto islamic]
Karl Heuer's avatar
Karl Heuer committed
114
  '("Islamic Date" . calendar-goto-islamic-date))
115 116
(define-key calendar-mode-map [menu-bar goto persian]
  '("Persian Date" . calendar-goto-persian-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
117
(define-key calendar-mode-map [menu-bar goto hebrew]
Karl Heuer's avatar
Karl Heuer committed
118
  '("Hebrew Date" . calendar-goto-hebrew-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
119
(define-key calendar-mode-map [menu-bar goto astro]
Karl Heuer's avatar
Karl Heuer committed
120
  '("Astronomical Date" . calendar-goto-astro-day-number))
Richard M. Stallman's avatar
Richard M. Stallman committed
121
(define-key calendar-mode-map [menu-bar goto iso]
Karl Heuer's avatar
Karl Heuer committed
122
  '("ISO Date" . calendar-goto-iso-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
123
(define-key calendar-mode-map [menu-bar goto gregorian]
Karl Heuer's avatar
Karl Heuer committed
124
  '("Other Date" . calendar-goto-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
125
(define-key calendar-mode-map [menu-bar goto end-of-year]
Karl Heuer's avatar
Karl Heuer committed
126
  '("End of Year" . calendar-end-of-year))
Richard M. Stallman's avatar
Richard M. Stallman committed
127
(define-key calendar-mode-map [menu-bar goto beginning-of-year]
Karl Heuer's avatar
Karl Heuer committed
128
  '("Beginning of Year" . calendar-beginning-of-year))
Richard M. Stallman's avatar
Richard M. Stallman committed
129
(define-key calendar-mode-map [menu-bar goto end-of-month]
Karl Heuer's avatar
Karl Heuer committed
130
  '("End of Month" . calendar-end-of-month))
Richard M. Stallman's avatar
Richard M. Stallman committed
131
(define-key calendar-mode-map [menu-bar goto beginning-of-month]
Karl Heuer's avatar
Karl Heuer committed
132
  '("Beginning of Month" . calendar-beginning-of-month))
Richard M. Stallman's avatar
Richard M. Stallman committed
133
(define-key calendar-mode-map [menu-bar goto end-of-week]
Karl Heuer's avatar
Karl Heuer committed
134
  '("End of Week" . calendar-end-of-week))
Richard M. Stallman's avatar
Richard M. Stallman committed
135
(define-key calendar-mode-map [menu-bar goto beginning-of-week]
Karl Heuer's avatar
Karl Heuer committed
136
  '("Beginning of Week" . calendar-beginning-of-week))
Richard M. Stallman's avatar
Richard M. Stallman committed
137
(define-key calendar-mode-map [menu-bar goto today]
138
  '("Today" . calendar-goto-today))
Richard M. Stallman's avatar
Richard M. Stallman committed
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187


(define-key calendar-mode-map [menu-bar goto mayan prev-rnd]
  '("Previous Round" . calendar-previous-calendar-round-date))
(define-key calendar-mode-map [menu-bar goto mayan nxt-rnd]
  '("Next Round" . calendar-next-calendar-round-date))
(define-key calendar-mode-map [menu-bar goto mayan prev-haab]
  '("Previous Haab" . calendar-previous-haab-date))
(define-key calendar-mode-map [menu-bar goto mayan next-haab]
  '("Next Haab" . calendar-next-haab-date))
(define-key calendar-mode-map [menu-bar goto mayan prev-tzol]
  '("Previous Tzolkin" . calendar-previous-tzolkin-date))
(define-key calendar-mode-map [menu-bar goto mayan next-tzol]
  '("Next Tzolkin" . calendar-next-tzolkin-date))

(define-key calendar-mode-map [menu-bar scroll]
  (cons "Scroll" (make-sparse-keymap "Scroll")))

(define-key calendar-mode-map [menu-bar scroll bk-12]
  '("Backward 1 Year" . "4\ev"))
(define-key calendar-mode-map [menu-bar scroll bk-3]
  '("Backward 3 Months" . scroll-calendar-right-three-months))
(define-key calendar-mode-map [menu-bar scroll bk-1]
  '("Backward 1 Month" . scroll-calendar-right))
(define-key calendar-mode-map [menu-bar scroll fwd-12]
  '("Forward 1 Year" . "4\C-v"))
(define-key calendar-mode-map [menu-bar scroll fwd-3]
  '("Forward 3 Months" . scroll-calendar-left-three-months))
(define-key calendar-mode-map [menu-bar scroll fwd-1]
  '("Forward 1 Month" . scroll-calendar-left))

(put 'calendar-forward-day 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-backward-day 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-forward-week 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-backward-week 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-forward-month 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-backward-month 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-forward-year 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-backward-year 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-beginning-of-year 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-end-of-year 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-beginning-of-month 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-end-of-month 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-end-of-week 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-beginning-of-week 'menu-enable '(calendar-cursor-to-date))
(put 'calendar-mouse-print-dates 'menu-enable '(calendar-event-to-date))
(put 'calendar-sunrise-sunset 'menu-enable '(calendar-event-to-date))
(put 'calendar-cursor-holidays 'menu-enable '(calendar-cursor-to-date))
(put 'view-diary-entries 'menu-enable '(calendar-cursor-to-date))
188
(put 'view-other-diary-entries 'menu-enable '(calendar-cursor-to-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
189 190 191 192 193 194 195 196 197 198 199 200
(put 'calendar-mouse-insert-hebrew-diary-entry
     'menu-enable
     '(calendar-cursor-to-date))
(put 'calendar-mouse-insert-islamic-diary-entry
     'menu-enable
     '(calendar-cursor-to-date))
(put 'insert-cyclic-diary-entry 'menu-enable '(calendar-cursor-to-date))
(put 'insert-block-diary-entry 'menu-enable '(calendar-cursor-to-date))
(put 'insert-anniversary-diary-entry 'menu-enable '(calendar-cursor-to-date))
(put 'insert-yearly-diary-entry 'menu-enable '(calendar-cursor-to-date))
(put 'insert-monthly-diary-entry 'menu-enable '(calendar-cursor-to-date))
(put 'insert-weekly-diary-entry 'menu-enable '(calendar-cursor-to-date))
201 202 203
(put 'cal-tex-cursor-day 'menu-enable '(calendar-cursor-to-date))
(put 'cal-tex-cursor-week 'menu-enable '(calendar-cursor-to-date))
(put 'cal-tex-cursor-week2 'menu-enable '(calendar-cursor-to-date))
204 205
(put 'cal-tex-cursor-week-iso 'menu-enable '(calendar-cursor-to-date))
(put 'cal-tex-cursor-week-monday 'menu-enable '(calendar-cursor-to-date))
206
(put 'cal-tex-cursor-filofax-2week
207
     'menu-enable '(calendar-cursor-to-date))
208
(put 'cal-tex-cursor-filofax-week 'menu-enable '(calendar-cursor-to-date))
209 210 211 212 213
(put 'cal-tex-cursor-month 'menu-enable '(calendar-cursor-to-date))
(put 'cal-tex-cursor-month-landscape 'menu-enable '(calendar-cursor-to-date))
(put 'cal-tex-cursor-year 'menu-enable '(calendar-cursor-to-date))
(put 'cal-tex-cursor-filofax-year 'menu-enable '(calendar-cursor-to-date))
(put 'cal-tex-cursor-year-landscape 'menu-enable '(calendar-cursor-to-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
214

215 216 217 218
(defun calendar-event-to-date (&optional error)
  "Date of last event.
If event is not on a specific date, signals an error if optional parameter
ERROR is t, otherwise just returns nil."
Richard M. Stallman's avatar
Richard M. Stallman committed
219
  (save-excursion
220
    (set-buffer (window-buffer (posn-window (event-start last-input-event))))
Richard M. Stallman's avatar
Richard M. Stallman committed
221
    (goto-char (posn-point (event-start last-input-event)))
222
    (calendar-cursor-to-date error)))
Richard M. Stallman's avatar
Richard M. Stallman committed
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253

(defun calendar-mouse-insert-hebrew-diary-entry (event)
  "Pop up menu to insert a Hebrew-date diary entry."
  (interactive "e")
  (let ((hebrew-selection
         (x-popup-menu
          event
          (list "Hebrew insert menu"
                (list (calendar-hebrew-date-string (calendar-cursor-to-date))
                      '("One time" . insert-hebrew-diary-entry)
                      '("Monthly" . insert-monthly-hebrew-diary-entry)
                      '("Yearly" . insert-yearly-hebrew-diary-entry))))))
    (and hebrew-selection (call-interactively hebrew-selection))))

(defun calendar-mouse-insert-islamic-diary-entry (event)
  "Pop up menu to insert an Islamic-date diary entry."
  (interactive "e")
  (let ((islamic-selection
         (x-popup-menu
          event
          (list "Islamic insert menu"
                (list (calendar-islamic-date-string (calendar-cursor-to-date))
                      '("One time" . insert-islamic-diary-entry)
                      '("Monthly" . insert-monthly-islamic-diary-entry)
                      '("Yearly" . insert-yearly-islamic-diary-entry))))))
    (and islamic-selection (call-interactively islamic-selection))))

(defun calendar-mouse-sunrise/sunset ()
  "Show sunrise/sunset times for mouse-selected date."
  (interactive)
  (save-excursion
254
    (calendar-mouse-goto-date (calendar-event-to-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
255 256 257 258 259 260
    (calendar-sunrise-sunset)))

(defun calendar-mouse-holidays ()
  "Show holidays for mouse-selected date."
  (interactive)
  (save-excursion
261
    (calendar-mouse-goto-date (calendar-event-to-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
262 263 264 265 266 267
    (calendar-cursor-holidays)))

(defun calendar-mouse-view-diary-entries ()
  "View diary entries on mouse-selected date."
  (interactive)
  (save-excursion
268
    (calendar-mouse-goto-date (calendar-event-to-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
269 270
    (view-diary-entries 1)))

271 272 273 274
(defun calendar-mouse-view-other-diary-entries ()
  "View diary entries from alternative file on mouse-selected date."
  (interactive)
  (save-excursion
275
    (calendar-mouse-goto-date (calendar-event-to-date))
276 277
    (call-interactively 'view-other-diary-entries)))

278 279 280 281
(defun calendar-mouse-insert-diary-entry ()
  "Insert diary entry for mouse-selected date."
  (interactive)
  (save-excursion
282
    (calendar-mouse-goto-date (calendar-event-to-date))
283 284
    (insert-diary-entry nil)))

285 286 287 288
(defun calendar-mouse-set-mark ()
  "Mark the date under the cursor."
  (interactive)
  (save-excursion
289
    (calendar-mouse-goto-date (calendar-event-to-date))
290 291
    (calendar-set-mark nil)))

292 293 294 295
(defun cal-tex-mouse-day ()
  "Make a buffer with LaTeX commands for the day mouse is on."
  (interactive)
  (save-excursion
296
    (calendar-mouse-goto-date (calendar-event-to-date))
297 298 299 300 301 302 303
    (cal-tex-cursor-day nil)))

(defun cal-tex-mouse-week ()
  "One page calendar for week indicated by cursor.
Holidays are included if `cal-tex-holidays' is t."
  (interactive)
  (save-excursion
304
    (calendar-mouse-goto-date (calendar-event-to-date))
305 306 307 308 309 310 311
    (cal-tex-cursor-week nil)))

(defun cal-tex-mouse-week2 ()
  "Make a buffer with LaTeX commands for the week cursor is on.
The printed output will be on two pages."
  (interactive)
  (save-excursion
312
    (calendar-mouse-goto-date (calendar-event-to-date))
313 314
    (cal-tex-cursor-week2 nil)))

315
(defun cal-tex-mouse-week-iso ()
316 317 318 319
  "One page calendar for week indicated by cursor.
Holidays are included if `cal-tex-holidays' is t."
  (interactive)
  (save-excursion
320
    (calendar-mouse-goto-date (calendar-event-to-date))
321
    (cal-tex-cursor-week-iso nil)))
322

323
(defun cal-tex-mouse-week-monday ()
324 325 326
  "One page calendar for week indicated by cursor."
  (interactive)
  (save-excursion
327
    (calendar-mouse-goto-date (calendar-event-to-date))
328
    (cal-tex-cursor-week-monday nil)))
329

330
(defun cal-tex-mouse-filofax-2week ()
331 332 333
  "One page Filofax calendar for week indicated by cursor."
  (interactive)
  (save-excursion
334
    (calendar-mouse-goto-date (calendar-event-to-date))
335
    (cal-tex-cursor-filofax-2week nil)))
336

337
(defun cal-tex-mouse-filofax-week ()
338 339 340
  "Two page Filofax calendar for week indicated by cursor."
  (interactive)
  (save-excursion
341
    (calendar-mouse-goto-date (calendar-event-to-date))
342
    (cal-tex-cursor-filofax-week nil)))
343 344 345 346 347 348

(defun cal-tex-mouse-month ()
  "Make a buffer with LaTeX commands for the month cursor is on.
Calendar is condensed onto one page."
  (interactive)
  (save-excursion
349
    (calendar-mouse-goto-date (calendar-event-to-date))
350 351 352 353 354 355 356
    (cal-tex-cursor-month nil)))

(defun cal-tex-mouse-month-landscape ()
  "Make a buffer with LaTeX commands for the month cursor is on.
The output is in landscape format, one month to a page."
  (interactive)
  (save-excursion
357
    (calendar-mouse-goto-date (calendar-event-to-date))
358 359 360 361 362 363
    (cal-tex-cursor-month-landscape nil)))

(defun cal-tex-mouse-year ()
  "Make a buffer with LaTeX commands for the year cursor is on."
  (interactive)
  (save-excursion
364
    (calendar-mouse-goto-date (calendar-event-to-date))
365 366 367 368 369 370
    (cal-tex-cursor-year nil)))

(defun cal-tex-mouse-filofax-year ()
  "Make a buffer with LaTeX commands for Filofax calendar of year cursor is on."
  (interactive)
  (save-excursion
371
    (calendar-mouse-goto-date (calendar-event-to-date))
372 373 374 375 376 377
    (cal-tex-cursor-filofax-year nil)))

(defun cal-tex-mouse-year-landscape ()
  "Make a buffer with LaTeX commands for the year cursor is on."
  (interactive)
  (save-excursion
378
    (calendar-mouse-goto-date (calendar-event-to-date))
379 380
    (cal-tex-cursor-year-landscape nil)))

Richard M. Stallman's avatar
Richard M. Stallman committed
381 382 383
(defun calendar-mouse-print-dates ()
  "Pop up menu of equivalent dates to mouse selected date."
  (interactive)
384 385 386 387 388
  (let ((date (calendar-event-to-date))
        (selection
         (x-popup-menu
          event
          (list
389
           (concat (calendar-date-string date) " (Gregorian)")
390 391 392 393 394 395 396 397
           (append
            (list
             (concat (calendar-date-string date) " (Gregorian)")
             (list (calendar-day-of-year-string date))
             (list (format "ISO date: %s" (calendar-iso-date-string date)))
             (list (format "Julian date: %s"
                           (calendar-julian-date-string date)))
             (list
Edward M. Reingold's avatar
Edward M. Reingold committed
398
              (format "Astronomical (Julian) day number (at noon UTC): %s.0"
399 400
                           (calendar-astro-date-string date)))
             (list (format "Hebrew date (before sunset): %s"
401 402 403
                           (calendar-hebrew-date-string date)))
             (list (format "Persian date: %s"
                           (calendar-persian-date-string date))))
404 405 406
            (let ((i (calendar-islamic-date-string date)))
              (if (not (string-equal i ""))
                  (list (list (format "Islamic date (before sunset): %s" i)))))
407 408 409 410 411
            (list
             (list (format "Chinese date: %s"
                           (calendar-chinese-date-string date))))
;            (list '("Chinese date (select to echo Chinese date)"
;                    . calendar-mouse-chinese-date))
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426
            (let ((c (calendar-coptic-date-string date)))
              (if (not (string-equal c ""))
                  (list (list (format "Coptic date: %s" c)))))
            (let ((e (calendar-ethiopic-date-string date)))
              (if (not (string-equal e ""))
                  (list (list (format "Ethiopic date: %s" e)))))
            (let ((f (calendar-french-date-string date)))
              (if (not (string-equal f ""))
                  (list (list (format "French Revolutionary date: %s" f)))))
            (list
             (list
              (format "Mayan date: %s"
                      (calendar-mayan-date-string date)))))))))
        (and selection (call-interactively selection))))

427 428 429 430
(defun calendar-mouse-chinese-date ()
  "Show Chinese equivalent for mouse-selected date."
  (interactive)
  (save-excursion
431
    (calendar-mouse-goto-date (calendar-event-to-date))
432
    (calendar-print-chinese-date)))
Richard M. Stallman's avatar
Richard M. Stallman committed
433

434 435 436 437
(defun calendar-mouse-goto-date (date)
  (set-buffer (window-buffer (posn-window (event-start last-input-event))))
  (calendar-goto-date date))

438 439
(defun calendar-mouse-2-date-menu (event)
  "Pop up menu for Mouse-2 for selected date in the calendar window."
Richard M. Stallman's avatar
Richard M. Stallman committed
440
  (interactive "e")
441 442 443 444
  (let* ((date (calendar-event-to-date t))
         (selection
          (x-popup-menu
           event
445
           (list (calendar-date-string date t nil)
446
                 (list
447
                  ""
448 449 450
                  '("Holidays" . calendar-mouse-holidays)
                  '("Mark date" . calendar-mouse-set-mark)
                  '("Sunrise/sunset" . calendar-mouse-sunrise/sunset)
451
                  '("Other calendars" . calendar-mouse-print-dates)
452
                  '("Prepare LaTeX buffer" . calendar-mouse-cal-tex-menu)
453 454 455 456 457
                  '("Diary entries" . calendar-mouse-view-diary-entries)
                  '("Insert diary entry" . calendar-mouse-insert-diary-entry)
                  '("Other diary file entries"
                    . calendar-mouse-view-other-diary-entries)
                  )))))
458 459
    (and selection (call-interactively selection))))

460 461 462 463 464 465
(defun calendar-mouse-cal-tex-menu (event)
  "Pop up submenu for Mouse-2 for cal-tex commands for selected date in the calendar window."
  (interactive "e")
  (let* ((selection
          (x-popup-menu
           event
466
           (list (calendar-date-string date t nil)
467
                 (list
468
                  ""
469 470 471
                  '("Daily (1 page)" . cal-tex-mouse-day)
                  '("Weekly (1 page)" . cal-tex-mouse-week)
                  '("Weekly (2 pages)" . cal-tex-mouse-week2)
472 473 474
                  '("Weekly (other style; 1 page)" . cal-tex-mouse-week-iso)
                  '("Weekly (yet another style; 1 page)" .
                    cal-tex-mouse-week-monday)
475 476 477 478 479 480 481 482 483 484 485 486 487 488
                  '("Monthly" . cal-tex-mouse-month)
                  '("Monthly (landscape)" . cal-tex-mouse-month-landscape)
                  '("Yearly" . cal-tex-mouse-year)
                  '("Yearly (landscape)" . cal-tex-mouse-year-landscape)
                  '("Filofax styles" . cal-tex-mouse-filofax)
                  )))))
    (and selection (call-interactively selection))))

(defun cal-tex-mouse-filofax (event)
  "Pop up sub-submenu for Mouse-2 for Filofax cal-tex commands for selected date."
  (interactive "e")
  (let* ((selection
          (x-popup-menu
           event
489
           (list (calendar-date-string date t nil)
490
                 (list
491 492 493 494 495
                  ""
                  '("Filofax Weekly (2-weeks-at-a-glance)" .
                    cal-tex-mouse-filofax-2week)
                  '("Filofax Weekly (week-at-a-glance)" .
                    cal-tex-mouse-filofax-week)
496 497 498 499
                  '("Filofax Yearly" . cal-tex-mouse-filofax-year)
                  )))))
    (and selection (call-interactively selection))))

500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
(define-key calendar-mouse-3-map [exit-calendar]
  '("Exit calendar" . exit-calendar))
(define-key calendar-mouse-3-map [show-diary]
  '("Show diary" . show-all-diary-entries))
(define-key calendar-mouse-3-map [lunar-phases]
  '("Lunar phases" . calendar-phases-of-moon))
(define-key calendar-mouse-3-map [unmark]
  '("Unmark" . calendar-unmark))
(define-key calendar-mouse-3-map [mark-holidays]
  '("Mark holidays" . mark-calendar-holidays))
(define-key calendar-mouse-3-map [list-holidays]
  '("List holidays" . list-calendar-holidays))
(define-key calendar-mouse-3-map [mark-diary-entries]
  '("Mark diary entries" . mark-diary-entries))
(define-key calendar-mouse-3-map [scroll-backward]
  '("Scroll backward" . scroll-calendar-right-three-months))
(define-key calendar-mouse-3-map [scroll-forward]
  '("Scroll forward" . scroll-calendar-left-three-months))
Richard M. Stallman's avatar
Richard M. Stallman committed
518 519 520 521 522 523

(run-hooks 'cal-menu-load-hook)

(provide 'cal-menu)

;;; cal-menu.el ends here