Fix bug: When message was selected in IMAIL and deleted by a different
authorChris Hanson <org/chris-hanson/cph>
Mon, 5 Jun 2000 18:16:44 +0000 (18:16 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 5 Jun 2000 18:16:44 +0000 (18:16 +0000)
user agent, IMAIL would end up in state where there is no selected
message.  Now, it selects another message.

v7/src/imail/imail-top.scm
v7/src/imail/todo.txt

index e1dae82bf78984ed4aeb709a6207b7a1eb52e837..ff7a01326d6b60bd48313adfe03a307c095f19d0 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: imail-top.scm,v 1.127 2000/06/05 17:50:10 cph Exp $
+;;; $Id: imail-top.scm,v 1.128 2000/06/05 18:16:44 cph Exp $
 ;;;
 ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology
 ;;;
@@ -838,8 +838,11 @@ With prefix argument N moves backward N messages with these flags."
          (user-homedir-pathname)))
      (add-event-receiver! (folder-modification-event folder)
        (lambda (folder type parameters)
-        type parameters
-        (maybe-add-command-suffix! notice-folder-modifications folder)))
+        (if (eq? type 'EXPUNGE)
+            (maybe-add-command-suffix! notice-message-expunge
+                                       folder
+                                       (car parameters))
+            (maybe-add-command-suffix! notice-folder-modifications folder))))
      (add-kill-buffer-hook buffer delete-associated-buffers)
      (add-kill-buffer-hook buffer stop-probe-folder-thread)
      (start-probe-folder-thread buffer))))
@@ -899,6 +902,20 @@ With prefix argument N moves backward N messages with these flags."
                               buffer)
          (buffer-modeline-event! buffer 'PROCESS-STATUS)))))
 
+(define (notice-message-expunge folder index)
+  (let ((buffer (imail-folder->buffer folder #f)))
+    (if buffer
+       (let ((m (selected-message #f buffer)))
+         (if (or (not m)
+                 (message-detached? m))
+             (select-message folder
+                             (let ((length (folder-length folder)))
+                               (cond ((< index length) index)
+                                     ((> length 0) (- length 1))
+                                     (else #f)))
+                             #t)))))
+  (notice-folder-modifications folder))
+
 (define (imail-mode-line-summary-string buffer)
   (let ((folder (selected-folder #f buffer))
        (message (selected-message #f buffer)))
@@ -1311,16 +1328,15 @@ With prefix argument N, undeletes backward N messages,
                                (imail-expunge-pop-up-messages folder)
                                (do-prompt)))
                             (do-prompt))))))
-              (let ((message
-                     (let ((message (selected-message)))
-                       (if (message-deleted? message)
-                           (or (next-message message message-undeleted?)
-                               (previous-message message message-undeleted?)
-                               (next-message message)
-                               (previous-message message))
-                           message))))
-                (expunge-deleted-messages folder)
-                (select-message folder message)))
+              (let ((message (selected-message)))
+                (if (message-deleted? message)
+                    (select-message
+                     folder
+                     (or (next-message message message-undeleted?)
+                         (previous-message message message-undeleted?)
+                         (next-message message)
+                         (previous-message message)))))
+              (expunge-deleted-messages folder))
              (else
               (message "Messages not expunged")))))))
 
index 36320fb72d569e61cbefb51e7054fb6bfaa1d4c8..94bfba73036ddee87f37d47ac66fc512bfb66d61 100644 (file)
@@ -1,13 +1,9 @@
 IMAIL To-Do List
-$Id: todo.txt,v 1.60 2000/06/05 17:34:57 cph Exp $
+$Id: todo.txt,v 1.61 2000/06/05 18:16:34 cph Exp $
 
 Bug fixes
 ---------
 
-* When message is selected in IMAIL and deleted by a different user
-  agent, IMAIL ends up in state that there is no selected message.
-  Instead, it should select another message.
-
 * M-x imail-copy-messages re-reads the target folder UIDs for each
   message that is written, when the target folder is not being
   visited.  [I haven't seen this lately.  Maybe it's fixed?]