diff options
| author | Edward M. Reingold | 1994-05-10 22:10:16 +0000 |
|---|---|---|
| committer | Edward M. Reingold | 1994-05-10 22:10:16 +0000 |
| commit | a6ee0a2f86c21d52329f71d1facd11ba764bb1e8 (patch) | |
| tree | d24121ec677b300f971870ca3818fcf45c0f5a4f | |
| parent | 21c8986e277687256fc21fb859d28ed933748902 (diff) | |
| download | emacs-a6ee0a2f86c21d52329f71d1facd11ba764bb1e8.tar.gz emacs-a6ee0a2f86c21d52329f71d1facd11ba764bb1e8.zip | |
(calendar-mode-map): Change binding of Mouse-2. Bind Mouse-3.
(calendar-event-to-date): Add optional error parameter.
(calendar-mouse-print-dates): Fix first line to show day of year.
(calendar-mouse-date-menu): Deleted; split into two new functions.
(calendar-mouse-2-date-menu, calendar-mouse-3-date-menu): The two functions.
| -rw-r--r-- | lisp/calendar/cal-menu.el | 100 |
1 files changed, 54 insertions, 46 deletions
diff --git a/lisp/calendar/cal-menu.el b/lisp/calendar/cal-menu.el index ef99d9bb47f..9fa128d6846 100644 --- a/lisp/calendar/cal-menu.el +++ b/lisp/calendar/cal-menu.el | |||
| @@ -36,7 +36,8 @@ | |||
| 36 | 36 | ||
| 37 | ;;; Code: | 37 | ;;; Code: |
| 38 | 38 | ||
| 39 | (define-key calendar-mode-map [down-mouse-2] 'calendar-mouse-date-menu) | 39 | (define-key calendar-mode-map [mouse-2] 'calendar-mouse-2-date-menu) |
| 40 | (define-key calendar-mode-map [mouse-3] 'calendar-mouse-3-date-menu) | ||
| 40 | 41 | ||
| 41 | (define-key calendar-mode-map [menu-bar moon] | 42 | (define-key calendar-mode-map [menu-bar moon] |
| 42 | '("Moon" . calendar-phases-of-moon)) | 43 | '("Moon" . calendar-phases-of-moon)) |
| @@ -176,12 +177,13 @@ | |||
| 176 | (put 'insert-monthly-diary-entry 'menu-enable '(calendar-cursor-to-date)) | 177 | (put 'insert-monthly-diary-entry 'menu-enable '(calendar-cursor-to-date)) |
| 177 | (put 'insert-weekly-diary-entry 'menu-enable '(calendar-cursor-to-date)) | 178 | (put 'insert-weekly-diary-entry 'menu-enable '(calendar-cursor-to-date)) |
| 178 | 179 | ||
| 179 | (defun calendar-event-to-date () | 180 | (defun calendar-event-to-date (&optional error) |
| 180 | "Date of last event. Value is nil if last event was not done on a date." | 181 | "Date of last event. |
| 182 | If event is not on a specific date, signals an error if optional parameter | ||
| 183 | ERROR is t, otherwise just returns nil." | ||
| 181 | (save-excursion | 184 | (save-excursion |
| 182 | (set-buffer (window-buffer (posn-window (event-start last-input-event)))) | ||
| 183 | (goto-char (posn-point (event-start last-input-event))) | 185 | (goto-char (posn-point (event-start last-input-event))) |
| 184 | (calendar-cursor-to-date))) | 186 | (calendar-cursor-to-date error))) |
| 185 | 187 | ||
| 186 | (defun calendar-mouse-insert-hebrew-diary-entry (event) | 188 | (defun calendar-mouse-insert-hebrew-diary-entry (event) |
| 187 | "Pop up menu to insert a Hebrew-date diary entry." | 189 | "Pop up menu to insert a Hebrew-date diary entry." |
| @@ -248,6 +250,7 @@ | |||
| 248 | (append | 250 | (append |
| 249 | (list | 251 | (list |
| 250 | (concat (calendar-date-string date) " (Gregorian)") | 252 | (concat (calendar-date-string date) " (Gregorian)") |
| 253 | (list (calendar-day-of-year-string date)) | ||
| 251 | (list (format "ISO date: %s" (calendar-iso-date-string date))) | 254 | (list (format "ISO date: %s" (calendar-iso-date-string date))) |
| 252 | (list (format "Julian date: %s" (calendar-julian-date-string date))) | 255 | (list (format "Julian date: %s" (calendar-julian-date-string date))) |
| 253 | (list (format "Astronomical (Julian) date (before noon): %s" | 256 | (list (format "Astronomical (Julian) date (before noon): %s" |
| @@ -264,48 +267,53 @@ | |||
| 264 | (list | 267 | (list |
| 265 | (format "Mayan date: %s" (calendar-mayan-date-string date))))))))) | 268 | (format "Mayan date: %s" (calendar-mayan-date-string date))))))))) |
| 266 | 269 | ||
| 267 | (defun calendar-mouse-date-menu (event) | 270 | (defun calendar-mouse-2-date-menu (event) |
| 268 | "Pop up menu for selected date." | 271 | "Pop up menu for Mouse-2 for selected date in the calendar window." |
| 269 | (interactive "e") | 272 | (interactive "e") |
| 270 | (let ((selection | 273 | (let* ((date (calendar-event-to-date t)) |
| 271 | (x-popup-menu | 274 | (selection |
| 272 | event | 275 | (x-popup-menu |
| 273 | (if (calendar-event-to-date) | 276 | event |
| 274 | (list "Menu" | 277 | (list "Menu" |
| 275 | (list | 278 | (list |
| 276 | (calendar-date-string | 279 | (calendar-date-string date t t) |
| 277 | (or (calendar-event-to-date) | 280 | '("Diary entries" . calendar-mouse-view-diary-entries) |
| 278 | (error "Mouse is not on a date!")) | 281 | '("Holidays" . calendar-mouse-holidays) |
| 279 | t t) | 282 | '("Mark date" . calendar-mouse-set-mark) |
| 280 | '("Diary entries" . calendar-mouse-view-diary-entries) | 283 | '("Sunrise/sunset" . calendar-mouse-sunrise/sunset) |
| 281 | '("Holidays" . calendar-mouse-holidays) | 284 | '("Other calendars" . calendar-mouse-print-dates)))))) |
| 282 | '("Mark date" . calendar-mouse-set-mark) | 285 | (and selection (call-interactively selection)))) |
| 283 | '("Sunrise/sunset" . calendar-mouse-sunrise/sunset) | 286 | |
| 284 | '("Other calendars" . calendar-mouse-print-dates))) | 287 | (defun calendar-mouse-3-date-menu (event) |
| 285 | (list "Menu" | 288 | "Pop up menu for Mouse-3 in the calendar window." |
| 286 | (list | 289 | (interactive "e") |
| 287 | (let ((m1 displayed-month) | 290 | (let* ((m1 displayed-month) |
| 288 | (y1 displayed-year) | 291 | (y1 displayed-year) |
| 289 | (m2 displayed-month) | 292 | (m2 displayed-month) |
| 290 | (y2 displayed-year)) | 293 | (y2 displayed-year) |
| 291 | (increment-calendar-month m1 y1 -1) | 294 | (junk (increment-calendar-month m1 y1 -1)) |
| 292 | (increment-calendar-month m2 y2 1) | 295 | (junk (increment-calendar-month m2 y2 1)) |
| 293 | (if (= y1 y2) | 296 | (selection |
| 294 | (format "%s--%s, %d" | 297 | (x-popup-menu |
| 295 | (substring (calendar-month-name m1) 0 3) | 298 | event |
| 296 | (substring (calendar-month-name m2) 0 3) y2) | 299 | (list "Menu" |
| 297 | (format "%s, %d--%s, %d" | 300 | (list |
| 298 | (substring (calendar-month-name m1) 0 3) y1 | 301 | (if (= y1 y2) |
| 299 | (substring (calendar-month-name m2) 0 3) y2))) | 302 | (format "%s--%s, %d" |
| 300 | '("Scroll forward" . scroll-calendar-left-three-months) | 303 | (substring (calendar-month-name m1) 0 3) |
| 301 | '("Scroll backward" . scroll-calendar-right-three-months) | 304 | (substring (calendar-month-name m2) 0 3) y2) |
| 302 | '("Show diary" . show-all-diary-entries) | 305 | (format "%s, %d--%s, %d" |
| 303 | '("Mark diary entries" . mark-diary-entries) | 306 | (substring (calendar-month-name m1) 0 3) y1 |
| 304 | '("List holidays" . list-calendar-holidays) | 307 | (substring (calendar-month-name m2) 0 3) y2)) |
| 305 | '("Mark holidays" . mark-calendar-holidays) | 308 | '("Scroll forward" . scroll-calendar-left-three-months) |
| 306 | '("Unmark" . calendar-unmark) | 309 | '("Scroll backward" . scroll-calendar-right-three-months) |
| 307 | '("Lunar phases" . calendar-phases-of-moon) | 310 | '("Show diary" . show-all-diary-entries) |
| 308 | '("Exit calendar" . exit-calendar))))))) | 311 | '("Mark diary entries" . mark-diary-entries) |
| 312 | '("List holidays" . list-calendar-holidays) | ||
| 313 | '("Mark holidays" . mark-calendar-holidays) | ||
| 314 | '("Unmark" . calendar-unmark) | ||
| 315 | '("Lunar phases" . calendar-phases-of-moon) | ||
| 316 | '("Exit calendar" . exit-calendar)))))) | ||
| 309 | (and selection (call-interactively selection)))) | 317 | (and selection (call-interactively selection)))) |
| 310 | 318 | ||
| 311 | (run-hooks 'cal-menu-load-hook) | 319 | (run-hooks 'cal-menu-load-hook) |