diff -u vm-6.95/Makefile vm-hacked/Makefile
--- vm-6.95/Makefile	Sun Jun 10 08:25:15 2001
+++ vm-hacked/Makefile	Tue Jun 26 19:40:16 2001
@@ -272,3 +272,15 @@
 vm-easymenu.elc:	vm-easymenu.el
 	@echo compiling vm-easymenu.el...
 	@$(EMACS) $(BATCHFLAGS) -l $(BYTEOPTS) -f batch-byte-compile vm-easymenu.el
+
+tags: TAGS
+
+TAGS: tapestry.el vm-folder.el vm-minibuf.el vm-search.el vm-vars.el\
+      vm-autoload.el vm-imap.el vm-misc.el vm-sort.el vm-version.el \
+      vm-byteopts.el vm-license.el vm-motion.el vm-startup.el vm-virtual.el\
+      vm-delete.el vm-macro.el vm-mouse.el vm-summary.el vm-window.el\
+      vm-digest.el vm-mark.el vm-page.el vm-thread.el\
+      vm-easymenu.el vm-menu.el vm-pop.el vm-toolbar.el\
+      vm-edit.el vm-message.el vm-reply.el vm-undo.el\
+      vm.el vm-mime.el vm-save.el vm-user.el
+	etags *.el
Only in vm-hacked: base64-decode
Only in vm-hacked: base64-encode
Common subdirectories: vm-6.95/pixmaps and vm-hacked/pixmaps
Only in vm-hacked: tapestry.elc
Only in vm-hacked: vm-autoload.el
Only in vm-hacked: vm-autoload.elc
diff -u vm-6.95/vm-delete.el vm-hacked/vm-delete.el
--- vm-6.95/vm-delete.el	Mon Dec  4 02:09:29 2000
+++ vm-hacked/vm-delete.el	Tue Jun 26 19:39:24 2001
@@ -227,6 +227,9 @@
 	(virtual (eq major-mode 'vm-virtual-mode))
 	(buffers-altered (make-vector 29 0))
 	prev virtual-messages)
+    ;; Take the messages off the server first.
+    (if vm-expunge-sync-with-server
+        (vm-expunge-pop-messages t))
     (while mp
       (cond
        ((and (vm-deleted-flag (car mp))
Only in vm-hacked: vm-delete.elc
Only in vm-hacked: vm-digest.elc
Only in vm-hacked: vm-easymenu.elc
Only in vm-hacked: vm-edit.elc
diff -u vm-6.95/vm-folder.el vm-hacked/vm-folder.el
--- vm-6.95/vm-folder.el	Sun Jul 22 07:12:54 2001
+++ vm-hacked/vm-folder.el	Mon Aug 27 21:57:21 2001
@@ -1207,6 +1207,7 @@
 	  oldpoint data)
       (while mp
 	(vm-increment vm-total-count)
+    (vm-read-spool-info mp)
 	(if (vm-attributes-of (car mp))
 	    ()
 	  (goto-char (vm-headers-of (car mp)))
@@ -1326,6 +1327,24 @@
 				vm-unread-count
 				vm-deleted-count))))))
 
+(defun vm-read-spool-info( message )
+  ;; check for spool information, and poke it into the attributes if
+  ;; available. Also update vm-pop-retrieved-messages to match reality.
+  (goto-char (vm-headers-of (car message )))
+  (cond
+   ((re-search-forward "^X-VM-Spool-Info: \\(.*\\)$"
+                       (vm-text-of (car message )) t)
+    (let ((spool-data (condition-case ()
+                          (car (read-from-string
+                                (buffer-substring (match-beginning 1)
+                                                  (match-end 1)))))))
+      (vm-set-spool-data-of (car message) spool-data)
+      (if spool-data
+          (or (member spool-data vm-pop-retrieved-messages)
+              (setq vm-pop-retrieved-messages
+                    (cons spool-data vm-pop-retrieved-messages))))))
+   (t)))
+
 (defun vm-read-babyl-attributes (message)
   (let ((case-fold-search t)
 	(labels nil)
@@ -1385,6 +1404,9 @@
       ;; untrustworthy.  tink the message modflag to force the
       ;; new attributes out if the user saves.
       (vm-set-modflag-of (car mp) t)
+      ;; snork the whence info regardless.
+      (vm-read-spool-info mp)
+
       (setq mp (cdr mp)))))
 
 (defun vm-compute-totals ()
Only in vm-hacked: vm-folder.elc
Only in vm-hacked: vm-imap.elc
Only in vm-hacked: vm-license.elc
Only in vm-hacked: vm-macro.elc
Only in vm-hacked: vm-mark.elc
Only in vm-hacked: vm-menu.elc
diff -u vm-6.95/vm-message.el vm-hacked/vm-message.el
--- vm-6.95/vm-message.el	Wed Feb 18 06:16:25 1998
+++ vm-hacked/vm-message.el	Tue Jun 26 19:39:24 2001
@@ -88,6 +88,9 @@
   (list 'aref (list 'aref message 1) 17))
 (defmacro vm-su-summary-mouse-track-overlay-of (message)
   (list 'aref (list 'aref message 1) 18))
+;; keep the message spool data with the message, too.
+(defmacro vm-spool-data-of (message)
+  (list 'aref (list 'aref message 1) 19))
 ;; message attribute vector
 (defmacro vm-attributes-of (message) (list 'aref message 2))
 (defmacro vm-new-flag (message) (list 'aref (list 'aref message 2) 0))
@@ -220,6 +223,8 @@
   (list 'aset (list 'aref message 1) 17 flag))
 (defmacro vm-set-su-summary-mouse-track-overlay-of (message overlay)
   (list 'aset (list 'aref message 1) 18 overlay))
+(defmacro vm-set-spool-data-of (message data)
+  (list 'aset (list 'aref message 1) 19 data))
 (defmacro vm-set-attributes-of (message attrs) (list 'aset message 2 attrs))
 ;; The other routines in attributes group are part of the undo system.
 (defun vm-set-edited-flag-of (message flag)
Only in vm-hacked: vm-message.elc
Only in vm-hacked: vm-mime.elc
Only in vm-hacked: vm-minibuf.elc
diff -u vm-6.95/vm-misc.el vm-hacked/vm-misc.el
--- vm-6.95/vm-misc.el	Mon Jul 23 03:30:34 2001
+++ vm-hacked/vm-misc.el	Mon Aug 27 21:59:44 2001
@@ -27,13 +27,13 @@
   (let ((curr list) (prev nil))
     (while curr
       (if (string-match regexp (car curr))
-	  (setq prev curr
-		curr (cdr curr))
-	(if (null prev)
-	    (setq list (cdr list)
-		  curr list)
-	  (setcdr prev (cdr curr))
-	  (setq curr (cdr curr)))))
+      (setq prev curr
+        curr (cdr curr))
+    (if (null prev)
+        (setq list (cdr list)
+          curr list)
+      (setcdr prev (cdr curr))
+      (setq curr (cdr curr)))))
     list ))
 
 (defun vm-parse (string regexp &optional matchn)
@@ -42,7 +42,7 @@
     (store-match-data nil)
     (while (string-match regexp string (match-end 0))
       (setq list (cons (substring string (match-beginning matchn)
-				  (match-end matchn)) list)))
+                  (match-end matchn)) list)))
     (nreverse list)))
 
 (defun vm-parse-addresses (string)
@@ -51,46 +51,46 @@
     (let (work-buffer)
       (save-excursion
        (unwind-protect
-	   (let (list start s char)
-	     (setq work-buffer (vm-make-work-buffer))
-	     (set-buffer work-buffer)
-	     (insert string)
-	     (goto-char (point-min))
-	     (skip-chars-forward "\t\f\n\r ")
-	     (setq start (point))
-	     (while (not (eobp))
-	       (skip-chars-forward "^\"\\\\,(")
-	       (setq char (following-char))
-	       (cond ((= char ?\\)
-		      (forward-char 1)
-		      (if (not (eobp))
-			  (forward-char 1)))
-		     ((= char ?,)
-		      (setq s (buffer-substring start (point)))
-		      (if (or (null (string-match "^[\t\f\n\r ]+$" s))
-			      (not (string= s "")))
-			  (setq list (cons s list)))
-		      (skip-chars-forward ",\t\f\n\r ")
-		      (setq start (point)))
-		     ((= char ?\")
-		      (re-search-forward "[^\\\\]\"" nil 0))
-		     ((= char ?\()
-		      (let ((parens 1))
-			(forward-char 1)
-			(while (and (not (eobp)) (not (zerop parens)))
-			  (re-search-forward "[()]" nil 0)
-			  (cond ((or (eobp)
-				     (= (char-after (- (point) 2)) ?\\)))
-				((= (preceding-char) ?\()
-				 (setq parens (1+ parens)))
-				(t
-				 (setq parens (1- parens)))))))))
-	     (setq s (buffer-substring start (point)))
-	     (if (and (null (string-match "^[\t\f\n\r ]+$" s))
-		      (not (string= s "")))
-		 (setq list (cons s list)))
-	     (nreverse list)) ; jwz: fixed order
-	(and work-buffer (kill-buffer work-buffer)))))))
+       (let (list start s char)
+         (setq work-buffer (vm-make-work-buffer))
+         (set-buffer work-buffer)
+         (insert string)
+         (goto-char (point-min))
+         (skip-chars-forward "\t\f\n\r ")
+         (setq start (point))
+         (while (not (eobp))
+           (skip-chars-forward "^\"\\\\,(")
+           (setq char (following-char))
+           (cond ((= char ?\\)
+              (forward-char 1)
+              (if (not (eobp))
+              (forward-char 1)))
+             ((= char ?,)
+              (setq s (buffer-substring start (point)))
+              (if (or (null (string-match "^[\t\f\n\r ]+$" s))
+                  (not (string= s "")))
+              (setq list (cons s list)))
+              (skip-chars-forward ",\t\f\n\r ")
+              (setq start (point)))
+             ((= char ?\")
+              (re-search-forward "[^\\\\]\"" nil 0))
+             ((= char ?\()
+              (let ((parens 1))
+            (forward-char 1)
+            (while (and (not (eobp)) (not (zerop parens)))
+              (re-search-forward "[()]" nil 0)
+              (cond ((or (eobp)
+                     (= (char-after (- (point) 2)) ?\\)))
+                ((= (preceding-char) ?\()
+                 (setq parens (1+ parens)))
+                (t
+                 (setq parens (1- parens)))))))))
+         (setq s (buffer-substring start (point)))
+         (if (and (null (string-match "^[\t\f\n\r ]+$" s))
+              (not (string= s "")))
+         (setq list (cons s list)))
+         (nreverse list)) ; jwz: fixed order
+    (and work-buffer (kill-buffer work-buffer)))))))
 
 (defun vm-parse-structured-header (string &optional sepchar keep-quotes)
   (if (null string)
@@ -98,115 +98,115 @@
     (let ((work-buffer nil))
       (save-excursion
        (unwind-protect
-	   (let ((list nil)
-		 (nonspecials "^\"\\\\( \t\n\r\f")
-		 start s char sp+sepchar)
-	     (if sepchar
-		 (setq nonspecials (concat nonspecials (list sepchar))
-		       sp+sepchar (concat "\t\f\n\r " (list sepchar))))
-	     (setq work-buffer (vm-make-work-buffer))
-	     (buffer-disable-undo work-buffer)
-	     (set-buffer work-buffer)
-	     (insert string)
-	     (goto-char (point-min))
-	     (skip-chars-forward "\t\f\n\r ")
-	     (setq start (point))
-	     (while (not (eobp))
-	       (skip-chars-forward nonspecials)
-	       (setq char (following-char))
-	       (cond ((looking-at "[ \t\n\r\f]")
-		      (delete-char 1))
-		     ((= char ?\\)
-		      (forward-char 1)
-		      (if (not (eobp))
-			  (forward-char 1)))
-		     ((and sepchar (= char sepchar))
-		      (setq s (buffer-substring start (point)))
-		      (if (or (null (string-match "^[\t\f\n\r ]+$" s))
-			      (not (string= s "")))
-			  (setq list (cons s list)))
-		      (skip-chars-forward sp+sepchar)
-		      (setq start (point)))
-		     ((looking-at " \t\n\r\f")
-		      (skip-chars-forward " \t\n\r\f"))
-		     ((= char ?\")
-		      (let ((done nil))
-			(if keep-quotes
-			    (forward-char 1)
-			  (delete-char 1))
-			(while (not done)
-			  (if (null (re-search-forward "[\\\\\"]" nil t))
-			      (setq done t)
-			    (setq char (char-after (1- (point))))
-			    (cond ((char-equal char ?\\)
-				   (delete-char -1)
-				   (if (eobp)
-				       (setq done t)
-				     (forward-char 1)))
-				  (t (if (not keep-quotes)
-					 (delete-char -1))
-				     (setq done t)))))))
-		     ((= char ?\()
-		      (let ((done nil)
-			    (pos (point))
-			    (parens 1))
-			(forward-char 1)
-			(while (not done)
-			  (if (null (re-search-forward "[\\\\()]" nil t))
-			      (setq done t)
-			    (setq char (char-after (1- (point))))
-			    (cond ((char-equal char ?\\)
-				   (if (eobp)
-				       (setq done t)
-				     (forward-char 1)))
-				  ((char-equal char ?\()
-				   (setq parens (1+ parens)))
-				  (t
-				   (setq parens (1- parens)
-					 done (zerop parens))))))
-			(delete-region pos (point))))))
-	     (setq s (buffer-substring start (point)))
-	     (if (and (null (string-match "^[\t\f\n\r ]+$" s))
-		      (not (string= s "")))
-		 (setq list (cons s list)))
-	     (nreverse list))
-	(and work-buffer (kill-buffer work-buffer)))))))
+       (let ((list nil)
+         (nonspecials "^\"\\\\( \t\n\r\f")
+         start s char sp+sepchar)
+         (if sepchar
+         (setq nonspecials (concat nonspecials (list sepchar))
+               sp+sepchar (concat "\t\f\n\r " (list sepchar))))
+         (setq work-buffer (vm-make-work-buffer))
+         (buffer-disable-undo work-buffer)
+         (set-buffer work-buffer)
+         (insert string)
+         (goto-char (point-min))
+         (skip-chars-forward "\t\f\n\r ")
+         (setq start (point))
+         (while (not (eobp))
+           (skip-chars-forward nonspecials)
+           (setq char (following-char))
+           (cond ((looking-at "[ \t\n\r\f]")
+              (delete-char 1))
+             ((= char ?\\)
+              (forward-char 1)
+              (if (not (eobp))
+              (forward-char 1)))
+             ((and sepchar (= char sepchar))
+              (setq s (buffer-substring start (point)))
+              (if (or (null (string-match "^[\t\f\n\r ]+$" s))
+                  (not (string= s "")))
+              (setq list (cons s list)))
+              (skip-chars-forward sp+sepchar)
+              (setq start (point)))
+             ((looking-at " \t\n\r\f")
+              (skip-chars-forward " \t\n\r\f"))
+             ((= char ?\")
+              (let ((done nil))
+            (if keep-quotes
+                (forward-char 1)
+              (delete-char 1))
+            (while (not done)
+              (if (null (re-search-forward "[\\\\\"]" nil t))
+                  (setq done t)
+                (setq char (char-after (1- (point))))
+                (cond ((char-equal char ?\\)
+                   (delete-char -1)
+                   (if (eobp)
+                       (setq done t)
+                     (forward-char 1)))
+                  (t (if (not keep-quotes)
+                     (delete-char -1))
+                     (setq done t)))))))
+             ((= char ?\()
+              (let ((done nil)
+                (pos (point))
+                (parens 1))
+            (forward-char 1)
+            (while (not done)
+              (if (null (re-search-forward "[\\\\()]" nil t))
+                  (setq done t)
+                (setq char (char-after (1- (point))))
+                (cond ((char-equal char ?\\)
+                   (if (eobp)
+                       (setq done t)
+                     (forward-char 1)))
+                  ((char-equal char ?\()
+                   (setq parens (1+ parens)))
+                  (t
+                   (setq parens (1- parens)
+                     done (zerop parens))))))
+            (delete-region pos (point))))))
+         (setq s (buffer-substring start (point)))
+         (if (and (null (string-match "^[\t\f\n\r ]+$" s))
+              (not (string= s "")))
+         (setq list (cons s list)))
+         (nreverse list))
+    (and work-buffer (kill-buffer work-buffer)))))))
 
 (defvar buffer-file-type)
 
 (defun vm-write-string (where string)
   (if (bufferp where)
       (vm-save-buffer-excursion
-	(set-buffer where)
-	(goto-char (point-max))
-	(let ((buffer-read-only nil))
-	  (insert string)))
+    (set-buffer where)
+    (goto-char (point-max))
+    (let ((buffer-read-only nil))
+      (insert string)))
     (let ((temp-buffer nil)
-	  (coding-system-for-write (vm-line-ending-coding-system)))
+      (coding-system-for-write (vm-line-ending-coding-system)))
       (unwind-protect
-	  (save-excursion
-	    (setq temp-buffer (generate-new-buffer "*vm-work*"))
-	    (set-buffer temp-buffer)
-	    (setq selective-display nil)
-	    (insert string)
-	    ;; correct for VM's uses of this function---
-	    ;; writing out message separators
-	    (setq buffer-file-type nil)
-	    ;; Tell MULE to pick the correct newline conversion.
-	    (if (fboundp 'set-buffer-file-coding-system)
-		(set-buffer-file-coding-system 
-		 (vm-line-ending-coding-system) nil))
-	    (write-region (point-min) (point-max) where t 'quiet))
-	(and temp-buffer (kill-buffer temp-buffer))))))
+      (save-excursion
+        (setq temp-buffer (generate-new-buffer "*vm-work*"))
+        (set-buffer temp-buffer)
+        (setq selective-display nil)
+        (insert string)
+        ;; correct for VM's uses of this function---
+        ;; writing out message separators
+        (setq buffer-file-type nil)
+        ;; Tell MULE to pick the correct newline conversion.
+        (if (fboundp 'set-buffer-file-coding-system)
+        (set-buffer-file-coding-system
+         (vm-line-ending-coding-system) nil))
+        (write-region (point-min) (point-max) where t 'quiet))
+    (and temp-buffer (kill-buffer temp-buffer))))))
 
 (defun vm-check-for-killed-summary ()
   (and (bufferp vm-summary-buffer) (null (buffer-name vm-summary-buffer))
        (let ((mp vm-message-list))
-	 (setq vm-summary-buffer nil)
-	 (while mp
-	   (vm-set-su-start-of (car mp) nil)
-	   (vm-set-su-end-of (car mp) nil)
-	   (setq mp (cdr mp)))))
+     (setq vm-summary-buffer nil)
+     (while mp
+       (vm-set-su-start-of (car mp) nil)
+       (vm-set-su-end-of (car mp) nil)
+       (setq mp (cdr mp)))))
   (and (bufferp vm-folders-summary-buffer)
        (null (buffer-name vm-folders-summary-buffer))
        (setq vm-folders-summary-buffer nil)))
