Function: mm-body-encoding

mm-body-encoding is a byte-compiled function defined in mm-bodies.el.gz.

Signature

(mm-body-encoding CHARSET &optional ENCODING)

Documentation

Do Content-Transfer-Encoding and return the encoding of the current buffer.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/mm-bodies.el.gz
(defun mm-body-encoding (charset &optional encoding)
  "Do Content-Transfer-Encoding and return the encoding of the current buffer."
  (when (stringp encoding)
    (setq encoding (intern (downcase encoding))))
  (let ((bits (mm-body-7-or-8))
	(longp (mm-long-lines-p 1000)))
    (require 'message)
    (cond
     ((and (not longp)
	   (not (and mm-use-ultra-safe-encoding
		     (or (save-excursion (re-search-forward " $" nil t))
			 (save-excursion (re-search-forward "^From " nil t)))))
	   (eq bits '7bit))
      bits)
     ((and (not mm-use-ultra-safe-encoding)
	   (not longp)
	   (not (cdr (assq charset mm-body-charset-encoding-alist)))
	   (or (eq t (cdr message-posting-charset))
	       (memq charset (cdr message-posting-charset))
	       (eq charset mail-parse-charset)))
      bits)
     (t
      (let ((encoding (or encoding
			  (cdr (assq charset mm-body-charset-encoding-alist))
			  (mm-qp-or-base64))))
	(when mm-use-ultra-safe-encoding
	  (setq encoding (mm-safer-encoding encoding)))
	(mm-encode-content-transfer-encoding encoding "text/plain")
	encoding)))))