]> code.delx.au - gnu-emacs/blobdiff - lisp/mail/rmail.el
* mail/rmail.el (rmail-show-message-1): When displaying a mime message,
[gnu-emacs] / lisp / mail / rmail.el
index b35e73612d7792a85257b9f04d66965ac2355d63..d150324fc79676c6a6125fe2729d6a296f2b83a3 100644 (file)
@@ -2762,7 +2762,8 @@ The current mail message becomes the message displayed."
   (let ((mbox-buf rmail-buffer)
        (view-buf rmail-view-buffer)
        blurb beg end body-start coding-system character-coding
-       is-text-message header-style)
+       is-text-message header-style
+       showing-message)
     (if (not msg)
        (setq msg rmail-current-message))
     (unless (setq blurb (rmail-no-mail-p))
@@ -2788,7 +2789,8 @@ The current mail message becomes the message displayed."
        (setq beg (rmail-msgbeg msg)
              end (rmail-msgend msg))
        (when (> (- end beg) rmail-show-message-verbose-min)
-         (message "Showing message %d" msg))
+         (setq showing-message t)
+         (message "Showing message %d..." msg))
        (narrow-to-region beg end)
        (goto-char beg)
        (with-current-buffer rmail-view-buffer
@@ -2802,6 +2804,8 @@ The current mail message becomes the message displayed."
                 (re-search-forward "mime-version: 1.0" nil t))
            (let ((rmail-buffer mbox-buf)
                  (rmail-view-buffer view-buf))
+             (setq showing-message t)
+             (message "Showing message %d..." msg)
              (set (make-local-variable 'rmail-mime-decoded) t)
              (funcall rmail-show-mime-function))
          (setq body-start (search-forward "\n\n" nil t))
@@ -2881,8 +2885,8 @@ The current mail message becomes the message displayed."
        (rmail-swap-buffers)
        (setq rmail-buffer-swapped t)
        (run-hooks 'rmail-show-message-hook)
-       (when (> (- end beg) rmail-show-message-verbose-min)
-         (message "Showing message %d...done" msg))))
+       (when showing-message
+         (setq blurb (format "Showing message %d...done" msg)))))
     blurb))
 
 (defun rmail-copy-headers (beg end &optional ignored-headers)
@@ -4528,17 +4532,22 @@ encoded string (and the same mask) will decode the string."
        (let ((coding-system-for-read coding-system-for-read)
              (case-fold-search t)
              unquote
-             armor-start armor-prefix armor-end after-end)
+             armor-start armor-prefix armor-end-regexp armor-end after-end)
 
          (setq armor-start (match-beginning 0)
                armor-prefix (buffer-substring
                              (line-beginning-position)
-                             armor-start)
-               armor-end (re-search-forward
-                          (concat "^"
-                                  armor-prefix
-                                  "-----END PGP MESSAGE-----$")
-                          nil t))
+                             armor-start))
+         (if (string-match "<pre>\\'" armor-prefix)
+             (setq armor-prefix ""))
+
+         (setq armor-end-regexp
+               (concat "^"
+                       armor-prefix
+                       "-----END PGP MESSAGE-----$"))
+         (setq armor-end (re-search-forward armor-end-regexp
+                                            nil t))
+
          (unless armor-end
            (error "Encryption armor beginning has no matching end"))
          (goto-char armor-start)
@@ -4559,13 +4568,13 @@ encoded string (and the same mask) will decode the string."
 
                ;; Use the charset specified in the armor.
                (unless coding-system-for-read
-                 (if (re-search-forward "^Charset: \\(.*\\)" nil t)
+                 (if (re-search-forward "^[ \t]*Charset[ \t\n]*:[ \t\n]*\\(.*\\)" nil t)
                      (setq coding-system-for-read
                            (epa--find-coding-system-for-mime-charset
                             (intern (downcase (match-string 1)))))))
 
                (goto-char (point-min))
-               (if (re-search-forward "^[ \t]*Content-transfer-encoding[ \t]*:[ \t]*quoted-printable[ \t]*$" nil t)
+               (if (re-search-forward "^[ \t]*Content-transfer-encoding[ \t\n]*:[ \t\n]*quoted-printable[ \t]*$" nil t)
                    (setq unquote t)))))
 
          (when unquote
@@ -4583,7 +4592,8 @@ encoded string (and the same mask) will decode the string."
               (goto-char armor-start)
               (current-buffer))))
 
