(defvar pmail-encoded-remote-password nil)
+(defvar pmail-expunge-counter 0
+ "A counter used to keep track of the number of expunged
+messages with a lower message number than the current message
+index.")
+
(defcustom pmail-preserve-inbox nil
"*Non-nil means leave incoming mail in the user's inbox--don't delete it."
:type 'boolean
(let ((attr-index (pmail-desc-get-attr-index attr)))
(set-buffer pmail-buffer)
(or msgnum (setq msgnum pmail-current-message))
- (pmail-desc-set-attribute attr-index state msgnum)
+ (pmail-desc-set-attribute msgnum attr-index state)
;; Deal with the summary buffer.
(when pmail-summary-buffer
(pmail-summary-update msgnum))))))
;; Clear the "unseen" attribute when we show a message, unless
;; it is already cleared.
(when (pmail-desc-attr-p pmail-desc-unseen-index n)
- (pmail-desc-set-attribute pmail-desc-unseen-index nil n))
+ (pmail-desc-set-attribute n pmail-desc-unseen-index nil))
(pmail-display-labels)
;; Deal with MIME
(if (eq pmail-enable-mime t)
(defun pmail-delete-message ()
"Delete this message and stay on it."
(interactive)
- (pmail-desc-set-attribute pmail-desc-deleted-index t pmail-current-message)
+ (pmail-desc-set-attribute pmail-current-message pmail-desc-deleted-index t)
(run-hooks 'pmail-delete-message-hook)
(pmail-show-message pmail-current-message))
(setq msg (1- msg)))
(if (= msg 0)
(error "No previous deleted message")
- (pmail-desc-set-attribute pmail-desc-deleted-index nil msg)
+ (pmail-desc-set-attribute msg pmail-desc-deleted-index nil)
(pmail-show-message msg)
(if (pmail-summary-exists)
(save-excursion
Returns t if a new message is displayed after the delete, or nil otherwise."
(interactive "P")
- (pmail-desc-set-attribute pmail-desc-deleted-index t pmail-current-message)
+ (pmail-desc-set-attribute pmail-current-message pmail-desc-deleted-index t)
(run-hooks 'pmail-delete-message-hook)
(let ((del-msg pmail-current-message))
(if (pmail-summary-exists)
(or (eq buffer-undo-list t) (setq buffer-undo-list nil))
;; Remove the messages from the buffer and from the Pmail message
;; descriptor vector.
+ (setq pmail-expunge-counter 0)
(pmail-desc-prune-deleted-messages 'pmail-expunge-callback)
+ (setq pmail-current-message (- pmail-current-message pmail-expunge-counter))
;; Deal with the summary buffer and update
;; the User status.
(let* ((omax (- (buffer-size) (point-max)))
message counter."
;; Process the various possible states to set the current message
;; counter.
- (setq pmail-total-messages (1- pmail-total-messages)
- pmail-current-message
- (cond
- ((= 0 pmail-total-messages) 0)
- ((> pmail-current-message n) (pmail-desc-get-previous pmail-desc-deleted-index n))
- ((> pmail-current-message n) 0)
- (t pmail-current-message))))
+ (setq pmail-total-messages (1- pmail-total-messages))
+ (if (>= pmail-current-message n)
+ (setq pmail-expunge-counter (1+ pmail-expunge-counter))))
;;; mbox: ready
(defun pmail-expunge ()
(let ((n (car msgnum-list)))
(set-buffer pmail-buffer)
(pmail-narrow-to-message n)
- (pmail-desc-set-attribute attr-index t n))))
+ (pmail-desc-set-attribute n attr-index t))))
(defun pmail-narrow-to-message (n)
"Narrow the current (pmail) buffer to bracket message N."
(nth pmail-desc-date-index (pmail-desc-get-descriptor n))))
(defun pmail-desc-get-previous (n attr-index &optional sense)
- "Return the index for the previous matching descriptor.
+ "Return the message index for the previous matching descriptor.
Starting with descriptor at index N locate the first previous
descriptor such that the attribute ATTR is set. SENSE, if
non-null will reverse the sense of the attribute test."
(let ((index (1- n)) flag result)
(while (and (> index 0) (not result))
- (if (listp (aref pmail-desc-vector index))
- (setq result (pmail-desc-get-match-index attr-index sense index)))
+ (if (listp (aref pmail-desc-vector (1- index)))
+ (setq result (pmail-desc-get-match-index index attr-index sense)))
(setq index (1- index)))
(or result 0)))
-(defun pmail-desc-get-match-index (attr-index sense n)
+(defun pmail-desc-get-match-index (n attr-index sense)
"Return the index N if the associated descriptor has a matching
attribute, nil otherwise. The attribute value must be set if
SENSE is nil, or unset if SENSE is non-nil."
(vconcat (delq t (append pmail-desc-vector nil))))
result))
-(defun pmail-desc-set-attribute (attr-index state n)
+(defun pmail-desc-set-attribute (n attr-index state)
"Set the attribute denoted by ATTR-INDEX in message N according to STATE.
If STATE is non-nil the attribute will be set to the single character code
associated with ATTR-INDEX in pmail-desc-attr-alist, otherwise the attribute is