Add hook to notice modifications to folders and reflect them in the
authorChris Hanson <org/chris-hanson/cph>
Fri, 7 Apr 2000 20:58:49 +0000 (20:58 +0000)
committerChris Hanson <org/chris-hanson/cph>
Fri, 7 Apr 2000 20:58:49 +0000 (20:58 +0000)
mode line.

v7/src/imail/imail-core.scm

index 0a2ed57447cb6d64c99e6a684d21c7ba824fb516..b2d58af9a3b3216a7582d927c3a36c62284e7b03 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-core.scm,v 1.26 2000/04/07 19:41:25 cph Exp $
+;;; $Id: imail-core.scm,v 1.27 2000/04/07 20:58:49 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
 ;;;
 (define-class <folder> ()
   (modified? define standard
             initial-value #t)
+  (modification-event define accessor
+                     initial-value (make-event-distributor))
   (properties define standard
              initializer make-1d-table))
 
 (define-generic folder-length (folder))
 
 (define (folder-modified! folder)
-  (set-folder-modified?! folder #t))
+  (if (not (folder-modified? folder))
+      (begin
+       (set-folder-modified?! folder #t)
+       (event-distributor/invoke! (folder-modification-event folder)
+                                  folder))))
 
 (define (folder-not-modified! folder)
-  (let ((count (folder-length folder)))
-    (do ((index 0 (+ index 1)))
-       ((= index count))
-      (message-not-modified! (get-message folder index))))
-  (set-folder-modified?! folder #f))
+  (if (folder-modified? folder)
+      (begin
+       (let ((count (folder-length folder)))
+         (do ((index 0 (+ index 1)))
+             ((= index count))
+           (message-not-modified! (get-message folder index))))
+       (set-folder-modified?! folder #f)
+       (event-distributor/invoke! (folder-modification-event folder)
+                                  folder))))
 
 ;; Get the INDEX'th message in FOLDER and return it.  Signal an
 ;; error for invalid INDEX.