From: ueno Date: Tue, 19 Mar 2002 21:26:34 +0000 (+0000) Subject: * gettext.el: Autoload `mime-content-type-parameter' and X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=40a915c4642d73e92254461a4a1a96427abd2223;p=elisp%2Fliece.git * gettext.el: Autoload `mime-content-type-parameter' and `mime-read-Content-Type' only when compiling. (gettext-parse-Content-Type): Add bogus detection logic. --- diff --git a/lisp/gettext.el b/lisp/gettext.el index 49fe10d..eae1a8b 100644 --- a/lisp/gettext.el +++ b/lisp/gettext.el @@ -34,7 +34,7 @@ (require 'static) (require 'poem) -(eval-and-compile +(eval-when-compile (autoload 'mime-content-type-parameter "mime-parse") (autoload 'mime-read-Content-Type "mime-parse")) @@ -115,15 +115,19 @@ (goto-char pos)) (nreverse strings))) -(defmacro gettext-parse-Content-Type (&optional header) - (require 'path-util) - (if (module-installed-p 'mime-parse) - (list 'with-temp-buffer - (list 'insert header) - '(mime-content-type-parameter - (mime-read-Content-Type) - "charset")) - 'gettext-default-mime-charset)) +(defun gettext-parse-Content-Type (&optional header) + "Return the MIME charset of PO file." + (with-temp-buffer + (insert header) + (if (require 'mime-parse nil 'noerror) + (mime-content-type-parameter (mime-read-Content-Type) "charset") + (goto-char (point-min)) + (if (re-search-forward + "^\"Content-Type: *text/plain;[ \t]*charset=\\([^\\]+\\)" + nil t) + (find-mime-charset-by-charsets + (list (buffer-substring (match-beginning 1) (match-end 1)))) + gettext-default-mime-charset)))) (defun gettext-mapcar* (function &rest args) "Apply FUNCTION to successive cars of all ARGS.