*** empty log message ***
[gnus] / lisp / mm-util.el
index 6069df9..699e183 100644 (file)
@@ -169,7 +169,7 @@ used as the line break code type of the coding system."
 (defsubst mm-enable-multibyte ()
   "Enable multibyte in the current buffer."
   (when (and (fboundp 'set-buffer-multibyte)
-            (default-value enable-multibyte-characters))
+            (default-value 'enable-multibyte-characters))
     (set-buffer-multibyte t)))
 
 (defsubst mm-disable-multibyte ()
@@ -205,7 +205,7 @@ See also `with-temp-file' and `with-output-to-string'."
        (multibyte (make-symbol "multibyte")))
     `(if (not (boundp 'enable-multibyte-characters))
         (with-temp-buffer ,@forms)
-       (let ((,multibyte (default-value enable-multibyte-characters))
+       (let ((,multibyte (default-value 'enable-multibyte-characters))
             ,temp-buffer)
         (unwind-protect
             (progn
@@ -222,6 +222,21 @@ See also `with-temp-file' and `with-output-to-string'."
 (put 'mm-with-unibyte-buffer 'lisp-indent-function 0)
 (put 'mm-with-unibyte-buffer 'edebug-form-spec '(body))
 
+(defun mm-find-charset-region (b e)
+  "Return a list of charsets in the region."
+  (if enable-multibyte-characters
+      (find-charset-region b e)
+    ;; We are in a unibyte buffer, so we futz around a bit.
+    (save-excursion
+      (save-restriction
+       (narrow-to-region b e)
+       (goto-char (point-min))
+       (let ((entry (assoc (capitalize current-language-environment)
+                           language-info-alist)))
+         (skip-chars-forward "\0-\177")
+         (if (eobp)
+             '(ascii)
+           (list 'ascii (car (last (assq 'charset entry))))))))))
 
 (provide 'mm-util)