>From 7353db6f568d0b32d2aaf72d58160e62a830ba25 Mon Sep 17 00:00:00 2001 From: Ivan Kanis Date: Thu, 24 Mar 2011 18:53:37 +0100 Subject: [PATCH 04/13] move diary update to its own function appt-check-diary --- appt.el | 84 +++++++++++++++++++++++++++++++++------------------------------ 1 files changed, 44 insertions(+), 40 deletions(-) diff --git a/appt.el b/appt.el index 3f8493b..9531797 100644 --- a/appt.el +++ b/appt.el @@ -315,46 +315,7 @@ displayed in a window: (cur-comp-time (+ (* 60 (nth 2 now)) (nth 1 now))) appt-comp-time appt-warn-time) (save-excursion - ;; At first check in any day, update appointments to today's list. - (if (or force ; eg initialize, diary save - (null appt-prev-comp-time) ; first check - (< cur-comp-time appt-prev-comp-time)) ; new day - (ignore-errors - (if appt-display-diary - (let ((diary-hook - (if (assoc 'appt-make-list diary-hook) - diary-hook - (cons 'appt-make-list diary-hook)))) - (diary)) - (let* ((diary-display-function 'appt-make-list) - (d-buff (find-buffer-visiting diary-file)) - (selective - (if d-buff ; diary buffer exists - (with-current-buffer d-buff - diary-selective-display))) - d-buff2) - ;; Not displaying the diary, so we can ignore - ;; diary-number-of-entries. Since appt.el only - ;; works on a daily basis, no need for more entries. - ;; FIXME why not using diary-list-entries with - ;; non-nil LIST-ONLY? - (diary 1) - ;; If the diary buffer existed before this command, - ;; restore its display state. Otherwise, kill it. - (and (setq d-buff2 (find-buffer-visiting diary-file)) - (if d-buff - (or selective - (with-current-buffer d-buff2 - (if diary-selective-display - ;; diary-show-all-entries displays - ;; the diary buffer. - (diary-unhide-everything)))) - ;; FIXME does not kill any included diary files. - ;; The real issue is that (diary) should not - ;; have the side effect of visiting all the - ;; diary files. It is not really appt.el's job to - ;; clean up this mess... - (kill-buffer d-buff2))))))) + (appt-check-diary force cur-comp-time) (setq appt-prev-comp-time cur-comp-time appt-mode-string nil appt-display-count nil) @@ -414,6 +375,49 @@ displayed in a window: (if appt-mode-string (sit-for 0))))))) +(defun appt-check-diary (force cur-comp-time) + "Update appointments to today's list." + ;; At first check in any day + (if (or force ; eg initialize, diary save + (null appt-prev-comp-time) ; first check + (< cur-comp-time appt-prev-comp-time)) ; new day + (ignore-errors + (if appt-display-diary + (let ((diary-hook + (if (assoc 'appt-make-list diary-hook) + diary-hook + (cons 'appt-make-list diary-hook)))) + (diary)) + (let* ((diary-display-function 'appt-make-list) + (d-buff (find-buffer-visiting diary-file)) + (selective + (if d-buff ; diary buffer exists + (with-current-buffer d-buff + diary-selective-display))) + d-buff2) + ;; Not displaying the diary, so we can ignore + ;; diary-number-of-entries. Since appt.el only + ;; works on a daily basis, no need for more entries. + ;; FIXME why not using diary-list-entries with + ;; non-nil LIST-ONLY? + (diary 1) + ;; If the diary buffer existed before this command, + ;; restore its display state. Otherwise, kill it. + (and (setq d-buff2 (find-buffer-visiting diary-file)) + (if d-buff + (or selective + (with-current-buffer d-buff2 + (if diary-selective-display + ;; diary-show-all-entries displays + ;; the diary buffer. + (diary-unhide-everything)))) + ;; FIXME does not kill any included diary files. + ;; The real issue is that (diary) should not + ;; have the side effect of visiting all the + ;; diary files. It is not really appt.el's job to + ;; clean up this mess... + (kill-buffer d-buff2))))))) + (defun appt-disp-window (min-to-app new-time appt-msg) "Display appointment due in MIN-TO-APP (a string) minutes. NEW-TIME is a string giving the date. Displays the appointment -- 1.7.1