update.
[elisp/apel.git] / emu-e20.el
index cdaf629..5eaafcf 100644 (file)
@@ -1,9 +1,8 @@
-;;; emu-e20.el --- emu API implementation for Emacs/mule (19.34.91)
+;;; emu-e20.el --- emu API implementation for Emacs 20.1 and 20.2
 
-;; Copyright (C) 1996,1997 Free Software Foundation, Inc.
+;; Copyright (C) 1996,1997,1998 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Id: emu-e20.el,v 7.9 1997/01/18 09:35:35 morioka Exp $
 ;; Keywords: emulation, compatibility, Mule
 
 ;; This file is part of emu.
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-;;; Code:
+;;; Commentary:
 
-;;; @ version specific features
-;;;
+;;    This module requires Emacs 20.1 and 20.2.
+
+;;; Code:
 
 (require 'emu-19)
 
 ;; (defalias 'charset-columns 'charset-width)
 
 (defun find-non-ascii-charset-string (string)
-  "Return a list of charsets in the STRING except ascii.
-\[emu-e20.el; Mule emulating function]"
+  "Return a list of charsets in the STRING except ascii."
   (delq 'ascii (find-charset-string string))
   )
 
 (defun find-non-ascii-charset-region (start end)
   "Return a list of charsets except ascii
-in the region between START and END.
-\[emu-e20.el; Mule emulating function]"
+in the region between START and END."
   (delq 'ascii (find-charset-string (buffer-substring start end)))
   )
 
@@ -66,26 +64,75 @@ in the region between START and END.
 ;;; @ coding system
 ;;;
 
-(defconst *noconv* 'no-conversion)
+(defsubst-maybe find-coding-system (obj)
+  "Return OBJ if it is a coding-system."
+  (if (coding-system-p obj)
+      obj))
 
-(defmacro as-binary-process (&rest body)
-  `(let (selective-display     ; Disable ^M to nl translation.
-        ;; for Emacs/mule
-        (coding-system-for-read  'no-conversion)
-        (coding-system-for-write 'no-conversion)
-        )
-     ,@ body))
+(defalias 'set-process-input-coding-system 'set-process-coding-system)
 
-(defmacro as-binary-input-file (&rest body)
-  `(let ((coding-system-for-read 'no-conversion))
-     ,@body))
 
-(defalias 'set-process-input-coding-system 'set-process-coding-system)
+;;; @ binary access
+;;;
+
+(defun insert-file-contents-as-binary (filename
+                                      &optional visit beg end replace)
+  "Like `insert-file-contents', q.v., but don't code and format conversion.
+Like `insert-file-contents-literary', but it allows find-file-hooks,
+automatic uncompression, etc.
+
+Namely this function ensures that only format decoding and character
+code conversion will not take place."
+  (let ((flag enable-multibyte-characters)
+       (coding-system-for-read 'binary)
+       format-alist)
+    (insert-file-contents filename visit beg end replace)
+    (setq enable-multibyte-characters flag)
+    ))
+
+(defalias 'insert-binary-file-contents 'insert-file-contents-as-binary)
+(make-obsolete 'insert-binary-file-contents 'insert-file-contents-as-binary)
+
+(defalias 'insert-binary-file-contents-literally
+  'insert-file-contents-literally)
 
 
 ;;; @ MIME charset
 ;;;
 
+(defsubst encode-mime-charset-region (start end charset)
+  "Encode the text between START and END as MIME CHARSET."
+  (let (cs)
+    (if (and enable-multibyte-characters
+            (setq cs (mime-charset-to-coding-system charset)))
+       (encode-coding-region start end cs)
+      )))
+
+(defsubst decode-mime-charset-region (start end charset)
+  "Decode the text between START and END as MIME CHARSET."
+  (let (cs)
+    (if (and enable-multibyte-characters
+            (setq cs (mime-charset-to-coding-system charset)))
+       (decode-coding-region start end cs)
+      )))
+
+(defsubst encode-mime-charset-string (string charset)
+  "Encode the STRING as MIME CHARSET."
+  (let (cs)
+    (if (and enable-multibyte-characters
+            (setq cs (mime-charset-to-coding-system charset)))
+       (encode-coding-string string cs)
+      string)))
+
+(defsubst decode-mime-charset-string (string charset)
+  "Decode the STRING as MIME CHARSET."
+  (let (cs)
+    (if (and enable-multibyte-characters
+            (setq cs (mime-charset-to-coding-system charset)))
+       (decode-coding-string string cs)
+      string)))
+
+
 (defvar charsets-mime-charset-alist
   '(((ascii)                                           . us-ascii)
     ((ascii latin-iso8859-1)                           . iso-8859-1)
@@ -123,67 +170,6 @@ in the region between START and END.
            chinese-cns11643-7)                         . iso-2022-int-1)
     ))
 
-(defvar default-mime-charset 'x-ctext)
-
-(defvar mime-charset-coding-system-alist
-  '((x-ctext           . coding-system-ctext)
-    (hz-gb-2312                . coding-system-hz)
-    (cn-gb-2312                . coding-system-euc-china)
-    (gb2312            . coding-system-euc-china)
-    (cn-big5           . coding-system-big5)
-    (iso-2022-jp-2     . coding-system-iso-2022-ss2-7)
-    (iso-2022-int-1    . coding-system-iso-2022-int)
-    (shift_jis         . coding-system-sjis)
-    ))
-
-(defun mime-charset-to-coding-system (charset &optional lbt)
-  (if (stringp charset)
-      (setq charset (intern (downcase charset)))
-    )
-  (let ((cs
-        (or (cdr (assq charset mime-charset-coding-system-alist))
-            (let ((cs (intern (concat "coding-system-"
-                                      (symbol-name charset)))))
-              (and (coding-system-p cs) cs)
-              ))))
-    (if lbt
-       (intern (concat (symbol-name cs) "-" (symbol-name lbt)))
-      cs)))
-
-(defun detect-mime-charset-region (start end)
-  "Return MIME charset for region between START and END. [emu-e20.el]"
-  (charsets-to-mime-charset
-   (find-charset-string (buffer-substring start end))
-   ))
-
-(defun encode-mime-charset-region (start end charset)
-  "Encode the text between START and END as MIME CHARSET. [emu-e20.el]"
-  (let ((cs (mime-charset-to-coding-system charset)))
-    (if cs
-       (encode-coding-region start end cs)
-      )))
-
-(defun decode-mime-charset-region (start end charset)
-  "Decode the text between START and END as MIME CHARSET. [emu-e20.el]"
-  (let ((cs (mime-charset-to-coding-system charset)))
-    (if cs
-       (decode-coding-region start end cs)
-      )))
-
-(defun encode-mime-charset-string (string charset)
-  "Encode the STRING as MIME CHARSET. [emu-e20.el]"
-  (let ((cs (mime-charset-to-coding-system charset)))
-    (if cs
-       (encode-coding-string string cs)
-      string)))
-
-(defun decode-mime-charset-string (string charset)
-  "Decode the STRING as MIME CHARSET. [emu-e20.el]"
-  (let ((cs (mime-charset-to-coding-system charset)))
-    (if cs
-       (decode-coding-string string cs)
-      string)))
-
 
 ;;; @ character
 ;;;
@@ -197,13 +183,10 @@ in the region between START and END.
 ;;;
 ;;; You should not use them.
 
-(defalias 'make-character 'make-char)
-
 (defun char-category (character)
   "Return string of category mnemonics for CHAR in TABLE.
 CHAR can be any multilingual character
-TABLE defaults to the current buffer's category table.
-\[emu-e20.el; Mule emulating function]"
+TABLE defaults to the current buffer's category table."
   (category-set-mnemonics (char-category-set character))
   )
 
@@ -216,8 +199,7 @@ TABLE defaults to the current buffer's category table.
 (defalias 'sset 'store-substring)
 
 (defun string-to-char-list (string)
-  "Return a list of which elements are characters in the STRING.
-\[emu-e20.el; Mule 2.3 emulating function]"
+  "Return a list of which elements are characters in the STRING."
   (let* ((len (length string))
         (i 0)
         l chr)
@@ -232,37 +214,11 @@ TABLE defaults to the current buffer's category table.
 (defalias 'string-to-int-list 'string-to-char-list)
 
 
-;;; @ regulation
-;;;
-
-;; (defun regulate-latin-char (chr)
-;;   (cond ((and (<= ?\e$B#A\e(B chr)(<= chr ?\e$B#Z\e(B))
-;;          (+ (- chr ?\e$B#A\e(B) ?A)
-;;          )
-;;         ((and (<= ?\e$B#a\e(B chr)(<= chr ?\e$B#z\e(B))
-;;          (+ (- chr ?\e$B#a\e(B) ?a)
-;;          )
-;;         ((eq chr ?\e$B!%\e(B) ?.)
-;;         ((eq chr ?\e$B!$\e(B) ?,)
-;;         (t chr)
-;;         ))
-
-;; (defun regulate-latin-string (str)
-;;   (let ((len (length str))
-;;         (i 0)
-;;         chr (dest ""))
-;;     (while (< i len)
-;;       (setq chr (sref str i))
-;;       (setq dest (concat dest
-;;                          (char-to-string (regulate-latin-char chr))))
-;;       (setq i (+ i (char-bytes chr)))
-;;       )
-;;     dest))
-
-
 ;;; @ end
 ;;;
 
+(require 'emu-20)
+
 (provide 'emu-e20)
 
 ;;; emu-e20.el ends here