cal-menu.el 21.4 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

Glenn Morris's avatar
Glenn Morris committed
3
;; Copyright (C) 1994, 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Glenn Morris's avatar
Glenn Morris committed
4
;;   Free Software Foundation, Inc.
Richard M. Stallman's avatar
Richard M. Stallman committed
5 6 7

;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
;;	Lara Rios <lrios@coewl.cen.uiuc.edu>
8
;; Maintainer: Glenn Morris <rgm@gnu.org>
Richard M. Stallman's avatar
Richard M. Stallman committed
9 10 11 12 13
;; Keywords: calendar
;; Human-Keywords: calendar, popup menus, menu bar

;; This file is part of GNU Emacs.

14 15
;; 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
16
;; the Free Software Foundation; either version 3, or (at your option)
17 18
;; any later version.

Richard M. Stallman's avatar
Richard M. Stallman committed
19
;; GNU Emacs is distributed in the hope that it will be useful,
20 21 22 23 24
;; 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
25
;; along with GNU Emacs; see the file COPYING.  If not, write to the
Lute Kamstra's avatar
Lute Kamstra committed
26 27
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
Richard M. Stallman's avatar
Richard M. Stallman committed
28 29 30 31 32 33 34 35

;;; Commentary:

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

;;; Code:

Glenn Morris's avatar
Glenn Morris committed
36 37 38
;; The code in this file is only called from calendar.el, but can't
;; require it (to supress undefined function warnings from compiler)
;; without a recursive require.
Glenn Morris's avatar
Glenn Morris committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
;; All these functions are either autoloaded, or autoloaded or defined
;; in calendar.el.
(declare-function calendar-increment-month "calendar" (n &optional mon yr))
(declare-function calendar-month-name      "calendar" (month &optional abbrev))
(declare-function extract-calendar-year    "calendar" (date))
(declare-function calendar-cursor-to-date  "calendar" (&optional error))
(declare-function holiday-list             "holidays" (y1 y2 &optional l label))
(declare-function calendar-sunrise-sunset  "solar"    nil)
(declare-function calendar-current-date    "calendar" nil)
(declare-function calendar-cursor-holidays "holidays" nil)
(declare-function calendar-date-string     "calendar"
                  (date &optional abbreviate nodayname))
(declare-function insert-diary-entry       "diary-lib" (arg))
(declare-function calendar-set-mark        "calendar"  (arg))
(declare-function cal-tex-cursor-day       "cal-tex"   (&optional arg))
(declare-function cal-tex-cursor-week      "cal-tex"   (&optional arg))
(declare-function cal-tex-cursor-week2     "cal-tex"   (&optional arg))
(declare-function cal-tex-cursor-week-iso  "cal-tex"   (&optional arg))
(declare-function cal-tex-cursor-week-monday     "cal-tex"    (&optional arg))
(declare-function cal-tex-cursor-filofax-daily   "cal-tex"    (&optional arg))
(declare-function cal-tex-cursor-filofax-2week   "cal-tex"    (&optional arg))
(declare-function cal-tex-cursor-filofax-week    "cal-tex"    (&optional arg))
(declare-function cal-tex-cursor-month           "cal-tex"    (arg))
(declare-function cal-tex-cursor-month-landscape "cal-tex"    (&optional arg))
(declare-function cal-tex-cursor-year            "cal-tex"    (&optional arg))
(declare-function cal-tex-cursor-filofax-year    "cal-tex"    (&optional arg))
(declare-function cal-tex-cursor-year-landscape  "cal-tex"    (&optional arg))
(declare-function calendar-day-of-year-string    "calendar"   (&optional date))
(declare-function calendar-iso-date-string       "cal-iso"    (&optional date))
(declare-function calendar-julian-date-string    "cal-julian" (&optional date))
(declare-function calendar-astro-date-string     "cal-julian" (&optional date))
(declare-function calendar-absolute-from-gregorian "calendar" (date))
(declare-function calendar-hebrew-date-string    "cal-hebrew" (&optional date))
(declare-function calendar-persian-date-string   "cal-persia" (&optional date))
(declare-function calendar-bahai-date-string     "cal-bahai"  (&optional date))
(declare-function calendar-islamic-date-string   "cal-islam"  (&optional date))
(declare-function calendar-chinese-date-string   "cal-china"  (&optional date))
(declare-function calendar-coptic-date-string    "cal-coptic" (&optional date))
(declare-function calendar-ethiopic-date-string  "cal-coptic" (&optional date))
(declare-function calendar-french-date-string    "cal-french" (&optional date))
(declare-function calendar-mayan-date-string     "cal-mayan"  (&optional date))
(declare-function calendar-print-chinese-date    "cal-china"  nil)
(declare-function calendar-goto-date             "cal-move"   (date))
Glenn Morris's avatar
Glenn Morris committed
82

