diff options
| author | Paul Reilly | 2008-09-01 08:35:24 +0000 |
|---|---|---|
| committer | Paul Reilly | 2008-09-01 08:35:24 +0000 |
| commit | e87ae05bed24cd611de98c470f043324a30e56cc (patch) | |
| tree | 51053edd6be37c45513bd7b3b6efe766a5948bde | |
| parent | d007e8e938ac11e9e37ab248292caa99e1c719aa (diff) | |
| download | emacs-e87ae05bed24cd611de98c470f043324a30e56cc.tar.gz emacs-e87ae05bed24cd611de98c470f043324a30e56cc.zip | |
Fix the expunge operation.
pmail.el (pmail-only-expunge): Manage pmail-total-messages in the
callback handler; remove the extra show message call.
(pmail-expunge-callback): Rewrite to handle all possible conditions.
pmaildesc.el (pmail-desc-get-previous, pmail-desc-get-match-index):
New functions.
| -rw-r--r-- | lisp/mail/pmail.el | 17 | ||||
| -rw-r--r-- | lisp/mail/pmaildesc.el | 28 |
2 files changed, 35 insertions, 10 deletions
diff --git a/lisp/mail/pmail.el b/lisp/mail/pmail.el index 09ec42d13e3..72abe896fbc 100644 --- a/lisp/mail/pmail.el +++ b/lisp/mail/pmail.el | |||
| @@ -2622,10 +2622,8 @@ See also user-option `pmail-confirm-expunge'." | |||
| 2622 | ;; Remove the messages from the buffer and from the Pmail message | 2622 | ;; Remove the messages from the buffer and from the Pmail message |
| 2623 | ;; descriptor vector. | 2623 | ;; descriptor vector. |
| 2624 | (pmail-desc-prune-deleted-messages 'pmail-expunge-callback) | 2624 | (pmail-desc-prune-deleted-messages 'pmail-expunge-callback) |
| 2625 | ;; Update the Pmail message counter, deal with the summary buffer, | 2625 | ;; Deal with the summary buffer and update |
| 2626 | ;; show the current message and update the User status. | 2626 | ;; the User status. |
| 2627 | (setq pmail-total-messages (pmail-desc-get-count)) | ||
| 2628 | (pmail-show-message pmail-current-message t) | ||
| 2629 | (let* ((omax (- (buffer-size) (point-max))) | 2627 | (let* ((omax (- (buffer-size) (point-max))) |
| 2630 | (omin (- (buffer-size) (point-min))) | 2628 | (omin (- (buffer-size) (point-min))) |
| 2631 | (opoint (if (and (> pmail-current-message 0) | 2629 | (opoint (if (and (> pmail-current-message 0) |
| @@ -2650,8 +2648,15 @@ See also user-option `pmail-confirm-expunge'." | |||
| 2650 | (defun pmail-expunge-callback (n) | 2648 | (defun pmail-expunge-callback (n) |
| 2651 | "Called after message N has been pruned to update the current Pmail | 2649 | "Called after message N has been pruned to update the current Pmail |
| 2652 | message counter." | 2650 | message counter." |
| 2653 | (if (< n pmail-current-message) | 2651 | ;; Process the various possible states to set the current message |
| 2654 | (setq pmail-current-message (1- pmail-current-message)))) | 2652 | ;; counter. |
| 2653 | (setq pmail-total-messages (1- pmail-total-messages) | ||
| 2654 | pmail-current-message | ||
| 2655 | (cond | ||
| 2656 | ((= 0 pmail-total-messages) 0) | ||
| 2657 | ((> pmail-current-message n) (pmail-desc-get-previous pmail-desc-deleted-index n)) | ||
| 2658 | ((> pmail-current-message n) 0) | ||
| 2659 | (t pmail-current-message)))) | ||
| 2655 | 2660 | ||
| 2656 | ;;; mbox: ready | 2661 | ;;; mbox: ready |
| 2657 | (defun pmail-expunge () | 2662 | (defun pmail-expunge () |
diff --git a/lisp/mail/pmaildesc.el b/lisp/mail/pmaildesc.el index 09887d4b76a..f2274cc23cb 100644 --- a/lisp/mail/pmaildesc.el +++ b/lisp/mail/pmaildesc.el | |||
| @@ -354,6 +354,27 @@ This includes the attributes." | |||
| 354 | (nth pmail-desc-date-month-index | 354 | (nth pmail-desc-date-month-index |
| 355 | (nth pmail-desc-date-index (pmail-desc-get-descriptor n)))) | 355 | (nth pmail-desc-date-index (pmail-desc-get-descriptor n)))) |
| 356 | 356 | ||
| 357 | (defun pmail-desc-get-previous (n attr-index &optional sense) | ||
| 358 | "Return the index for the previous matching descriptor. | ||
| 359 | Starting with descriptor at index N locate the first previous | ||
| 360 | descriptor such that the attribute ATTR is set. SENSE, if | ||
| 361 | non-null will reverse the sense of the attribute test." | ||
| 362 | (let ((index (1- n)) flag result) | ||
| 363 | (while (and (> index 0) (not result)) | ||
| 364 | (if (listp (aref pmail-desc-vector index)) | ||
| 365 | (setq result (pmail-desc-get-match-index attr-index sense index))) | ||
| 366 | (setq index (1- index))) | ||
| 367 | (or result 0))) | ||
| 368 | |||
| 369 | (defun pmail-desc-get-match-index (attr-index sense n) | ||
| 370 | "Return the index N if the associated descriptor has a matching | ||
| 371 | attribute, nil otherwise. The attribute value must be set if | ||
| 372 | SENSE is nil, or unset if SENSE is non-nil." | ||
| 373 | (let (flag (pmail-desc-attr-p attr-index n)) | ||
| 374 | (if (or (and flag (not sense)) (and (not flag) sense)) | ||
| 375 | n | ||
| 376 | nil))) | ||
| 377 | |||
| 357 | (defun pmail-desc-get-sender (n) | 378 | (defun pmail-desc-get-sender (n) |
| 358 | "Return the User registered as the mail sender." | 379 | "Return the User registered as the mail sender." |
| 359 | (nth pmail-desc-sender-index (pmail-desc-get-descriptor n))) | 380 | (nth pmail-desc-sender-index (pmail-desc-get-descriptor n))) |
| @@ -395,11 +416,10 @@ displayed in the Pmail summary buffer." | |||
| 395 | Return the number of messages removed. Invoke CALLBACK immediately | 416 | Return the number of messages removed. Invoke CALLBACK immediately |
| 396 | after a message has been deleted.." | 417 | after a message has been deleted.." |
| 397 | 418 | ||
| 398 | ;; Set the callback. | 419 | ;; Set the callback and remove all messages marked for deletion from |
| 420 | ;; the Pmail buffer and their descriptors from the Pmail message | ||
| 421 | ;; vector. | ||
| 399 | (setq pmail-desc-delete-callback callback) | 422 | (setq pmail-desc-delete-callback callback) |
| 400 | |||
| 401 | ;; Remove all messages marked for deletion from the Pmail buffer and | ||
| 402 | ;; their descriptors from the Pmail message vector. | ||
| 403 | (let ((result (length (delq t (mapcar 'pmail-desc-delete-maybe | 423 | (let ((result (length (delq t (mapcar 'pmail-desc-delete-maybe |
| 404 | (pmail-desc-make-index-list)))))) | 424 | (pmail-desc-make-index-list)))))) |
| 405 | (setq pmail-desc-vector | 425 | (setq pmail-desc-vector |