X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Frfc2047.el;h=1f07cb6df98a8fb1b15fb21b48325034e336da57;hb=5357096aae0887174a86d6a6796112d6b3d2d53e;hp=0cbb7327a2d57389040e0ad29313118c068ccd53;hpb=4f9a9bcacfb7b260f0053324bf022e4b14f65155;p=elisp%2Fgnus.git- diff --git a/lisp/rfc2047.el b/lisp/rfc2047.el index 0cbb732..1f07cb6 100644 --- a/lisp/rfc2047.el +++ b/lisp/rfc2047.el @@ -97,6 +97,25 @@ quoted-printable and base64 respectively.") ;;; Functions for encoding RFC2047 messages ;;; +(defun rfc2047-qp-or-base64 () + "Return the type with which to encode the buffer. +This is either `base64' or `quoted-printable'." + (save-excursion + (let ((limit (min (point-max) (+ 2000 (point-min)))) + (n8bit 0)) + (goto-char (point-min)) + (skip-chars-forward "\x20-\x7f\r\n\t" limit) + (while (< (point) limit) + (incf n8bit) + (forward-char 1) + (skip-chars-forward "\x20-\x7f\r\n\t" limit)) + (if (or (< (* 6 n8bit) (- limit (point-min))) + ;; Don't base64, say, a short line with a single + ;; non-ASCII char when splitting parts by charset. + (= n8bit 1)) + 'quoted-printable + 'base64)))) + (defun rfc2047-narrow-to-field () "Narrow the buffer to the header on the current line." (beginning-of-line) @@ -382,12 +401,12 @@ By default, the region is treated as containing addresses (see ;; encoding, choose the one that's shorter. (save-restriction (narrow-to-region b e) - (if (eq (mm-qp-or-base64) 'base64) + (if (eq (rfc2047-qp-or-base64) 'base64) 'B 'Q)))) (start (concat "=?" (downcase (symbol-name mime-charset)) "?" - (downcase (symbol-name encoding)) "?")) + (upcase (symbol-name encoding)) "?")) (factor (case mime-charset ((iso-8859-5 iso-8859-7 iso-8859-8 koi8-r) 1) ((big5 gb2312 euc-kr) 2) @@ -588,8 +607,8 @@ By default, the region is treated as containing addresses (see (eval-and-compile (defconst rfc2047-encoded-word-regexp - "=\\?\\([^][\000-\040()<>@,\;:\\\"/?.=]+\\)\\?\\(B\\|Q\\)\ -\\?\\([!->@-~ +]*\\)\\?=")) + "=\\?\\([^][\000-\040()<>@,\;:*\\\"/?.=]+\\)\\(?:\\*[^?]+\\)?\ +\\?\\(B\\|Q\\)\\?\\([!->@-~ ]*\\)\\?=")) ;; Fixme: This should decode in place, not cons intermediate strings. ;; Also check whether it needs to worry about delimiting fields like