diff options
| author | Glenn Morris | 2008-03-08 21:18:35 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-03-08 21:18:35 +0000 |
| commit | cb17eeaed9aab43d50d6e10126d025ce9c7e704c (patch) | |
| tree | 8b463af3183bee3b7f7c8c6bee6deeb0848a9186 | |
| parent | f1209c4f6586deeaeb90ff913c876f0ffad241fd (diff) | |
| download | emacs-cb17eeaed9aab43d50d6e10126d025ce9c7e704c.tar.gz emacs-cb17eeaed9aab43d50d6e10126d025ce9c7e704c.zip | |
Formatting changes only.
| -rw-r--r-- | lisp/calendar/appt.el | 99 |
1 files changed, 34 insertions, 65 deletions
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el index a43b46e13e5..d8663e02afc 100644 --- a/lisp/calendar/appt.el +++ b/lisp/calendar/appt.el | |||
| @@ -226,7 +226,7 @@ If this is non-nil, appointment checking is active.") | |||
| 226 | The string STRING describes the appointment, due in integer MINS minutes. | 226 | The string STRING describes the appointment, due in integer MINS minutes. |
| 227 | The format of the visible reminder is controlled by `appt-display-format'. | 227 | The format of the visible reminder is controlled by `appt-display-format'. |
| 228 | The variable `appt-audible' controls the audible reminder." | 228 | The variable `appt-audible' controls the audible reminder." |
| 229 | ;; let binding for backwards compatability. Remove when obsolete | 229 | ;; Let-binding for backwards compatability. Remove when obsolete |
| 230 | ;; vars appt-msg-window and appt-visible are dropped. | 230 | ;; vars appt-msg-window and appt-visible are dropped. |
| 231 | (let ((appt-display-format | 231 | (let ((appt-display-format |
| 232 | (if (eq appt-display-format 'ignore) | 232 | (if (eq appt-display-format 'ignore) |
| @@ -236,8 +236,7 @@ The variable `appt-audible' controls the audible reminder." | |||
| 236 | (cond ((eq appt-display-format 'window) | 236 | (cond ((eq appt-display-format 'window) |
| 237 | (funcall appt-disp-window-function | 237 | (funcall appt-disp-window-function |
| 238 | (number-to-string mins) | 238 | (number-to-string mins) |
| 239 | ;; TODO - use calendar-month-abbrev-array rather | 239 | ;; TODO - use calendar-month-abbrev-array rather than %b? |
| 240 | ;; than %b? | ||
| 241 | (format-time-string "%a %b %e " (current-time)) | 240 | (format-time-string "%a %b %e " (current-time)) |
| 242 | string) | 241 | string) |
| 243 | (run-at-time (format "%d sec" appt-display-duration) | 242 | (run-at-time (format "%d sec" appt-display-duration) |
| @@ -300,14 +299,12 @@ displayed in a window: | |||
| 300 | 299 | ||
| 301 | `appt-delete-window-function' | 300 | `appt-delete-window-function' |
| 302 | Function called to remove appointment window and buffer." | 301 | Function called to remove appointment window and buffer." |
| 303 | |||
| 304 | (let* ((min-to-app -1) | 302 | (let* ((min-to-app -1) |
| 305 | (prev-appt-mode-string appt-mode-string) | 303 | (prev-appt-mode-string appt-mode-string) |
| 306 | (prev-appt-display-count (or appt-display-count 0)) | 304 | (prev-appt-display-count (or appt-display-count 0)) |
| 307 | ;; Non-nil means do a full check for pending appointments | 305 | ;; Non-nil means do a full check for pending appointments and |
| 308 | ;; and display in whatever ways the user has selected. | 306 | ;; display in whatever ways the user has selected. When no |
| 309 | ;; When no appointment is being displayed, | 307 | ;; appointment is being displayed, we always do a full check. |
| 310 | ;; we always do a full check. | ||
| 311 | (full-check | 308 | (full-check |
| 312 | (or (not appt-now-displayed) | 309 | (or (not appt-now-displayed) |
| 313 | ;; This is true every appt-display-interval minutes. | 310 | ;; This is true every appt-display-interval minutes. |
| @@ -315,21 +312,16 @@ displayed in a window: | |||
| 315 | ;; Non-nil means only update the interval displayed in the mode line. | 312 | ;; Non-nil means only update the interval displayed in the mode line. |
| 316 | (mode-line-only | 313 | (mode-line-only |
| 317 | (and (not full-check) appt-now-displayed))) | 314 | (and (not full-check) appt-now-displayed))) |
| 318 | |||
| 319 | (when (or full-check mode-line-only) | 315 | (when (or full-check mode-line-only) |
| 320 | (save-excursion | 316 | (save-excursion |
| 321 | |||
| 322 | ;; Get the current time and convert it to minutes | 317 | ;; Get the current time and convert it to minutes |
| 323 | ;; from midnight. ie. 12:01am = 1, midnight = 0. | 318 | ;; from midnight, i.e.: 12:01am = 1, midnight = 0. |
| 324 | |||
| 325 | (let* ((now (decode-time)) | 319 | (let* ((now (decode-time)) |
| 326 | (cur-hour (nth 2 now)) | 320 | (cur-hour (nth 2 now)) |
| 327 | (cur-min (nth 1 now)) | 321 | (cur-min (nth 1 now)) |
| 328 | (cur-comp-time (+ (* cur-hour 60) cur-min))) | 322 | (cur-comp-time (+ (* cur-hour 60) cur-min))) |
| 329 | |||
| 330 | ;; At the first check in any given day, update our | 323 | ;; At the first check in any given day, update our |
| 331 | ;; appointments to today's list. | 324 | ;; appointments to today's list. |
| 332 | |||
| 333 | (if (or force ; eg initialize, diary save | 325 | (if (or force ; eg initialize, diary save |
| 334 | (null appt-prev-comp-time) ; first check | 326 | (null appt-prev-comp-time) ; first check |
| 335 | (< cur-comp-time appt-prev-comp-time)) ; new day | 327 | (< cur-comp-time appt-prev-comp-time)) ; new day |
| @@ -344,12 +336,12 @@ displayed in a window: | |||
| 344 | (d-buff (find-buffer-visiting | 336 | (d-buff (find-buffer-visiting |
| 345 | (substitute-in-file-name diary-file))) | 337 | (substitute-in-file-name diary-file))) |
| 346 | (selective | 338 | (selective |
| 347 | (if d-buff ; Diary buffer exists. | 339 | (if d-buff ; diary buffer exists |
| 348 | (with-current-buffer d-buff | 340 | (with-current-buffer d-buff |
| 349 | diary-selective-display)))) | 341 | diary-selective-display)))) |
| 350 | (diary) | 342 | (diary) |
| 351 | ;; If the diary buffer existed before this command, | 343 | ;; If the diary buffer existed before this command, |
| 352 | ;; restore its display state. Otherwise, kill it. | 344 | ;; restore its display state. Otherwise, kill it. |
| 353 | (if d-buff | 345 | (if d-buff |
| 354 | ;; Displays the diary buffer. | 346 | ;; Displays the diary buffer. |
| 355 | (or selective (diary-show-all-entries)) | 347 | (or selective (diary-show-all-entries)) |
| @@ -358,16 +350,12 @@ displayed in a window: | |||
| 358 | (substitute-in-file-name diary-file))) | 350 | (substitute-in-file-name diary-file))) |
| 359 | (kill-buffer d-buff))))) | 351 | (kill-buffer d-buff))))) |
| 360 | (error nil))) | 352 | (error nil))) |
| 361 | |||
| 362 | (setq appt-prev-comp-time cur-comp-time | 353 | (setq appt-prev-comp-time cur-comp-time |
| 363 | appt-mode-string nil | 354 | appt-mode-string nil |
| 364 | appt-display-count nil) | 355 | appt-display-count nil) |
| 365 | 356 | ;; If there are entries in the list, and the user wants a | |
| 366 | ;; If there are entries in the list, and the | 357 | ;; message issued, get the first time off of the list and |
| 367 | ;; user wants a message issued, | 358 | ;; calculate the number of minutes until the appointment. |
| 368 | ;; get the first time off of the list | ||
| 369 | ;; and calculate the number of minutes until the appointment. | ||
| 370 | |||
| 371 | (if (and appt-issue-message appt-time-msg-list) | 359 | (if (and appt-issue-message appt-time-msg-list) |
| 372 | (let ((appt-comp-time (car (car (car appt-time-msg-list))))) | 360 | (let ((appt-comp-time (car (car (car appt-time-msg-list))))) |
| 373 | (setq min-to-app (- appt-comp-time cur-comp-time)) | 361 | (setq min-to-app (- appt-comp-time cur-comp-time)) |
| @@ -378,25 +366,21 @@ displayed in a window: | |||
| 378 | (if appt-time-msg-list | 366 | (if appt-time-msg-list |
| 379 | (setq appt-comp-time | 367 | (setq appt-comp-time |
| 380 | (car (car (car appt-time-msg-list)))))) | 368 | (car (car (car appt-time-msg-list)))))) |
| 381 | |||
| 382 | ;; If we have an appointment between midnight and | 369 | ;; If we have an appointment between midnight and |
| 383 | ;; 'appt-message-warning-time' minutes after midnight, | 370 | ;; `appt-message-warning-time' minutes after midnight, |
| 384 | ;; we must begin to issue a message before midnight. | 371 | ;; we must begin to issue a message before midnight. |
| 385 | ;; Midnight is considered 0 minutes and 11:59pm is | 372 | ;; Midnight is considered 0 minutes and 11:59pm is |
| 386 | ;; 1439 minutes. Therefore we must recalculate the minutes | 373 | ;; 1439 minutes. Therefore we must recalculate the |
| 387 | ;; to appointment variable. It is equal to the number of | 374 | ;; minutes to appointment variable. It is equal to the |
| 388 | ;; minutes before midnight plus the number of | 375 | ;; number of minutes before midnight plus the number |
| 389 | ;; minutes after midnight our appointment is. | 376 | ;; of minutes after midnight our appointment is. |
| 390 | |||
| 391 | (if (and (< appt-comp-time appt-message-warning-time) | 377 | (if (and (< appt-comp-time appt-message-warning-time) |
| 392 | (> (+ cur-comp-time appt-message-warning-time) | 378 | (> (+ cur-comp-time appt-message-warning-time) |
| 393 | appt-max-time)) | 379 | appt-max-time)) |
| 394 | (setq min-to-app (+ (- (1+ appt-max-time) cur-comp-time) | 380 | (setq min-to-app (+ (- (1+ appt-max-time) cur-comp-time) |
| 395 | appt-comp-time))) | 381 | appt-comp-time))) |
| 396 | 382 | ;; Issue warning if the appointment time is within | |
| 397 | ;; issue warning if the appointment time is | 383 | ;; appt-message-warning time. |
| 398 | ;; within appt-message-warning time | ||
| 399 | |||
| 400 | (when (and (<= min-to-app appt-message-warning-time) | 384 | (when (and (<= min-to-app appt-message-warning-time) |
| 401 | (>= min-to-app 0)) | 385 | (>= min-to-app 0)) |
| 402 | (setq appt-now-displayed t | 386 | (setq appt-now-displayed t |
| @@ -407,28 +391,24 @@ displayed in a window: | |||
| 407 | (when appt-display-mode-line | 391 | (when appt-display-mode-line |
| 408 | (setq appt-mode-string | 392 | (setq appt-mode-string |
| 409 | (format " App't in %s min." min-to-app))) | 393 | (format " App't in %s min." min-to-app))) |
| 410 | 394 | ;; When an appointment is reached, delete it from | |
| 411 | ;; When an appointment is reached, | 395 | ;; the list. Reset the count to 0 in case we |
| 412 | ;; delete it from the list. | 396 | ;; display another appointment on the next cycle. |
| 413 | ;; Reset the count to 0 in case we display another | ||
| 414 | ;; appointment on the next cycle. | ||
| 415 | (if (zerop min-to-app) | 397 | (if (zerop min-to-app) |
| 416 | (setq appt-time-msg-list (cdr appt-time-msg-list) | 398 | (setq appt-time-msg-list (cdr appt-time-msg-list) |
| 417 | appt-display-count nil))))) | 399 | appt-display-count nil))))) |
| 418 | 400 | ;; If we have changed the mode line string, redisplay all | |
| 419 | ;; If we have changed the mode line string, | 401 | ;; mode lines. |
| 420 | ;; redisplay all mode lines. | ||
| 421 | (and appt-display-mode-line | 402 | (and appt-display-mode-line |
| 422 | (not (equal appt-mode-string | 403 | (not (equal appt-mode-string |
| 423 | prev-appt-mode-string)) | 404 | prev-appt-mode-string)) |
| 424 | (progn | 405 | (progn |
| 425 | (force-mode-line-update t) | 406 | (force-mode-line-update t) |
| 426 | ;; If the string now has a notification, | 407 | ;; If the string now has a notification, redisplay |
| 427 | ;; redisplay right now. | 408 | ;; right now. |
| 428 | (if appt-mode-string | 409 | (if appt-mode-string |
| 429 | (sit-for 0))))))))) | 410 | (sit-for 0))))))))) |
| 430 | 411 | ||
| 431 | |||
| 432 | (defun appt-disp-window (min-to-app new-time appt-msg) | 412 | (defun appt-disp-window (min-to-app new-time appt-msg) |
| 433 | "Display appointment message APPT-MSG in a separate buffer. | 413 | "Display appointment message APPT-MSG in a separate buffer. |
| 434 | The appointment is due in MIN-TO-APP (a string) minutes. | 414 | The appointment is due in MIN-TO-APP (a string) minutes. |
| @@ -559,12 +539,10 @@ appointment package (if it is not already active)." | |||
| 559 | (setq appt-time-msg-list | 539 | (setq appt-time-msg-list |
| 560 | (delq elt appt-time-msg-list)))) | 540 | (delq elt appt-time-msg-list)))) |
| 561 | (if diary-entries-list | 541 | (if diary-entries-list |
| 562 | |||
| 563 | ;; Cycle through the entry-list (diary-entries-list) | 542 | ;; Cycle through the entry-list (diary-entries-list) |
| 564 | ;; looking for entries beginning with a time. If | 543 | ;; looking for entries beginning with a time. If the |
| 565 | ;; the entry begins with a time, add it to the | 544 | ;; entry begins with a time, add it to the |
| 566 | ;; appt-time-msg-list. Then sort the list. | 545 | ;; appt-time-msg-list. Then sort the list. |
| 567 | |||
| 568 | (let ((entry-list diary-entries-list) | 546 | (let ((entry-list diary-entries-list) |
| 569 | (new-time-string "")) | 547 | (new-time-string "")) |
| 570 | ;; Skip diary entries for dates before today. | 548 | ;; Skip diary entries for dates before today. |
| @@ -590,25 +568,20 @@ appointment package (if it is not already active)." | |||
| 590 | ;; Get the whole string for this appointment. | 568 | ;; Get the whole string for this appointment. |
| 591 | (appt-time-string | 569 | (appt-time-string |
| 592 | (substring time-string beg (if end (1- end))))) | 570 | (substring time-string beg (if end (1- end))))) |
| 593 | |||
| 594 | ;; Add this appointment to appt-time-msg-list. | 571 | ;; Add this appointment to appt-time-msg-list. |
| 595 | (let* ((appt-time (list (appt-convert-time only-time))) | 572 | (let* ((appt-time (list (appt-convert-time only-time))) |
| 596 | (time-msg (list appt-time appt-time-string))) | 573 | (time-msg (list appt-time appt-time-string))) |
| 597 | (setq appt-time-msg-list | 574 | (setq appt-time-msg-list |
| 598 | (nconc appt-time-msg-list (list time-msg)))) | 575 | (nconc appt-time-msg-list (list time-msg)))) |
| 599 | |||
| 600 | ;; Discard this appointment from the string. | 576 | ;; Discard this appointment from the string. |
| 601 | (setq time-string | 577 | (setq time-string |
| 602 | (if end (substring time-string end) ""))))) | 578 | (if end (substring time-string end) ""))))) |
| 603 | (setq entry-list (cdr entry-list))))) | 579 | (setq entry-list (cdr entry-list))))) |
| 604 | (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)) | 580 | (setq appt-time-msg-list (appt-sort-list appt-time-msg-list)) |
| 605 | 581 | ;; Get the current time and convert it to minutes from | |
| 606 | ;; Get the current time and convert it to minutes | 582 | ;; midnight, i.e. 12:01am = 1, midnight = 0, so that the |
| 607 | ;; from midnight. ie. 12:01am = 1, midnight = 0, | 583 | ;; elements in the list that are earlier than the present |
| 608 | ;; so that the elements in the list | 584 | ;; time can be removed. |
| 609 | ;; that are earlier than the present time can | ||
| 610 | ;; be removed. | ||
| 611 | |||
| 612 | (let* ((now (decode-time)) | 585 | (let* ((now (decode-time)) |
| 613 | (cur-hour (nth 2 now)) | 586 | (cur-hour (nth 2 now)) |
| 614 | (cur-min (nth 1 now)) | 587 | (cur-min (nth 1 now)) |
| @@ -639,17 +612,14 @@ hour and minute parts." | |||
| 639 | (hr (if (string-match "[0-9]*[0-9]" time2conv) | 612 | (hr (if (string-match "[0-9]*[0-9]" time2conv) |
| 640 | (string-to-number (match-string 0 time2conv)) | 613 | (string-to-number (match-string 0 time2conv)) |
| 641 | 0))) | 614 | 0))) |
| 642 | 615 | ;; Convert the time appointment time into 24 hour time. | |
| 643 | ;; convert the time appointment time into 24 hour time | ||
| 644 | (cond ((and (string-match "pm" time2conv) (< hr 12)) | 616 | (cond ((and (string-match "pm" time2conv) (< hr 12)) |
| 645 | (setq hr (+ 12 hr))) | 617 | (setq hr (+ 12 hr))) |
| 646 | ((and (string-match "am" time2conv) (= hr 12)) | 618 | ((and (string-match "am" time2conv) (= hr 12)) |
| 647 | (setq hr 0))) | 619 | (setq hr 0))) |
| 648 | 620 | ;; Convert the actual time into minutes. | |
| 649 | ;; convert the actual time into minutes. | ||
| 650 | (+ (* hr 60) min))) | 621 | (+ (* hr 60) min))) |
| 651 | 622 | ||
| 652 | |||
| 653 | (defun appt-update-list () | 623 | (defun appt-update-list () |
| 654 | "If the current buffer is visiting the diary, update appointments. | 624 | "If the current buffer is visiting the diary, update appointments. |
| 655 | This function is intended for use with `write-file-functions'." | 625 | This function is intended for use with `write-file-functions'." |
| @@ -659,7 +629,6 @@ This function is intended for use with `write-file-functions'." | |||
| 659 | (appt-check t))) | 629 | (appt-check t))) |
| 660 | nil) | 630 | nil) |
| 661 | 631 | ||
| 662 | |||
| 663 | ;; In Emacs-21.3, the manual documented the following procedure to | 632 | ;; In Emacs-21.3, the manual documented the following procedure to |
| 664 | ;; activate this package: | 633 | ;; activate this package: |
| 665 | ;; (display-time) | 634 | ;; (display-time) |