Importing pgnus-0.13
[elisp/gnus.git-] / lisp / mm-util.el
index 67018f4..48ad195 100644 (file)
     (fset 'mm-encode-coding-string (lambda (s a) s))))
 
 (eval-and-compile
+  (if (fboundp 'encode-coding-region)
+      (fset 'mm-encode-coding-region 'encode-coding-region)
+    (fset 'mm-encode-coding-string 'ignore)))
+
+(eval-and-compile
+  (if (fboundp 'decode-coding-region)
+      (fset 'mm-decode-coding-region 'decode-coding-region)
+    (fset 'mm-decode-coding-string 'ignore)))
+
+(eval-and-compile
   (if (fboundp 'coding-system-list)
       (fset 'mm-coding-system-list 'coding-system-list)
     (fset 'mm-coding-system-list 'ignore)))
 
+(eval-and-compile
+  (if (fboundp 'coding-system-equal)
+      (fset 'mm-coding-system-equal 'coding-system-equal)
+    (fset 'mm-coding-system-equal 'equal)))
+
 (defvar mm-mime-mule-charset-alist
   '((us-ascii ascii)
     (iso-8859-1 latin-iso8859-1)
@@ -139,6 +154,30 @@ used as the line break code type of the coding system."
       (setq idx (1+ idx)))
     string))
 
+(defun mm-enable-multibyte ()
+  "Enable multibyte in the current buffer."
+  (when (fboundp 'set-buffer-multibyte)
+    (set-buffer-multibyte t)))
+
+(defun mm-insert-rfc822-headers (charset encoding)
+  "Insert text/plain headers with CHARSET and ENCODING."
+  (insert "MIME-Version: 1.0\n")
+  (insert "Content-Type: text/plain; charset=\""
+         (downcase (symbol-name charset)) "\"\n")
+  (insert "Content-Transfer-Encoding: "
+         (downcase (symbol-name encoding)) "\n"))
+
+(defun mm-content-type-charset (header)
+  "Return the charset parameter from HEADER."
+  (when (string-match "charset *= *\"? *\\([-0-9a-zA-Z_]+\\)\"? *$" header)
+    (intern (downcase (match-string 1 header)))))
+
+(defun mm-read-coding-system (prompt)
+  "Prompt the user for a coding system."
+  (completing-read
+   prompt (mapcar (lambda (s) (list (symbol-name (car s))))
+                 mm-mime-mule-charset-alist)))
+
 (provide 'mm-util)
 
 ;;; mm-util.el ends here