]> git.eshelyaron.com Git - emacs.git/commitdiff
(appt-check): Remove superfluous progn.
authorGlenn Morris <rgm@gnu.org>
Wed, 24 Mar 2004 18:36:20 +0000 (18:36 +0000)
committerGlenn Morris <rgm@gnu.org>
Wed, 24 Mar 2004 18:36:20 +0000 (18:36 +0000)
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>.

lisp/calendar/appt.el

index d002b6fd212908bfe222a65968b631098e042ede..002aec878cae6e253ee7697b634ef5e3919f6181 100644 (file)
@@ -325,19 +325,33 @@ displayed in a window:
          ;; 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 @@ hour and minute parts."
 (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)))