Importing Pterodactyl Gnus v0.87.
[elisp/gnus.git-] / lisp / mm-util.el
index 1634ce3..2ade070 100644 (file)
 (defvar mm-charset-synonym-alist
   '((big5 . cn-big5)
     (gb2312 . cn-gb-2312)
-    (iso-2022-jp-2 . iso-2022-7bit-ss2)
     (x-ctext . ctext))
   "A mapping from invalid charset names to the real charset names.")
 
@@ -252,7 +251,9 @@ See also `with-temp-file' and `with-output-to-string'."
 (defun mm-find-charset-region (b e)
   "Return a list of charsets in the region."
   (cond
-   ((fboundp 'find-charset-region)
+   ((and (boundp 'enable-multibyte-characters)
+        enable-multibyte-characters
+        (fboundp 'find-charset-region))
     (find-charset-region b e))
    ((not (boundp 'current-language-environment))
     (save-excursion
@@ -285,6 +286,19 @@ See also `with-temp-file' and `with-output-to-string'."
            mm-mime-mule-charset-alist)
     nil t)))
 
+(defun mm-quote-arg (arg)
+  "Return a version of ARG that is safe to evaluate in a shell."
+  (let ((pos 0) new-pos accum)
+    ;; *** bug: we don't handle newline characters properly
+    (while (setq new-pos (string-match "[]*[;!'`\"$\\& \t{} |()<>]" arg pos))
+      (push (substring arg pos new-pos) accum)
+      (push "\\" accum)
+      (push (list (aref arg new-pos)) accum)
+      (setq pos (1+ new-pos)))
+    (if (= pos 0)
+        arg
+      (apply 'concat (nconc (nreverse accum) (list (substring arg pos)))))))
+
 (provide 'mm-util)
 
 ;;; mm-util.el ends here