diff options
| author | Paul Reilly | 2008-10-17 02:43:35 +0000 |
|---|---|---|
| committer | Paul Reilly | 2008-10-17 02:43:35 +0000 |
| commit | 8e4487de7b180bef9bce1b20a7391aa973f9f574 (patch) | |
| tree | 04e08a431cf5b9dee12b8e2fb2c84a3609f4a0c9 | |
| parent | 393566216f8622ca3a41ff361cf8db40e1132276 (diff) | |
| download | emacs-8e4487de7b180bef9bce1b20a7391aa973f9f574.tar.gz emacs-8e4487de7b180bef9bce1b20a7391aa973f9f574.zip | |
(pmail): Remove a redundant message counter reset call; try to
minimize the attempts to show a message (ideally it should be done
once and only once).
(pmail-convert-babyl-to-mbox): Set up the global message variables
after inserting the converted mbox file into the Pmail buffer; avoid
an unecessary message display function call.
(pmail-show-message-maybe): Use the current message number when the
optional argument is not passed.
| -rw-r--r-- | lisp/mail/pmail.el | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/lisp/mail/pmail.el b/lisp/mail/pmail.el index dd400686a24..83ff47df266 100644 --- a/lisp/mail/pmail.el +++ b/lisp/mail/pmail.el | |||
| @@ -855,28 +855,28 @@ If `pmail-display-summary' is non-nil, make a summary for this PMAIL file." | |||
| 855 | ;; who have find-file-visit-truename set to t. | 855 | ;; who have find-file-visit-truename set to t. |
| 856 | (existed (find-buffer-visiting file-name)) | 856 | (existed (find-buffer-visiting file-name)) |
| 857 | run-mail-hook msg-shown) | 857 | run-mail-hook msg-shown) |
| 858 | ;; Like find-file, but in the case where a buffer existed | 858 | ;; Determine if an existing mail file has been changed behind the |
| 859 | ;; and the file was reverted, recompute the message-data. | 859 | ;; scene... |
| 860 | ;; We used to bind enable-local-variables to nil here, | ||
| 861 | ;; but that should not be needed now that pmail-mode | ||
| 862 | ;; sets it locally to nil. | ||
| 863 | ;; (Binding a variable locally with let is not safe if it has | ||
| 864 | ;; buffer-local bindings.) | ||
| 865 | (if (and existed (not (verify-visited-file-modtime existed))) | 860 | (if (and existed (not (verify-visited-file-modtime existed))) |
| 861 | ;; The mail file has been changed. Revisit it and reset the | ||
| 862 | ;; message state variables when in pmail mode. | ||
| 866 | (progn | 863 | (progn |
| 867 | (find-file file-name) | 864 | (find-file file-name) |
| 868 | (when (and (verify-visited-file-modtime existed) | 865 | (when (and (verify-visited-file-modtime existed) |
| 869 | (eq major-mode 'pmail-mode)) | 866 | (eq major-mode 'pmail-mode)) |
| 870 | (pmail-forget-messages) | ||
| 871 | (pmail-set-message-counters))) | 867 | (pmail-set-message-counters))) |
| 868 | ;; The mail file is either unchanged or not visited. Visit it. | ||
| 872 | (switch-to-buffer | 869 | (switch-to-buffer |
| 873 | (let ((enable-local-variables nil)) | 870 | (let ((enable-local-variables nil)) |
| 874 | (find-file-noselect file-name)))) | 871 | (find-file-noselect file-name)))) |
| 872 | ;; Insure that the collection and view buffers are in sync and | ||
| 873 | ;; insure that a message is not being edited. | ||
| 875 | (setq pmail-buffers-swapped-p nil) | 874 | (setq pmail-buffers-swapped-p nil) |
| 876 | (if (eq major-mode 'pmail-edit-mode) | 875 | (if (eq major-mode 'pmail-edit-mode) |
| 877 | (error "Exit Pmail Edit mode before getting new mail")) | 876 | (error "Exit Pmail Edit mode before getting new mail")) |
| 878 | ;; Insure that the Rmail file is in mbox format, the buffer is in | 877 | ;; Insure that the Rmail file is in mbox format, the buffer is in |
| 879 | ;; Pmail mode and has been scanned to find all the messages. | 878 | ;; Pmail mode and has been scanned to find all the messages |
| 879 | ;; (setting the global message variables in the process). | ||
| 880 | (pmail-convert-file-maybe) | 880 | (pmail-convert-file-maybe) |
| 881 | (unless (eq major-mode 'pmail-mode) | 881 | (unless (eq major-mode 'pmail-mode) |
| 882 | (pmail-mode-2)) | 882 | (pmail-mode-2)) |
| @@ -884,9 +884,11 @@ If `pmail-display-summary' is non-nil, make a summary for this PMAIL file." | |||
| 884 | (pmail-maybe-set-message-counters) | 884 | (pmail-maybe-set-message-counters) |
| 885 | ;; Show the first unread message and process summary mode. | 885 | ;; Show the first unread message and process summary mode. |
| 886 | (unwind-protect | 886 | (unwind-protect |
| 887 | (unless (and (not file-name-arg) (pmail-get-new-mail)) | 887 | ;; Only get new mail when there is not a file name argument. |
| 888 | (pmail-show-message-maybe (pmail-first-unseen-message))) | 888 | (unless file-name-arg |
| 889 | (pmail-get-new-mail)) | ||
| 889 | (progn | 890 | (progn |
| 891 | (pmail-show-message-maybe (pmail-first-unseen-message)) | ||
| 890 | (if pmail-display-summary (pmail-summary)) | 892 | (if pmail-display-summary (pmail-summary)) |
| 891 | (pmail-construct-io-menu) | 893 | (pmail-construct-io-menu) |
| 892 | (if run-mail-hook | 894 | (if run-mail-hook |
| @@ -951,7 +953,9 @@ MSGNUM, if present, indicates the malformed message." | |||
| 951 | (message "Replacing BABYL format with mbox format...") | 953 | (message "Replacing BABYL format with mbox format...") |
| 952 | (let ((inhibit-read-only t)) | 954 | (let ((inhibit-read-only t)) |
| 953 | (erase-buffer) | 955 | (erase-buffer) |
| 954 | (insert-file-contents-literally new-file)) | 956 | (insert-file-contents-literally new-file) |
| 957 | (goto-char (point-max)) | ||
| 958 | (pmail-set-message-counters)) | ||
| 955 | (message "Replacing BABYL format with mbox format...done")) | 959 | (message "Replacing BABYL format with mbox format...done")) |
| 956 | (delete-file old-file) | 960 | (delete-file old-file) |
| 957 | (delete-file new-file)))) | 961 | (delete-file new-file)))) |
| @@ -1670,7 +1674,7 @@ new messages are found, nil otherwise." | |||
| 1670 | (save-restriction | 1674 | (save-restriction |
| 1671 | (let ((new-messages 0) | 1675 | (let ((new-messages 0) |
| 1672 | (spam-filter-p (and (featurep 'pmail-spam-filter) pmail-use-spam-filter)) | 1676 | (spam-filter-p (and (featurep 'pmail-spam-filter) pmail-use-spam-filter)) |
| 1673 | blurb success suffix) | 1677 | blurb result success suffix) |
| 1674 | (narrow-to-region (point) (point)) | 1678 | (narrow-to-region (point) (point)) |
| 1675 | ;; Read in the contents of the inbox files, renaming them as | 1679 | ;; Read in the contents of the inbox files, renaming them as |
| 1676 | ;; necessary, and adding to the list of files to delete | 1680 | ;; necessary, and adding to the list of files to delete |
| @@ -1729,11 +1733,13 @@ new messages are found, nil otherwise." | |||
| 1729 | (if rsf-beep (beep t)) | 1733 | (if rsf-beep (beep t)) |
| 1730 | (sleep-for rsf-sleep-after-message)) | 1734 | (sleep-for rsf-sleep-after-message)) |
| 1731 | 1735 | ||
| 1732 | ;; Move to the first new message | 1736 | ;; Establish the return value and move to the first new |
| 1733 | ;; unless we have other unseen messages before it. | 1737 | ;; message unless we have other unseen messages before it. |
| 1734 | (pmail-show-message-maybe (pmail-first-unseen-message)) | 1738 | (setq result (> new-messages 0)) |
| 1739 | (when result | ||
| 1740 | (pmail-show-message-maybe (pmail-first-unseen-message))) | ||
| 1735 | (run-hooks 'pmail-after-get-new-mail-hook) | 1741 | (run-hooks 'pmail-after-get-new-mail-hook) |
| 1736 | (> new-messages 0))))) | 1742 | result)))) |
| 1737 | 1743 | ||
| 1738 | (defun pmail-get-new-mail-filter-spam (new-message-count) | 1744 | (defun pmail-get-new-mail-filter-spam (new-message-count) |
| 1739 | "Process new messages for spam." | 1745 | "Process new messages for spam." |
| @@ -2838,13 +2844,14 @@ If summary buffer is currently displayed, update current message there also." | |||
| 2838 | (pmail-swap-buffers-maybe) | 2844 | (pmail-swap-buffers-maybe) |
| 2839 | (pmail-maybe-set-message-counters) | 2845 | (pmail-maybe-set-message-counters) |
| 2840 | (widen) | 2846 | (widen) |
| 2841 | (let (blurb) | 2847 | (let ((msgnum (or n pmail-current-message)) |
| 2848 | blurb) | ||
| 2842 | (if (zerop pmail-total-messages) | 2849 | (if (zerop pmail-total-messages) |
| 2843 | (save-excursion | 2850 | (save-excursion |
| 2844 | (with-current-buffer pmail-view-buffer | 2851 | (with-current-buffer pmail-view-buffer |
| 2845 | (erase-buffer) | 2852 | (erase-buffer) |
| 2846 | (setq blurb "No mail."))) | 2853 | (setq blurb "No mail."))) |
| 2847 | (setq blurb (pmail-show-message n)) | 2854 | (setq blurb (pmail-show-message msgnum)) |
| 2848 | (when mail-mailing-lists | 2855 | (when mail-mailing-lists |
| 2849 | (pmail-unknown-mail-followup-to)) | 2856 | (pmail-unknown-mail-followup-to)) |
| 2850 | (if transient-mark-mode (deactivate-mark)) | 2857 | (if transient-mark-mode (deactivate-mark)) |