aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2011-01-14 13:04:10 +0900
committerKenichi Handa2011-01-14 13:04:10 +0900
commit1a6a03e4a30d48bdbb3f188c7de0c0ab09e16992 (patch)
treed177aa94494772bb703fead94d8f760271b6fa24
parent07ee9351461ff93feabd66f36ccfdc0ff7b5dcfc (diff)
downloademacs-1a6a03e4a30d48bdbb3f188c7de0c0ab09e16992.tar.gz
emacs-1a6a03e4a30d48bdbb3f188c7de0c0ab09e16992.zip
Fix setting of buffer-file-coding-system of RMAIL buffer.
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/mail/rmailmm.el34
2 files changed, 41 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4fc3a1fb49e..9ed8ee80c89 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12011-01-14 Kenichi Handa <handa@m17n.org>
2
3 * mail/rmailmm.el (rmail-mime-insert-header): Set
4 rmail-mime-coding-system to a cons whose car is the last coding
5 system used to decode the header.
6 (rmail-mime-find-header-encoding): New function.
7 (rmail-mime-insert-decoded-text): Override
8 rmail-mime-coding-system if it is a cons.
9 (rmail-show-mime): If only a header part was decoded, find the
10 coding system while ignoring mm-charset-override-alist.
11
12011-01-12 Kenichi Handa <handa@m17n.org> 122011-01-12 Kenichi Handa <handa@m17n.org>
2 13
3 * mail/rmailmm.el (rmail-mime-next-item) 14 * mail/rmailmm.el (rmail-mime-next-item)
diff --git a/lisp/mail/rmailmm.el b/lisp/mail/rmailmm.el
index 3a43e4c069e..d6af925d461 100644
--- a/lisp/mail/rmailmm.el
+++ b/lisp/mail/rmailmm.el
@@ -460,12 +460,27 @@ See `rmail-mime-entity' for the detail."
460 (rmail-copy-headers (point) (aref header 1))))) 460 (rmail-copy-headers (point) (aref header 1)))))
461 (rfc2047-decode-region pos (point)) 461 (rfc2047-decode-region pos (point))
462 (if (and last-coding-system-used (not rmail-mime-coding-system)) 462 (if (and last-coding-system-used (not rmail-mime-coding-system))
463 (setq rmail-mime-coding-system last-coding-system-used)) 463 (setq rmail-mime-coding-system (cons last-coding-system-used nil)))
464 (goto-char (point-min)) 464 (goto-char (point-min))
465 (rmail-highlight-headers) 465 (rmail-highlight-headers)
466 (goto-char (point-max)) 466 (goto-char (point-max))
467 (insert "\n")))) 467 (insert "\n"))))
468 468
469(defun rmail-mime-find-header-encoding (header)
470 "Retun the last coding system used to decode HEADER.
471HEADER is a header component of a MIME-entity object (see
472`rmail-mime-entity')."
473 (with-temp-buffer
474 (let ((last-coding-system-used nil))
475 (with-current-buffer rmail-mime-mbox-buffer
476 (let ((rmail-buffer rmail-mime-mbox-buffer)
477 (rmail-view-buffer rmail-mime-view-buffer))
478 (save-excursion
479 (goto-char (aref header 0))
480 (rmail-copy-headers (point) (aref header 1)))))
481 (rfc2047-decode-region (point-min) (point-max))
482 last-coding-system-used)))
483
469(defun rmail-mime-text-handler (content-type 484(defun rmail-mime-text-handler (content-type
470 content-disposition 485 content-disposition
471 content-transfer-encoding) 486 content-transfer-encoding)
@@ -498,7 +513,7 @@ See `rmail-mime-entity' for the detail."
498 ((string= transfer-encoding "quoted-printable") 513 ((string= transfer-encoding "quoted-printable")
499 (quoted-printable-decode-region pos (point)))))) 514 (quoted-printable-decode-region pos (point))))))
500 (decode-coding-region pos (point) coding-system) 515 (decode-coding-region pos (point) coding-system)
501 (or rmail-mime-coding-system 516 (if (or (not rmail-mime-coding-system) (consp rmail-mime-coding-system))
502 (setq rmail-mime-coding-system coding-system)) 517 (setq rmail-mime-coding-system coding-system))
503 (or (bolp) (insert "\n")))) 518 (or (bolp) (insert "\n"))))
504 519
@@ -1274,8 +1289,19 @@ attachments as specfied by `rmail-mime-attachment-dirs-alist'."
1274 (with-current-buffer rmail-mime-view-buffer 1289 (with-current-buffer rmail-mime-view-buffer
1275 (erase-buffer) 1290 (erase-buffer)
1276 (rmail-mime-insert entity) 1291 (rmail-mime-insert entity)
1277 (if rmail-mime-coding-system 1292 (if (consp rmail-mime-coding-system)
1278 (set-buffer-file-coding-system rmail-mime-coding-system t t))) 1293 ;; Decoding is done by rfc2047-decode-region only for a
1294 ;; header. But, as the used coding system may have been
1295 ;; overriden by mm-charset-override-alist, we can't
1296 ;; trust (car rmail-mime-coding-system). So, here we
1297 ;; try the decoding again with mm-charset-override-alist
1298 ;; bound to nil.
1299 (let ((mm-charset-override-alist nil))
1300 (setq rmail-mime-coding-system
1301 (rmail-mime-find-header-encoding
1302 (rmail-mime-entity-header entity)))))
1303 (set-buffer-file-coding-system
1304 (coding-system-base rmail-mime-coding-system) t t))
1279 ;; Decoding failed. ENTITY is an error message. Insert the 1305 ;; Decoding failed. ENTITY is an error message. Insert the
1280 ;; original message body as is, and show warning. 1306 ;; original message body as is, and show warning.
1281 (let ((region (with-current-buffer rmail-mime-mbox-buffer 1307 (let ((region (with-current-buffer rmail-mime-mbox-buffer