aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Reilly2008-09-23 11:30:17 +0000
committerPaul Reilly2008-09-23 11:30:17 +0000
commite93edd3fca3fa40ba3a257e5718d65cb40b47d4b (patch)
treee4417fb5a97bde36059d9e6c6d87889f5f54fcb7
parent8ca37e61fc16825314bc5eebcd86282102eb2961 (diff)
downloademacs-e93edd3fca3fa40ba3a257e5718d65cb40b47d4b.tar.gz
emacs-e93edd3fca3fa40ba3a257e5718d65cb40b47d4b.zip
First pass at handling decoding the mbox message into the view buffer.
-rw-r--r--lisp/mail/pmail.el203
1 files changed, 132 insertions, 71 deletions
diff --git a/lisp/mail/pmail.el b/lisp/mail/pmail.el
index e82a02e6bca..1b7c37de915 100644
--- a/lisp/mail/pmail.el
+++ b/lisp/mail/pmail.el
@@ -910,7 +910,7 @@ If `pmail-display-summary' is non-nil, make a summary for this PMAIL file."
910 (pmail-maybe-set-message-counters) 910 (pmail-maybe-set-message-counters)
911 (unwind-protect 911 (unwind-protect
912 (unless (and (not file-name-arg) (pmail-get-new-mail)) 912 (unless (and (not file-name-arg) (pmail-get-new-mail))
913 (pmail-show-message (pmail-first-unseen-message))) 913 (pmail-show-message-maybe (pmail-first-unseen-message)))
914 (progn 914 (progn
915 (if pmail-display-summary (pmail-summary)) 915 (if pmail-display-summary (pmail-summary))
916 (pmail-construct-io-menu) 916 (pmail-construct-io-menu)
@@ -984,6 +984,18 @@ Note: This is the header of an pmail file.
984Note: If you are seeing it in pmail, 984Note: If you are seeing it in pmail,
985Note: it means the file has no messages in it.\n\^_"))) 985Note: it means the file has no messages in it.\n\^_")))
986 986
987(defun pmail-get-coding-system ()
988 "Return a suitable coding system to use for the mail message in
989the region."
990 (let ((content-type-header (mail-fetch-field "content-type"))
991 separator)
992 (save-excursion
993 (setq separator (search-forward "\n\n")))
994 (if (and content-type-header
995 (string-match pmail-mime-charset-pattern content-type-header))
996 (substring content-type-header (match-beginning 1) (match-end 1))
997 'undecided)))
998
987;; Decode Babyl formatted part at the head of current buffer by 999;; Decode Babyl formatted part at the head of current buffer by
988;; pmail-file-coding-system, or if it is nil, do auto conversion. 1000;; pmail-file-coding-system, or if it is nil, do auto conversion.
989 1001
@@ -1036,7 +1048,7 @@ Note: it means the file has no messages in it.\n\^_")))
1036 (define-key pmail-mode-map "g" 'pmail-get-new-mail) 1048 (define-key pmail-mode-map "g" 'pmail-get-new-mail)
1037 (define-key pmail-mode-map "h" 'pmail-summary) 1049 (define-key pmail-mode-map "h" 'pmail-summary)
1038 (define-key pmail-mode-map "i" 'pmail-input) 1050 (define-key pmail-mode-map "i" 'pmail-input)
1039 (define-key pmail-mode-map "j" 'pmail-show-message) 1051 (define-key pmail-mode-map "j" 'pmail-show-message-maybe)
1040 (define-key pmail-mode-map "k" 'pmail-kill-label) 1052 (define-key pmail-mode-map "k" 'pmail-kill-label)
1041 (define-key pmail-mode-map "l" 'pmail-summary-by-labels) 1053 (define-key pmail-mode-map "l" 'pmail-summary-by-labels)
1042 (define-key pmail-mode-map "\e\C-h" 'pmail-summary) 1054 (define-key pmail-mode-map "\e\C-h" 'pmail-summary)
@@ -1252,7 +1264,7 @@ Instead, these commands are available:
1252\\[pmail-previous-message] Move to Previous message whether deleted or not. 1264\\[pmail-previous-message] Move to Previous message whether deleted or not.
1253\\[pmail-first-message] Move to the first message in Pmail file. 1265\\[pmail-first-message] Move to the first message in Pmail file.
1254\\[pmail-last-message] Move to the last message in Pmail file. 1266\\[pmail-last-message] Move to the last message in Pmail file.
1255\\[pmail-show-message] Jump to message specified by numeric position in file. 1267\\[pmail-show-message-maybe] Jump to message specified by numeric position in file.
1256\\[pmail-search] Search for string and show message it is found in. 1268\\[pmail-search] Search for string and show message it is found in.
1257\\[pmail-delete-forward] Delete this message, move to next nondeleted. 1269\\[pmail-delete-forward] Delete this message, move to next nondeleted.
1258\\[pmail-delete-backward] Delete this message, move to previous nondeleted. 1270\\[pmail-delete-backward] Delete this message, move to previous nondeleted.
@@ -1298,7 +1310,7 @@ Instead, these commands are available:
1298 (goto-char (point-max)) 1310 (goto-char (point-max))
1299 (set-buffer-multibyte t))) 1311 (set-buffer-multibyte t)))
1300 (pmail-set-message-counters) 1312 (pmail-set-message-counters)
1301 (pmail-show-message pmail-total-messages) 1313 (pmail-show-message-maybe pmail-total-messages)
1302 (when finding-pmail-file 1314 (when finding-pmail-file
1303 (when pmail-display-summary 1315 (when pmail-display-summary
1304 (pmail-summary)) 1316 (pmail-summary))
@@ -1339,7 +1351,10 @@ Instead, these commands are available:
1339 (make-local-variable 'pmail-buffer) 1351 (make-local-variable 'pmail-buffer)
1340 (setq pmail-buffer (current-buffer)) 1352 (setq pmail-buffer (current-buffer))
1341 (make-local-variable 'pmail-view-buffer) 1353 (make-local-variable 'pmail-view-buffer)
1342 (setq pmail-view-buffer (pmail-generate-viewer-buffer)) 1354 (save-excursion
1355 (setq pmail-view-buffer (pmail-generate-viewer-buffer))
1356 (set-buffer pmail-view-buffer)
1357 (set-buffer-multibyte t))
1343 (make-local-variable 'pmail-summary-buffer) 1358 (make-local-variable 'pmail-summary-buffer)
1344 (make-local-variable 'pmail-summary-vector) 1359 (make-local-variable 'pmail-summary-vector)
1345 (make-local-variable 'pmail-current-message) 1360 (make-local-variable 'pmail-current-message)
@@ -1421,7 +1436,7 @@ Instead, these commands are available:
1421 (set-buffer-multibyte t)) 1436 (set-buffer-multibyte t))
1422 (goto-char (point-max)) 1437 (goto-char (point-max))
1423 (pmail-set-message-counters) 1438 (pmail-set-message-counters)
1424 (pmail-show-message pmail-total-messages) 1439 (pmail-show-message-maybe pmail-total-messages)
1425 (run-hooks 'pmail-mode-hook)))) 1440 (run-hooks 'pmail-mode-hook))))
1426 1441
1427;; Return a list of files from this buffer's Mail: option. 1442;; Return a list of files from this buffer's Mail: option.
@@ -1501,7 +1516,7 @@ original copy."
1501 (goto-char (pmail-msgend pmail-current-message)) 1516 (goto-char (pmail-msgend pmail-current-message))
1502 (insert string) 1517 (insert string)
1503 (pmail-forget-messages) 1518 (pmail-forget-messages)
1504 (pmail-show-message number) 1519 (pmail-show-message-maybe number)
1505 (message "Message duplicated"))) 1520 (message "Message duplicated")))
1506 1521
1507;;;###autoload 1522;;;###autoload
@@ -1774,12 +1789,12 @@ It returns t if it got any new messages."
1774 1789
1775 ;; Move to the first new message 1790 ;; Move to the first new message
1776 ;; unless we have other unseen messages before it. 1791 ;; unless we have other unseen messages before it.
1777 (pmail-show-message (pmail-first-unseen-message)) 1792 (pmail-show-message-maybe (pmail-first-unseen-message))
1778 (run-hooks 'pmail-after-get-new-mail-hook) 1793 (run-hooks 'pmail-after-get-new-mail-hook)
1779 (setq found t)))) 1794 (setq found t))))
1780 found) 1795 found)
1781 ;; Don't leave the buffer screwed up if we get a disk-full error. 1796 ;; Don't leave the buffer screwed up if we get a disk-full error.
1782 (or found (pmail-show-message))))) 1797 (or found (pmail-show-message-maybe)))))
1783 1798
1784(defun pmail-parse-url (file) 1799(defun pmail-parse-url (file)
1785 "Parse the supplied URL. Return (list MAILBOX-NAME REMOTE PASSWORD GOT-PASSWORD) 1800 "Parse the supplied URL. Return (list MAILBOX-NAME REMOTE PASSWORD GOT-PASSWORD)
@@ -1976,13 +1991,13 @@ is non-nil if the user has supplied the password interactively.
1976 1991
1977;; Decode the region specified by FROM and TO by CODING. 1992;; Decode the region specified by FROM and TO by CODING.
1978;; If CODING is nil or an invalid coding system, decode by `undecided'. 1993;; If CODING is nil or an invalid coding system, decode by `undecided'.
1979(defun pmail-decode-region (from to coding) 1994(defun pmail-decode-region (from to coding &optional destination)
1980 (if (or (not coding) (not (coding-system-p coding))) 1995 (if (or (not coding) (not (coding-system-p coding)))
1981 (setq coding 'undecided)) 1996 (setq coding 'undecided))
1982 ;; Use -dos decoding, to remove ^M characters left from base64 or 1997 ;; Use -dos decoding, to remove ^M characters left from base64 or
1983 ;; rogue qp-encoded text. 1998 ;; rogue qp-encoded text.
1984 (decode-coding-region from to 1999 (decode-coding-region
1985 (coding-system-change-eol-conversion coding 1)) 2000 from to (coding-system-change-eol-conversion coding 1) destination)
1986 ;; Don't reveal the fact we used -dos decoding, as users generally 2001 ;; Don't reveal the fact we used -dos decoding, as users generally
1987 ;; will not expect the PMAIL buffer to use DOS EOL format. 2002 ;; will not expect the PMAIL buffer to use DOS EOL format.
1988 (setq buffer-file-coding-system 2003 (setq buffer-file-coding-system
@@ -2382,8 +2397,7 @@ those header fields whose names match that regexp. Otherwise,
2382copy all header fields whose names do not match 2397copy all header fields whose names do not match
2383`rmail-ignored-headers' (unless they also match 2398`rmail-ignored-headers' (unless they also match
2384`rmail-nonignored-headers')." 2399`rmail-nonignored-headers')."
2385 (let ((result "") 2400 (let ((header-start-regexp "\n[^ \t]")
2386 (header-start-regexp "\n[^ \t]")
2387 lim) 2401 lim)
2388 (with-current-buffer pmail-buffer 2402 (with-current-buffer pmail-buffer
2389 (when (search-forward "\n\n" nil t) 2403 (when (search-forward "\n\n" nil t)
@@ -2398,7 +2412,7 @@ copy all header fields whose names do not match
2398 (cond 2412 (cond
2399 ;; Handle the case where all headers should be copied. 2413 ;; Handle the case where all headers should be copied.
2400 ((eq pmail-header-style 'full) 2414 ((eq pmail-header-style 'full)
2401 (setq result (buffer-substring beg (point-max)))) 2415 (prepend-to-buffer pmail-view-buffer beg (point-max)))
2402 ;; Handle the case where the headers matching the diplayed 2416 ;; Handle the case where the headers matching the diplayed
2403 ;; headers regexp should be copied. 2417 ;; headers regexp should be copied.
2404 ((and pmail-displayed-headers (null ignored-headers)) 2418 ((and pmail-displayed-headers (null ignored-headers))
@@ -2408,7 +2422,7 @@ copy all header fields whose names do not match
2408 (1+ (match-beginning 0)) 2422 (1+ (match-beginning 0))
2409 (point-max)))) 2423 (point-max))))
2410 (when (looking-at pmail-displayed-headers) 2424 (when (looking-at pmail-displayed-headers)
2411 (setq result (concat result (buffer-substring (point) lim)))) 2425 (append-to-buffer pmail-view-buffer (point) lim))
2412 (goto-char lim))) 2426 (goto-char lim)))
2413 ;; Handle the ignored headers. 2427 ;; Handle the ignored headers.
2414 ((or ignored-headers (setq ignored-headers pmail-ignored-headers)) 2428 ((or ignored-headers (setq ignored-headers pmail-ignored-headers))
@@ -2420,19 +2434,9 @@ copy all header fields whose names do not match
2420 (if (and (looking-at ignored-headers) 2434 (if (and (looking-at ignored-headers)
2421 (not (looking-at pmail-nonignored-headers))) 2435 (not (looking-at pmail-nonignored-headers)))
2422 (goto-char lim) 2436 (goto-char lim)
2423 (setq result (concat result (buffer-substring (point) lim))) 2437 (append-to-buffer pmail-view-buffer (point) lim)
2424 (goto-char lim)))) 2438 (goto-char lim))))
2425 (t (error "No headers selected for display!")))))) 2439 (t (error "No headers selected for display!"))))))))
2426 result))
2427
2428(defun pmail-copy-body (beg end)
2429 "Return the message body to be displayed in the view buffer.
2430BEG and END marks the start and end positions of the message in
2431the mail buffer."
2432 (with-current-buffer pmail-buffer
2433 (if (search-forward "\n\n" nil t)
2434 (buffer-substring (point) end)
2435 (error "Invalid message format: no header/body separator"))))
2436 2440
2437(defun pmail-toggle-header (&optional arg) 2441(defun pmail-toggle-header (&optional arg)
2438 "Show original message header if pruned header currently shown, or vice versa. 2442 "Show original message header if pruned header currently shown, or vice versa.
@@ -2444,7 +2448,7 @@ otherwise, show it in full."
2444 ((and (numberp arg) (> arg 0)) 'normal) 2448 ((and (numberp arg) (> arg 0)) 'normal)
2445 ((eq pmail-header-style 'full) 'normal) 2449 ((eq pmail-header-style 'full) 'normal)
2446 (t 'full))) 2450 (t 'full)))
2447 (pmail-show-message)) 2451 (pmail-show-message-maybe))
2448 2452
2449;; Lifted from repos-count-screen-lines. 2453;; Lifted from repos-count-screen-lines.
2450;; Return number of screen lines between START and END. 2454;; Return number of screen lines between START and END.
@@ -2750,7 +2754,7 @@ the message. Point is at the beginning of the message."
2750 (let ((pmail-show-message-hook 2754 (let ((pmail-show-message-hook
2751 (list (function (lambda () 2755 (list (function (lambda ()
2752 (goto-char (point-min))))))) 2756 (goto-char (point-min)))))))
2753 (pmail-show-message pmail-current-message))) 2757 (pmail-show-message-maybe pmail-current-message)))
2754 2758
2755(defun pmail-end-of-message () 2759(defun pmail-end-of-message ()
2756 "Show bottom of current message." 2760 "Show bottom of current message."
@@ -2759,7 +2763,7 @@ the message. Point is at the beginning of the message."
2759 (list (function (lambda () 2763 (list (function (lambda ()
2760 (goto-char (point-max)) 2764 (goto-char (point-max))
2761 (recenter (1- (window-height)))))))) 2765 (recenter (1- (window-height))))))))
2762 (pmail-show-message pmail-current-message))) 2766 (pmail-show-message-maybe pmail-current-message)))
2763 2767
2764(defun pmail-unknown-mail-followup-to () 2768(defun pmail-unknown-mail-followup-to ()
2765 "Handle a \"Mail-Followup-To\" header field with an unknown mailing list. 2769 "Handle a \"Mail-Followup-To\" header field with an unknown mailing list.
@@ -2801,7 +2805,7 @@ If so restore the actual mbox message collection."
2801 (buffer-swap-text pmail-view-buffer) 2805 (buffer-swap-text pmail-view-buffer)
2802 (setq pmail-buffers-swapped-p nil)))) 2806 (setq pmail-buffers-swapped-p nil))))
2803 2807
2804(defun pmail-show-message (&optional n no-summary) 2808(defun pmail-show-message-maybe (&optional n no-summary)
2805 "Show message number N (prefix argument), counting from start of file. 2809 "Show message number N (prefix argument), counting from start of file.
2806If summary buffer is currently displayed, update current message there also." 2810If summary buffer is currently displayed, update current message there also."
2807 (interactive "p") 2811 (interactive "p")
@@ -2816,39 +2820,10 @@ If summary buffer is currently displayed, update current message there also."
2816 (with-current-buffer pmail-view-buffer 2820 (with-current-buffer pmail-view-buffer
2817 (erase-buffer) 2821 (erase-buffer)
2818 (setq blurb "No mail."))) 2822 (setq blurb "No mail.")))
2819 (if (not n) 2823 (setq blurb (pmail-show-message n)))
2820 (setq n pmail-current-message)
2821 (cond ((<= n 0)
2822 (setq n 1
2823 pmail-current-message 1
2824 blurb "No previous message"))
2825 ((> n pmail-total-messages)
2826 (setq n pmail-total-messages
2827 pmail-current-message pmail-total-messages
2828 blurb "No following message"))
2829 (t
2830 (setq pmail-current-message n))))
2831 (let ((buf pmail-buffer)
2832 (beg (pmail-msgbeg n))
2833 (end (pmail-msgend n))
2834 headers body)
2835 (goto-char beg)
2836 (setq headers (pmail-copy-headers beg end)
2837 body (pmail-copy-body beg end))
2838 (pmail-set-attribute pmail-unseen-attr-index nil)
2839 (with-current-buffer pmail-view-buffer
2840 (erase-buffer)
2841 (insert headers "\n")
2842 (pmail-highlight-headers)
2843 (insert body)
2844 (goto-char (point-min)))))
2845 (when mail-mailing-lists 2824 (when mail-mailing-lists
2846 (pmail-unknown-mail-followup-to)) 2825 (pmail-unknown-mail-followup-to))
2847 (if transient-mark-mode (deactivate-mark)) 2826 (if transient-mark-mode (deactivate-mark))
2848 (pmail-display-labels)
2849 (buffer-swap-text pmail-view-buffer)
2850 (setq pmail-buffers-swapped-p t)
2851 (run-hooks 'pmail-show-message-hook)
2852 ;; If there is a summary buffer, try to move to this message 2827 ;; If there is a summary buffer, try to move to this message
2853 ;; in that buffer. But don't complain if this message 2828 ;; in that buffer. But don't complain if this message
2854 ;; is not mentioned in the summary. 2829 ;; is not mentioned in the summary.
@@ -2863,6 +2838,93 @@ If summary buffer is currently displayed, update current message there also."
2863 (if blurb 2838 (if blurb
2864 (message blurb)))) 2839 (message blurb))))
2865 2840
2841(defun pmail-is-text-p ()
2842 "Return t if the region contains a text message, nil
2843otherwise."
2844 (save-excursion
2845 (let ((text-regexp "\\(text\\|message\\)/")
2846 (content-type-header (mail-fetch-field "content-type")))
2847 ;; The message is text if either there is no content type header
2848 ;; (a default of "text/plain; charset=US-ASCII" is assumed) or
2849 ;; the base content type is either text or message.
2850 (or (not content-type-header)
2851 (string-match text-regexp content-type-header)))))
2852
2853(defun pmail-show-message (&optional msg)
2854 "Show message MSG using a special view buffer.
2855Return text to display in the minibuffer if MSG is out of
2856range (displaying a reasonable choice as well), nil otherwise.
2857The current mail message becomes the message displayed."
2858 (let ((mbox-buf pmail-buffer)
2859 (view-buf pmail-view-buffer)
2860 blurb beg end body-start coding-system character-coding is-text-message)
2861 (if (not msg)
2862 (setq msg pmail-current-message))
2863 (cond ((<= msg 0)
2864 (setq msg 1
2865 pmail-current-message 1
2866 blurb "No previous message"))
2867 ((> msg pmail-total-messages)
2868 (setq msg pmail-total-messages
2869 pmail-current-message pmail-total-messages
2870 blurb "No following message"))
2871 (t (setq pmail-current-message msg)))
2872 (with-current-buffer pmail-buffer
2873 ;; Mark the message as seen, bracket the message in the mail
2874 ;; buffer and determine the coding system the transfer encoding.
2875 (pmail-set-attribute pmail-unseen-attr-index nil)
2876 (setq beg (pmail-msgbeg msg)
2877 end (pmail-msgend msg))
2878 (widen)
2879 (narrow-to-region beg end)
2880 (goto-char beg)
2881 (setq body-start (search-forward "\n\n" nil t))
2882 (narrow-to-region beg (point))
2883 (goto-char beg)
2884 (setq character-coding (mail-fetch-field "content-transfer-encoding")
2885 is-text-message (pmail-is-text-p)
2886 coding-system (pmail-get-coding-system))
2887 (widen)
2888 (narrow-to-region beg end)
2889 ;; Decode the message body into an empty view buffer using a
2890 ;; unibyte temporary buffer where the character decoding takes
2891 ;; place.
2892 (with-current-buffer pmail-view-buffer
2893 (erase-buffer))
2894 (with-temp-buffer
2895 (set-buffer-multibyte nil)
2896 (insert-buffer-substring mbox-buf body-start end)
2897 (cond
2898 ((string= character-coding "quoted-printable")
2899 (mail-unquote-printable-region (point-min) (point-max)))
2900 ((and (string= character-coding "base64") is-text-message)
2901 (base64-decode-region (point-min) (point-max)))
2902 ((eq character-coding 'uuencode)
2903 (error "Not supported yet."))
2904 (t))
2905 (pmail-decode-region (point-min) (point-max) coding-system view-buf))
2906 ;; Copy the headers to the front of the message view buffer.
2907 (with-current-buffer pmail-view-buffer
2908 (goto-char (point-min)))
2909 (pmail-copy-headers beg end)
2910 ;; Add the separator (blank line) between headers and body;
2911 ;; highlight the message, activate any URL like text and add
2912 ;; special highlighting for and quoted material.
2913 (with-current-buffer pmail-view-buffer
2914 (insert "\n")
2915 (goto-char (point-min))
2916 (pmail-highlight-headers)
2917 ;(pmail-activate-urls)
2918 ;(pmail-process-quoted-material)
2919 )
2920 ;; Update the mode-line with message status information and swap
2921 ;; the view buffer/mail buffer contents.
2922 (pmail-display-labels)
2923 (buffer-swap-text pmail-view-buffer)
2924 (setq pmail-buffers-swapped-p t)
2925 (run-hooks 'pmail-show-message-hook))
2926 blurb))
2927
2866;; Find all occurrences of certain fields, and highlight them. 2928;; Find all occurrences of certain fields, and highlight them.
2867(defun pmail-highlight-headers () 2929(defun pmail-highlight-headers ()
2868 ;; Do this only if the system supports faces. 2930 ;; Do this only if the system supports faces.
@@ -2950,7 +3012,7 @@ With prefix arg N, moves forward N messages, or backward if N is negative."
2950 (interactive "p") 3012 (interactive "p")
2951 (set-buffer pmail-buffer) 3013 (set-buffer pmail-buffer)
2952 (pmail-maybe-set-message-counters) 3014 (pmail-maybe-set-message-counters)
2953 (pmail-show-message (+ pmail-current-message n))) 3015 (pmail-show-message-maybe (+ pmail-current-message n)))
2954 3016
2955(defun pmail-previous-message (n) 3017(defun pmail-previous-message (n)
2956 "Show previous message whether deleted or not. 3018 "Show previous message whether deleted or not.
@@ -2978,7 +3040,7 @@ Returns t if a new message is being shown, nil otherwise."
2978 (if (not (pmail-message-deleted-p current)) 3040 (if (not (pmail-message-deleted-p current))
2979 (setq lastwin current n (1+ n)))) 3041 (setq lastwin current n (1+ n))))
2980 (if (/= lastwin pmail-current-message) 3042 (if (/= lastwin pmail-current-message)
2981 (progn (pmail-show-message lastwin) 3043 (progn (pmail-show-message-maybe lastwin)
2982 t) 3044 t)
2983 (if (< n 0) 3045 (if (< n 0)
2984 (message "No previous nondeleted message")) 3046 (message "No previous nondeleted message"))
@@ -2997,13 +3059,13 @@ or forward if N is negative."
2997 "Show first message in file." 3059 "Show first message in file."
2998 (interactive) 3060 (interactive)
2999 (pmail-maybe-set-message-counters) 3061 (pmail-maybe-set-message-counters)
3000 (pmail-show-message 1)) 3062 (pmail-show-message-maybe (< 1 pmail-total-messages)))
3001 3063
3002(defun pmail-last-message () 3064(defun pmail-last-message ()
3003 "Show last message in file." 3065 "Show last message in file."
3004 (interactive) 3066 (interactive)
3005 (pmail-maybe-set-message-counters) 3067 (pmail-maybe-set-message-counters)
3006 (pmail-show-message pmail-total-messages)) 3068 (pmail-show-message-maybe pmail-total-messages))
3007 3069
3008(defun pmail-what-message () 3070(defun pmail-what-message ()
3009 (let ((where (point)) 3071 (let ((where (point))
@@ -3113,7 +3175,7 @@ Interactively, empty argument means use same regexp used last time."
3113 (setq n (+ n (if reversep 1 -1))))) 3175 (setq n (+ n (if reversep 1 -1)))))
3114 (if win 3176 (if win
3115 (progn 3177 (progn
3116 (pmail-show-message msg) 3178 (pmail-show-message-maybe msg)
3117 ;; Search forward (if this is a normal search) or backward 3179 ;; Search forward (if this is a normal search) or backward
3118 ;; (if this is a reverse search) through this message to 3180 ;; (if this is a reverse search) through this message to
3119 ;; position point. This search may fail because REGEXP 3181 ;; position point. This search may fail because REGEXP
@@ -3245,7 +3307,7 @@ If N is negative, go backwards instead."
3245 (if done (setq found i))) 3307 (if done (setq found i)))
3246 (setq n (if forward (1- n) (1+ n)))))) 3308 (setq n (if forward (1- n) (1+ n))))))
3247 (if found 3309 (if found
3248 (pmail-show-message found) 3310 (pmail-show-message-maybe found)
3249 (error "No %s message with same subject" 3311 (error "No %s message with same subject"
3250 (if forward "following" "previous"))))) 3312 (if forward "following" "previous")))))
3251 3313
@@ -3281,7 +3343,7 @@ If N is negative, go forwards instead."
3281 (if (= msg 0) 3343 (if (= msg 0)
3282 (error "No previous deleted message") 3344 (error "No previous deleted message")
3283 (if (/= msg pmail-current-message) 3345 (if (/= msg pmail-current-message)
3284 (pmail-show-message msg)) 3346 (pmail-show-message-maybe msg))
3285 (pmail-set-attribute pmail-deleted-attr-index nil) 3347 (pmail-set-attribute pmail-deleted-attr-index nil)
3286 (if (pmail-summary-exists) 3348 (if (pmail-summary-exists)
3287 (save-excursion 3349 (save-excursion
@@ -3416,8 +3478,7 @@ See also user-option `pmail-confirm-expunge'."
3416 (if (not win) 3478 (if (not win)
3417 (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax))) 3479 (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax)))
3418 (if (not dont-show) 3480 (if (not dont-show)
3419 (pmail-show-message 3481 (pmail-show-message-maybe (< pmail-current-message pmail-total-messages)))
3420 (if (zerop pmail-current-message) 1 nil)))
3421 (pmail-swap-buffers-maybe) 3482 (pmail-swap-buffers-maybe)
3422 (if pmail-enable-mime 3483 (if pmail-enable-mime
3423 (goto-char (+ (point-min) opoint)) 3484 (goto-char (+ (point-min) opoint))