Move `string-as-unibyte', `string-as-multibyte', `char-int',
[elisp/apel.git] / emu.el
diff --git a/emu.el b/emu.el
index 3684e7c..7ab6efb 100644 (file)
--- a/emu.el
+++ b/emu.el
@@ -27,7 +27,7 @@
 (require 'poe)
 
 (defvar running-emacs-18 (<= emacs-major-version 18))
-(defvar running-xemacs (string-match "XEmacs" emacs-version))
+(defvar running-xemacs (featurep 'xemacs))
 
 (defvar running-mule-merged-emacs (and (not (boundp 'MULE))
                                       (not running-xemacs) (featurep 'mule)))
@@ -74,6 +74,9 @@
        (defvar mouse-button-3 nil)
        ))
 
+(require 'poem)
+(require 'mcharset)
+
 (cond (running-xemacs
        (if (featurep 'mule)
           ;; for XEmacs with MULE
        ))
 
 
-;;; @ MIME charset
-;;;
-
-(defun charsets-to-mime-charset (charsets)
-  "Return MIME charset from list of charset CHARSETS.
-This function refers variable `charsets-mime-charset-alist'
-and `default-mime-charset'."
-  (if charsets
-      (or (catch 'tag
-           (let ((rest charsets-mime-charset-alist)
-                 cell)
-             (while (setq cell (car rest))
-               (if (catch 'not-subset
-                     (let ((set1 charsets)
-                           (set2 (car cell))
-                           obj)
-                       (while set1
-                         (setq obj (car set1))
-                         (or (memq obj set2)
-                             (throw 'not-subset nil))
-                         (setq set1 (cdr set1)))
-                       t))
-                   (throw 'tag (cdr cell)))
-               (setq rest (cdr rest)))))
-         default-mime-charset)))
-
-
-;;; @ Emacs 20.3 emulation
+;;; @ Mule emulating aliases
 ;;;
+;;; You should not use it.
 
-(defmacro-maybe string-as-unibyte (string)
-  "Return a unibyte string with the same individual bytes as STRING.
-If STRING is unibyte, the result is STRING itself.
-\[Emacs 20.3 emulating macro]"
-  string)
-
-(defmacro-maybe string-as-multibyte (string)
-  "Return a multibyte string with the same individual bytes as STRING.
-If STRING is multibyte, the result is STRING itself.
-\[Emacs 20.3 emulating macro]"
-  string)
+(or (boundp '*noconv*)
+    (defconst *noconv* 'binary
+      "Coding-system for binary.
+This constant is defined to emulate old MULE anything older than MULE 2.3.
+It is obsolete, so don't use it."))
 
 
-;;; @ for XEmacs 20
+;;; @ without code-conversion
 ;;;
 
-(or (fboundp 'char-int)
-    (fset 'char-int (symbol-function 'identity))
-    )
-(or (fboundp 'int-char)
-    (fset 'int-char (symbol-function 'identity))
-    )
-(or (fboundp 'char-or-char-int-p)
-    (fset 'char-or-char-int-p (symbol-function 'integerp))
-    )
+(defalias 'insert-binary-file-contents 'insert-file-contents-as-binary)
+(make-obsolete 'insert-binary-file-contents 'insert-file-contents-as-binary)
+
+(defun-maybe insert-binary-file-contents-literally (filename
+                                                   &optional visit
+                                                   beg end replace)
+  "Like `insert-file-contents-literally', q.v., but don't code conversion.
+A buffer may be modified in several ways after reading into the buffer due
+to advanced Emacs features, such as file-name-handlers, format decoding,
+find-file-hooks, etc.
+  This function ensures that none of these modifications will take place.
+\[emu-nemacs.el]"
+  (as-binary-input-file
+   ;; Returns list absolute file name and length of data inserted.
+   (insert-file-contents-literally filename visit beg end replace)))
 
 
 ;;; @ for text/richtext and text/enriched