X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fmm-util.el;h=48ad1957122fa833f82cd0042139979af39e02f0;hb=8105541ee890397f15d41f6ac2d1a818ce80e0f4;hp=67018f4baf6dcedd0c5218e6996a6e29a2f2a6d6;hpb=efabe10f0e7b9efc08982cf7430df51648dac426;p=elisp%2Fgnus.git- diff --git a/lisp/mm-util.el b/lisp/mm-util.el index 67018f4..48ad195 100644 --- a/lisp/mm-util.el +++ b/lisp/mm-util.el @@ -35,10 +35,25 @@ (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