-         (push (list armor-start (- (point-max) after-end))
+         (push (list armor-start (- (point-max) after-end) mime
+                     armor-end-regexp)
                decrypts)))
 
       (unless decrypts
@@ -4599,14 +4609,35 @@ encoded string (and the same mask) will decode the string."
              (narrow-to-region beg end)
              (goto-char (point-min))
              (dolist (d decrypts)
+               ;; Find, in the real Rmail buffer, the same armors
+               ;; that we found and decrypted in the view buffer.
                (if (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
-                   (let (armor-start armor-end)
+                   (let (armor-start armor-end armor-end-regexp)
                      (setq armor-start (match-beginning 0)
-                           armor-end (re-search-forward "^-----END PGP MESSAGE-----$"
-                                                        nil t))
+                           armor-end-regexp (nth 3 d)
+                           armor-end (re-search-forward
+                                      armor-end-regexp
+                                      nil t))
+
+                     ;; Found as expected -- now replace it with the decrypt.
                      (when armor-end
                        (delete-region armor-start armor-end)
-                       (insert-buffer-substring from-buffer (nth 0 d) (nth 1 d)))))))))))))
+                       (insert-buffer-substring from-buffer (nth 0 d) (nth 1 d)))
+
+                     ;; Change the mime type (if this is in a mime part)
+                     ;; so this part will display by default
+                     ;; when the message is shown later.
+                     (when (nth 2 d)
+                       (goto-char armor-start)
+                       (when (re-search-backward "^--" nil t)
+                         (save-restriction
+                           (narrow-to-region (point) armor-start)
+                           (when (re-search-forward "^content-type[ \t\n]*:[ \t\n]*" nil t)
+                             (when (looking-at "[^\n \t;]+")
+                               (let ((value (match-string 0)))
+                                 (unless (member value '("text/plain" "text/html"))
+                                   (replace-match "text/plain"))))))))
+                     ))))))))))
  
 \f
 ;;;;  Desktop support
@@ -4660,7 +4691,7 @@ encoded string (and the same mask) will decode the string."
 \f
 ;;; Start of automatically extracted autoloads.
 \f
-;;;### (autoloads nil "rmailedit" "rmailedit.el" "b155463a02e4aa9256ac21997ea003e9")
+;;;### (autoloads nil "rmailedit" "rmailedit.el" "f6da7267316d02c90b9d314ce95b3c22")
 ;;; Generated autoloads from rmailedit.el
 
 (autoload 'rmail-edit-current-message "rmailedit" "\
@@ -4670,7 +4701,7 @@ Edit the contents of this message.
 
 ;;;***
 \f
-;;;### (autoloads nil "rmailkwd" "rmailkwd.el" "d462d15a119ee2a1733de2bc31bf347c")
+;;;### (autoloads nil "rmailkwd" "rmailkwd.el" "298dcda7febb6e4ebf0a166101f40650")
 ;;; Generated autoloads from rmailkwd.el
 
 (autoload 'rmail-add-label "rmailkwd" "\
@@ -4713,7 +4744,7 @@ With prefix argument N moves forward N messages with these labels.
 
 ;;;***
 \f
-;;;### (autoloads nil "rmailmm" "rmailmm.el" "6446c799d49a6df8519b11bfe2e3cbea")
+;;;### (autoloads nil "rmailmm" "rmailmm.el" "a17df5ef8968113c8f6a78cf85c82da4")
 ;;; Generated autoloads from rmailmm.el
 
 (autoload 'rmail-mime "rmailmm" "\
@@ -4739,7 +4770,7 @@ The arguments ARG and STATE have no effect in this case.
 
 ;;;***
 \f
-;;;### (autoloads nil "rmailmsc" "rmailmsc.el" "0950b0ad020610737220948bb3f37c17")
+;;;### (autoloads nil "rmailmsc" "rmailmsc.el" "c3f0d33739768fc12acc4258ae0da72e")
 ;;; Generated autoloads from rmailmsc.el
 
 (autoload 'set-rmail-inbox-list "rmailmsc" "\
@@ -4753,7 +4784,7 @@ This applies only to the current session.
 
 ;;;***
 \f
-;;;### (autoloads nil "rmailsort" "rmailsort.el" "4106a6e4898795822554ce931f531ab8")
+;;;### (autoloads nil "rmailsort" "rmailsort.el" "8f551773021df4fa1a14ec2517e6a4f1")
 ;;; Generated autoloads from rmailsort.el
 
 (autoload 'rmail-sort-by-date "rmailsort" "\
@@ -4810,7 +4841,7 @@ If prefix argument REVERSE is non-nil, sorts in reverse order.
 
 ;;;***
 \f
-;;;### (autoloads nil "rmailsum" "rmailsum.el" "ee1fa556cd65d7ef457a97ab560e15da")
+;;;### (autoloads nil "rmailsum" "rmailsum.el" "3203e61425330fc20f3154b559f8b539")
 ;;; Generated autoloads from rmailsum.el
 
 (autoload 'rmail-summary "rmailsum" "\
@@ -4857,7 +4888,7 @@ SENDERS is a string of regexps separated by commas.
 
 ;;;***
 \f
-;;;### (autoloads nil "undigest" "undigest.el" "f30d93eb6a006ac64080a1ee8a45a1af")
+;;;### (autoloads nil "undigest" "undigest.el" "912d4d3bf762991df5d4d02f42358025")
 ;;; Generated autoloads from undigest.el
 
 (autoload 'undigestify-rmail-message "undigest" "\