diff options
| author | Stefan Monnier | 2007-07-25 21:58:18 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-07-25 21:58:18 +0000 |
| commit | 05efa389a5bb4f99824037596a347278eb58fa85 (patch) | |
| tree | 5b910d565248c572dfb8c0b30f1d908814e6dc3e | |
| parent | 3fbd3d25db322671626995e49c270f0b53835e1a (diff) | |
| download | emacs-05efa389a5bb4f99824037596a347278eb58fa85.tar.gz emacs-05efa389a5bb4f99824037596a347278eb58fa85.zip | |
Break dependency on calendar.el (i.e. do not modify calendar-mode-map),
use easy-menu, and make sure that C-h k can be used on the menu entries.
(cal-menu-holiday-window-suffix, cal-menu-set-date-title): New funs.
(cal-menu-moon-menu, cal-menu-diary-menu, cal-menu-holidays-menu)
(cal-menu-goto-menu, cal-menu-scroll-menu): New consts.
(cal-menu-context-mouse-menu, cal-menu-global-mouse-menu): New menus.
(calendar-flatten, cal-menu-update): Remove.
(calendar-mouse-insert-hebrew-diary-entry)
(calendar-mouse-insert-islamic-diary-entry)
(calendar-mouse-insert-bahai-diary-entry):
Remove (fold into cal-menu-diary-menu).
(calendar-mouse-2-date-menu, calendar-mouse-cal-tex-menu)
(cal-tex-mouse-filofax): Remove (fold into cal-menu-context-mouse-menu).
(calendar-mouse-3-map): Remove (turn into cal-menu-global-mouse-menu).
(calendar-mouse-view-diary-entries): Minor simplifications.
(calendar-event-to-date): Use with-current-buffer.
| -rw-r--r-- | lisp/calendar/cal-menu.el | 471 |
1 files changed, 157 insertions, 314 deletions
diff --git a/lisp/calendar/cal-menu.el b/lisp/calendar/cal-menu.el index 25929976dbd..c8f5d59bca2 100644 --- a/lisp/calendar/cal-menu.el +++ b/lisp/calendar/cal-menu.el | |||
| @@ -36,146 +36,116 @@ | |||
| 36 | (defvar displayed-month) | 36 | (defvar displayed-month) |
| 37 | (defvar displayed-year) | 37 | (defvar displayed-year) |
| 38 | 38 | ||
| 39 | ;; Don't require calendar because calendar requires us. | 39 | (defconst cal-menu-moon-menu |
| 40 | ;; (eval-when-compile (require 'calendar)) | 40 | '("Moon" |
| 41 | (defvar calendar-mode-map) | 41 | ["Lunar Phases" calendar-phases-of-moon])) |
| 42 | 42 | ||
| 43 | (define-key calendar-mode-map [menu-bar edit] 'undefined) | 43 | (defconst cal-menu-diary-menu |
| 44 | (define-key calendar-mode-map [menu-bar search] 'undefined) | 44 | '("Diary" |
| 45 | 45 | ["Other File" view-other-diary-entries] | |
| 46 | (define-key calendar-mode-map [down-mouse-2] 'calendar-mouse-2-date-menu) | 46 | ["Cursor Date" diary-view-entries] |
| 47 | (define-key calendar-mode-map [mouse-2] 'ignore) | 47 | ["Mark All" mark-diary-entries] |
| 48 | 48 | ["Show All" diary-show-all-entries] | |
| 49 | (defvar calendar-mouse-3-map (make-sparse-keymap "Calendar")) | 49 | ["Insert Diary Entry" insert-diary-entry] |
| 50 | (define-key calendar-mode-map [down-mouse-3] calendar-mouse-3-map) | 50 | ["Insert Weekly" insert-weekly-diary-entry] |
| 51 | 51 | ["Insert Monthly" insert-monthly-diary-entry] | |
| 52 | (define-key calendar-mode-map [menu-bar moon] | 52 | ["Insert Yearly" insert-yearly-diary-entry] |
| 53 | (cons "Moon" (make-sparse-keymap "Moon"))) | 53 | ["Insert Anniversary" insert-anniversary-diary-entry] |
| 54 | 54 | ["Insert Block" insert-block-diary-entry] | |
| 55 | (define-key calendar-mode-map [menu-bar moon moon] | 55 | ["Insert Cyclic" insert-cyclic-diary-entry] |
| 56 | '("Lunar Phases" . calendar-phases-of-moon)) | 56 | ("Insert Baha'i" |
| 57 | 57 | [" " nil :suffix (calendar-bahai-date-string (calendar-cursor-to-date))] | |
| 58 | (define-key calendar-mode-map [menu-bar diary] | 58 | ["One time" insert-bahai-diary-entry] |
| 59 | (cons "Diary" (make-sparse-keymap "Diary"))) | 59 | ["Monthly" insert-monthly-bahai-diary-entry] |
| 60 | 60 | ["Yearly" insert-yearly-bahai-diary-entry]) | |
| 61 | (define-key calendar-mode-map [menu-bar diary heb] | 61 | ("Insert Islamic" |
| 62 | '("Insert Hebrew" . calendar-mouse-insert-hebrew-diary-entry)) | 62 | [" " nil :suffix (calendar-islamic-date-string (calendar-cursor-to-date))] |
| 63 | (define-key calendar-mode-map [menu-bar diary isl] | 63 | ["One time" insert-islamic-diary-entry] |
| 64 | '("Insert Islamic" . calendar-mouse-insert-islamic-diary-entry)) | 64 | ["Monthly" insert-monthly-islamic-diary-entry] |
| 65 | (define-key calendar-mode-map [menu-bar diary baha] | 65 | ["Yearly" insert-yearly-islamic-diary-entry]) |
| 66 | '("Insert Baha'i" . calendar-mouse-insert-bahai-diary-entry)) | 66 | ("Insert Hebrew" |
| 67 | (define-key calendar-mode-map [menu-bar diary cyc] | 67 | [" " nil :suffix (calendar-hebrew-date-string (calendar-cursor-to-date))] |
| 68 | '("Insert Cyclic" . insert-cyclic-diary-entry)) | 68 | ["One time" insert-hebrew-diary-entry] |
| 69 | (define-key calendar-mode-map [menu-bar diary blk] | 69 | ["Monthly" insert-monthly-hebrew-diary-entry] |
| 70 | '("Insert Block" . insert-block-diary-entry)) | 70 | ["Yearly" insert-yearly-hebrew-diary-entry]))) |
| 71 | (define-key calendar-mode-map [menu-bar diary ann] | 71 | |
| 72 | '("Insert Anniversary" . insert-anniversary-diary-entry)) | 72 | (defun cal-menu-holiday-window-suffix () |
| 73 | (define-key calendar-mode-map [menu-bar diary yr] | 73 | (let ((my1 (calendar-increment-month -1)) |
| 74 | '("Insert Yearly" . insert-yearly-diary-entry)) | 74 | (my2 (calendar-increment-month 1))) |
| 75 | (define-key calendar-mode-map [menu-bar diary mon] | 75 | (if (= (cdr my1) (cdr my2)) |
| 76 | '("Insert Monthly" . insert-monthly-diary-entry)) | 76 | (format "%s-%s, %d" |
| 77 | (define-key calendar-mode-map [menu-bar diary wk] | 77 | (calendar-month-name (car my1) 'abbrev) |
| 78 | '("Insert Weekly" . insert-weekly-diary-entry)) | 78 | (calendar-month-name (car my2) 'abbrev) |
| 79 | (define-key calendar-mode-map [menu-bar diary ent] | 79 | (cdr my2)) |
| 80 | '("Insert Diary Entry" . insert-diary-entry)) | 80 | (format "%s, %d-%s, %d" |
| 81 | (define-key calendar-mode-map [menu-bar diary all] | 81 | (calendar-month-name (car my1) 'abbrev) |
| 82 | '("Show All" . diary-show-all-entries)) | 82 | (cdr my1) |
| 83 | (define-key calendar-mode-map [menu-bar diary mark] | 83 | (calendar-month-name (car my2) 'abbrev) |
| 84 | '("Mark All" . mark-diary-entries)) | 84 | (cdr my2))))) |
| 85 | (define-key calendar-mode-map [menu-bar diary view] | 85 | |
| 86 | '("Cursor Date" . diary-view-entries)) | 86 | (defconst cal-menu-holidays-menu |
| 87 | (define-key calendar-mode-map [menu-bar diary view] | 87 | `("Holidays" |
| 88 | '("Other File" . view-other-diary-entries)) | 88 | ["For Cursor Date -" calendar-cursor-holidays |
| 89 | 89 | :suffix (calendar-date-string (calendar-cursor-to-date) t t) | |
| 90 | (define-key calendar-mode-map [menu-bar Holidays] | 90 | :visible (calendar-cursor-to-date)] |
| 91 | (cons "Holidays" (make-sparse-keymap "Holidays"))) | 91 | ["For Window -" list-calendar-holidays |
| 92 | 92 | :suffix (cal-menu-holiday-window-suffix)] | |
| 93 | (define-key calendar-mode-map [menu-bar goto] | 93 | ["For Today -" cal-menu-today-holidays |
| 94 | (cons "Goto" (make-sparse-keymap "Goto"))) | 94 | :suffix (calendar-date-string (calendar-current-date) t t)] |
| 95 | 95 | "--" | |
| 96 | (define-key calendar-mode-map [menu-bar goto french] | 96 | ,@(let ((l ())) |
| 97 | '("French Date" . calendar-goto-french-date)) | 97 | ;; Show 11 years--5 before, 5 after year of middle month. |
| 98 | (define-key calendar-mode-map [menu-bar goto mayan] | 98 | (dotimes (i 11) |
| 99 | (cons "Mayan Date" (make-sparse-keymap "Mayan"))) | 99 | (push (vector "For Year" |
| 100 | (define-key calendar-mode-map [menu-bar goto ethiopic] | 100 | `(lambda () |
| 101 | '("Ethiopic Date" . calendar-goto-ethiopic-date)) | 101 | (interactive) |
| 102 | (define-key calendar-mode-map [menu-bar goto coptic] | 102 | (list-holidays (+ displayed-year ,(- i 5)))) |
| 103 | '("Coptic Date" . calendar-goto-coptic-date)) | 103 | :suffix `(number-to-string (+ displayed-year ,(- i 5)))) |
| 104 | (define-key calendar-mode-map [menu-bar goto chinese] | 104 | l)) |
| 105 | '("Chinese Date" . calendar-goto-chinese-date)) | 105 | (nreverse l)) |
| 106 | (define-key calendar-mode-map [menu-bar goto julian] | 106 | "--" |
| 107 | '("Julian Date" . calendar-goto-julian-date)) | 107 | ["Unmark Calendar" calendar-unmark] |
| 108 | (define-key calendar-mode-map [menu-bar goto islamic] | 108 | ["Mark Holidays" mark-calendar-holidays])) |
| 109 | '("Islamic Date" . calendar-goto-islamic-date)) | 109 | |
| 110 | (define-key calendar-mode-map [menu-bar goto persian] | 110 | (defconst cal-menu-goto-menu |
| 111 | '("Baha'i Date" . calendar-goto-bahai-date)) | 111 | '("Goto" |
| 112 | (define-key calendar-mode-map [menu-bar goto persian] | 112 | ["Today" calendar-goto-today] |
| 113 | '("Persian Date" . calendar-goto-persian-date)) | 113 | ["Beginning of Week" calendar-beginning-of-week] |
| 114 | (define-key calendar-mode-map [menu-bar goto hebrew] | 114 | ["End of Week" calendar-end-of-week] |
| 115 | '("Hebrew Date" . calendar-goto-hebrew-date)) | 115 | ["Beginning of Month" calendar-beginning-of-month] |
| 116 | (define-key calendar-mode-map [menu-bar goto astro] | 116 | ["End of Month" calendar-end-of-month] |
| 117 | '("Astronomical Date" . calendar-goto-astro-day-number)) | 117 | ["Beginning of Year" calendar-beginning-of-year] |
| 118 | (define-key calendar-mode-map [menu-bar goto iso] | 118 | ["End of Year" calendar-end-of-year] |
| 119 | '("ISO Date" . calendar-goto-iso-date)) | 119 | ["Other Date" calendar-goto-date] |
| 120 | (define-key calendar-mode-map [menu-bar goto iso-week] | 120 | ["Day of Year" calendar-goto-day-of-year] |
| 121 | '("ISO Week" . calendar-goto-iso-week)) | 121 | ["ISO Week" calendar-goto-iso-week] |
| 122 | (define-key calendar-mode-map [menu-bar goto day-of-year] | 122 | ["ISO Date" calendar-goto-iso-date] |
| 123 | '("Day of Year" . calendar-goto-day-of-year)) | 123 | ["Astronomical Date" calendar-goto-astro-day-number] |
| 124 | (define-key calendar-mode-map [menu-bar goto gregorian] | 124 | ["Hebrew Date" calendar-goto-hebrew-date] |
| 125 | '("Other Date" . calendar-goto-date)) | 125 | ["Persian Date" calendar-goto-persian-date] |
| 126 | (define-key calendar-mode-map [menu-bar goto end-of-year] | 126 | ["Baha'i Date" calendar-goto-bahai-date] |
| 127 | '("End of Year" . calendar-end-of-year)) | 127 | ["Islamic Date" calendar-goto-islamic-date] |
| 128 | (define-key calendar-mode-map [menu-bar goto beginning-of-year] | 128 | ["Julian Date" calendar-goto-julian-date] |
| 129 | '("Beginning of Year" . calendar-beginning-of-year)) | 129 | ["Chinese Date" calendar-goto-chinese-date] |
| 130 | (define-key calendar-mode-map [menu-bar goto end-of-month] | 130 | ["Coptic Date" calendar-goto-coptic-date] |
| 131 | '("End of Month" . calendar-end-of-month)) | 131 | ["Ethiopic Date" calendar-goto-ethiopic-date] |
| 132 | (define-key calendar-mode-map [menu-bar goto beginning-of-month] | 132 | ("Mayan Date" |
| 133 | '("Beginning of Month" . calendar-beginning-of-month)) | 133 | ["Next Tzolkin" calendar-next-tzolkin-date] |
| 134 | (define-key calendar-mode-map [menu-bar goto end-of-week] | 134 | ["Previous Tzolkin" calendar-previous-tzolkin-date] |
| 135 | '("End of Week" . calendar-end-of-week)) | 135 | ["Next Haab" calendar-next-haab-date] |
| 136 | (define-key calendar-mode-map [menu-bar goto beginning-of-week] | 136 | ["Previous Haab" calendar-previous-haab-date] |
| 137 | '("Beginning of Week" . calendar-beginning-of-week)) | 137 | ["Next Round" calendar-next-calendar-round-date] |
| 138 | (define-key calendar-mode-map [menu-bar goto today] | 138 | ["Previous Round" calendar-previous-calendar-round-date]) |
| 139 | '("Today" . calendar-goto-today)) | 139 | ["French Date" calendar-goto-french-date])) |
| 140 | 140 | ||
| 141 | 141 | (defconst cal-menu-scroll-menu | |
| 142 | (define-key calendar-mode-map [menu-bar goto mayan prev-rnd] | 142 | '("Scroll" |
| 143 | '("Previous Round" . calendar-previous-calendar-round-date)) | 143 | ["Forward 1 Month" scroll-calendar-left] |
| 144 | (define-key calendar-mode-map [menu-bar goto mayan nxt-rnd] | 144 | ["Forward 3 Months" scroll-calendar-left-three-months] |
| 145 | '("Next Round" . calendar-next-calendar-round-date)) | 145 | ["Forward 1 Year" "4\C-v"] |
| 146 | (define-key calendar-mode-map [menu-bar goto mayan prev-haab] | 146 | ["Backward 1 Month" scroll-calendar-right] |
| 147 | '("Previous Haab" . calendar-previous-haab-date)) | 147 | ["Backward 3 Months" scroll-calendar-right-three-months] |
| 148 | (define-key calendar-mode-map [menu-bar goto mayan next-haab] | 148 | ["Backward 1 Year" "4\ev"])) |
| 149 | '("Next Haab" . calendar-next-haab-date)) | ||
| 150 | (define-key calendar-mode-map [menu-bar goto mayan prev-tzol] | ||
| 151 | '("Previous Tzolkin" . calendar-previous-tzolkin-date)) | ||
| 152 | (define-key calendar-mode-map [menu-bar goto mayan next-tzol] | ||
| 153 | '("Next Tzolkin" . calendar-next-tzolkin-date)) | ||
| 154 | |||
| 155 | (define-key calendar-mode-map [menu-bar scroll] | ||
| 156 | (cons "Scroll" (make-sparse-keymap "Scroll"))) | ||
| 157 | |||
| 158 | (define-key calendar-mode-map [menu-bar scroll bk-12] | ||
| 159 | '("Backward 1 Year" . "4\ev")) | ||
| 160 | (define-key calendar-mode-map [menu-bar scroll bk-3] | ||
| 161 | '("Backward 3 Months" . scroll-calendar-right-three-months)) | ||
| 162 | (define-key calendar-mode-map [menu-bar scroll bk-1] | ||
| 163 | '("Backward 1 Month" . scroll-calendar-right)) | ||
| 164 | (define-key calendar-mode-map [menu-bar scroll fwd-12] | ||
| 165 | '("Forward 1 Year" . "4\C-v")) | ||
| 166 | (define-key calendar-mode-map [menu-bar scroll fwd-3] | ||
| 167 | '("Forward 3 Months" . scroll-calendar-left-three-months)) | ||
| 168 | (define-key calendar-mode-map [menu-bar scroll fwd-1] | ||
| 169 | '("Forward 1 Month" . scroll-calendar-left)) | ||
| 170 | |||
| 171 | (defun calendar-flatten (list) | ||
| 172 | "Flatten LIST eliminating sublists structure; result is a list of atoms. | ||
| 173 | This is the same as the preorder list of leaves in a rooted forest." | ||
| 174 | (if (atom list) | ||
| 175 | (list list) | ||
| 176 | (if (cdr list) | ||
| 177 | (append (calendar-flatten (car list)) (calendar-flatten (cdr list))) | ||
| 178 | (calendar-flatten (car list))))) | ||
| 179 | 149 | ||
| 180 | (defun cal-menu-x-popup-menu (position menu) | 150 | (defun cal-menu-x-popup-menu (position menu) |
| 181 | "Like `x-popup-menu', but prints an error message if popup menus are | 151 | "Like `x-popup-menu', but prints an error message if popup menus are |
| @@ -202,103 +172,15 @@ not available." | |||
| 202 | (let ((year (1- (extract-calendar-year (calendar-cursor-to-date))))) | 172 | (let ((year (1- (extract-calendar-year (calendar-cursor-to-date))))) |
| 203 | (list-holidays year year))) | 173 | (list-holidays year year))) |
| 204 | 174 | ||
| 205 | (defun cal-menu-update () | ||
| 206 | ;; Update the holiday part of calendar menu bar for the current display. | ||
| 207 | (condition-case nil | ||
| 208 | (if (eq major-mode 'calendar-mode) | ||
| 209 | (let ((l)) | ||
| 210 | ;; Show 11 years--5 before, 5 after year of middle month | ||
| 211 | (dotimes (i 11) | ||
| 212 | (let ((y (+ displayed-year -5 i))) | ||
| 213 | (push (vector (format "For Year %s" y) | ||
| 214 | (list (list 'lambda 'nil '(interactive) | ||
| 215 | (list 'list-holidays y y))) | ||
| 216 | t) | ||
| 217 | l))) | ||
| 218 | (setq l (cons ["Mark Holidays" mark-calendar-holidays t] | ||
| 219 | (cons ["Unmark Calendar" calendar-unmark t] | ||
| 220 | (cons "--" l)))) | ||
| 221 | (define-key calendar-mode-map [menu-bar Holidays] | ||
| 222 | (cons "Holidays" (easy-menu-create-menu "Holidays" (nreverse l)))) | ||
| 223 | (define-key calendar-mode-map [menu-bar Holidays separator] | ||
| 224 | '("--")) | ||
| 225 | (define-key calendar-mode-map [menu-bar Holidays today] | ||
| 226 | `(,(format "For Today (%s)" | ||
| 227 | (calendar-date-string (calendar-current-date) t t)) | ||
| 228 | . cal-menu-today-holidays)) | ||
| 229 | (let ((title | ||
| 230 | (let ((my1 (calendar-increment-month -1)) | ||
| 231 | (my2 (calendar-increment-month 1))) | ||
| 232 | (if (= (cdr my1) (cdr my2)) | ||
| 233 | (format "%s-%s, %d" | ||
| 234 | (calendar-month-name (car my1) 'abbrev) | ||
| 235 | (calendar-month-name (car my2) 'abbrev) | ||
| 236 | (cdr my2)) | ||
| 237 | (format "%s, %d-%s, %d" | ||
| 238 | (calendar-month-name (car my1) 'abbrev) | ||
| 239 | (cdr my1) | ||
| 240 | (calendar-month-name (car my2) 'abbrev) | ||
| 241 | (cdr my2)))))) | ||
| 242 | (define-key calendar-mode-map [menu-bar Holidays 3-month] | ||
| 243 | `(,(format "For Window (%s)" title) | ||
| 244 | . list-calendar-holidays))) | ||
| 245 | (let ((date (calendar-cursor-to-date))) | ||
| 246 | (if date | ||
| 247 | (define-key calendar-mode-map [menu-bar Holidays 1-day] | ||
| 248 | `(,(format "For Cursor Date (%s)" | ||
| 249 | (calendar-date-string date t t)) | ||
| 250 | . calendar-cursor-holidays)))))) | ||
| 251 | ;; Try to avoid entering infinite beep mode in case of errors. | ||
| 252 | (error (ding)))) | ||
| 253 | |||
| 254 | (defun calendar-event-to-date (&optional error) | 175 | (defun calendar-event-to-date (&optional error) |
| 255 | "Date of last event. | 176 | "Date of last event. |
| 256 | If event is not on a specific date, signals an error if optional parameter | 177 | If event is not on a specific date, signals an error if optional parameter |
| 257 | ERROR is t, otherwise just returns nil." | 178 | ERROR is t, otherwise just returns nil." |
| 258 | (save-excursion | 179 | (with-current-buffer |
| 259 | (set-buffer (window-buffer (posn-window (event-start last-input-event)))) | 180 | (window-buffer (posn-window (event-start last-input-event))) |
| 260 | (goto-char (posn-point (event-start last-input-event))) | 181 | (goto-char (posn-point (event-start last-input-event))) |
| 261 | (calendar-cursor-to-date error))) | 182 | (calendar-cursor-to-date error))) |
| 262 | 183 | ||
| 263 | (defun calendar-mouse-insert-hebrew-diary-entry (event) | ||
| 264 | "Pop up menu to insert a Hebrew-date diary entry." | ||
| 265 | (interactive "e") | ||
| 266 | (let ((hebrew-selection | ||
| 267 | (cal-menu-x-popup-menu | ||
| 268 | event | ||
| 269 | (list "Hebrew insert menu" | ||
| 270 | (list (calendar-hebrew-date-string (calendar-cursor-to-date)) | ||
| 271 | '("One time" . insert-hebrew-diary-entry) | ||
| 272 | '("Monthly" . insert-monthly-hebrew-diary-entry) | ||
| 273 | '("Yearly" . insert-yearly-hebrew-diary-entry)))))) | ||
| 274 | (and hebrew-selection (call-interactively hebrew-selection)))) | ||
| 275 | |||
| 276 | (defun calendar-mouse-insert-islamic-diary-entry (event) | ||
| 277 | "Pop up menu to insert an Islamic-date diary entry." | ||
| 278 | (interactive "e") | ||
| 279 | (let ((islamic-selection | ||
| 280 | (cal-menu-x-popup-menu | ||
| 281 | event | ||
| 282 | (list "Islamic insert menu" | ||
| 283 | (list (calendar-islamic-date-string (calendar-cursor-to-date)) | ||
| 284 | '("One time" . insert-islamic-diary-entry) | ||
| 285 | '("Monthly" . insert-monthly-islamic-diary-entry) | ||
| 286 | '("Yearly" . insert-yearly-islamic-diary-entry)))))) | ||
| 287 | (and islamic-selection (call-interactively islamic-selection)))) | ||
| 288 | |||
| 289 | (defun calendar-mouse-insert-bahai-diary-entry (event) | ||
| 290 | "Pop up menu to insert an Baha'i-date diary entry." | ||
| 291 | (interactive "e") | ||
| 292 | (let ((bahai-selection | ||
| 293 | (x-popup-menu | ||
| 294 | event | ||
| 295 | (list "Baha'i insert menu" | ||
| 296 | (list (calendar-bahai-date-string (calendar-cursor-to-date)) | ||
| 297 | '("One time" . insert-bahai-diary-entry) | ||
| 298 | '("Monthly" . insert-monthly-bahai-diary-entry) | ||
| 299 | '("Yearly" . insert-yearly-bahai-diary-entry)))))) | ||
| 300 | (and bahai-selection (call-interactively bahai-selection)))) | ||
| 301 | |||
| 302 | (defun calendar-mouse-sunrise/sunset () | 184 | (defun calendar-mouse-sunrise/sunset () |
| 303 | "Show sunrise/sunset times for mouse-selected date." | 185 | "Show sunrise/sunset times for mouse-selected date." |
| 304 | (interactive) | 186 | (interactive) |
| @@ -337,12 +219,12 @@ Use optional DATE and alternative file DIARY. | |||
| 337 | 219 | ||
| 338 | Any holidays are shown if `holidays-in-diary-buffer' is t." | 220 | Any holidays are shown if `holidays-in-diary-buffer' is t." |
| 339 | (interactive "i\ni\ne") | 221 | (interactive "i\ni\ne") |
| 340 | (let* ((date (if date date (calendar-event-to-date))) | 222 | (let* ((date (or date (calendar-event-to-date))) |
| 341 | (diary-file (if diary diary diary-file)) | 223 | (diary-file (if diary diary diary-file)) |
| 342 | (diary-list-include-blanks nil) | 224 | (diary-list-include-blanks nil) |
| 343 | (diary-display-hook 'ignore) | 225 | (diary-display-hook 'ignore) |
| 344 | (diary-entries | 226 | (diary-entries |
| 345 | (mapcar (lambda (x) (split-string (car (cdr x)) "\^M\\|\n")) | 227 | (mapcar (lambda (x) (split-string (cadr x) "\n")) |
| 346 | (diary-list-entries date 1 'list-only))) | 228 | (diary-list-entries date 1 'list-only))) |
| 347 | (holidays (if holidays-in-diary-buffer | 229 | (holidays (if holidays-in-diary-buffer |
| 348 | (check-calendar-holidays date))) | 230 | (check-calendar-holidays date))) |
| @@ -360,7 +242,7 @@ Any holidays are shown if `holidays-in-diary-buffer' is t." | |||
| 360 | (if holidays | 242 | (if holidays |
| 361 | (list "--shadow-etched-in" "--shadow-etched-in")) | 243 | (list "--shadow-etched-in" "--shadow-etched-in")) |
| 362 | (if diary-entries | 244 | (if diary-entries |
| 363 | (mapcar 'list (calendar-flatten diary-entries)) | 245 | (mapcar 'list (apply 'append diary-entries)) |
| 364 | '("None"))))))) | 246 | '("None"))))))) |
| 365 | (and selection (call-interactively selection)))) | 247 | (and selection (call-interactively selection)))) |
| 366 | 248 | ||
| @@ -543,88 +425,49 @@ The output is in landscape format, one month to a page." | |||
| 543 | (set-buffer (window-buffer (posn-window (event-start last-input-event)))) | 425 | (set-buffer (window-buffer (posn-window (event-start last-input-event)))) |
| 544 | (calendar-goto-date date)) | 426 | (calendar-goto-date date)) |
| 545 | 427 | ||
| 546 | (defun calendar-mouse-2-date-menu (event) | 428 | (easy-menu-define cal-menu-context-mouse-menu nil |
| 547 | "Pop up menu for Mouse-2 for selected date in the calendar window." | 429 | "Pop up menu for Mouse-2 for selected date in the calendar window." |
| 548 | (interactive "e") | 430 | '("foo" :filter cal-menu-set-date-title |
| 549 | (let* ((date (calendar-event-to-date t)) | 431 | "--" |
| 550 | (selection | 432 | ["Holidays" calendar-mouse-holidays] |
| 551 | (cal-menu-x-popup-menu | 433 | ["Mark date" calendar-mouse-set-mark] |
| 552 | event | 434 | ["Sunrise/sunset" calendar-mouse-sunrise/sunset] |
| 553 | (list (calendar-date-string date t nil) | 435 | ["Other calendars" calendar-mouse-print-dates] |
| 554 | (list | 436 | ("Prepare LaTeX buffer" |
| 555 | "" | 437 | ["Daily (1 page)" cal-tex-mouse-day] |
| 556 | '("Holidays" . calendar-mouse-holidays) | 438 | ["Weekly (1 page)" cal-tex-mouse-week] |
| 557 | '("Mark date" . calendar-mouse-set-mark) | 439 | ["Weekly (2 pages)" cal-tex-mouse-week2] |
| 558 | '("Sunrise/sunset" . calendar-mouse-sunrise/sunset) | 440 | ["Weekly (other style; 1 page)" cal-tex-mouse-week-iso] |
| 559 | '("Other calendars" . calendar-mouse-print-dates) | 441 | ["Weekly (yet another style; 1 page)" cal-tex-mouse-week-monday] |
| 560 | '("Prepare LaTeX buffer" . calendar-mouse-cal-tex-menu) | 442 | ["Monthly" cal-tex-mouse-month] |
| 561 | '("Diary entries" . calendar-mouse-view-diary-entries) | 443 | ["Monthly (landscape)" cal-tex-mouse-month-landscape] |
| 562 | '("Insert diary entry" . calendar-mouse-insert-diary-entry) | 444 | ["Yearly" cal-tex-mouse-year] |
| 563 | '("Other diary file entries" | 445 | ["Yearly (landscape)" cal-tex-mouse-year-landscape] |
| 564 | . calendar-mouse-view-other-diary-entries) | 446 | ("Filofax styles" |
| 565 | ))))) | 447 | ["Filofax Daily (one-day-per-page)" cal-tex-mouse-filofax-daily] |
| 566 | (and selection (call-interactively selection)))) | 448 | ["Filofax Weekly (2-weeks-at-a-glance)" cal-tex-mouse-filofax-2week] |
| 567 | 449 | ["Filofax Weekly (week-at-a-glance)" cal-tex-mouse-filofax-week] | |
| 568 | (defun calendar-mouse-cal-tex-menu (event) | 450 | ["Filofax Yearly" cal-tex-mouse-filofax-year])) |
| 569 | "Pop up submenu for Mouse-2 for cal-tex commands for selected date in the calendar window." | 451 | ["Diary entries" calendar-mouse-view-diary-entries] |
| 570 | (interactive "e") | 452 | ["Insert diary entry" calendar-mouse-insert-diary-entry] |
| 571 | (let* ((selection | 453 | ["Other diary file entries" calendar-mouse-view-other-diary-entries])) |
| 572 | (cal-menu-x-popup-menu | 454 | |
| 573 | event | 455 | (defun cal-menu-set-date-title (menu) |
| 574 | (list (calendar-date-string (calendar-event-to-date t) t nil) | 456 | (easy-menu-filter-return |
| 575 | (list | 457 | menu (calendar-date-string (calendar-event-to-date t) t nil))) |
| 576 | "" | 458 | |
| 577 | '("Daily (1 page)" . cal-tex-mouse-day) | 459 | (easy-menu-define cal-menu-global-mouse-menu nil |
| 578 | '("Weekly (1 page)" . cal-tex-mouse-week) | 460 | "Menu bound to a mouse event, not specific to the mouse-click location." |
| 579 | '("Weekly (2 pages)" . cal-tex-mouse-week2) | 461 | '("Calendar" |
| 580 | '("Weekly (other style; 1 page)" . cal-tex-mouse-week-iso) | 462 | ["Scroll forward" scroll-calendar-left-three-months] |
| 581 | '("Weekly (yet another style; 1 page)" . | 463 | ["Scroll backward" scroll-calendar-right-three-months] |
| 582 | cal-tex-mouse-week-monday) | 464 | ["Mark diary entries" mark-diary-entries] |
| 583 | '("Monthly" . cal-tex-mouse-month) | 465 | ["List holidays" list-calendar-holidays] |
| 584 | '("Monthly (landscape)" . cal-tex-mouse-month-landscape) | 466 | ["Mark holidays" mark-calendar-holidays] |
| 585 | '("Yearly" . cal-tex-mouse-year) | 467 | ["Unmark" calendar-unmark] |
| 586 | '("Yearly (landscape)" . cal-tex-mouse-year-landscape) | 468 | ["Lunar phases" calendar-phases-of-moon] |
| 587 | '("Filofax styles" . cal-tex-mouse-filofax) | 469 | ["Show diary" diary-show-all-entries] |
| 588 | ))))) | 470 | ["Exit calendar" exit-calendar])) |
| 589 | (and selection (call-interactively selection)))) | ||
| 590 | |||
| 591 | (defun cal-tex-mouse-filofax (event) | ||
| 592 | "Pop up sub-submenu for Mouse-2 for Filofax cal-tex commands for selected date." | ||
| 593 | (interactive "e") | ||
| 594 | (let* ((selection | ||
| 595 | (cal-menu-x-popup-menu | ||
| 596 | event | ||
| 597 | (list (calendar-date-string (calendar-event-to-date t) t nil) | ||
| 598 | (list | ||
| 599 | "" | ||
| 600 | '("Filofax Daily (one-day-per-page)" . | ||
| 601 | cal-tex-mouse-filofax-daily) | ||
| 602 | '("Filofax Weekly (2-weeks-at-a-glance)" . | ||
| 603 | cal-tex-mouse-filofax-2week) | ||
| 604 | '("Filofax Weekly (week-at-a-glance)" . | ||
| 605 | cal-tex-mouse-filofax-week) | ||
| 606 | '("Filofax Yearly" . cal-tex-mouse-filofax-year) | ||
| 607 | ))))) | ||
| 608 | (and selection (call-interactively selection)))) | ||
| 609 | |||
| 610 | (define-key calendar-mouse-3-map [exit-calendar] | ||
| 611 | '("Exit calendar" . exit-calendar)) | ||
| 612 | (define-key calendar-mouse-3-map [show-diary] | ||
| 613 | '("Show diary" . diary-show-all-entries)) | ||
| 614 | (define-key calendar-mouse-3-map [lunar-phases] | ||
| 615 | '("Lunar phases" . calendar-phases-of-moon)) | ||
| 616 | (define-key calendar-mouse-3-map [unmark] | ||
| 617 | '("Unmark" . calendar-unmark)) | ||
| 618 | (define-key calendar-mouse-3-map [mark-holidays] | ||
| 619 | '("Mark holidays" . mark-calendar-holidays)) | ||
| 620 | (define-key calendar-mouse-3-map [list-holidays] | ||
| 621 | '("List holidays" . list-calendar-holidays)) | ||
| 622 | (define-key calendar-mouse-3-map [mark-diary-entries] | ||
| 623 | '("Mark diary entries" . mark-diary-entries)) | ||
| 624 | (define-key calendar-mouse-3-map [scroll-backward] | ||
| 625 | '("Scroll backward" . scroll-calendar-right-three-months)) | ||
| 626 | (define-key calendar-mouse-3-map [scroll-forward] | ||
| 627 | '("Scroll forward" . scroll-calendar-left-three-months)) | ||
| 628 | 471 | ||
| 629 | (run-hooks 'cal-menu-load-hook) | 472 | (run-hooks 'cal-menu-load-hook) |
| 630 | 473 | ||