fix gnus-group-sort-function custom type
[gnus] / lisp / mm-util.el
index 0ce0229..3b7581d 100644 (file)
@@ -34,7 +34,7 @@
     (iso-8859-3 latin-iso8859-3)
     (iso-8859-4 latin-iso8859-4)
     (iso-8859-5 cyrillic-iso8859-5)
-    ;; Non-mule (X)Emacs uses the last mule-charset for 8bit characters.
+  ;; Non-mule (X)Emacs uses the last mule-charset for 8bit characters.
     ;; The fake mule-charset, gnus-koi8-r, tells Gnus that the default
     ;; charset is koi8-r, not iso-8859-5.
     (koi8-r cyrillic-iso8859-5 gnus-koi8-r)
      (subst-char-in-string
       . (lambda (from to string) ;; stolen (and renamed) from nnheader.el
          "Replace characters in STRING from FROM to TO."
-         (let ((string (substring string 0))   ;Copy string.
+         (let ((string (substring string 0)) ;Copy string.
                (len (length string))
                (idx 0))
            ;; Replace all occurrences of FROM with TO.
              (setq idx (1+ idx)))
            string)))
      (string-as-unibyte . identity)
+     (string-as-multibyte . identity)
      (multibyte-string-p . ignore))))
 
 (eval-and-compile
 (eval-and-compile
   (defalias 'mm-read-coding-system
     (cond
-     ((fboundp 'read-coding-system) 
+     ((fboundp 'read-coding-system)
       (if (and (featurep 'xemacs)
-               (<= (string-to-number emacs-version) 21.1))
-          (lambda (prompt &optional default-coding-system)
-            (read-coding-system prompt))
-        'read-coding-system))
+              (<= (string-to-number emacs-version) 21.1))
+         (lambda (prompt &optional default-coding-system)
+           (read-coding-system prompt))
+       'read-coding-system))
      (t (lambda (prompt &optional default-coding-system)
          "Prompt the user for a coding system."
          (completing-read
     (cn-gb . cn-gb-2312)
     ;; Windows-1252 is actually a superset of Latin-1.  See also
     ;; `gnus-article-dumbquotes-map'.
-    ,(unless (mm-coding-system-p 'windows-1252) ; should be defined eventually
+    ,(unless (mm-coding-system-p 'windows-1252)        ; should be defined eventually
        '(windows-1252 . iso-8859-1))
+    ;; Windows-1250 is a variant of Latin-2 heavily used by Microsoft
+    ;; Outlook users in Czech republic. Use this to allow reading of their
+    ;; e-mails. cp1250 should be defined by M-x codepage-setup.
+    ,(unless (mm-coding-system-p 'windows-1250)        ; should be defined eventually
+       '(windows-1250 . cp1250))
     (x-ctext . ctext))
   "A mapping from invalid charset names to the real charset names.")
 
    (t mm-binary-coding-system))
   "Coding system of auto save file.")
 
+(defvar mm-universal-coding-system mm-auto-save-coding-system
+  "The universal Coding system.")
+
 ;;; Internal variables:
 
 ;;; Functions:
@@ -247,7 +256,7 @@ used as the line break code type of the coding system."
 Only do this if the default value of `enable-multibyte-characters' is
 non-nil.  This is a no-op in XEmacs."
   (when (and (not (featurep 'xemacs))
-             (boundp 'default-enable-multibyte-characters)
+            (boundp 'default-enable-multibyte-characters)
             default-enable-multibyte-characters
             (fboundp 'set-buffer-multibyte))
     (set-buffer-multibyte t)))
@@ -263,7 +272,7 @@ This is a no-op in XEmacs."
   "Enable multibyte in the current buffer.
 Only used in Emacs Mule 4."
   (when (and (not (featurep 'xemacs))
-             (boundp 'default-enable-multibyte-characters)
+            (boundp 'default-enable-multibyte-characters)
             default-enable-multibyte-characters
             (fboundp 'set-buffer-multibyte)
             (fboundp 'charsetp)
@@ -305,10 +314,10 @@ If the charset is `composition', return the actual one."
           (progn
             (setq mail-parse-mule-charset
                   (and (boundp 'current-language-environment)
-                     (car (last
-                           (assq 'charset
-                                 (assoc current-language-environment
-                                        language-info-alist))))))
+                       (car (last
+                             (assq 'charset
+                                   (assoc current-language-environment
+                                          language-info-alist))))))
             (if (or (not mail-parse-mule-charset)
                     (eq mail-parse-mule-charset 'ascii))
                 (setq mail-parse-mule-charset
@@ -405,13 +414,13 @@ Mule4 only."
              (fboundp 'set-buffer-multibyte)
              (fboundp 'charsetp)
              (not (charsetp 'eight-bit-control))) ;; For Emacs Mule 4 only.
-       (let ((,buffer (current-buffer)))
-        (unwind-protect
-            (let (default-enable-multibyte-characters)
-              (set-buffer-multibyte nil)
-              ,@forms)
-          (set-buffer ,buffer)
-          (set-buffer-multibyte t)))
+        (let ((,buffer (current-buffer)))
+          (unwind-protect
+              (let (default-enable-multibyte-characters)
+                (set-buffer-multibyte nil)
+                ,@forms)
+            (set-buffer ,buffer)
+            (set-buffer-multibyte t)))
        (let (default-enable-multibyte-characters)
         ,@forms))))
 (put 'mm-with-unibyte-current-buffer-mule4 'lisp-indent-function 0)
@@ -428,15 +437,16 @@ Mule4 only."
   "Return a list of Emacs charsets in the region B to E."
   (cond
    ((and (mm-multibyte-p)
-        (fboundp 'find-charset-region))
+        (fboundp 'find-charset-region))
     ;; Remove composition since the base charsets have been included.
     ;; Remove eight-bit-*, treat them as ascii.
     (let ((css (find-charset-region b e)))
       (mapcar (lambda (cs) (setq css (delq cs css)))
-             '(composition eight-bit-control eight-bit-graphic))
+             '(composition eight-bit-control eight-bit-graphic
+                           control-1))
       css))
    (t
-    ;; We are in a unibyte buffer or XEmacs non-mule, so we futz around a bit.
+;; We are in a unibyte buffer or XEmacs non-mule, so we futz around a bit.
     (save-excursion
       (save-restriction
        (narrow-to-region b e)
@@ -498,7 +508,7 @@ If INHIBIT is non-nil, inhibit mm-inhibit-file-name-handlers.
        (auto-mode-alist (if inhibit nil (mm-auto-mode-alist)))
        (default-major-mode 'fundamental-mode)
        (enable-local-variables nil)
-        (after-insert-file-functions nil)
+       (after-insert-file-functions nil)
        (enable-local-eval nil)
        (find-file-hooks nil)
        (inhibit-file-name-operation (if inhibit