@@ -215,8 +215,8 @@
   (and (bufferp vm-presentation-buffer-handle)
        (null (buffer-name vm-presentation-buffer-handle))
        (progn
-	 (setq vm-presentation-buffer-handle nil
-	       vm-presentation-buffer nil))))
+     (setq vm-presentation-buffer-handle nil
+           vm-presentation-buffer nil))))
 
 (defun vm-check-for-killed-folder ()
   (and (bufferp vm-mail-buffer) (null (buffer-name vm-mail-buffer))
@@ -231,7 +231,7 @@
 
 (defun vm-vector-to-list (vector)
   (let ((i (1- (length vector)))
-	list)
+    list)
     (while (>= i 0)
       (setq list (cons (aref vector i) list))
       (vm-decrement i))
@@ -240,14 +240,14 @@
 (defun vm-extend-vector (vector length &optional fill)
   (let ((vlength (length vector)))
     (if (< vlength length)
-	(apply 'vector (nconc (vm-vector-to-list vector)
-			      (make-list (- length vlength) fill)))
+    (apply 'vector (nconc (vm-vector-to-list vector)
+                  (make-list (- length vlength) fill)))
       vector )))
 
 (defun vm-obarray-to-string-list (blobarray)
   (let ((list nil))
     (mapatoms (function (lambda (s) (setq list (cons (symbol-name s) list))))
-	      blobarray)
+          blobarray)
     list ))
 
 (defun vm-mapcar (function &rest lists)
@@ -269,11 +269,11 @@
   (let ((p list) (reverse (if reverse 'not 'identity)) prev)
     (while p
       (if (funcall reverse (funcall predicate (car p)))
-	  (if (null prev)
-	      (setq list (cdr list) p list)
-	    (setcdr prev (cdr p))
-	    (setq p (cdr p)))
-	(setq prev p p (cdr p))))
+      (if (null prev)
+          (setq list (cdr list) p list)
+        (setcdr prev (cdr p))
+        (setq p (cdr p)))
+    (setq prev p p (cdr p))))
     list ))
 
 (defun vm-delete-directory-file-names (list)
@@ -295,7 +295,7 @@
   (and (file-regular-p file)
        (stringp vm-index-file-suffix)
        (let ((str (concat (regexp-quote vm-index-file-suffix) "$")))
-	 (string-match str file))
+     (string-match str file))
        t ))
 
 (defun vm-delete-duplicates (list &optional all hack-addresses)
@@ -306,21 +306,21 @@
  and only the address part is compared (so that \"Name <foo>\" and \"foo\"
  would be considered to be equivalent.)"
   (let ((hashtable vm-delete-duplicates-obarray)
-	(new-list nil)
-	sym-string sym)
+    (new-list nil)
+    sym-string sym)
     (fillarray hashtable 0)
     (while list
       (setq sym-string
-	    (if hack-addresses
-		(nth 1 (funcall vm-chop-full-name-function (car list)))
-	      (car list))
-	    sym-string (or sym-string "-unparseable-garbage-")
-	    sym (intern (if hack-addresses (downcase sym-string) sym-string)
-			hashtable))
+        (if hack-addresses
+        (nth 1 (funcall vm-chop-full-name-function (car list)))
+          (car list))
+        sym-string (or sym-string "-unparseable-garbage-")
+        sym (intern (if hack-addresses (downcase sym-string) sym-string)
+                    hashtable))
       (if (boundp sym)
-	  (and all (setcar (symbol-value sym) nil))
-	(setq new-list (cons (car list) new-list))
-	(set sym new-list))
+      (and all (setcar (symbol-value sym) nil))
+    (setq new-list (cons (car list) new-list))
+    (set sym new-list))
       (setq list (cdr list)))
     (delq nil (nreverse new-list))))
 
@@ -328,7 +328,7 @@
   (catch 'done
     (while list
       (and (equal (car list) thing)
-	   (throw 'done list))
+       (throw 'done list))
       (setq list (cdr list)))
     nil ))
 
@@ -336,16 +336,16 @@
 
 (defun vm-delqual (ob list)
   (let ((prev nil)
-	(curr list))
+    (curr list))
     (while curr
       (if (not (equal ob (car curr)))
-	  (setq prev curr
-		curr (cdr curr))
-	(if (null prev)
-	    (setq list (cdr list)
-		  curr list)
-	  (setq curr (cdr curr))
-	  (setcdr prev curr))))
+      (setq prev curr
+        curr (cdr curr))
+    (if (null prev)
+        (setq list (cdr list)
+          curr list)
+      (setq curr (cdr curr))
+      (setcdr prev curr))))
     list ))
 
 (defun vm-copy-local-variables (buffer &rest variables)
@@ -363,25 +363,25 @@
 (defun vm-error-if-folder-empty ()
   (while (null vm-message-list)
     (if vm-folder-type
-	(signal 'unrecognized-folder-type nil)
+    (signal 'unrecognized-folder-type nil)
       (signal 'folder-empty nil))))
 
 (defun vm-copy (object)
   (cond ((consp object)
-	 (let (return-value cons)
-	   (setq return-value (cons (vm-copy (car object)) nil)
-		 cons return-value
-		 object (cdr object))
-	   (while (consp object)
-	     (setcdr cons (cons (vm-copy (car object)) nil))
-	     (setq cons (cdr cons)
-		   object (cdr object)))
-	   (setcdr cons object)
-	   return-value ))
-	((vectorp object) (apply 'vector (mapcar 'vm-copy object)))
-	((stringp object) (copy-sequence object))
-	((markerp object) (copy-marker object))
-	(t object)))
+     (let (return-value cons)
+       (setq return-value (cons (vm-copy (car object)) nil)
+         cons return-value
+         object (cdr object))
+       (while (consp object)
+         (setcdr cons (cons (vm-copy (car object)) nil))
+         (setq cons (cdr cons)
+           object (cdr object)))
+       (setcdr cons object)
+       return-value ))
+    ((vectorp object) (apply 'vector (mapcar 'vm-copy object)))
+    ((stringp object) (copy-sequence object))
+    ((markerp object) (copy-marker object))
+    (t object)))
 
 (defun vm-run-message-hook (message &optional hook-variable)
   (save-excursion
@@ -389,8 +389,8 @@
     (vm-save-restriction
       (widen)
       (save-excursion
-	(narrow-to-region (vm-headers-of message) (vm-text-end-of message))
-	(run-hooks hook-variable)))))
+    (narrow-to-region (vm-headers-of message) (vm-text-end-of message))
+    (run-hooks hook-variable)))))
 
 (defun vm-error-free-call (function &rest args)
   (condition-case nil
@@ -410,66 +410,66 @@
 (defun vm-timezone-make-date-sortable (string)
   (or (cdr (assq string vm-sortable-date-alist))
       (let ((vect (vm-parse-date string))
-	    (date (vm-parse (current-time-string) " *\\([^ ]+\\)")))
-	;; if specified date is incomplete fill in the holes
-	;; with useful information, defaulting to the current
-	;; date and timezone for everything except hh:mm:ss which
-	;; defaults to midnight.
-	(if (equal (aref vect 1) "")
-	    (aset vect 1 (nth 2 date)))
-	(if (equal (aref vect 2) "")
-	    (aset vect 2 (nth 1 date)))
-	(if (equal (aref vect 3) "")
-	    (aset vect 3 (nth 4 date)))
-	(if (equal (aref vect 4) "")
-	    (aset vect 4 "00:00:00"))
-	(if (equal (aref vect 5) "")
-	    (aset vect 5 (vm-current-time-zone)))
-	;; save this work so we won't have to do it again
-	(setq vm-sortable-date-alist
-	      (cons (cons string
-			  (condition-case nil
-			      (timezone-make-date-sortable
-			       (format "%s %s %s %s %s"
-				       (aref vect 1)
-				       (aref vect 2)
-				       (aref vect 3)
-				       (aref vect 4)
-				       (aref vect 5)))
-			    (error "1970010100:00:00")))
-		    vm-sortable-date-alist))
-	;; return result
-	(cdr (car vm-sortable-date-alist)))))
+        (date (vm-parse (current-time-string) " *\\([^ ]+\\)")))
+    ;; if specified date is incomplete fill in the holes
+    ;; with useful information, defaulting to the current
+    ;; date and timezone for everything except hh:mm:ss which
+    ;; defaults to midnight.
+    (if (equal (aref vect 1) "")
+        (aset vect 1 (nth 2 date)))
+    (if (equal (aref vect 2) "")
+        (aset vect 2 (nth 1 date)))
+    (if (equal (aref vect 3) "")
+        (aset vect 3 (nth 4 date)))
+    (if (equal (aref vect 4) "")
+        (aset vect 4 "00:00:00"))
+    (if (equal (aref vect 5) "")
+        (aset vect 5 (vm-current-time-zone)))
+    ;; save this work so we won't have to do it again
+    (setq vm-sortable-date-alist
+          (cons (cons string
+              (condition-case nil
+                  (timezone-make-date-sortable
+                   (format "%s %s %s %s %s"
+                       (aref vect 1)
+                       (aref vect 2)
+                       (aref vect 3)
+                       (aref vect 4)
+                       (aref vect 5)))
+                (error "1970010100:00:00")))
+            vm-sortable-date-alist))
+    ;; return result
+    (cdr (car vm-sortable-date-alist)))))
 
 (defun vm-current-time-zone ()
   (or (condition-case nil
-	  (let* ((zone (car (current-time-zone)))
-		 (absmin (/ (vm-abs zone) 60)))
-	    (format "%c%02d%02d" (if (< zone 0) ?- ?+)
-		    (/ absmin 60) (% absmin 60)))
-	(error nil))
+      (let* ((zone (car (current-time-zone)))
+         (absmin (/ (vm-abs zone) 60)))
+        (format "%c%02d%02d" (if (< zone 0) ?- ?+)
+            (/ absmin 60) (% absmin 60)))
+    (error nil))
       (let ((temp-buffer nil))
-	(condition-case nil
-	    (unwind-protect
-		(save-excursion
-		  (setq temp-buffer (vm-make-work-buffer))
-		  (set-buffer temp-buffer)
-		  (call-process "date" nil temp-buffer nil)
-		  (nth 4 (vm-parse (vm-buffer-string-no-properties)
-				   " *\\([^ ]+\\)")))
-	      (and temp-buffer (kill-buffer temp-buffer)))
-	  (error nil)))
+    (condition-case nil
+        (unwind-protect
+        (save-excursion
+          (setq temp-buffer (vm-make-work-buffer))
+          (set-buffer temp-buffer)
+          (call-process "date" nil temp-buffer nil)
+          (nth 4 (vm-parse (vm-buffer-string-no-properties)
+                   " *\\([^ ]+\\)")))
+          (and temp-buffer (kill-buffer temp-buffer)))
+      (error nil)))
       ""))
 
 (defun vm-should-generate-summary ()
   (cond ((eq vm-startup-with-summary t) t)
-	((integerp vm-startup-with-summary)
-	 (let ((n vm-startup-with-summary))
-	   (cond ((< n 0) (null (nth (vm-abs n) vm-message-list)))
-		 ((= n 0) nil)
-		 (t (nth (1- n) vm-message-list)))))
-	(vm-startup-with-summary t)
-	(t nil)))
+    ((integerp vm-startup-with-summary)
+     (let ((n vm-startup-with-summary))
+       (cond ((< n 0) (null (nth (vm-abs n) vm-message-list)))
+         ((= n 0) nil)
+         (t (nth (1- n) vm-message-list)))))
+    (vm-startup-with-summary t)
+    (t nil)))
 
 (defun vm-find-composition-buffer (&optional not-picky)
   (let ((b-list (buffer-list)) choice alternate)
@@ -477,22 +477,22 @@
      (while b-list
        (set-buffer (car b-list))
        (if (eq major-mode 'mail-mode)
-	   (if (buffer-modified-p)
-	       (setq choice (current-buffer)
-		     b-list nil)
-	     (and not-picky (null alternate)
-		  (setq alternate (current-buffer)))
-	     (setq b-list (cdr b-list)))
-	 (setq b-list (cdr b-list))))
+       (if (buffer-modified-p)
+           (setq choice (current-buffer)
+             b-list nil)
+         (and not-picky (null alternate)
+          (setq alternate (current-buffer)))
+         (setq b-list (cdr b-list)))
+     (setq b-list (cdr b-list))))
     (or choice alternate))))
 
 (defun vm-get-file-buffer (file)
   "Like get-file-buffer, but also checks buffers against FILE's truename"
   (or (get-file-buffer file)
       (and (fboundp 'file-truename)
-	   (get-file-buffer (file-truename file)))
+       (get-file-buffer (file-truename file)))
       (and (fboundp 'find-buffer-visiting)
-	   (find-buffer-visiting file))))
+       (find-buffer-visiting file))))
 
 (defun vm-set-region-face (start end face)
   (let ((e (vm-make-extent start end)))
@@ -500,19 +500,19 @@
 
 (defun vm-default-buffer-substring-no-properties (beg end &optional buffer)
   (let ((s (if buffer
-	       (save-excursion
-		 (set-buffer buffer)
-		 (buffer-substring beg end))
-	     (buffer-substring beg end))))
+           (save-excursion
+         (set-buffer buffer)
+         (buffer-substring beg end))
+         (buffer-substring beg end))))
     (set-text-properties 0 (length s) nil s)
     (copy-sequence s)))
 
 (fset 'vm-buffer-substring-no-properties
   (cond ((fboundp 'buffer-substring-no-properties)
-	 (function buffer-substring-no-properties))
-	(vm-xemacs-p
-	 (function buffer-substring))
-	(t (function vm-default-buffer-substring-no-properties))))
+     (function buffer-substring-no-properties))
+    (vm-xemacs-p
+     (function buffer-substring))
+    (t (function vm-default-buffer-substring-no-properties))))
 
 (defun vm-buffer-string-no-properties ()
   (vm-buffer-substring-no-properties (point-min) (point-max)))
