Changes committed gnus/lisp (ChangeLog mm-encode.el mml.el)

"Katsumi Yamaoka" <[email protected]> Mon, 07 Sep 2009 10:37:39 +0200
Newsgroups gmane.emacs.gnus.commits
Message-ID <[email protected]>
Modified: ChangeLog mm-encode.el mml.el

* mm-encode.el (mm-encode-buffer): Don't force 7bit encoding since MTA
 may break data.  Suggested by Dmitri Paduchikh <[email protected]>.
 Add the optional argument `encoding' that overrides the default.

* mml.el (mml-generate-mime-1): Pass encoding defined by a user to
 mm-encode-buffer.


Index: ChangeLog
diff -u gnus/lisp/ChangeLog:7.2009 gnus/lisp/ChangeLog:7.2010
--- ChangeLog:7.2009	Thu Sep  3 01:16:39 2009
+++ ChangeLog	Mon Sep  7 10:37:39 2009
@@ -1,3 +1,12 @@
+2009-09-07  Katsumi Yamaoka  <[email protected]>
+
+	* mm-encode.el (mm-encode-buffer): Don't force 7bit encoding since MTA
+	may break data.  Suggested by Dmitri Paduchikh <[email protected]>.
+	Add the optional argument `encoding' that overrides the default.
+
+	* mml.el (mml-generate-mime-1): Pass encoding defined by a user to
+	mm-encode-buffer.
+
 2009-09-02  Karl Kleinpaste  <[email protected]>
 
 	* gnus-art.el (gnus-article-read-summary-keys):
Index: mm-encode.el
diff -u gnus/lisp/mm-encode.el:7.17 gnus/lisp/mm-encode.el:7.18
--- mm-encode.el:7.17	Thu Jan 22 08:02:16 2009
+++ mm-encode.el	Mon Sep  7 10:37:39 2009
@@ -137,22 +137,19 @@
    (t
     (error "Unknown encoding %s" encoding))))
 
-(defun mm-encode-buffer (type)
-  "Encode the buffer which contains data of MIME type TYPE.
+(defun mm-encode-buffer (type &optional encoding)
+  "Encode the buffer which contains data of MIME type TYPE by ENCODING.
 TYPE is a string or a list of the components.
+The optional ENCODING overrides the encoding determined according to
+TYPE and `mm-content-transfer-encoding-defaults'.
 The encoding used is returned."
-  (let* ((mime-type (if (stringp type) type (car type)))
-	 (encoding
-	  (or (and (listp type)
-		   (cadr (assq 'encoding type)))
-	      (mm-content-transfer-encoding mime-type)))
-	 (bits (mm-body-7-or-8)))
-    ;; We force buffers that are 7bit to be unencoded, no matter
-    ;; what the preferred encoding is.
-    ;; Only if the buffers don't contain lone lines.
-    (when (and (eq bits '7bit) (not (mm-long-lines-p 76)))
-      (setq encoding bits))
-    (mm-encode-content-transfer-encoding encoding mime-type)
+  (let ((mime-type (if (stringp type) type (car type))))
+    (mm-encode-content-transfer-encoding
+     (or encoding
+	 (setq encoding (or (and (listp type)
+				 (cadr (assq 'encoding type)))
+			    (mm-content-transfer-encoding mime-type))))
+     mime-type)
     encoding))
 
 (defun mm-insert-headers (type encoding &optional file)
Index: mml.el
diff -u gnus/lisp/mml.el:7.77 gnus/lisp/mml.el:7.78
--- mml.el:7.77	Mon Aug 31 02:10:23 2009
+++ mml.el	Mon Sep  7 10:37:39 2009
@@ -585,7 +585,9 @@
 			(unless raw
 			  (setq charset	(mm-encode-body charset))))
 		    (insert contents)))))
-	      (setq encoding (mm-encode-buffer type)
+	      (if (setq encoding (cdr (assq 'encoding cont)))
+		  (setq encoding (intern (downcase encoding))))
+	      (setq encoding (mm-encode-buffer type encoding)
 		    coded (mm-string-as-multibyte (buffer-string))))
 	    (mml-insert-mime-headers cont type charset encoding nil)
 	    (insert "\n" coded))))