comparison lisp/gnus/mm-util.el @ 90133:4da4a09e8b1b

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-31 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 206-222) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 45-52) - Update from CVS - Update from CVS: texi Makefile.in CVS keyw cruft - Update from CVS: ChangeLog tweaks
author Miles Bader <miles@gnu.org>
date Thu, 31 Mar 2005 09:58:14 +0000
parents 7e3f621f1dd4 c0aa521e0ca7
children 146c086df160
comparison
equal deleted inserted replaced
90132:4080fe8b4f0f 90133:4da4a09e8b1b
82 (if dir-flag 82 (if dir-flag
83 (make-directory file)) 83 (make-directory file))
84 file))) 84 file)))
85 (insert-byte . insert-char) 85 (insert-byte . insert-char)
86 (multibyte-char-to-unibyte . identity)))) 86 (multibyte-char-to-unibyte . identity))))
87
88 (eval-and-compile
89 (cond
90 ((fboundp 'replace-in-string)
91 (defalias 'mm-replace-in-string 'replace-in-string))
92 ((fboundp 'replace-regexp-in-string)
93 (defun mm-replace-in-string (string regexp newtext &optional literal)
94 "Replace all matches for REGEXP with NEWTEXT in STRING.
95 If LITERAL is non-nil, insert NEWTEXT literally. Return a new
96 string containing the replacements.
97
98 This is a compatibility function for different Emacsen."
99 (replace-regexp-in-string regexp newtext string nil literal)))
100 (t
101 (defun mm-replace-in-string (string regexp newtext &optional literal)
102 "Replace all matches for REGEXP with NEWTEXT in STRING.
103 If LITERAL is non-nil, insert NEWTEXT literally. Return a new
104 string containing the replacements.
105
106 This is a compatibility function for different Emacsen."
107 (let ((start 0) tail)
108 (while (string-match regexp string start)
109 (setq tail (- (length string) (match-end 0)))
110 (setq string (replace-match newtext nil literal string))
111 (setq start (- (length string) tail))))
112 string))))
87 113
88 (eval-and-compile 114 (eval-and-compile
89 (defalias 'mm-char-or-char-int-p 115 (defalias 'mm-char-or-char-int-p
90 (cond 116 (cond
91 ((fboundp 'char-or-char-int-p) 'char-or-char-int-p) 117 ((fboundp 'char-or-char-int-p) 'char-or-char-int-p)
553 But this is very much a corner case, so don't worry about it." 579 But this is very much a corner case, so don't worry about it."
554 (let ((systems mm-coding-system-priorities) csets psets curset) 580 (let ((systems mm-coding-system-priorities) csets psets curset)
555 581
556 ;; Load the Latin Unity library, if available. 582 ;; Load the Latin Unity library, if available.
557 (when (and (not (featurep 'latin-unity)) (locate-library "latin-unity")) 583 (when (and (not (featurep 'latin-unity)) (locate-library "latin-unity"))
558 (require 'latin-unity)) 584 (ignore-errors (require 'latin-unity)))
559 585
560 ;; Now, can we use it? 586 ;; Now, can we use it?
561 (if (featurep 'latin-unity) 587 (if (featurep 'latin-unity)
562 (progn 588 (progn
563 (setq csets (latin-unity-representations-feasible-region begin end) 589 (setq csets (latin-unity-representations-feasible-region begin end)
598 ;; take its default action, which equally applies to GNU Emacs. 624 ;; take its default action, which equally applies to GNU Emacs.
599 nil))) 625 nil)))
600 626
601 (defmacro mm-xemacs-find-mime-charset (begin end) 627 (defmacro mm-xemacs-find-mime-charset (begin end)
602 (when (featurep 'xemacs) 628 (when (featurep 'xemacs)
603 `(mm-xemacs-find-mime-charset-1 ,begin ,end))) 629 `(and (featurep 'mule) (mm-xemacs-find-mime-charset-1 ,begin ,end))))
604 630
605 (defun mm-find-mime-charset-region (b e &optional hack-charsets) 631 (defun mm-find-mime-charset-region (b e &optional hack-charsets)
606 "Return the MIME charsets needed to encode the region between B and E. 632 "Return the MIME charsets needed to encode the region between B and E.
607 nil means ASCII, a single-element list represents an appropriate MIME 633 nil means ASCII, a single-element list represents an appropriate MIME
608 charset, and a longer list means no appropriate charset." 634 charset, and a longer list means no appropriate charset."