@@ -531,67 +531,67 @@
 
 (if (not (fboundp 'vm-extent-property))
     (if vm-fsfemacs-p
-	(fset 'vm-extent-property 'overlay-get)
+    (fset 'vm-extent-property 'overlay-get)
       (fset 'vm-extent-property 'extent-property)))
 
 (if (not (fboundp 'vm-extent-object))
     (if vm-fsfemacs-p
-	(fset 'vm-extent-object 'overlay-buffer)
+    (fset 'vm-extent-object 'overlay-buffer)
       (fset 'vm-extent-object 'extent-object)))
 
 (if (not (fboundp 'vm-set-extent-property))
     (if vm-fsfemacs-p
-	(fset 'vm-set-extent-property 'overlay-put)
+    (fset 'vm-set-extent-property 'overlay-put)
       (fset 'vm-set-extent-property 'set-extent-property)))
 
 (if (not (fboundp 'vm-set-extent-endpoints))
     (if vm-fsfemacs-p
-	(fset 'vm-set-extent-endpoints 'move-overlay)
+    (fset 'vm-set-extent-endpoints 'move-overlay)
       (fset 'vm-set-extent-endpoints 'set-extent-endpoints)))
 
 (if (not (fboundp 'vm-make-extent))
     (if vm-fsfemacs-p
-	(fset 'vm-make-extent 'make-overlay)
+    (fset 'vm-make-extent 'make-overlay)
       (fset 'vm-make-extent 'make-extent)))
 
 (if (not (fboundp 'vm-extent-end-position))
     (if vm-fsfemacs-p
-	(fset 'vm-extent-end-position 'overlay-end)
+    (fset 'vm-extent-end-position 'overlay-end)
       (fset 'vm-extent-end-position 'extent-end-position)))
 
 (if (not (fboundp 'vm-extent-start-position))
     (if vm-fsfemacs-p
-	(fset 'vm-extent-start-position 'overlay-start)
+    (fset 'vm-extent-start-position 'overlay-start)
       (fset 'vm-extent-start-position 'extent-start-position)))
 
 (if (not (fboundp 'vm-detach-extent))
     (if vm-fsfemacs-p
-	(fset 'vm-detach-extent 'delete-overlay)
+    (fset 'vm-detach-extent 'delete-overlay)
       (fset 'vm-detach-extent 'detach-extent)))
 
 (if (not (fboundp 'vm-extent-properties))
     (if vm-fsfemacs-p
-	(fset 'vm-extent-properties 'overlay-properties)
+    (fset 'vm-extent-properties 'overlay-properties)
       (fset 'vm-extent-properties 'extent-properties)))
 
 (defun vm-extent-at (pos &optional object property)
   (if (fboundp 'extent-at)
       (extent-at pos object property)
     (let ((o-list (overlays-at pos))
-	  (o nil))
+      (o nil))
       (if (null property)
-	  (car o-list)
-	(while o-list
-	  (if (overlay-get (car o-list) property)
-	      (setq o (car o-list)
-		    o-list nil)
-	    (setq o-list (cdr o-list))))
-	o ))))
+      (car o-list)
+    (while o-list
+      (if (overlay-get (car o-list) property)
+          (setq o (car o-list)
+            o-list nil)
+        (setq o-list (cdr o-list))))
+    o ))))
 
 (defun vm-copy-extent (e)
   (let ((props (vm-extent-properties e))
-	(ee (vm-make-extent (vm-extent-start-position e)
-			    (vm-extent-end-position e))))
+    (ee (vm-make-extent (vm-extent-start-position e)
+                (vm-extent-end-position e))))
     (while props
       (vm-set-extent-property ee (car props) (car (cdr props)))
       (setq props (cdr (cdr props))))))
@@ -600,17 +600,17 @@
   (let ((done nil) filename)
     (while (not done)
       (setq filename (convert-standard-filename
-		      (expand-file-name (format "vm%d%s"
-						vm-tempfile-counter
-					       (or filename-suffix ""))
-					vm-temp-file-directory))
-	    vm-tempfile-counter (1+ vm-tempfile-counter)
-	    done (not (file-exists-p filename))))
+              (expand-file-name (format "vm%d%s"
+                        vm-tempfile-counter
+                           (or filename-suffix ""))
+                    vm-temp-file-directory))
+        vm-tempfile-counter (1+ vm-tempfile-counter)
+        done (not (file-exists-p filename))))
     filename ))
 
 (defun vm-make-work-buffer (&optional name)
   (let ((default-enable-multibyte-characters nil)
-	work-buffer)
+    work-buffer)
     (setq work-buffer (generate-new-buffer (or name "*vm-workbuf*")))
     (buffer-disable-undo work-buffer)
 ;; probably not worth doing since no one sets buffer-offer-save
@@ -622,7 +622,7 @@
 
 (defun vm-make-multibyte-work-buffer (&optional name)
   (let ((default-enable-multibyte-characters t)
-	work-buffer)
+    work-buffer)
     (setq work-buffer (generate-new-buffer (or name "*vm-workbuf*")))
     (buffer-disable-undo work-buffer)
 ;; probably not worth doing since no one sets buffer-offer-save
@@ -635,8 +635,8 @@
 (defun vm-insert-char (char &optional count ignored buffer)
   (condition-case nil
       (progn
-	(insert-char char count ignored buffer)
-	(fset 'vm-insert-char 'insert-char))
+    (insert-char char count ignored buffer)
+    (fset 'vm-insert-char 'insert-char))
     (wrong-number-of-arguments
      (fset 'vm-insert-char 'vm-xemacs-compatible-insert-char)
      (vm-insert-char char count ignored buffer))))
@@ -652,7 +652,7 @@
   (catch 'done
     (while list1
       (and (memq (car list1) list2)
-	   (throw 'done t))
+       (throw 'done t))
       (setq list1 (cdr list1)))
     nil ))
 
@@ -669,23 +669,23 @@
 (defsubst vm-with-string-as-temp-buffer (string function)
   (let ((work-buffer nil))
     (unwind-protect
-	(save-excursion
-	  (setq work-buffer (vm-make-multibyte-work-buffer))
-	  (set-buffer work-buffer)
-	  (insert string)
-	  (funcall function)
-	  (buffer-string))
+    (save-excursion
+      (setq work-buffer (vm-make-multibyte-work-buffer))
+      (set-buffer work-buffer)
+      (insert string)
+      (funcall function)
+      (buffer-string))
       (and work-buffer (kill-buffer work-buffer)))))
 
 (defun vm-string-assoc (elt list)
   (let ((case-fold-search t)
-	(found nil)
-	(elt (regexp-quote elt)))
+    (found nil)
+    (elt (regexp-quote elt)))
     (while (and list (not found))
       (if (and (equal 0 (string-match elt (car (car list))))
-	       (= (match-end 0) (length (car (car list)))))
-	  (setq found t)
-	(setq list (cdr list))))
+           (= (match-end 0) (length (car (car list)))))
+      (setq found t)
+    (setq list (cdr list))))
     (car list)))
 
 (defun vm-nonneg-string (n)
@@ -695,32 +695,32 @@
 
 (defun vm-string-member (elt list)
   (let ((case-fold-search t)
-	(found nil)
-	(elt (regexp-quote elt)))
+    (found nil)
+    (elt (regexp-quote elt)))
     (while (and list (not found))
       (if (and (equal 0 (string-match elt (car list)))
-	       (= (match-end 0) (length (car list))))
-	  (setq found t)
-	(setq list (cdr list))))
+           (= (match-end 0) (length (car list))))
+      (setq found t)
+    (setq list (cdr list))))
     list))
 
 (defun vm-string-equal-ignore-case (str1 str2)
   (let ((case-fold-search t)
-	(reg (regexp-quote str1)))
+    (reg (regexp-quote str1)))
     (and (equal 0 (string-match reg str2))
-	 (= (match-end 0) (length str2)))))
+     (= (match-end 0) (length str2)))))
 
 (defun vm-time-difference (t1 t2)
   (let (usecs secs 65536-secs carry)
     (setq usecs (- (nth 2 t1) (nth 2 t2)))
     (if (< usecs 0)
-	(setq carry 1
-	      usecs (+ usecs 1000000))
+    (setq carry 1
+          usecs (+ usecs 1000000))
       (setq carry 0))
     (setq secs (- (nth 1 t1) (nth 1 t2) carry))
     (if (< secs 0)
-	 (setq carry 1
-	       secs (+ secs 65536))
+     (setq carry 1
+           secs (+ secs 65536))
       (setq carry 0))
     (setq 65536-secs (- (nth 0 t1) (nth 0 t2) carry))
     (+ (* 65536-secs 65536)
@@ -748,137 +748,137 @@
 
 (defun vm-fill-paragraphs-containing-long-lines (len start end)
   (let ((done nil)
-	(buffer-read-only nil)
-	(fill-column vm-paragraph-fill-column)
-	;; user doesn't want long lines, so set this to zero for them.
-	(filladapt-fill-column-forward-fuzz 0))
+    (buffer-read-only nil)
+    (fill-column vm-paragraph-fill-column)
+    ;; user doesn't want long lines, so set this to zero for them.
+    (filladapt-fill-column-forward-fuzz 0))
     (save-excursion
       (vm-save-restriction
        (widen)
        (or (markerp end) (setq end (vm-marker end)))
        (goto-char start)
        (while (not done)
-	 (re-search-forward "$" end t)
-	 (if (>= (current-column) len)
-	     ;; ignore errors
-	     (condition-case nil
-		 (fill-paragraph nil)
-	       (error nil)))
-	 (forward-line)
-	 (setq done (>= (point) end)))))))
+     (re-search-forward "$" end t)
+     (if (>= (current-column) len)
+         ;; ignore errors
+         (condition-case nil
+         (fill-paragraph nil)
+           (error nil)))
+     (forward-line)
+     (setq done (>= (point) end)))))))
 
 (defun vm-make-message-id ()
   (let (hostname
-	(time (current-time)))
+    (time (current-time)))
     (setq hostname (cond ((string-match "\\." (system-name))
-			  (system-name))
-			 ((and (stringp mail-host-address)
-			       (string-match "\\." mail-host-address))
-			  mail-host-address)
-			 (t "gargle.gargle.HOWL")))
+              (system-name))
+             ((and (stringp mail-host-address)
+                   (string-match "\\." mail-host-address))
+              mail-host-address)
+             (t "gargle.gargle.HOWL")))
     (format "<%d.%d.%d.%d@%s>"
-	    (car time) (nth 1 time) (nth 2 time)
-	    (random 1000000)
-	    hostname)))
+        (car time) (nth 1 time) (nth 2 time)
+        (random 1000000)
+        hostname)))
 
 (defun vm-keep-some-buffers (buffer ring-variable number-to-keep)
   (if (memq buffer (symbol-value ring-variable))
       (set ring-variable (delq buffer (symbol-value ring-variable))))
   (set ring-variable (cons buffer (symbol-value ring-variable)))
   (set ring-variable (vm-delete 'buffer-name
-				(symbol-value ring-variable) t))
+                (symbol-value ring-variable) t))
   (if (not (eq number-to-keep t))
       (let ((extras (nthcdr (or number-to-keep 0)
-			    (symbol-value ring-variable))))
-	(mapcar (function
-		 (lambda (b)
-		   (and (buffer-name b)
-			(or (not (buffer-modified-p b))
-			    (not (vm-buffer-variable-value
-				  b buffer-offer-save)))
-			(kill-buffer b))))
-		extras)
-	(and (symbol-value ring-variable) extras
-	     (setcdr (memq (car extras) (symbol-value ring-variable))
-		     nil)))))
+                (symbol-value ring-variable))))
+    (mapcar (function
+         (lambda (b)
+           (and (buffer-name b)
+            (or (not (buffer-modified-p b))
+                (not (vm-buffer-variable-value
+                  b buffer-offer-save)))
+            (kill-buffer b))))
+        extras)
+    (and (symbol-value ring-variable) extras
+         (setcdr (memq (car extras) (symbol-value ring-variable))
+             nil)))))
 
 (defvar enable-multibyte-characters)
 (defun vm-fsfemacs-nonmule-display-8bit-chars ()
-  (cond ((and vm-fsfemacs-p 
-	      (or (not vm-fsfemacs-mule-p)
-		  (and (boundp 'enable-multibyte-characters)
-		       (not enable-multibyte-characters))))
-	 (let* (tab (i 160))
-	   ;; We need the function make-display-table, but it is
-	   ;; in disp-table.el, which overwrites the value of
-	   ;; standard-display-table when it is loaded, which
-	   ;; sucks.  So here we cruftily copy just enough goop
-	   ;; out of disp-table.el so that a display table can be
-	   ;; created, and thereby avoid loading disp-table.
-	   (put 'display-table 'char-table-extra-slots 6)
-	   (setq tab (make-char-table 'display-table nil))
-	   (while (< i 256)
-	     (aset tab i (vector i))
-	     (setq i (1+ i)))
-	   (setq buffer-display-table tab)))))
+  (cond ((and vm-fsfemacs-p
+          (or (not vm-fsfemacs-mule-p)
+          (and (boundp 'enable-multibyte-characters)
+               (not enable-multibyte-characters))))
+     (let* (tab (i 160))
+       ;; We need the function make-display-table, but it is
+       ;; in disp-table.el, which overwrites the value of
+       ;; standard-display-table when it is loaded, which
+       ;; sucks.  So here we cruftily copy just enough goop
+       ;; out of disp-table.el so that a display table can be
+       ;; created, and thereby avoid loading disp-table.
+       (put 'display-table 'char-table-extra-slots 6)
+       (setq tab (make-char-table 'display-table nil))
+       (while (< i 256)
+         (aset tab i (vector i))
+         (setq i (1+ i)))
+       (setq buffer-display-table tab)))))
 
 (defun vm-url-decode-string (string)
   (vm-with-string-as-temp-buffer string 'vm-url-decode-buffer))
 
 (defun vm-url-decode-buffer ()
   (let ((case-fold-search nil)
-	(hex-digit-alist '((?0 .  0)  (?1 .  1)  (?2 .  2)  (?3 .  3)
-			   (?4 .  4)  (?5 .  5)  (?6 .  6)  (?7 .  7)
-			   (?8 .  8)  (?9 .  9)  (?A . 10)  (?B . 11)
-			   (?C . 12)  (?D . 13)  (?E . 14)  (?F . 15)))
-	char)
+    (hex-digit-alist '((?0 .  0)  (?1 .  1)  (?2 .  2)  (?3 .  3)
+               (?4 .  4)  (?5 .  5)  (?6 .  6)  (?7 .  7)
+               (?8 .  8)  (?9 .  9)  (?A . 10)  (?B . 11)
+               (?C . 12)  (?D . 13)  (?E . 14)  (?F . 15)))
+    char)
     (save-excursion
       (goto-char (point-min))
       (while (re-search-forward "%[0-9A-F][0-9A-F]" nil t)
-	(insert-char (+ (* (cdr (assq (char-after (- (point) 2))
-				      hex-digit-alist))
-			   16)
-			(cdr (assq (char-after (- (point) 1))
-				   hex-digit-alist)))
-		     1)
-	(delete-region (- (point) 1) (- (point) 4))))))
+    (insert-char (+ (* (cdr (assq (char-after (- (point) 2))
+                      hex-digit-alist))
+               16)
+            (cdr (assq (char-after (- (point) 1))
+                   hex-digit-alist)))
+             1)
+    (delete-region (- (point) 1) (- (point) 4))))))
 
 (defun vm-md5-region (start end)
   (if (fboundp 'md5)
       (md5 (current-buffer) start end)
     (let ((buffer nil)
-	  (retval nil)
-	  (curbuf (current-buffer)))
+      (retval nil)
+      (curbuf (current-buffer)))
       (unwind-protect
-	  (save-excursion
-	    (setq buffer (vm-make-work-buffer))
-	    (set-buffer buffer)
-	    (insert-buffer-substring curbuf start end)
-	    ;; call-process-region calls write-region.
-	    ;; don't let it do CR -> LF translation.
-	    (setq selective-display nil)
-	    (setq retval
-		  (call-process-region (point-min) (point-max)
-				       (or shell-file-name "/bin/sh")
-				       t buffer nil
-				       shell-command-switch
-				       vm-pop-md5-program))
-	    (if (not (equal retval 0))
-		(progn
-		  (error "%s failed: exited with code %s"
-			 vm-pop-md5-program retval)))
-	    (goto-char (point-min))
-	    (if (or (re-search-forward "[^0-9a-f\n]" nil t)
-		    (< (point-max) 32))
-		(error "%s produced bogus MD5 digest '%s'"
-		       vm-pop-md5-program 
-		       (vm-buffer-substring-no-properties (point-min) 
-							  (point-max))))
-	    ;; MD5 digest is 32 chars long
-	    ;; mddriver adds a newline to make neaten output for tty
-	    ;; viewing, make sure we leave it behind.
-	    (vm-buffer-substring-no-properties (point-min) (+ (point-min) 32)))
-	(and buffer (kill-buffer buffer))))))
+      (save-excursion
+        (setq buffer (vm-make-work-buffer))
+        (set-buffer buffer)
+        (insert-buffer-substring curbuf start end)
+        ;; call-process-region calls write-region.
+        ;; don't let it do CR -> LF translation.
+        (setq selective-display nil)
+        (setq retval
+          (call-process-region (point-min) (point-max)
+                       (or shell-file-name "/bin/sh")
+                       t buffer nil
+                       shell-command-switch
+                       vm-pop-md5-program))
+        (if (not (equal retval 0))
+        (progn
+          (error "%s failed: exited with code %s"
+             vm-pop-md5-program retval)))
+        (goto-char (point-min))
+        (if (or (re-search-forward "[^0-9a-f\n]" nil t)
+                (< (point-max) 32))
+            (error "%s produced bogus MD5 digest '%s'"
+                     vm-pop-md5-program
+                     (vm-buffer-substring-no-properties (point-min)
+                                                        (point-max))))
+        ;; MD5 digest is 32 chars long
+        ;; mddriver adds a newline to make neaten output for tty
+        ;; viewing, make sure we leave it behind.
+        (vm-buffer-substring-no-properties (point-min) (+ (point-min) 32)))
+    (and buffer (kill-buffer buffer))))))
 
 ;; output is in hex
 (defun vm-md5-string (string)
@@ -886,37 +886,37 @@
       (md5 string)
     (vm-with-string-as-temp-buffer
      string (function
-	     (lambda ()
-	       (goto-char (point-min))
-	       (insert (vm-md5-region (point-min) (point-max)))
-	       (delete-region (point) (point-max)))))))
+         (lambda ()
+           (goto-char (point-min))
+           (insert (vm-md5-region (point-min) (point-max)))
+           (delete-region (point) (point-max)))))))
 
 ;; output is the raw digest bits, not hex
 (defun vm-md5-raw-string (s)
   (setq s (vm-md5-string s))
   (let ((raw (make-string 16 0))
-	(i 0) n
-	(hex-digit-alist '((?0 .  0)  (?1 .  1)  (?2 .  2)  (?3 .  3)
-			   (?4 .  4)  (?5 .  5)  (?6 .  6)  (?7 .  7)
-			   (?8 .  8)  (?9 .  9)  (?A . 10)  (?B . 11)
-			   (?C . 12)  (?D . 13)  (?E . 14)  (?F . 15)
-			   ;; some mailer uses lower-case hex
-			   ;; digits despite this being forbidden
-			   ;; by the MIME spec.
-			   (?a . 10)  (?b . 11)  (?c . 12)  (?d . 13)
-			   (?e . 14)  (?f . 15))))
+    (i 0) n
+    (hex-digit-alist '((?0 .  0)  (?1 .  1)  (?2 .  2)  (?3 .  3)
+               (?4 .  4)  (?5 .  5)  (?6 .  6)  (?7 .  7)
+               (?8 .  8)  (?9 .  9)  (?A . 10)  (?B . 11)
+               (?C . 12)  (?D . 13)  (?E . 14)  (?F . 15)
+               ;; some mailer uses lower-case hex
+               ;; digits despite this being forbidden
+               ;; by the MIME spec.
+               (?a . 10)  (?b . 11)  (?c . 12)  (?d . 13)
+               (?e . 14)  (?f . 15))))
     (while (< i 32)
       (setq n (+ (* (cdr (assoc (aref s i) hex-digit-alist)) 16)
-		 (cdr (assoc (aref s (1+ i)) hex-digit-alist))))
+         (cdr (assoc (aref s (1+ i)) hex-digit-alist))))
       (aset raw (/ i 2) n)
       (setq i (+ i 2)))
     raw ))
 
 (defun vm-xor-string (s1 s2)
   (let ((len (length s1))
-	result (i 0))
+    result (i 0))
     (if (/= len (length s2))
-	(error "strings not of equal length"))
+    (error "strings not of equal length"))
     (setq result (make-string len 0))
     (while (< i len)
       (aset result i (logxor (aref s1 i) (aref s2 i)))
Only in vm-hacked: vm-misc.elc
Only in vm-hacked: vm-motion.elc
Only in vm-hacked: vm-mouse.elc
Only in vm-hacked: vm-page.elc
diff -u vm-6.95/vm-pop.el vm-hacked/vm-pop.el
--- vm-6.95/vm-pop.el	Sat Jul 21 08:17:59 2001
+++ vm-hacked/vm-pop.el	Mon Aug 27 22:00:50 2001
@@ -36,442 +36,475 @@
 ;; same messages again and again.
 (defun vm-pop-move-mail (source destination)
   (let ((process nil)
-	(folder-type vm-folder-type)
-	(m-per-session vm-pop-messages-per-session)
-	(b-per-session vm-pop-bytes-per-session)
-	(handler (and (fboundp 'find-file-name-handler)
-		      (condition-case ()
-			  (find-file-name-handler source 'vm-pop-move-mail)
-			(wrong-number-of-arguments
-			  (find-file-name-handler source)))))
-	(popdrop (vm-safe-popdrop-string source))
-	(statblob nil)
-	(can-uidl t)
-	(msgid (list nil (vm-popdrop-sans-password source) 'uidl))
-	(pop-retrieved-messages vm-pop-retrieved-messages)
-	auto-expunge x
-	mailbox-count mailbox-size message-size response
-	n (retrieved 0) retrieved-bytes process-buffer uidl)
+    (folder-type vm-folder-type)
+    (m-per-session vm-pop-messages-per-session)
+    (b-per-session vm-pop-bytes-per-session)
+    (handler (and (fboundp 'find-file-name-handler)
+              (condition-case ()
+              (find-file-name-handler source 'vm-pop-move-mail)
+            (wrong-number-of-arguments
+              (find-file-name-handler source)))))
+    (popdrop (vm-safe-popdrop-string source))
+    (statblob nil)
+    (can-uidl t)
+    (msgid (list nil (vm-popdrop-sans-password source) 'uidl))
+    (pop-retrieved-messages vm-pop-retrieved-messages)
+    auto-expunge x
+    mailbox-count mailbox-size message-size response
+    n (retrieved 0) retrieved-bytes process-buffer uidl)
     (setq auto-expunge (cond ((setq x (assoc source vm-pop-auto-expunge-alist))
-			      (cdr x))
-			     ((setq x (assoc (vm-popdrop-sans-password source)
-					     vm-pop-auto-expunge-alist))
-			      (cdr x))
-			     (t vm-pop-expunge-after-retrieving)))
+                  (cdr x))
+                 ((setq x (assoc (vm-popdrop-sans-password source)
+                         vm-pop-auto-expunge-alist))
+                  (cdr x))
+                 (t vm-pop-expunge-after-retrieving)))
     (unwind-protect
-	(catch 'done
-	  (if handler
-	      (throw 'done
-		     (funcall handler 'vm-pop-move-mail source destination)))
-	  (setq process (vm-pop-make-session source))
-	  (or process (throw 'done nil))
-	  (setq process-buffer (process-buffer process))
-	  (save-excursion
-	    (set-buffer process-buffer)
-	    (setq vm-folder-type (or folder-type vm-default-folder-type))
-	    ;; find out how many messages are in the box.
-	    (vm-pop-send-command process "STAT")
-	    (setq response (vm-pop-read-stat-response process)
-		  mailbox-count (nth 0 response)
-		  mailbox-size (nth 1 response))
-	    ;; forget it if the command fails
-	    ;; or if there are no messages present.
-	    (if (or (null mailbox-count)
-		    (< mailbox-count 1))
-		(throw 'done nil))
-	    ;; loop through the maildrop retrieving and deleting
-	    ;; messages as we go.
-	    (setq n 1 retrieved-bytes 0)
-	    (setq statblob (vm-pop-start-status-timer))
-	    (vm-set-pop-stat-x-box statblob popdrop)
-	    (vm-set-pop-stat-x-maxmsg statblob mailbox-count)
-	    (while (and (<= n mailbox-count)
-			(or (not (natnump m-per-session))
-			    (< retrieved m-per-session))
-			(or (not (natnump b-per-session))
-			    (< retrieved-bytes b-per-session)))
-	      (catch 'skip
-		(vm-set-pop-stat-x-currmsg statblob n)
-		(if can-uidl
-		    (condition-case nil
-			(let (list)
-			  (vm-pop-send-command process (format "UIDL %d" n))
-			  (setq response (vm-pop-read-response process t))
-			  (if (null response)
-			      (signal 'vm-cant-uidl nil))
-			  (setq list (vm-parse response "\\([\041-\176]+\\) *")
-				uidl (nth 2 list))
-			  (if (null uidl)
-			      (signal 'vm-cant-uidl nil))
-			  (setcar msgid uidl)
-			  (if (member msgid pop-retrieved-messages)
-			      (progn
-				(if vm-pop-ok-to-ask
-				    (message
-				     "Skipping message %d (of %d) from %s (retrieved already)..."
-				     n mailbox-count popdrop))
-				(throw 'skip t))))
-		      (vm-cant-uidl
-		       ;; something failed, so UIDL must not be working.
-		       (if (and (not auto-expunge)
-				(or (not vm-pop-ok-to-ask)
-				    (not (vm-pop-ask-about-no-uidl popdrop))))
-			   (progn
-			     (message "Skipping mailbox %s (no UIDL support)"
-				      popdrop)
-			     (throw 'done (not (equal retrieved 0))))
-			 ;; user doesn't care, so go ahead and
-			 ;; expunge from the server
-			 (setq can-uidl nil
-			       msgid nil)))))
-		(vm-pop-send-command process (format "LIST %d" n))
-		(setq message-size (vm-pop-read-list-response process))
-		(vm-set-pop-stat-x-need statblob message-size)
-		(if (and (integerp vm-pop-max-message-size)
-			 (> message-size vm-pop-max-message-size)
-			 (progn
-			   (setq response
-				 (if vm-pop-ok-to-ask
-				     (vm-pop-ask-about-large-message
-				      process popdrop message-size n)
-				   'skip))
-			   (not (eq response 'retrieve))))
-		    (progn
-		      (if (eq response 'delete)
-			  (progn
-			    (message "Deleting message %d..." n)
-			    (vm-pop-send-command process (format "DELE %d" n))
-			    (and (null (vm-pop-read-response process))
-				 (throw 'done (not (equal retrieved 0)))))
-			(if vm-pop-ok-to-ask
-			    (message "Skipping message %d..." n)
-			  (message
-			   "Skipping message %d in %s, too large (%d > %d)..."
-			   n popdrop message-size vm-pop-max-message-size)))
-		      (throw 'skip t)))
-		(message "Retrieving message %d (of %d) from %s..."
-			 n mailbox-count popdrop)
-		(vm-pop-send-command process (format "RETR %d" n))
-		(and (null (vm-pop-read-response process))
-		     (throw 'done (not (equal retrieved 0))))
-		(and (null (vm-pop-retrieve-to-crashbox process destination
-							statblob))
-		     (throw 'done (not (equal retrieved 0))))
-		(vm-increment retrieved)
-		(and b-per-session
-		     (setq retrieved-bytes (+ retrieved-bytes message-size)))
-		(if (and (not auto-expunge) msgid)
-		    (setq pop-retrieved-messages
-			  (cons (copy-sequence msgid)
-				pop-retrieved-messages))
-		  ;; Either the user doesn't want the messages
-		  ;; kept in the mailbox or there's no UIDL
-		  ;; support so there's no way to remember what
-		  ;; messages we've retrieved.  Delete the
-		  ;; message now.
-		  (vm-pop-send-command process (format "DELE %d" n))
-		  ;; DELE can't fail but Emacs or this code might
-		  ;; blow a gasket and spew filth down the
-		  ;; connection, so...
-		  (and (null (vm-pop-read-response process))
-		       (throw 'done (not (equal retrieved 0))))))
-	      (vm-increment n))
-	     (not (equal retrieved 0)) ))
+    (catch 'done
+      (if handler
+          (throw 'done
+             (funcall handler 'vm-pop-move-mail source destination)))
+      (setq process (vm-pop-make-session source))
+      (or process (throw 'done nil))
+      (setq process-buffer (process-buffer process))
+      (save-excursion
+        (set-buffer process-buffer)
+        (setq vm-folder-type (or folder-type vm-default-folder-type))
+        ;; find out how many messages are in the box.
+        (vm-pop-send-command process "STAT")
+        (setq response (vm-pop-read-stat-response process)
+          mailbox-count (nth 0 response)
+          mailbox-size (nth 1 response))
+        ;; forget it if the command fails
+        ;; or if there are no messages present.
+        (if (or (null mailbox-count)
+            (< mailbox-count 1))
+        (throw 'done nil))
+        ;; loop through the maildrop retrieving and deleting
+        ;; messages as we go.
+        (setq n 1 retrieved-bytes 0)
+        (setq statblob (vm-pop-start-status-timer))
+        (vm-set-pop-stat-x-box statblob popdrop)
+        (vm-set-pop-stat-x-maxmsg statblob mailbox-count)
+        (while (and (<= n mailbox-count)
+            (or (not (natnump m-per-session))
+                (< retrieved m-per-session))
+            (or (not (natnump b-per-session))
+                (< retrieved-bytes b-per-session)))
+          (catch 'skip
+        (vm-set-pop-stat-x-currmsg statblob n)
+        (if can-uidl
+            (condition-case nil
+            (let (list)
+              (vm-pop-send-command process (format "UIDL %d" n))
+              (setq response (vm-pop-read-response process t))
+              (if (null response)
+                  (signal 'vm-cant-uidl nil))
+              (setq list (vm-parse response "\\([\041-\176]+\\) *")
+                uidl (nth 2 list))
+              (if (null uidl)
+                  (signal 'vm-cant-uidl nil))
+              (setcar msgid uidl)
+              (if (member msgid pop-retrieved-messages)
+                  (progn
+                (if vm-pop-ok-to-ask
+                    (message
+                     "Skipping message %d (of %d) from %s (retrieved already)..."
+                     n mailbox-count popdrop))
+                (throw 'skip t))))
+              (vm-cant-uidl
+               ;; something failed, so UIDL must not be working.
+               (if (and (not auto-expunge)
+                (or (not vm-pop-ok-to-ask)
+                    (not (vm-pop-ask-about-no-uidl popdrop))))
+               (progn
+                 (message "Skipping mailbox %s (no UIDL support)"
+                      popdrop)
+                 (throw 'done (not (equal retrieved 0))))
+             ;; user doesn't care, so go ahead and
+             ;; expunge from the server
+             (setq can-uidl nil
+                   msgid nil)))))
+        (vm-pop-send-command process (format "LIST %d" n))
+        (setq message-size (vm-pop-read-list-response process))
+        (vm-set-pop-stat-x-need statblob message-size)
+        (if (and (integerp vm-pop-max-message-size)
+             (> message-size vm-pop-max-message-size)
+             (progn
+               (setq response
+                 (if vm-pop-ok-to-ask
+                     (vm-pop-ask-about-large-message
+                      process popdrop message-size n)
+                   'skip))
+               (not (eq response 'retrieve))))
+            (progn
+              (if (eq response 'delete)
+              (progn
+                (message "Deleting message %d..." n)
+                (vm-pop-send-command process (format "DELE %d" n))
+                (and (null (vm-pop-read-response process))
+                 (throw 'done (not (equal retrieved 0)))))
+            (if vm-pop-ok-to-ask
+                (message "Skipping message %d..." n)
+              (message
+               "Skipping message %d in %s, too large (%d > %d)..."
+               n popdrop message-size vm-pop-max-message-size)))
+              (throw 'skip t)))
+        (message "Retrieving message %d (of %d) from %s..."
+             n mailbox-count popdrop)
+        (vm-pop-send-command process (format "RETR %d" n))
+        (and (null (vm-pop-read-response process))
+             (throw 'done (not (equal retrieved 0))))
+        (and (null (vm-pop-retrieve-to-crashbox process destination
+                            statblob (copy-sequence msgid)))
+             (throw 'done (not (equal retrieved 0))))
+        (vm-increment retrieved)
+        (and b-per-session
+             (setq retrieved-bytes (+ retrieved-bytes message-size)))
+        (if (and (not auto-expunge) msgid)
+            (setq pop-retrieved-messages
+              (cons (copy-sequence msgid)
+                pop-retrieved-messages))
+          ;; Either the user doesn't want the messages
+          ;; kept in the mailbox or there's no UIDL
+          ;; support so there's no way to remember what
+          ;; messages we've retrieved.  Delete the
+          ;; message now.
+          (vm-pop-send-command process (format "DELE %d" n))
+          ;; DELE can't fail but Emacs or this code might
+          ;; blow a gasket and spew filth down the
+          ;; connection, so...
+          (and (null (vm-pop-read-response process))
+               (throw 'done (not (equal retrieved 0))))))
+          (vm-increment n))
+         (not (equal retrieved 0)) ))
       (setq vm-pop-retrieved-messages pop-retrieved-messages)
       (if (and (eq vm-flush-interval t) (not (equal retrieved 0)))
-	  (vm-stuff-pop-retrieved))
+      (vm-stuff-pop-retrieved))
       (and statblob (vm-pop-stop-status-timer statblob))
       (if process
-	  (vm-pop-end-session process)))))
+      (vm-pop-end-session process)))))
 
 (defun vm-pop-check-mail (source)
   (let ((process nil)
-	(handler (and (fboundp 'find-file-name-handler)
-		      (condition-case ()
-			  (find-file-name-handler source 'vm-pop-check-mail)
-			(wrong-number-of-arguments
-			 (find-file-name-handler source)))))
-	(retrieved vm-pop-retrieved-messages)
-	(popdrop (vm-popdrop-sans-password source))
-	(count 0)
-	x response)
+    (handler (and (fboundp 'find-file-name-handler)
+              (condition-case ()
+              (find-file-name-handler source 'vm-pop-check-mail)
+            (wrong-number-of-arguments
+             (find-file-name-handler source)))))
+    (retrieved vm-pop-retrieved-messages)
+    (popdrop (vm-popdrop-sans-password source))
+    (count 0)
+    x response)
     (unwind-protect
-	(save-excursion
-	  (catch 'done
-	    (if handler
-		(throw 'done
-		       (funcall handler 'vm-pop-check-mail source)))
-	    (setq process (vm-pop-make-session source))
-	    (or process (throw 'done nil))
-	    (set-buffer (process-buffer process))
-	    (vm-pop-send-command process "UIDL")
-	    (setq response (vm-pop-read-uidl-long-response process))
-	    (if (null response)
-		;; server doesn't understand UIDL
-		nil
-	      (if (null (car response))
-		  ;; (nil . nil) is returned if there are no
-		  ;; messages in the mailbox.
-		  (progn
-		    (vm-store-folder-totals source '(0 0 0 0))
-		    (throw 'done nil))
-		(while response
-		  (if (not (and (setq x (assoc (cdr (car response)) retrieved))
-				(equal (nth 1 x) popdrop)
-				(eq (nth 2 x) 'uidl)))
-		      (vm-increment count))
-		  (setq response (cdr response))))
-	      (vm-store-folder-totals source (list count 0 0 0))
-	      (throw 'done (not (eq count 0))))
-	    (vm-pop-send-command process "STAT")
-	    (setq response (vm-pop-read-stat-response process))
-	    (if (null response)
-		nil
-	      (vm-store-folder-totals source (list (car response) 0 0 0))
-	      (not (equal 0 (car response))))))
+    (save-excursion
+      (catch 'done
+        (if handler
+        (throw 'done
+               (funcall handler 'vm-pop-check-mail source)))
+        (setq process (vm-pop-make-session source))
+        (or process (throw 'done nil))
+        (set-buffer (process-buffer process))
+        (vm-pop-send-command process "UIDL")
+        (setq response (vm-pop-read-uidl-long-response process))
+        (if (null response)
+        ;; server doesn't understand UIDL
+        nil
+          (if (null (car response))
+          ;; (nil . nil) is returned if there are no
+          ;; messages in the mailbox.
+          (progn
+            (vm-store-folder-totals source '(0 0 0 0))
+            (throw 'done nil))
+        (while response
+          (if (not (and (setq x (assoc (cdr (car response)) retrieved))
+                (equal (nth 1 x) popdrop)
+                (eq (nth 2 x) 'uidl)))
+              (vm-increment count))
+          (setq response (cdr response))))
+          (vm-store-folder-totals source (list count 0 0 0))
+          (throw 'done (not (eq count 0))))
+        (vm-pop-send-command process "STAT")
+        (setq response (vm-pop-read-stat-response process))
+        (if (null response)
+        nil
+          (vm-store-folder-totals source (list (car response) 0 0 0))
+          (not (equal 0 (car response))))))
       (and process (vm-pop-end-session process nil vm-pop-ok-to-ask)))))
 
-(defun vm-expunge-pop-messages ()
-  "Deletes all messages from POP mailbox that have already been retrieved
-into the current folder.  VM sends POP DELE commands to all the
-relevant POP servers to remove the messages."
+(defun vm-expunge-pop-messages (&optional sync-only)
+  "Deletes all messages from POP mailbox that have already been
+retrieved into the current folder.  VM sends POP DELE commands to all
+the relevant POP servers to remove the messages. If sync-only is set,
+only deletes messages flagged as deleted."
   (interactive)
   (vm-follow-summary-cursor)
   (vm-select-folder-buffer)
   (vm-check-for-killed-summary)
   (vm-error-if-virtual-folder)
   (let ((process nil)
-	(source nil)
-	(trouble nil)
-	(delete-count 0)
-	(vm-global-block-new-mail t)
-	(vm-pop-ok-to-ask t)
-	popdrop uidl-alist data mp match)
+        (use-marks (eq last-command 'vm-next-command-uses-marks))
+    (source nil)
+    (trouble nil)
+    (delete-count 0)
+    (vm-global-block-new-mail t)
+    (vm-pop-ok-to-ask t)
+        (pop-retrieved-messages vm-pop-retrieved-messages)
+    popdrop uidl-alist data mp match)
     (unwind-protect
-	(save-excursion
-	  (setq vm-pop-retrieved-messages
-		(sort vm-pop-retrieved-messages
-		      (function (lambda (a b)
-				  (cond ((string-lessp (nth 1 a) (nth 1 b)) t)
-					((string-lessp (nth 1 b)
-						       (nth 1 a))
-					 nil)
-					((string-lessp (car a) (car b)) t)
-					(t nil))))))
-	  (setq mp vm-pop-retrieved-messages)
-	  (while mp
-	    (condition-case nil
-		(catch 'replay
-		  (setq data (car mp))
-		  (if (not (equal source (nth 1 data)))
-		      (progn
-			(if process
-			    (progn
-			     (vm-pop-end-session process)
-			     (setq process nil)))
-			(setq source (nth 1 data))
-			(setq popdrop (vm-safe-popdrop-string source))
-			(condition-case nil
-			    (progn
-			      (message "Opening POP session to %s..." popdrop)
-			      (setq process (vm-pop-make-session source))
-			      (if (null process)
-				  (signal 'error nil))
-			      (message "Expunging messages in %s..." popdrop))
-			  (error
-			   (message
-			    "Couldn't open POP session to %s, skipping..."
-			    popdrop)
-			   (setq trouble (cons popdrop trouble))
-			   (sleep-for 2)
-			   (while (equal (nth 1 (car mp)) source)
-			     (setq mp (cdr mp)))
-			   (throw 'replay t)))
-			(set-buffer (process-buffer process))
-			(vm-pop-send-command process "UIDL")
-			(setq uidl-alist
-			      (vm-pop-read-uidl-long-response process))
-			(if (null uidl-alist)
-			    (signal 'vm-uidl-failed nil))))
-		  (if (setq match (rassoc (car data) uidl-alist))
-		      (progn
-			(vm-pop-send-command process
-					     (format "DELE %s" (car match)))
-			(if (null (vm-pop-read-response process))
-			    (signal 'vm-dele-failed nil))
-			(vm-increment delete-count)))
-		  (setq mp (cdr mp)))
-	      (vm-dele-failed
-	       (message "DELE %s failed on %s, skipping rest of mailbox..."
-			(car match) popdrop)
-	       (setq trouble (cons popdrop trouble))
-	       (sleep-for 2)
-	       (while (equal (nth 1 (car mp)) source)
-		 (setq mp (cdr mp)))
-	       (throw 'replay t))
-	      (vm-uidl-failed
-	       (message "UIDL %s failed on %s, skipping this mailbox..."
-			(car match) popdrop)
-	       (setq trouble (cons popdrop trouble))
-	       (sleep-for 2)
-	       (while (equal (nth 1 (car mp)) source)
-		 (setq mp (cdr mp)))
-	       (throw 'replay t))))
-	  (if trouble
-	      (progn
-		(set-buffer (get-buffer-create "*POP Expunge Trouble*"))
-		(setq buffer-read-only nil)
-		(erase-buffer)
-		(insert (format "%s POP message%s expunged.\n\n"
-				(if (zerop delete-count) "No" delete-count)
-				(if (= delete-count 1) "" "s")))
-		(insert "VM had problems expunging messages from:\n")
-		(nreverse trouble)
-		(setq mp trouble)
-		(while mp
-		  (insert "   " (car mp) "\n")
-		  (setq mp (cdr mp)))
-		(setq buffer-read-only t)
-		(display-buffer (current-buffer)))
-	    (message "%s POP message%s expunged."
-		     (if (zerop delete-count) "No" delete-count)
-		     (if (= delete-count 1) "" "s"))))
+    (save-excursion
+      ;; if sync-only is set, pop-retrieved-messages is munged to only
+      ;; list messages that are flagged for deletion.
+      (if sync-only
+          (progn
+            (setq pop-retrieved-messages nil)
+            (let ((mp vm-message-list))
+              (while mp
+                (let ((spool-data (vm-spool-data-of (car mp))))
+                  (if (and spool-data
+                           (vm-deleted-flag (car mp))
+                           (or (not use-marks)
+                               (vm-mark-of (car mp))))
+                      (setq pop-retrieved-messages (cons
+                                                    (copy-sequence spool-data)
+                                                    pop-retrieved-messages)))
+                  (setq mp (cdr mp)))))))
+      ;; now do happy-fun-sorting-thing
+      (setq pop-retrieved-messages
+        (sort pop-retrieved-messages
+              (function (lambda (a b)
+                  (cond ((string-lessp (nth 1 a) (nth 1 b)) t)
+                    ((string-lessp (nth 1 b)
+                               (nth 1 a))
+                     nil)
+                    ((string-lessp (car a) (car b)) t)
+                    (t nil))))))
+      (setq mp pop-retrieved-messages)
+      (while mp
+        (condition-case nil
+        (catch 'replay
+          (setq data (car mp))
+          (if (not (equal source (nth 1 data)))
+              (progn
+            (if process
+                (progn
+                 (vm-pop-end-session process)
+                 (setq process nil)))
+            (setq source (nth 1 data))
+            (setq popdrop (vm-safe-popdrop-string source))
+            (condition-case nil
+                (progn
+                  (message "Opening POP session to %s..." popdrop)
+                  (setq process (vm-pop-make-session source))
+                  (if (null process)
+                  (signal 'error nil))
+                  (message "Expunging messages in %s..." popdrop))
+              (error
+               (message
+                "Couldn't open POP session to %s, skipping..."
+                popdrop)
+               (setq trouble (cons popdrop trouble))
+               (sleep-for 2)
+               (while (equal (nth 1 (car mp)) source)
+                 (setq mp (cdr mp)))
+               (throw 'replay t)))
+            (set-buffer (process-buffer process))
+            (vm-pop-send-command process "UIDL")
+            (setq uidl-alist
+                  (vm-pop-read-uidl-long-response process))
+            (if (null uidl-alist)
+                (signal 'vm-uidl-failed nil))))
+          (if (setq match (rassoc (car data) uidl-alist))
+              (progn
+            (vm-pop-send-command process
+                         (format "DELE %s" (car match)))
+            (if (null (vm-pop-read-response process))
+                (signal 'vm-dele-failed nil))
+            (vm-increment delete-count)))
+          (setq mp (cdr mp)))
+          (vm-dele-failed
+           (message "DELE %s failed on %s, skipping rest of mailbox..."
+            (car match) popdrop)
+           (setq trouble (cons popdrop trouble))
+           (sleep-for 2)
+           (while (equal (nth 1 (car mp)) source)
+         (setq mp (cdr mp)))
+           (throw 'replay t))
+          (vm-uidl-failed
+           (message "UIDL %s failed on %s, skipping this mailbox..."
+            (car match) popdrop)
+           (setq trouble (cons popdrop trouble))
+           (sleep-for 2)
+           (while (equal (nth 1 (car mp)) source)
+         (setq mp (cdr mp)))
+           (throw 'replay t))))
+      (if trouble
+          (progn
+        (set-buffer (get-buffer-create "*POP Expunge Trouble*"))
+        (setq buffer-read-only nil)
+        (erase-buffer)
+        (insert (format "%s POP message%s expunged.\n\n"
+                (if (zerop delete-count) "No" delete-count)
+                (if (= delete-count 1) "" "s")))
+        (insert "VM had problems expunging messages from:\n")
+        (nreverse trouble)
+        (setq mp trouble)
+        (while mp
+          (insert "   " (car mp) "\n")
+          (setq mp (cdr mp)))
+        (setq buffer-read-only t)
+        (display-buffer (current-buffer)))
+        (message "%s POP message%s expunged."
+             (if (zerop delete-count) "No" delete-count)
+             (if (= delete-count 1) "" "s"))))
       (and process (vm-pop-end-session process)))
-    (or trouble (setq vm-pop-retrieved-messages nil))))
+    (or trouble (if sync-only
+                    (progn ;; sync up pop-retrieved-messages properly XXX
+                      (setq vm-pop-retrieved-messages nil)
+                      (let ((mp vm-message-list))
+                        (while mp
+                          (let ((spool-data (vm-spool-data-of (car mp))))
+                            (if spool-data
+                                (setq vm-pop-retrieved-messages
+                                      (cons
+                                       (copy-sequence spool-data)
+                                       vm-pop-retrieved-messages)))
+                            (setq mp (cdr mp))))))
+                  (setq vm-pop-retrieved-messages nil)))))
+
 
 (defun vm-pop-make-session (source)
   (let ((process-to-shutdown nil)
-	process
-	(popdrop (vm-safe-popdrop-string source))
-	(coding-system-for-read (vm-binary-coding-system))
-	(coding-system-for-write (vm-binary-coding-system))
-	greeting timestamp
-	host port auth user pass source-list process-buffer source-nopwd)
+    process
+    (popdrop (vm-safe-popdrop-string source))
+    (coding-system-for-read (vm-binary-coding-system))
+    (coding-system-for-write (vm-binary-coding-system))
+    greeting timestamp
+    host port auth user pass source-list process-buffer source-nopwd)
     (unwind-protect
-	(catch 'done
-	  ;; parse the maildrop
-	  (setq source-list (vm-parse source "\\([^:]+\\):?")
-		host (nth 0 source-list)
-		port (nth 1 source-list)
-		auth (nth 2 source-list)
-		user (nth 3 source-list)
-		pass (nth 4 source-list)
-		source-nopwd (vm-popdrop-sans-password source))
-	  ;; carp if parts are missing
-	  (if (null host)
-	      (error "No host in POP maildrop specification, \"%s\""
-		     source))
-	  (if (null port)
-	      (error "No port in POP maildrop specification, \"%s\""
-		     source))
-	  (if (string-match "^[0-9]+$" port)
-	      (setq port (string-to-int port)))
-	  (if (null auth)
-	      (error
-	       "No authentication method in POP maildrop specification, \"%s\""
-	       source))
-	  (if (null user)
-	      (error "No user in POP maildrop specification, \"%s\""
-		     source))
-	  (if (null pass)
-	      (error "No password in POP maildrop specification, \"%s\""
-		     source))
-	  (if (equal pass "*")
-	      (progn
-		(setq pass (car (cdr (assoc source-nopwd vm-pop-passwords))))
-		(if (null pass)
-		    (if (null vm-pop-ok-to-ask)
-			(progn (message "Need password for %s" popdrop)
-			       (throw 'done nil))
-		      (setq pass
-			    (vm-read-password
-			     (format "POP password for %s: "
-				     popdrop)))))))
-	  ;; save the password for the sake of
-	  ;; vm-expunge-pop-messages, which passes password-less
-	  ;; popdrop specifications to vm-make-pop-session.
-	  (if (null (assoc source-nopwd vm-pop-passwords))
-	      (setq vm-pop-passwords (cons (list source-nopwd pass)
-					   vm-pop-passwords)))
-	  ;; get the trace buffer
-	  (setq process-buffer
-		(vm-make-work-buffer (format "trace of POP session to %s"
-					     host)))
-	  (save-excursion
-	    (set-buffer process-buffer)
-	    (buffer-disable-undo process-buffer)
-	    ;; clear the trace buffer of old output
-	    (erase-buffer)
-	    ;; Tell MULE not to mess with the text.
-	    (if (fboundp 'set-buffer-file-coding-system)
-		(set-buffer-file-coding-system (vm-binary-coding-system) t))
-	    (insert "starting POP session " (current-time-string) "\n")
-	    (insert (format "connecting to %s:%s\n" host port))
-	    ;; open the connection to the server
-	    (setq process (open-network-stream "POP" process-buffer host port))
-	    (and (null process) (throw 'done nil))
-	    (insert "connected\n")
-	    (process-kill-without-query process)
-	    (make-local-variable 'vm-pop-read-point)
-	    (setq vm-pop-read-point (point))
-	    (if (null (setq greeting (vm-pop-read-response process t)))
-		(progn (delete-process process)
-		       (throw 'done nil)))
-	    (setq process-to-shutdown process)
-	    ;; authentication
-	    (cond ((equal auth "pass")
-		   (vm-pop-send-command process (format "USER %s" user))
-		   (and (null (vm-pop-read-response process))
-			(throw 'done nil))
-		   (vm-pop-send-command process (format "PASS %s" pass))
-		   (if (null (vm-pop-read-response process))
-		       (progn
-			 (setq vm-pop-passwords
-			       (delete (list source-nopwd pass)
-				       vm-pop-passwords))
-			 (message "POP password for %s incorrect" popdrop)
-			 ;; don't sleep unless we're running synchronously.
-			 (if vm-pop-ok-to-ask
-			     (sleep-for 2))
-			 (throw 'done nil))))
-		  ((equal auth "rpop")
-		   (vm-pop-send-command process (format "USER %s" user))
-		   (and (null (vm-pop-read-response process))
-			(throw 'done nil))
-		   (vm-pop-send-command process (format "RPOP %s" pass))
-		   (and (null (vm-pop-read-response process))
-			(throw 'done nil)))
-		  ((equal auth "apop")
-		   (setq timestamp (vm-parse greeting "[^<]+\\(<[^>]+>\\)")
-			 timestamp (car timestamp))
-		   (if (null timestamp)
-		       (progn
-			 (goto-char (point-max))
+    (catch 'done
+      ;; parse the maildrop
+      (setq source-list (vm-parse source "\\([^:]+\\):?")
+        host (nth 0 source-list)
+        port (nth 1 source-list)
+        auth (nth 2 source-list)
+        user (nth 3 source-list)
+        pass (nth 4 source-list)
+        source-nopwd (vm-popdrop-sans-password source))
+      ;; carp if parts are missing
+      (if (null host)
+          (error "No host in POP maildrop specification, \"%s\""
+             source))
+      (if (null port)
+          (error "No port in POP maildrop specification, \"%s\""
+             source))
+      (if (string-match "^[0-9]+$" port)
+          (setq port (string-to-int port)))
+      (if (null auth)
+          (error
+           "No authentication method in POP maildrop specification, \"%s\""
+           source))
+      (if (null user)
+          (error "No user in POP maildrop specification, \"%s\""
+             source))
+      (if (null pass)
+          (error "No password in POP maildrop specification, \"%s\""
+             source))
+      (if (equal pass "*")
+          (progn
+        (setq pass (car (cdr (assoc source-nopwd vm-pop-passwords))))
+        (if (null pass)
+            (if (null vm-pop-ok-to-ask)
+            (progn (message "Need password for %s" popdrop)
+                   (throw 'done nil))
+              (setq pass
+                (vm-read-password
+                 (format "POP password for %s: "
+                     popdrop)))))))
+      ;; save the password for the sake of
+      ;; vm-expunge-pop-messages, which passes password-less
+      ;; popdrop specifications to vm-make-pop-session.
+      (if (null (assoc source-nopwd vm-pop-passwords))
+          (setq vm-pop-passwords (cons (list source-nopwd pass)
+                       vm-pop-passwords)))
+      ;; get the trace buffer
+      (setq process-buffer
+        (vm-make-work-buffer (format "trace of POP session to %s"
+                         host)))
+      (save-excursion
+        (set-buffer process-buffer)
+        (buffer-disable-undo process-buffer)
+        ;; clear the trace buffer of old output
+        (erase-buffer)
+        ;; Tell MULE not to mess with the text.
+        (if (fboundp 'set-buffer-file-coding-system)
+        (set-buffer-file-coding-system (vm-binary-coding-system) t))
+        (insert "starting POP session " (current-time-string) "\n")
+        (insert (format "connecting to %s:%s\n" host port))
+        ;; open the connection to the server
+        (setq process (open-network-stream "POP" process-buffer host port))
+        (and (null process) (throw 'done nil))
+        (insert "connected\n")
+        (process-kill-without-query process)
+        (make-local-variable 'vm-pop-read-point)
+        (setq vm-pop-read-point (point))
+        (if (null (setq greeting (vm-pop-read-response process t)))
+        (progn (delete-process process)
+               (throw 'done nil)))
+        (setq process-to-shutdown process)
+        ;; authentication
+        (cond ((equal auth "pass")
+           (vm-pop-send-command process (format "USER %s" user))
+           (and (null (vm-pop-read-response process))
+            (throw 'done nil))
+           (vm-pop-send-command process (format "PASS %s" pass))
+           (if (null (vm-pop-read-response process))
+               (progn
+             (setq vm-pop-passwords
+                   (delete (list source-nopwd pass)
+                       vm-pop-passwords))
+             (message "POP password for %s incorrect" popdrop)
+             ;; don't sleep unless we're running synchronously.
+             (if vm-pop-ok-to-ask
+                 (sleep-for 2))
+             (throw 'done nil))))
+          ((equal auth "rpop")
+           (vm-pop-send-command process (format "USER %s" user))
+           (and (null (vm-pop-read-response process))
+            (throw 'done nil))
+           (vm-pop-send-command process (format "RPOP %s" pass))
+           (and (null (vm-pop-read-response process))
+            (throw 'done nil)))
+          ((equal auth "apop")
+           (setq timestamp (vm-parse greeting "[^<]+\\(<[^>]+>\\)")
+             timestamp (car timestamp))
+           (if (null timestamp)
+               (progn
+             (goto-char (point-max))
    (insert-before-markers "<<< ooops, no timestamp found in greeting! >>>\n")
-			 (message "Server of %s does not support APOP" popdrop)
-			 ;; don't sleep unless we're running synchronously
-			 (if vm-pop-ok-to-ask
-			     (sleep-for 2))
-			 (throw 'done nil)))
-		   (vm-pop-send-command
-		    process
-		    (format "APOP %s %s"
-			    user
-			    (vm-pop-md5 (concat timestamp pass))))
-		   (if (null (vm-pop-read-response process))
-		       (progn
-			 (setq vm-pop-passwords
-			       (delete (list source-nopwd pass)
-				       vm-pop-passwords))
-			 (message "POP password for %s incorrect" popdrop)
-			 (if vm-pop-ok-to-ask
-			     (sleep-for 2))
-			 (throw 'done nil))))
-		  (t (error "Don't know how to authenticate using %s" auth)))
-	    (setq process-to-shutdown nil)
-	    process ))
+             (message "Server of %s does not support APOP" popdrop)
+             ;; don't sleep unless we're running synchronously
+             (if vm-pop-ok-to-ask
+                 (sleep-for 2))
+             (throw 'done nil)))
+           (vm-pop-send-command
+            process
+            (format "APOP %s %s"
+                user
+                (vm-pop-md5 (concat timestamp pass))))
+           (if (null (vm-pop-read-response process))
+               (progn
+             (setq vm-pop-passwords
+                   (delete (list source-nopwd pass)
+                       vm-pop-passwords))
+             (message "POP password for %s incorrect" popdrop)
+             (if vm-pop-ok-to-ask
+                 (sleep-for 2))
+             (throw 'done nil))))
+          (t (error "Don't know how to authenticate using %s" auth)))
+        (setq process-to-shutdown nil)
+        process ))
       (if process-to-shutdown
-	  (vm-pop-end-session process-to-shutdown t)))))
+      (vm-pop-end-session process-to-shutdown t)))))
 
 (defun vm-pop-end-session (process &optional keep-buffer verbose)
   (save-excursion
@@ -485,21 +518,21 @@
     ;; So we provide an option and let the user decide what
     ;; works best for them.
     (if vm-pop-read-quit-response
-	(progn
-	  (and verbose
-	       (message "Waiting for response to POP QUIT command..."))
-	  (vm-pop-read-response process)
-	  (and verbose
-	       (message "Waiting for response to POP QUIT command... done"))))
+    (progn
+      (and verbose
+           (message "Waiting for response to POP QUIT command..."))
+      (vm-pop-read-response process)
+      (and verbose
+           (message "Waiting for response to POP QUIT command... done"))))
     (if (not keep-buffer)
-	(kill-buffer (process-buffer process))
+    (kill-buffer (process-buffer process))
       (save-excursion
        (set-buffer (process-buffer process))
        (rename-buffer (concat "saved " (buffer-name)) t)
        (vm-keep-some-buffers (current-buffer) 'vm-kept-pop-buffers
-			     vm-pop-keep-failed-trace-buffers)))
+                 vm-pop-keep-failed-trace-buffers)))
     (if (fboundp 'add-async-timeout)
-	(add-async-timeout 2 'delete-process process)
+    (add-async-timeout 2 'delete-process process)
       (run-at-time 2 nil 'delete-process process))))
 
 (defun vm-pop-stat-timer (o) (aref o 0))
@@ -528,7 +561,7 @@
 
 (defun vm-pop-start-status-timer ()
   (let ((blob (make-vector 11 nil))
-	timer)
+    timer)
     (setq timer (add-timeout 5 'vm-pop-report-retrieval-status blob 5))
     (vm-set-pop-stat-timer blob timer)
     blob ))
@@ -540,24 +573,24 @@
 
 (defun vm-pop-report-retrieval-status (o)
   (cond ((null (vm-pop-stat-x-got o)) t)
-	;; should not be possible, but better safe...
-	((not (eq (vm-pop-stat-x-box o) (vm-pop-stat-y-box o))) t)
-	((not (eq (vm-pop-stat-x-currmsg o) (vm-pop-stat-y-currmsg o))) t)
-	(t (message "Retrieving message %d (of %d) from %s, %s..."
-		    (vm-pop-stat-x-currmsg o)
-		    (vm-pop-stat-x-maxmsg o)
-		    (vm-pop-stat-x-box o)
-		    (format "%d%s of %d%s"
-			    (vm-pop-stat-x-got o)
-			    (if (> (vm-pop-stat-x-got o)
-				   (vm-pop-stat-x-need o))
-				"!"
-			      "")
-			    (vm-pop-stat-x-need o)
-			    (if (eq (vm-pop-stat-x-got o)
-				    (vm-pop-stat-y-got o))
-				" (stalled)"
-			      "")))))
+    ;; should not be possible, but better safe...
+    ((not (eq (vm-pop-stat-x-box o) (vm-pop-stat-y-box o))) t)
+    ((not (eq (vm-pop-stat-x-currmsg o) (vm-pop-stat-y-currmsg o))) t)
+    (t (message "Retrieving message %d (of %d) from %s, %s..."
+            (vm-pop-stat-x-currmsg o)
+            (vm-pop-stat-x-maxmsg o)
+            (vm-pop-stat-x-box o)
+            (format "%d%s of %d%s"
+                (vm-pop-stat-x-got o)
+                (if (> (vm-pop-stat-x-got o)
+                   (vm-pop-stat-x-need o))
+                "!"
+                  "")
+                (vm-pop-stat-x-need o)
+                (if (eq (vm-pop-stat-x-got o)
+                    (vm-pop-stat-y-got o))
+                " (stalled)"
+                  "")))))
   (vm-set-pop-stat-y-box o (vm-pop-stat-x-box o))
   (vm-set-pop-stat-y-currmsg o (vm-pop-stat-x-currmsg o))
   (vm-set-pop-stat-y-maxmsg o (vm-pop-stat-x-maxmsg o))
@@ -575,7 +608,7 @@
 
 (defun vm-pop-read-response (process &optional return-response-string)
   (let ((case-fold-search nil)
-	 match-end)
+     match-end)
     (goto-char vm-pop-read-point)
     (while (not (search-forward "\r\n" nil t))
       (accept-process-output process)
@@ -583,11 +616,11 @@
     (setq match-end (point))
     (goto-char vm-pop-read-point)
     (if (not (looking-at "+OK"))
-	(progn (setq vm-pop-read-point match-end) nil)
+    (progn (setq vm-pop-read-point match-end) nil)
       (setq vm-pop-read-point match-end)
       (if return-response-string
-	  (buffer-substring (point) match-end)
-	t ))))
+      (buffer-substring (point) match-end)
+    t ))))
 
 (defun vm-pop-read-past-dot-sentinel-line (process)
   (let ((case-fold-search nil))
@@ -596,120 +629,120 @@
       (beginning-of-line)
       ;; save-excursion doesn't work right
       (let ((opoint (point)))
-	(accept-process-output process)
-	(goto-char opoint)))
+    (accept-process-output process)
+    (goto-char opoint)))
     (setq vm-pop-read-point (point))))
 
 (defun vm-pop-read-stat-response (process)
   (let ((response (vm-pop-read-response process t))
-	list)
+    list)
     (if (null response)
-	nil
+    nil
       (setq list (vm-parse response "\\([^ ]+\\) *"))
       (list (string-to-int (nth 1 list)) (string-to-int (nth 2 list))))))
 
 (defun vm-pop-read-list-response (process)
   (let ((response (vm-pop-read-response process t)))
     (and response
-	 (string-to-int (nth 2 (vm-parse response "\\([^ ]+\\) *"))))))
+     (string-to-int (nth 2 (vm-parse response "\\([^ ]+\\) *"))))))
 
 (defun vm-pop-read-uidl-long-response (process)
   (let ((start vm-pop-read-point)
-	(list nil)
-	n uidl)
+    (list nil)
+    n uidl)
     (catch 'done
       (goto-char start)
       (while (not (re-search-forward "^\\.\r\n\\|^-ERR .*$" nil 0))
-	(beginning-of-line)
-	;; save-excursion doesn't work right
-	(let ((opoint (point)))
-	  (accept-process-output process)
-	  (goto-char opoint)))
+    (beginning-of-line)
+    ;; save-excursion doesn't work right
+    (let ((opoint (point)))
+      (accept-process-output process)
+      (goto-char opoint)))
       (setq vm-pop-read-point (point-marker))
       (goto-char start)
       ;; no uidl support, bail.
       (if (not (looking-at "\\+OK"))
-	  (throw 'done nil))
+      (throw 'done nil))
       (forward-line 1)
       (while (not (eq (char-after (point)) ?.))
-	;; not loking at a number, bail.
-	(if (not (looking-at "[0-9]"))
-	    (throw 'done nil))
-	(setq n (int-to-string (read (current-buffer))))
-	(skip-chars-forward " ")
-	(setq start (point))
-	(skip-chars-forward "\041-\176")
-	;; no tag after the message number, bail.
-	(if (= start (point))
-	    (throw 'done nil))
-	(setq uidl (buffer-substring start (point)))
-	(setq list (cons (cons n uidl) list))
-	(forward-line 1))
+    ;; not loking at a number, bail.
+    (if (not (looking-at "[0-9]"))
+        (throw 'done nil))
+    (setq n (int-to-string (read (current-buffer))))
+    (skip-chars-forward " ")
+    (setq start (point))
+    (skip-chars-forward "\041-\176")
+    ;; no tag after the message number, bail.
+    (if (= start (point))
+        (throw 'done nil))
+    (setq uidl (buffer-substring start (point)))
+    (setq list (cons (cons n uidl) list))
+    (forward-line 1))
       ;; returning nil means the uidl command failed so don't
       ;; return nil if there aren't any messages.
       (if (null list)
-	  (cons nil nil)
-	list ))))
+      (cons nil nil)
+    list ))))
 
 (defun vm-pop-ask-about-large-message (process popdrop size n)
   (let ((work-buffer nil)
-	(pop-buffer (current-buffer))
-	start end)
+    (pop-buffer (current-buffer))
+    start end)
     (unwind-protect
-	(save-excursion
-	  (save-window-excursion
-	    (vm-pop-send-command process (format "TOP %d %d" n 0))
-	    (if (vm-pop-read-response process)
-		(progn
-		  (setq start vm-pop-read-point)
-		  (vm-pop-read-past-dot-sentinel-line process)
-		  (setq end vm-pop-read-point)
-		  (setq work-buffer (generate-new-buffer
-				     (format "*headers of %s message %d*"
-					     popdrop n)))
-		  (set-buffer work-buffer)
-		  (insert-buffer-substring pop-buffer start end)
-		  (forward-line -1)
-		  (delete-region (point) (point-max))
-		  (vm-pop-cleanup-region (point-min) (point-max))
-		  (vm-display-buffer work-buffer)
-		  (setq minibuffer-scroll-window (selected-window))
-		  (goto-char (point-min))
-		  (if (re-search-forward "^Received:" nil t)
-		      (progn
-			(goto-char (match-beginning 0))
-			(vm-reorder-message-headers
-			 nil vm-visible-headers
-			 vm-invisible-header-regexp)))
-		  (set-window-point (selected-window) (point))))
-	    (if (y-or-n-p (format "Message %d, size = %d, retrieve? " n size))
-		'retrieve
-	      (if (y-or-n-p (format "Delete message %d from popdrop? " n size))
-		  'delete
-		'skip))))
+    (save-excursion
+      (save-window-excursion
+        (vm-pop-send-command process (format "TOP %d %d" n 0))
+        (if (vm-pop-read-response process)
+        (progn
+          (setq start vm-pop-read-point)
+          (vm-pop-read-past-dot-sentinel-line process)
+          (setq end vm-pop-read-point)
+          (setq work-buffer (generate-new-buffer
+                     (format "*headers of %s message %d*"
+                         popdrop n)))
+          (set-buffer work-buffer)
+          (insert-buffer-substring pop-buffer start end)
+          (forward-line -1)
+          (delete-region (point) (point-max))
+          (vm-pop-cleanup-region (point-min) (point-max))
+          (vm-display-buffer work-buffer)
+          (setq minibuffer-scroll-window (selected-window))
+          (goto-char (point-min))
+          (if (re-search-forward "^Received:" nil t)
+              (progn
+            (goto-char (match-beginning 0))
+            (vm-reorder-message-headers
+             nil vm-visible-headers
+             vm-invisible-header-regexp)))
+          (set-window-point (selected-window) (point))))
+        (if (y-or-n-p (format "Message %d, size = %d, retrieve? " n size))
+        'retrieve
+          (if (y-or-n-p (format "Delete message %d from popdrop? " n size))
+          'delete
+        'skip))))
       (and work-buffer (kill-buffer work-buffer)))))
 
 (defun vm-pop-ask-about-no-uidl (popdrop)
   (let ((work-buffer nil)
-	(pop-buffer (current-buffer))
-	start end)
+    (pop-buffer (current-buffer))
+    start end)
     (unwind-protect
-	(save-excursion
-	  (save-window-excursion
-	    (setq work-buffer (generate-new-buffer
-			       (format "*trouble with %s*" popdrop)))
-	    (set-buffer work-buffer)
-	    (insert
+    (save-excursion
+      (save-window-excursion
+        (setq work-buffer (generate-new-buffer
+                   (format "*trouble with %s*" popdrop)))
+        (set-buffer work-buffer)
+        (insert
 "You have asked VM to leave messages on the server for the POP mailbox "
 popdrop
 ".  VM cannot do so because the server does not seem to support the POP UIDL command.\n\nYou can either continue to retrieve messages from this mailbox with VM deleting the messages from the server, or you can skip this mailbox, leaving messages on the server and not retrieving any messages.")
-	    (fill-individual-paragraphs (point-min) (point-max))
-	    (vm-display-buffer work-buffer)
-	    (setq minibuffer-scroll-window (selected-window))
-	    (yes-or-no-p "Continue retrieving anyway? ")))
+        (fill-individual-paragraphs (point-min) (point-max))
+        (vm-display-buffer work-buffer)
+        (setq minibuffer-scroll-window (selected-window))
+        (yes-or-no-p "Continue retrieving anyway? ")))
       (and work-buffer (kill-buffer work-buffer)))))
 
-(defun vm-pop-retrieve-to-crashbox (process crash statblob)
+(defun vm-pop-retrieve-to-crashbox (process crash statblob spooldata)
   (let ((start vm-pop-read-point) end)
     (goto-char start)
     (vm-set-pop-stat-x-got statblob 0)
@@ -717,17 +750,17 @@
       (beginning-of-line)
       ;; save-excursion doesn't work right
       (let* ((opoint (point))
-	     (func
-	      (function
-	       (lambda (beg end len)
-		 (if vm-pop-read-point
-		     (progn
-		       (vm-set-pop-stat-x-got statblob (- end start))
-		       (if (zerop (% (random) 10))
-			   (vm-pop-report-retrieval-status statblob)))))))
-	     (after-change-functions (cons func after-change-functions)))
-	(accept-process-output process)
-	(goto-char opoint)))
+         (func
+          (function
+           (lambda (beg end len)
+         (if vm-pop-read-point
+             (progn
+               (vm-set-pop-stat-x-got statblob (- end start))
+               (if (zerop (% (random) 10))
+               (vm-pop-report-retrieval-status statblob)))))))
+         (after-change-functions (cons func after-change-functions)))
+    (accept-process-output process)
+    (goto-char opoint)))
     (vm-set-pop-stat-x-got statblob nil)
     (setq vm-pop-read-point (point-marker))
     (goto-char (match-beginning 0))
@@ -737,36 +770,38 @@
     ;; separators, some don't.  Figure out what kind we're
     ;; talking to and do the right thing.
     (if (eq (vm-get-folder-type nil start end) 'unknown)
-	(progn
-	  (vm-munge-message-separators vm-folder-type start end)
-	  (goto-char start)
-	  ;; avoid the consing and stat() call for all but babyl
-	  ;; files, since this will probably slow things down.
-	  ;; only babyl files have the folder header, and we
-	  ;; should only insert it if the crash box is empty.
-	  (if (and (eq vm-folder-type 'babyl)
-		   (let ((attrs (file-attributes crash)))
-		     (or (null attrs) (equal 0 (nth 7 attrs)))))
-	      (let ((opoint (point)))
-		(vm-convert-folder-header nil vm-folder-type)
-		;; if start is a marker, then it was moved
-		;; forward by the insertion.  restore it.
-		(setq start opoint)
-		(goto-char start)
-		(vm-skip-past-folder-header)))
-	  (insert (vm-leading-message-separator))
-	  (save-restriction
-	    (narrow-to-region (point) end)
-	    (vm-convert-folder-type-headers 'baremessage vm-folder-type))
-	  (goto-char end)
-	  (insert-before-markers (vm-trailing-message-separator))))
+    (progn
+      (vm-munge-message-separators vm-folder-type start end)
+      (goto-char start)
+      ;; avoid the consing and stat() call for all but babyl
+      ;; files, since this will probably slow things down.
+      ;; only babyl files have the folder header, and we
+      ;; should only insert it if the crash box is empty.
+      (if (and (eq vm-folder-type 'babyl)
+           (let ((attrs (file-attributes crash)))
+             (or (null attrs) (equal 0 (nth 7 attrs)))))
+          (let ((opoint (point)))
+        (vm-convert-folder-header nil vm-folder-type)
+        ;; if start is a marker, then it was moved
+        ;; forward by the insertion.  restore it.
+        (setq start opoint)
+        (goto-char start)
+        (vm-skip-past-folder-header)))
+      (insert (vm-leading-message-separator))
+      ;; This links the pop UIDL and server to the message.
+      (insert (concat "X-VM-Spool-Info: " (prin1-to-string spooldata) "\n"))
+      (save-restriction
+        (narrow-to-region (point) end)
+        (vm-convert-folder-type-headers 'baremessage vm-folder-type))
+      (goto-char end)
+      (insert-before-markers (vm-trailing-message-separator))))
     ;; Set file type to binary for DOS/Windows.  I don't know if
     ;; this is correct to do or not; it depends on whether the
     ;; the CRLF or the LF newline convention is used on the inbox
     ;; associated with this crashbox.  This setting assumes the LF
     ;; newline convention is used.
     (let ((buffer-file-type t)
-	  (selective-display nil))
+      (selective-display nil))
       (write-region start end crash t 0))
     (delete-region start end)
     t ))
@@ -792,31 +827,31 @@
 (defun vm-pop-md5 (string)
   (let ((buffer nil))
     (unwind-protect
-	(save-excursion
-	  (setq buffer (vm-make-work-buffer))
-	  (set-buffer buffer)
-	  ;; call-process-region calls write-region.
-	  ;; don't let it do CR -> LF translation.
-	  (setq selective-display nil)
-	  (insert string)
-	  (if (fboundp 'md5)
-	      (progn
-		(goto-char (point-min))
-		(insert (md5 buffer (point-min) (point-max)))
-		(delete-region (point) (point-max)))
-	    (call-process-region (point-min) (point-max)
-				 (or shell-file-name "/bin/sh") t buffer nil
-				 shell-command-switch vm-pop-md5-program))
-	  ;; MD5 digest is 32 chars long
-	  ;; mddriver adds a newline to make neaten output for tty
-	  ;; viewing, make sure we leave it behind.
-	  (vm-buffer-substring-no-properties (point-min) (+ (point-min) 32)))
+    (save-excursion
+      (setq buffer (vm-make-work-buffer))
+      (set-buffer buffer)
+      ;; call-process-region calls write-region.
+      ;; don't let it do CR -> LF translation.
+      (setq selective-display nil)
+      (insert string)
+      (if (fboundp 'md5)
+          (progn
+        (goto-char (point-min))
+        (insert (md5 buffer (point-min) (point-max)))
+        (delete-region (point) (point-max)))
+        (call-process-region (point-min) (point-max)
+                 (or shell-file-name "/bin/sh") t buffer nil
+                 shell-command-switch vm-pop-md5-program))
+      ;; MD5 digest is 32 chars long
+      ;; mddriver adds a newline to make neaten output for tty
+      ;; viewing, make sure we leave it behind.
+      (vm-buffer-substring-no-properties (point-min) (+ (point-min) 32)))
       (and buffer (kill-buffer buffer)))))
 
 (defun vm-popdrop-sans-password (source)
   (let (source-list)
     (setq source-list (vm-parse source "\\([^:]+\\):?"))
     (concat (nth 0 source-list) ":"
-	    (nth 1 source-list) ":"
-	    (nth 2 source-list) ":"
-	    (nth 3 source-list) ":*")))
+        (nth 1 source-list) ":"
+        (nth 2 source-list) ":"
+        (nth 3 source-list) ":*")))
Only in vm-hacked: vm-pop.el.rej
Only in vm-hacked: vm-pop.elc
Only in vm-hacked: vm-reply.elc
Only in vm-hacked: vm-save.elc
Only in vm-hacked: vm-search.elc
Only in vm-hacked: vm-sort.elc
Only in vm-hacked: vm-startup.elc
Only in vm-hacked: vm-summary.elc
Only in vm-hacked: vm-thread.elc
Only in vm-hacked: vm-toolbar.elc
Only in vm-hacked: vm-undo.elc
Only in vm-hacked: vm-user.elc
diff -u vm-6.95/vm-vars.el vm-hacked/vm-vars.el
--- vm-6.95/vm-vars.el	Tue Jul 24 04:53:59 2001
+++ vm-hacked/vm-vars.el	Mon Aug 27 21:57:21 2001
@@ -223,6 +223,11 @@
 folder's file name.  If the folder does not have a file name,
 the function will not be called.")
 
+(defvar vm-expunge-sync-with-server t
+  "*Non-nil value makes VM try to update the server when a local
+folder is expunged, i.e. it deletes the message on the server
+corresponding to each locally-deleted message.")
+
 (defvar vm-pop-md5-program "md5"
   "*Program that reads a message on its standard input and writes an
 MD5 digest on its output.")
@@ -3681,7 +3686,7 @@
 append a space to words that complete unambiguously.")
 (defconst vm-attributes-vector-length 9)
 (defconst vm-cache-vector-length 21)
-(defconst vm-softdata-vector-length 19)
+(defconst vm-softdata-vector-length 20)
 (defconst vm-location-data-vector-length 6)
 (defconst vm-mirror-data-vector-length 5)
 (defconst vm-folder-summary-vector-length 15)
Only in vm-hacked: vm-vars.elc
Only in vm-hacked: vm-version.elc
Only in vm-hacked: vm-virtual.elc
Only in vm-hacked: vm-window.elc
Only in vm-hacked: vm.el
Only in vm-hacked: vm.elc

