From: yamaoka Date: Tue, 14 Nov 2000 03:03:57 +0000 (+0000) Subject: Synch with Gnus. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ea725a663243315436a4016e896903e02b072e1;p=elisp%2Fgnus.git- Synch with Gnus. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4d896fc..c81216a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2000-11-13 20:43:37 ShengHuo ZHU + + * mm-decode.el (mm-get-part): Don't call mm-insert-part. + * mml.el (mml-generate-mime-1): Use charset attribute. + * mm-bodies.el (mm-encode-body): Add parameter charset. + * mm-util.el (mm-mime-charset): Show error when find 8-bit characters. + 2000-11-13 16:09:09 ShengHuo ZHU * mml2015.el (mml2015-mailcrypt-decrypt): Handle quit. diff --git a/lisp/mm-bodies.el b/lisp/mm-bodies.el index f35d273..d4c3677 100644 --- a/lisp/mm-bodies.el +++ b/lisp/mm-bodies.el @@ -51,60 +51,61 @@ Valid encodings are `7bit', `8bit', `quoted-printable' and `base64'." (const base64)))) :group 'mime) -(defun mm-encode-body () +(defun mm-encode-body (&optional charset) "Encode a body. Should be called narrowed to the body that is to be encoded. If there is more than one non-ASCII MULE charset, then list of found MULE charsets are returned. +If CHARSET is non-nil, it is used. If successful, the MIME charset is returned. If no encoding was done, nil is returned." (if (not (mm-multibyte-p)) ;; In the non-Mule case, we search for non-ASCII chars and ;; return the value of `mail-parse-charset' if any are found. - (save-excursion - (goto-char (point-min)) - (if (re-search-forward "[^\x0-\x7f]" nil t) - (or mail-parse-charset - (message-options-get 'mm-encody-body-charset) - (message-options-set - 'mm-encody-body-charset - (mm-read-charset "Charset used in the article: "))) - ;; The logic in `mml-generate-mime-1' confirms that it's OK - ;; to return nil here. - nil)) + (or charset + (save-excursion + (goto-char (point-min)) + (if (re-search-forward "[^\x0-\x7f]" nil t) + (or mail-parse-charset + (message-options-get 'mm-encody-body-charset) + (message-options-set + 'mm-encody-body-charset + (mm-read-charset "Charset used in the article: "))) + ;; The logic in `mml-generate-mime-1' confirms that it's OK + ;; to return nil here. + nil))) (save-excursion - (goto-char (point-min)) - (let ((charsets (mm-find-mime-charset-region (point-min) (point-max))) + (if charset + (progn + (mm-encode-coding-region (point-min) (point-max) charset) charset) - (cond - ;; No encoding. - ((null charsets) - nil) - ;; Too many charsets. - ((> (length charsets) 1) - charsets) - ;; We encode. - (t - (let ((charset (car charsets)) - start) - (when (or t - ;; We always decode. - (not (mm-coding-system-equal - charset buffer-file-coding-system))) - (while (not (eobp)) - (if (eq (mm-charset-after) 'ascii) - (when start - (save-restriction - (narrow-to-region start (point)) - (mm-encode-coding-region start (point) charset) - (goto-char (point-max))) - (setq start nil)) - (unless start - (setq start (point)))) - (forward-char 1)) - (when start - (mm-encode-coding-region start (point) charset) - (setq start nil))) + (goto-char (point-min)) + (let ((charsets (mm-find-mime-charset-region (point-min) (point-max))) + start) + (cond + ;; No encoding. + ((null charsets) + nil) + ;; Too many charsets. + ((> (length charsets) 1) + charsets) + ;; We encode. + (t + (setq charset (car charsets)) + (while (not (eobp)) + (if (eq (mm-charset-after) 'ascii) + (when start + (save-restriction + (narrow-to-region start (point)) + (mm-encode-coding-region start (point) charset) + (goto-char (point-max))) + (setq start nil)) + (unless start + (setq start (point)))) + (forward-char 1)) + (when start + (mm-encode-coding-region start (point) charset) + (setq start nil)) charset))))))) (defun mm-body-encoding (charset &optional encoding) diff --git a/lisp/mm-decode.el b/lisp/mm-decode.el index 4020aa9..e7ef10f 100644 --- a/lisp/mm-decode.el +++ b/lisp/mm-decode.el @@ -740,7 +740,12 @@ external if displayed external." (defun mm-get-part (handle) "Return the contents of HANDLE as a string." (mm-with-unibyte-buffer - (mm-insert-part handle) + (insert (with-current-buffer (mm-handle-buffer handle) + (mm-with-unibyte-current-buffer-mule4 + (buffer-string)))) + (mm-decode-content-transfer-encoding + (mm-handle-encoding handle) + (mm-handle-media-type handle)) (buffer-string))) (defun mm-insert-part (handle) diff --git a/lisp/mm-util.el b/lisp/mm-util.el index 4a09259..d25b6aa 100644 --- a/lisp/mm-util.el +++ b/lisp/mm-util.el @@ -287,6 +287,8 @@ If the charset is `composition', return the actual one." (defun mm-mime-charset (charset) "Return the MIME charset corresponding to the MULE CHARSET." + (if (eq charset 'unknown) + (error "8-bit characters are found in the message, please specify charset.")) (if (and (fboundp 'coding-system-get) (fboundp 'get-charset-property)) ;; This exists in Emacs 20. (or diff --git a/lisp/mml.el b/lisp/mml.el index 0d8facf..8bafd18 100644 --- a/lisp/mml.el +++ b/lisp/mml.el @@ -292,12 +292,15 @@ If MML is non-nil, return the buffer up till the correspondent mml tag." (if (and (not raw) (member (car (split-string type "/")) '("text" "message"))) (with-temp-buffer + (setq charset (mm-charset-to-coding-system + (cdr (assq 'charset cont)))) (cond ((cdr (assq 'buffer cont)) (insert-buffer-substring (cdr (assq 'buffer cont)))) ((and (setq filename (cdr (assq 'filename cont))) (not (equal (cdr (assq 'nofile cont)) "yes"))) - (mm-insert-file-contents filename)) + (let ((coding-system-for-read charset)) + (mm-insert-file-contents filename))) ((eq 'mml (car cont)) (insert (cdr (assq 'contents cont)))) (t @@ -324,7 +327,7 @@ If MML is non-nil, return the buffer up till the correspondent mml tag." ;; ignore 0x1b, it is part of iso-2022-jp (setq encoding (mm-body-7-or-8)))) (t - (setq charset (mm-encode-body)) + (setq charset (mm-encode-body charset)) (setq encoding (mm-body-encoding charset (cdr (assq 'encoding cont)))))) (setq coded (buffer-string)))