2001-07-15 Pavel Jan\e,Bm\e(Bk <Pavel@Janik.cz>
[gnus] / lisp / rfc2047.el
index 7d04a83..4b8cff9 100644 (file)
@@ -127,15 +127,23 @@ Should be called narrowed to the head of the message."
        (save-restriction
          (rfc2047-narrow-to-field)
          (if (not (rfc2047-encodable-p))
-             (if (and (eq (mm-body-7-or-8) '8bit)
-                      (mm-multibyte-p)
-                      (mm-coding-system-p
-                       (car message-posting-charset)))
-                      ;; 8 bit must be decoded.
-                      ;; Is message-posting-charset a coding system?
-                      (mm-encode-coding-region
-                       (point-min) (point-max)
-                       (car message-posting-charset)))
+             (prog1
+               (if (and (eq (mm-body-7-or-8) '8bit)
+                        (mm-multibyte-p)
+                        (mm-coding-system-p
+                         (car message-posting-charset)))
+                   ;; 8 bit must be decoded.
+                   ;; Is message-posting-charset a coding system?
+                   (mm-encode-coding-region
+                    (point-min) (point-max)
+                    (car message-posting-charset)))
+               ;; No encoding necessary, but folding is nice
+               (rfc2047-fold-region (save-excursion
+                                      (goto-char (point-min))
+                                      (skip-chars-forward "^:")
+                                      (and (looking-at ": ")
+                                           (forward-char 2))
+                                      (point)) (point-max)))
            ;; We found something that may perhaps be encoded.
            (setq method nil
                  alist rfc2047-header-encoding-alist)
@@ -168,7 +176,7 @@ Should be called narrowed to the head of the message."
                            (y-or-n-p
                             "Some texts are not encoded. Encode anyway?")))
                       (rfc2047-encode-region (point-min) (point-max))
-                    (error "Cannot send unencoded text."))))
+                    (error "Cannot send unencoded text"))))
             ((mm-coding-system-p method)
              (if (and (featurep 'mule)
                       (if (boundp 'default-enable-multibyte-characters)
@@ -331,7 +339,7 @@ The buffer may be narrowed."
          (goto-char (or break qword-break))
          (setq break nil
                qword-break nil)
-         (if (looking-at " \t")
+         (if (looking-at "[ \t]")
              (insert "\n")
            (insert "\n "))
          (setq bol (1- (point)))
@@ -365,7 +373,7 @@ The buffer may be narrowed."
        (goto-char (or break qword-break))
        (setq break nil
              qword-break nil)
-         (if (looking-at " \t")
+         (if (looking-at "[ \t]")
              (insert "\n")
            (insert "\n "))
        (setq bol (1- (point)))