- (delq nil (list 'ascii
- (or (car (last (assq mail-parse-charset
- mm-mime-mule-charset-alist)))
- 'latin-iso8859-1)))))))
- (t
- ;; 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 current-language-environment
- language-info-alist)))
- (skip-chars-forward "\0-\177")
- (if (eobp)
- '(ascii)
- (delq nil (list 'ascii
- (or (car (last (assq 'charset entry)))
- 'latin-iso8859-1))))))))))
-
-(defun mm-read-charset (prompt)
- "Return a charset."
- (intern
- (completing-read
- prompt
- (mapcar (lambda (e) (list (symbol-name (car e))))
- 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)))))))
+ (let (charset)
+ (setq charset
+ (and (boundp 'current-language-environment)
+ (car (last (assq 'charset
+ (assoc current-language-environment
+ language-info-alist))))))
+ (if (eq charset 'ascii) (setq charset nil))
+ (or charset
+ (setq charset
+ (car (last (assq mail-parse-charset
+ mm-mime-mule-charset-alist)))))
+ (list 'ascii (or charset 'latin-iso8859-1)))))))))
+
+(static-if (fboundp 'shell-quote-argument)
+ (defalias 'mm-quote-arg 'shell-quote-argument)
+ (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))))))))