Importing pgnus-0.64
[elisp/gnus.git-] / lisp / mm-util.el
index 2cd6003..13b5fdd 100644 (file)
 
 ;;; Code:
 
+(defvar mm-running-xemacs (string-match "XEmacs" emacs-version))
+
+(defvar mm-binary-coding-system 
+    (if mm-running-xemacs
+       'binary 'no-conversion)
+    "100% binary coding system.")   
+
 (defvar mm-default-coding-system nil
   "The default coding system to use.")  
 
 (defvar mm-known-charsets '(iso-8859-1)
-  "List of known charsets.")
+  "List of known charsets.
+Use this under non-Mule Emacsen to specify which charsets your Emacs
+can display.  Also see `mm-default-charset'.")
+
+(defvar mm-default-charset 'iso-8859-1
+  "Default charset assumed to be used when viewing non-ASCII characters.
+This variable is used only in non-Mule Emacsen.")
 
 (defvar mm-mime-mule-charset-alist
   '((us-ascii ascii)
@@ -42,8 +55,9 @@
     (iso-8859-7 greek-iso8859-7)
     (iso-8859-8 hebrew-iso8859-8)
     (iso-8859-9 latin-iso8859-9)
+    (iso-2022-jp-2 japanese-jisx0208)
     (iso-2022-jp latin-jisx0201
-                japanese-jisx0208-1978 japanese-jisx0208)
+                japanese-jisx0208-1978)
     (euc-kr korean-ksc5601)
     (cn-gb-2312 chinese-gb2312)
     (cn-big5 chinese-big5-1 chinese-big5-2)
     dest)
   "Charset/coding system alist.")
 
+;;;Internal variable
+(defvar mm-charset-iso-8859-1-forced nil)
+
 (defun mm-mule-charset-to-mime-charset (charset)
   "Return the MIME charset corresponding to MULE CHARSET."
   (let ((alist mm-mime-mule-charset-alist)
@@ -134,6 +151,9 @@ If optional argument LBT (`unix', `dos' or `mac') is specified, it is
 used as the line break code type of the coding system."
   (when (stringp charset)
     (setq charset (intern (downcase charset))))
+  (if (and mm-charset-iso-8859-1-forced 
+          (eq charset 'iso-8859-1))
+      (setq charset mm-charset-iso-8859-1-forced))
   (setq charset
        (or (cdr (assq charset mm-charset-coding-system-alist))
            charset))
@@ -142,7 +162,8 @@ used as the line break code type of the coding system."
   (cond
    ;; Running in a non-MULE environment.
    ((and (null (mm-get-coding-system-list))
-        (memq charset mm-known-charsets))
+        (or (eq charset mm-default-charset)
+            (memq charset mm-known-charsets)))
     charset)
    ;; ascii
    ((eq charset 'us-ascii)
@@ -214,7 +235,9 @@ See also `with-temp-file' and `with-output-to-string'."
                     (get-buffer-create (generate-new-buffer-name " *temp*")))
               (unwind-protect
                   (with-current-buffer ,temp-buffer
-                    (let (buffer-file-coding-system)
+                    (let ((buffer-file-coding-system mm-binary-coding-system)
+                          (coding-system-for-read mm-binary-coding-system)
+                          (coding-system-for-write mm-binary-coding-system))
                       ,@forms))
                 (and (buffer-name ,temp-buffer)
                      (kill-buffer ,temp-buffer))))
@@ -226,7 +249,8 @@ See also `with-temp-file' and `with-output-to-string'."
   "Return a list of charsets in the region."
   (cond
    ((and (boundp 'enable-multibyte-characters)
-        enable-multibyte-characters)
+        enable-multibyte-characters
+        (fboundp 'find-charset-region))
     (find-charset-region b e))
    ((not (boundp 'current-language-environment))
     (save-excursion