changeset 54535:f5c18c1f02ce

(appt-check): Remove superfluous progn. When finished with diary buffer: if it was not being displayed before, kill it; otherwise restore its original state. Suggested by Matthew Mundell <matt@mundell.ukfsn.org>.
author Glenn Morris <rgm@gnu.org>
date Wed, 24 Mar 2004 18:36:20 +0000
parents 9739834841d5
children 934d92d8b496
files lisp/calendar/appt.el
diffstat 1 files changed, 25 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/calendar/appt.el	Tue Mar 23 21:44:31 2004 +0000
+++ b/lisp/calendar/appt.el	Wed Mar 24 18:36:20 2004 +0000
@@ -325,19 +325,33 @@
 	  ;; At the first check in any given day, update our
 	  ;; appointments to today's list.
 
-	  (if (or force
+	  (if (or force                 ; eg initialize, diary save
                   (null appt-prev-comp-time)             ; first check
 		  (< cur-comp-time appt-prev-comp-time)) ; new day
 	      (condition-case nil
-		  (progn
-		    (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-hook 'appt-make-list))
-			(diary))))
+                  (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-hook 'appt-make-list)
+                          (d-buff (find-buffer-visiting
+                                   (substitute-in-file-name diary-file)))
+                          selective)
+                      (if d-buff        ; diary buffer exists
+                          (with-current-buffer d-buff
+                            (setq selective selective-display)))
+                      (diary)
+                      ;; If the diary buffer existed before this command,
+                      ;; restore its display state. Otherwise, kill it.
+                      (if d-buff
+                          ;; Displays the diary buffer.
+                          (or selective (show-all-diary-entries))
+                        (and
+                         (setq d-buff (find-buffer-visiting
+                                       (substitute-in-file-name diary-file)))
+                         (kill-buffer d-buff)))))
 		(error nil)))
 
 	  (setq appt-prev-comp-time cur-comp-time
@@ -637,7 +651,7 @@
 (defun appt-update-list ()
   "If the current buffer is visiting the diary, update appointments.
 This function is intended for use with `write-file-functions'."
-  (and (equal buffer-file-name (expand-file-name diary-file))
+  (and (string-equal buffer-file-name (expand-file-name diary-file))
        appt-timer
        (let ((appt-display-diary nil))
          (appt-check t)))