Implement WITH-OPEN-FOLDER, which guarantees that the folder is opened
authorChris Hanson <org/chris-hanson/cph>
Mon, 22 May 2000 19:44:44 +0000 (19:44 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 22 May 2000 19:44:44 +0000 (19:44 +0000)
and closed as necessary.

v7/src/imail/imail-core.scm

index 8f67c48809f3bd2e4c58e69f43fc14cc19eafb39..c725bb219fb200278dcea97fa0d53a976d3064a1 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-core.scm,v 1.83 2000/05/22 15:07:55 cph Exp $
+;;; $Id: imail-core.scm,v 1.84 2000/05/22 19:44:44 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
 ;;;
 
 (define-generic %open-folder (url))
 
+(define (with-open-folder url thunk)
+  (let ((folder (get-memoized-folder url)))
+    (if folder
+       (thunk)
+       (let ((folder (%open-folder url)))
+         (let ((v (thunk)))
+           (close-folder folder)
+           v)))))
+
 ;; -------------------------------------------------------------------
 ;; Close FOLDER, freeing up connections, memory, etc.  Subsequent use
 ;; of the folder must work, but may incur a significant time or space