diff options
| author | Glenn Morris | 2003-08-17 22:48:54 +0000 |
|---|---|---|
| committer | Glenn Morris | 2003-08-17 22:48:54 +0000 |
| commit | f9df0ca0420622ab4716bf712ffeecb81b860d70 (patch) | |
| tree | 99881124c08b993f56b2ffa285d3c7417dc91fc3 | |
| parent | c34ff8ac891e67ccfdf926e87fbe68219b141b53 (diff) | |
| download | emacs-f9df0ca0420622ab4716bf712ffeecb81b860d70.tar.gz emacs-f9df0ca0420622ab4716bf712ffeecb81b860d70.zip | |
Edward M. Reingold <reingold@emr.cs.iit.edu>
(calendar-mode-map): Add `calendar-goto-day-of-year' to menu.
(calendar-flatten): New function.
(calendar-mouse-view-other-diary-entries)
(calendar-mouse-view-diary-entries): Rewritten to put any holidays in
the menu title and to show multi-line diary entries correctly in the
menu.
| -rw-r--r-- | lisp/calendar/cal-menu.el | 82 |
1 files changed, 44 insertions, 38 deletions
diff --git a/lisp/calendar/cal-menu.el b/lisp/calendar/cal-menu.el index 3b973586ca0..b6f5cbfc193 100644 --- a/lisp/calendar/cal-menu.el +++ b/lisp/calendar/cal-menu.el | |||
| @@ -117,6 +117,8 @@ | |||
| 117 | '("Astronomical Date" . calendar-goto-astro-day-number)) | 117 | '("Astronomical Date" . calendar-goto-astro-day-number)) |
| 118 | (define-key calendar-mode-map [menu-bar goto iso] | 118 | (define-key calendar-mode-map [menu-bar goto iso] |
| 119 | '("ISO Date" . calendar-goto-iso-date)) | 119 | '("ISO Date" . calendar-goto-iso-date)) |
| 120 | (define-key calendar-mode-map [menu-bar goto day-of-year] | ||
| 121 | '("Day of Year" . calendar-goto-day-of-year)) | ||
| 120 | (define-key calendar-mode-map [menu-bar goto gregorian] | 122 | (define-key calendar-mode-map [menu-bar goto gregorian] |
| 121 | '("Other Date" . calendar-goto-date)) | 123 | '("Other Date" . calendar-goto-date)) |
| 122 | (define-key calendar-mode-map [menu-bar goto end-of-year] | 124 | (define-key calendar-mode-map [menu-bar goto end-of-year] |
| @@ -164,6 +166,15 @@ | |||
| 164 | (define-key calendar-mode-map [menu-bar scroll fwd-1] | 166 | (define-key calendar-mode-map [menu-bar scroll fwd-1] |
| 165 | '("Forward 1 Month" . scroll-calendar-left)) | 167 | '("Forward 1 Month" . scroll-calendar-left)) |
| 166 | 168 | ||
| 169 | (defun calendar-flatten (list) | ||
| 170 | "Flatten LIST eliminating sublists structure; result is a list of atoms. | ||
| 171 | This is the same as the preorder list of leaves in a rooted forest." | ||
| 172 | (if (atom list) | ||
| 173 | (list list) | ||
| 174 | (if (cdr list) | ||
| 175 | (append (calendar-flatten (car list)) (calendar-flatten (cdr list))) | ||
| 176 | (calendar-flatten (car list))))) | ||
| 177 | |||
| 167 | (defun cal-menu-x-popup-menu (position menu) | 178 | (defun cal-menu-x-popup-menu (position menu) |
| 168 | "Like `x-popup-menu', but prints an error message if popup menus are | 179 | "Like `x-popup-menu', but prints an error message if popup menus are |
| 169 | not available." | 180 | not available." |
| @@ -307,53 +318,48 @@ ERROR is t, otherwise just returns nil." | |||
| 307 | (if l l '("None"))))))) | 318 | (if l l '("None"))))))) |
| 308 | (and selection (call-interactively selection)))) | 319 | (and selection (call-interactively selection)))) |
| 309 | 320 | ||
| 310 | (defun calendar-mouse-view-diary-entries () | 321 | (defun calendar-mouse-view-diary-entries (&optional date diary) |
| 311 | "Pop up menu of diary entries for mouse selected date." | 322 | "Pop up menu of diary entries for mouse-selected date. |
| 323 | Use optional DATE and alternative file DIARY. | ||
| 324 | |||
| 325 | Any holidays are shown if `holidays-in-diary-buffer' is t." | ||
| 312 | (interactive) | 326 | (interactive) |
| 313 | (let* ((date (calendar-event-to-date)) | 327 | (let* ((date (if date date (calendar-event-to-date))) |
| 314 | (l (mapcar '(lambda (x) (list (car (cdr x)))) | 328 | (diary-file (if diary diary diary-file)) |
| 315 | (let ((diary-list-include-blanks nil) | 329 | (diary-list-include-blanks nil) |
| 316 | (diary-display-hook 'ignore)) | 330 | (diary-display-hook 'ignore) |
| 317 | (list-diary-entries date 1)))) | 331 | (diary-entries |
| 332 | (mapcar '(lambda (x) (split-string (car (cdr x)) "\^M\\|\n")) | ||
| 333 | (list-diary-entries date 1))) | ||
| 334 | (holidays (if holidays-in-diary-buffer | ||
| 335 | (mapcar '(lambda (x) (list x)) | ||
| 336 | (check-calendar-holidays date)))) | ||
| 337 | (title (concat "Diary entries " | ||
| 338 | (if diary (format "from %s " diary) "") | ||
| 339 | "for " | ||
| 340 | (calendar-date-string date))) | ||
| 318 | (selection | 341 | (selection |
| 319 | (cal-menu-x-popup-menu | 342 | (cal-menu-x-popup-menu |
| 320 | event | 343 | event |
| 321 | (list | 344 | (list title |
| 322 | (format "Diary entries for %s" (calendar-date-string date)) | 345 | (append |
| 323 | (append | 346 | (list title) |
| 324 | (list (format "Diary entries for %s" (calendar-date-string date))) | 347 | (if holidays |
| 325 | (if l l '("None"))))))) | 348 | (mapcar '(lambda (x) (list (concat " " (car x)))) |
| 349 | holidays)) | ||
| 350 | (if holidays | ||
| 351 | (list "--shadow-etched-in" "--shadow-etched-in")) | ||
| 352 | (if diary-entries | ||
| 353 | (mapcar 'list (calendar-flatten diary-entries)) | ||
| 354 | '("None"))))))) | ||
| 326 | (and selection (call-interactively selection)))) | 355 | (and selection (call-interactively selection)))) |
| 327 | 356 | ||
| 328 | (defun calendar-mouse-view-other-diary-entries () | 357 | (defun calendar-mouse-view-other-diary-entries () |
| 329 | "Pop up menu of diary entries from alternative file on mouse-selected date." | 358 | "Pop up menu of diary entries from alternative file on mouse-selected date." |
| 330 | (interactive) | 359 | (interactive) |
| 331 | (let* ((date (calendar-event-to-date)) | 360 | (calendar-mouse-view-diary-entries |
| 332 | (diary-list-include-blanks nil) | 361 | (calendar-event-to-date) |
| 333 | (diary-display-hook 'ignore) | 362 | (read-file-name "Enter diary file name: " default-directory nil t))) |
| 334 | (diary-file (read-file-name | ||
| 335 | "Enter diary file name: " | ||
| 336 | default-directory nil t)) | ||
| 337 | ; The following doesn't really do the right thing. The problem is | ||
| 338 | ; that a newline in the diary entry does not give a newline in a | ||
| 339 | ; pop-up menu; for that you need a separate list item. When the (car | ||
| 340 | ; (cdr x)) contains newlines, the item should be split into a list of | ||
| 341 | ; items. Too minor and messy to worry about. | ||
| 342 | (l (mapcar '(lambda (x) (list (car (cdr x)))) | ||
| 343 | (list-diary-entries date 1))) | ||
| 344 | (selection | ||
| 345 | (cal-menu-x-popup-menu | ||
| 346 | event | ||
| 347 | (list | ||
| 348 | (format "Diary entries from %s for %s" | ||
| 349 | diary-file | ||
| 350 | (calendar-date-string date)) | ||
| 351 | (append | ||
| 352 | (list (format "Diary entries from %s for %s" | ||
| 353 | diary-file | ||
| 354 | (calendar-date-string date))) | ||
| 355 | (if l l '("None"))))))) | ||
| 356 | (and selection (call-interactively selection)))) | ||
| 357 | 363 | ||
| 358 | (defun calendar-mouse-insert-diary-entry () | 364 | (defun calendar-mouse-insert-diary-entry () |
| 359 | "Insert diary entry for mouse-selected date." | 365 | "Insert diary entry for mouse-selected date." |