83 84
(defvar displayed-year)

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
(defconst cal-menu-moon-menu
  '("Moon"
    ["Lunar Phases" calendar-phases-of-moon]))

(defconst cal-menu-diary-menu
  '("Diary"
    ["Other File" view-other-diary-entries]
    ["Cursor Date" diary-view-entries]
    ["Mark All" mark-diary-entries]
    ["Show All" diary-show-all-entries]
    ["Insert Diary Entry" insert-diary-entry]
    ["Insert Weekly" insert-weekly-diary-entry]
    ["Insert Monthly" insert-monthly-diary-entry]
    ["Insert Yearly" insert-yearly-diary-entry]
    ["Insert Anniversary" insert-anniversary-diary-entry]
    ["Insert Block" insert-block-diary-entry]
    ["Insert Cyclic" insert-cyclic-diary-entry]
    ("Insert Baha'i"
     [" " nil :suffix (calendar-bahai-date-string (calendar-cursor-to-date))]
104 105 106
     ["One time" diary-bahai-insert-entry]
     ["Monthly" diary-bahai-insert-monthly-entry]
     ["Yearly" diary-bahai-insert-yearly-entry])
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
    ("Insert Islamic"
     [" " nil :suffix (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])
    ("Insert Hebrew"
     [" " nil :suffix (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])))

(defun cal-menu-holiday-window-suffix ()
  (let ((my1 (calendar-increment-month -1))
        (my2 (calendar-increment-month 1)))
    (if (= (cdr my1) (cdr my2))
        (format "%s-%s, %d"
                (calendar-month-name (car my1) 'abbrev)
                (calendar-month-name (car my2) 'abbrev)
                (cdr my2))
      (format "%s, %d-%s, %d"
              (calendar-month-name (car my1) 'abbrev)
              (cdr my1)
              (calendar-month-name (car my2) 'abbrev)
              (cdr my2)))))

(defconst cal-menu-holidays-menu
  `("Holidays"
    ["For Cursor Date -" calendar-cursor-holidays
     :suffix (calendar-date-string (calendar-cursor-to-date) t t)
     :visible (calendar-cursor-to-date)]
137
    ["For Window -" calendar-list-holidays
138 139 140 141 142 143
     :suffix (cal-menu-holiday-window-suffix)]
    ["For Today -" cal-menu-today-holidays
     :suffix (calendar-date-string (calendar-current-date) t t)]
    "--"
    ,@(let ((l ()))
        ;; Show 11 years--5 before, 5 after year of middle month.
144 145
        ;; We used to use :suffix rather than :label and bumped into
        ;; an easymenu bug:
146
        ;; http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01813.html
147
        ;; The bug has since been fixed.
148
        (dotimes (i 11)
149
          (push (vector (format "hol-year-%d" i)
150 151 152 153
                        `(lambda ()
                           (interactive)
                           (holiday-list (+ displayed-year ,(- i 5))
                                         (+ displayed-year ,(- i 5))))
154 155
                        :label `(format "For Year %d"
                                       (+ displayed-year ,(- i 5))))
156
                l))
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
        (nreverse l))
    "--"
    ["Unmark Calendar" calendar-unmark]
    ["Mark Holidays" mark-calendar-holidays]))

(defconst cal-menu-goto-menu
  '("Goto"
    ["Today" calendar-goto-today]
    ["Beginning of Week" calendar-beginning-of-week]
    ["End of Week" calendar-end-of-week]
    ["Beginning of Month" calendar-beginning-of-month]
    ["End of Month" calendar-end-of-month]
    ["Beginning of Year" calendar-beginning-of-year]
    ["End of Year" calendar-end-of-year]
    ["Other Date" calendar-goto-date]
    ["Day of Year" calendar-goto-day-of-year]
    ["ISO Week" calendar-goto-iso-week]
    ["ISO Date" calendar-goto-iso-date]
    ["Astronomical Date" calendar-goto-astro-day-number]
    ["Hebrew Date" calendar-goto-hebrew-date]
    ["Persian Date" calendar-goto-persian-date]
178
    ["Baha'i Date" calendar-bahai-goto-date]
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
    ["Islamic Date" calendar-goto-islamic-date]
    ["Julian Date" calendar-goto-julian-date]
    ["Chinese Date" calendar-goto-chinese-date]
    ["Coptic Date" calendar-goto-coptic-date]
    ["Ethiopic Date" calendar-goto-ethiopic-date]
    ("Mayan Date"
     ["Next Tzolkin" calendar-next-tzolkin-date]
     ["Previous Tzolkin" calendar-previous-tzolkin-date]
     ["Next Haab" calendar-next-haab-date]
     ["Previous Haab" calendar-previous-haab-date]
     ["Next Round" calendar-next-calendar-round-date]
     ["Previous Round" calendar-previous-calendar-round-date])
    ["French Date" calendar-goto-french-date]))

(defconst cal-menu-scroll-menu
  '("Scroll"
195 196
    ["Forward 1 Month" calendar-scroll-left]
    ["Forward 3 Months" calendar-scroll-left-three-months]
197
    ["Forward 1 Year" "4\C-v"]
198 199
    ["Backward 1 Month" calendar-scroll-right]
    ["Backward 3 Months" calendar-scroll-right-three-months]
200
    ["Backward 1 Year" "4\ev"]))
201

202 203 204 205 206
(defun cal-menu-x-popup-menu (position menu)
  "Like `x-popup-menu', but prints an error message if popup menus are
not available."
  (if (display-popup-menus-p)
      (x-popup-menu position menu)
207
    (error "Popup menus are not available on this system")))
208

209 210 211 212
(defun cal-menu-list-holidays-year ()
  "Display a list of the holidays of the selected date's year."
  (interactive)
  (let ((year (extract-calendar-year (calendar-cursor-to-date))))
213
    (holiday-list year year)))
214 215 216 217 218

(defun cal-menu-list-holidays-following-year ()
  "Display a list of the holidays of the following year."
  (interactive)
  (let ((year (1+ (extract-calendar-year (calendar-cursor-to-date)))))
219
    (holiday-list year year)))
220 221 222 223 224

(defun cal-menu-list-holidays-previous-year ()
  "Display a list of the holidays of the previous year."
  (interactive)
  (let ((year (1- (extract-calendar-year (calendar-cursor-to-date)))))
225
    (holiday-list year year)))
226

227 228 229 230
(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."
231 232
  (with-current-buffer
      (window-buffer (posn-window (event-start last-input-event)))
Richard M. Stallman's avatar
Richard M. Stallman committed
233
    (goto-char (posn-point (event-start last-input-event)))
234
    (calendar-cursor-to-date error)))
Richard M. Stallman's avatar
Richard M. Stallman committed
235 236 237 238 239

(defun calendar-mouse-sunrise/sunset ()
  "Show sunrise/sunset times for mouse-selected date."
  (interactive)
  (save-excursion
240
    (calendar-mouse-goto-date (calendar-event-to-date))
Richard M. Stallman's avatar
Richard M. Stallman committed
241 242
    (calendar-sunrise-sunset)))

243 244 245 246 247 248 249
(defun cal-menu-today-holidays ()
  "Show holidays for today's date."
  (interactive)
  (save-excursion
    (calendar-cursor-to-date (calendar-current-date))
    (calendar-cursor-holidays)))

250
(autoload 'calendar-check-holidays "holidays")
251 252
(autoload 'diary-list-entries "diary-lib")

253
(defun calendar-mouse-holidays (&optional event)
254
  "Pop up menu of holidays for mouse selected date."
255
  (interactive "e")
256
  (let* ((date (calendar-event-to-date))
257
         (l (mapcar 'list (calendar-check-holidays date)))
258
         (selection
259
          (cal-menu-x-popup-menu
260 261 262 263 264 265 266
           event
           (list
            (format "Holidays for %s" (calendar-date-string date))
            (append
             (list (format "Holidays for %s" (calendar-date-string date)))
             (if l l '("None")))))))
    (and selection (call-interactively selection))))
Richard M. Stallman's avatar
Richard M. Stallman committed
267

268
(defun calendar-mouse-view-diary-entries (&optional date diary event)
269 270 271 272
  "Pop up menu of diary entries for mouse-selected date.
Use optional DATE and alternative file DIARY.

Any holidays are shown if `holidays-in-diary-buffer' is t."
273
  (interactive "i\ni\ne")
274
  (let* ((date (or date (calendar-event-to-date)))
275 276 277 278
         (diary-file (if diary diary diary-file))
         (diary-list-include-blanks nil)
         (diary-display-hook 'ignore)
         (diary-entries
279
          (mapcar (lambda (x) (split-string (cadr x) "\n"))
280
                  (diary-list-entries date 1 'list-only)))
281
         (holidays (if holidays-in-diary-buffer
282
                       (calendar-check-holidays date)))
283 284 285 286
         (title (concat "Diary entries "
                        (if diary (format "from %s " diary) "")
                        "for "
                        (calendar-date-string date)))
287
         (selection
288
          (cal-menu-x-popup-menu
289
           event
290 291 292
           (list title
                 (append
                  (list title)
293
                  (mapcar (lambda (x) (list (concat "     " x))) holidays)
294 295 296
                  (if holidays
                      (list "--shadow-etched-in" "--shadow-etched-in"))
                  (if diary-entries
297
                      (mapcar 'list (apply 'append diary-entries))
298
                    '("None")))))))
299
    (and selection (call-interactively selection))))
Richard M. Stallman's avatar
Richard M. Stallman committed
300

301
(defun calendar-mouse-view-other-diary-entries ()
302
  "Pop up menu of diary entries from alternative file on mouse-selected date."
303
  (interactive)
304 305 306
  (calendar-mouse-view-diary-entries
   (calendar-event-to-date)
   (read-file-name "Enter diary file name: " default-directory nil t)))
307

308 309 310 311
(defun calendar-mouse-insert-diary-entry ()
  "Insert diary entry for mouse-selected date."
  (interactive)
  (save-excursion
312
    (calendar-mouse-goto-date (calendar-event-to-date))
313 314
    (insert-diary-entry nil)))

315 316 317 318
(defun calendar-mouse-set-mark ()
  "Mark the date under the cursor."
  (interactive)
  (save-excursion
319
    (calendar-mouse-goto-date (calendar-event-to-date))
320 321
    (calendar-set-mark nil)))

322 323 324 325
(defun cal-tex-mouse-day ()
  "Make a buffer with LaTeX commands for the day mouse is on."
  (interactive)
  (save-excursion
326
    (calendar-mouse-goto-date (calendar-event-to-date))
327 328 329 330 331 332 333
    (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
334
    (calendar-mouse-goto-date (calendar-event-to-date))
335 336 337 338 339 340 341
    (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
342
    (calendar-mouse-goto-date (calendar-event-to-date))
343 344
    (cal-tex-cursor-week2 nil)))

345
(defun cal-tex-mouse-week-iso ()
346 347 348 349
  "One page calendar for week indicated by cursor.
Holidays are included if `cal-tex-holidays' is t."
  (interactive)
  (save-excursion
350
    (calendar-mouse-goto-date (calendar-event-to-date))
351
    (cal-tex-cursor-week-iso nil)))
352

353
(defun cal-tex-mouse-week-monday ()
354 355 356
  "One page calendar for week indicated by cursor."
  (interactive)
  (save-excursion
357
    (calendar-mouse-goto-date (calendar-event-to-date))
358
    (cal-tex-cursor-week-monday nil)))
359

360 361 362 363 364 365 366
(defun cal-tex-mouse-filofax-daily ()
  "Day-per-page Filofax calendar for week indicated by cursor."
  (interactive)
  (save-excursion
    (calendar-mouse-goto-date (calendar-event-to-date))
    (cal-tex-cursor-filofax-daily nil)))

367
(defun cal-tex-mouse-filofax-2week ()
368 369 370
  "One page Filofax calendar for week indicated by cursor."
  (interactive)
  (save-excursion
371
    (calendar-mouse-goto-date (calendar-event-to-date))
372
    (cal-tex-cursor-filofax-2week nil)))
373

374
(defun cal-tex-mouse-filofax-week ()
375 376 377
  "Two page Filofax calendar for week indicated by cursor."
  (interactive)
  (save-excursion
378
    (calendar-mouse-goto-date (calendar-event-to-date))
379
    (cal-tex-cursor-filofax-week nil)))
380 381 382 383 384 385

(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
386
    (calendar-mouse-goto-date (calendar-event-to-date))
387 388 389 390 391 392 393
    (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
394
    (calendar-mouse-goto-date (calendar-event-to-date))
395 396 397 398 399 400
    (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
401
    (calendar-mouse-goto-date (calendar-event-to-date))
402 403 404 405 406 407
    (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
408
    (calendar-mouse-goto-date (calendar-event-to-date))
409 410 411 412 413 414
    (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
415
    (calendar-mouse-goto-date (calendar-event-to-date))
416 417
    (cal-tex-cursor-year-landscape nil)))

418
(defun calendar-mouse-print-dates (&optional event)
Richard M. Stallman's avatar
Richard M. Stallman committed
419
  "Pop up menu of equivalent dates to mouse selected date."
420 421
  (interactive "e")
  (let* ((date (calendar-event-to-date))
422
        (selection
423
         (cal-menu-x-popup-menu
424 425
          event
          (list
426
           (concat (calendar-date-string date) " (Gregorian)")
427 428 429 430 431 432 433 434
           (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
435
              (format "Astronomical (Julian) day number (at noon UTC): %s.0"
436
                           (calendar-astro-date-string date)))
437
             (list
438
              (format "Fixed (RD) date: %s"
439
                      (calendar-absolute-from-gregorian date)))
440
             (list (format "Hebrew date (before sunset): %s"
441 442
                           (calendar-hebrew-date-string date)))
             (list (format "Persian date: %s"
443 444 445
                           (calendar-persian-date-string date)))
             (list (format "Baha'i date (before sunset): %s"
                           (calendar-bahai-date-string date))))
446 447 448
            (let ((i (calendar-islamic-date-string date)))
              (if (not (string-equal i ""))
                  (list (list (format "Islamic date (before sunset): %s" i)))))
449 450 451
            (list
             (list (format "Chinese date: %s"
                           (calendar-chinese-date-string date))))
452 453
            ;; (list '("Chinese date (select to echo Chinese date)"
            ;;         . calendar-mouse-chinese-date))
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
            (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))))

469 470 471 472
(defun calendar-mouse-chinese-date ()
  "Show Chinese equivalent for mouse-selected date."
  (interactive)
  (save-excursion
473
    (calendar-mouse-goto-date (calendar-event-to-date))
474
    (calendar-print-chinese-date)))
Richard M. Stallman's avatar
Richard M. Stallman committed
475

476 477 478 479
(defun calendar-mouse-goto-date (date)
  (set-buffer (window-buffer (posn-window (event-start last-input-event))))
  (calendar-goto-date date))

480
(easy-menu-define cal-menu-context-mouse-menu nil
481
  "Pop up menu for Mouse-2 for selected date in the calendar window."
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
  '("foo" :filter cal-menu-set-date-title
    "--"
    ["Holidays" calendar-mouse-holidays]
    ["Mark date" calendar-mouse-set-mark]
    ["Sunrise/sunset" calendar-mouse-sunrise/sunset]
    ["Other calendars" calendar-mouse-print-dates]
    ("Prepare LaTeX buffer"
     ["Daily (1 page)" cal-tex-mouse-day]
     ["Weekly (1 page)" cal-tex-mouse-week]
     ["Weekly (2 pages)" cal-tex-mouse-week2]
     ["Weekly (other style; 1 page)" cal-tex-mouse-week-iso]
     ["Weekly (yet another style; 1 page)" cal-tex-mouse-week-monday]
     ["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"
      ["Filofax Daily (one-day-per-page)" cal-tex-mouse-filofax-daily]
      ["Filofax Weekly (2-weeks-at-a-glance)" cal-tex-mouse-filofax-2week]
      ["Filofax Weekly (week-at-a-glance)" cal-tex-mouse-filofax-week]
      ["Filofax Yearly" cal-tex-mouse-filofax-year]))
    ["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]))

(defun cal-menu-set-date-title (menu)
  (easy-menu-filter-return
   menu (calendar-date-string (calendar-event-to-date t) t nil)))

(easy-menu-define cal-menu-global-mouse-menu nil
  "Menu bound to a mouse event, not specific to the mouse-click location."
  '("Calendar"
514 515
    ["Scroll forward" calendar-scroll-left-three-months]
    ["Scroll backward" calendar-scroll-right-three-months]
516
    ["Mark diary entries" mark-diary-entries]
517 518
    ["List holidays" calendar-list-holidays]
    ["Mark holidays" calendar-mark-holidays]
519 520 521 522
    ["Unmark" calendar-unmark]
    ["Lunar phases" calendar-phases-of-moon]
    ["Show diary" diary-show-all-entries]
    ["Exit calendar" exit-calendar]))
Richard M. Stallman's avatar
Richard M. Stallman committed
523 524 525 526 527

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

(provide 'cal-menu)

528
;; arch-tag: aa81cf73-ce89-48a4-97ec-9ef861e87fe9
Richard M. Stallman's avatar
Richard M. Stallman committed
529
;;; cal-menu.el ends here