update.
[elisp/apel.git] / emu-nemacs.el
index 5dfc04f..d5a3b4d 100644 (file)
@@ -1,12 +1,11 @@
-;;; emu-nemacs.el --- Mule 2 emulation module for NEmacs
+;;; emu-nemacs.el --- emu API implementation for NEmacs
 
-;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
+;; Copyright (C) 1995,1996,1997,1998 MORIOKA Tomohiko
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Id: emu-nemacs.el,v 7.49 1996/10/01 13:26:34 morioka Exp $
 ;; Keywords: emulation, compatibility, NEmacs, mule
 
-;; This file is part of tl (Tiny Library).
+;; This file is part of emu.
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
 ;;; @ character set
 ;;;
 
-(defconst charset-ascii 0 "Character set of ASCII")
-(defconst charset-jisx0208 146 "Character set of JIS X0208-1983")
+(put 'ascii
+     'charset-description "Character set of ASCII")
+(put 'ascii
+     'charset-registry "ASCII")
+
+(put 'japanese-jisx0208
+     'charset-description "Character set of JIS X0208-1983")
+(put 'japanese-jisx0208
+     'charset-registry "JISX0208.1983")
 
 (defun charset-description (charset)
   "Return description of CHARSET. [emu-nemacs.el]"
-  (if (< charset 128)
-      (documentation-property 'charset-ascii 'variable-documentation)
-    (documentation-property 'charset-jisx0208 'variable-documentation)
-    ))
+  (get charset 'charset-description)
+  )
 
 (defun charset-registry (charset)
   "Return registry name of CHARSET. [emu-nemacs.el]"
-  (if (< charset 128)
-      "ASCII"
-    "JISX0208.1983"))
+  (get charset 'charset-registry)
+  )
 
-(defun charset-columns (charset)
+(defun charset-width (charset)
   "Return number of columns a CHARSET occupies when displayed.
 \[emu-nemacs.el]"
-  (if (< charset 128)
+  (if (eq charset 'ascii)
       1
     2))
 
@@ -63,7 +66,7 @@
   "Return a list of charsets in the string.
 \[emu-nemacs.el; Mule emulating function]"
   (if (string-match "[\200-\377]" str)
-      (list lc-jp)
+      '(japanese-jisx0208)
     ))
 
 (defalias 'find-non-ascii-charset-string 'find-charset-string)
@@ -77,7 +80,7 @@
          (goto-char start)
          (re-search-forward "[\200-\377]" nil t)
          ))
-      (list lc-jp)
+      '(japanese-jisx0208)
     ))
 
 (defalias 'find-non-ascii-charset-region 'find-charset-region)
 ;;; @@ for old MULE emulation
 ;;;
 
-(defconst lc-ascii 0)
-(defconst lc-jp  146)
+;;(defconst lc-ascii 0)
+;;(defconst lc-jp  146)
 
 
 ;;; @ coding system
        (,@ body)
        )))
 
+(defmacro as-binary-output-file (&rest body)
+  (` (let (kanji-flag)
+       (,@ body)
+       )))
+
 
 ;;; @@ for old MULE emulation
 ;;;
@@ -199,11 +207,44 @@ else returns nil. [emu-nemacs.el; Mule emulating function]"
          ))))
 
 
+;;; @ binary access
+;;;
+
+(defun insert-file-contents-as-binary (filename
+                                      &optional visit beg end replace)
+  "Like `insert-file-contents', q.v., but don't character code conversion.
+\[emu-nemacs.el]"
+  (let (kanji-flag)
+    (insert-file-contents filename visit beg end replace)
+    ))
+
+(fset 'insert-binary-file-contents 'insert-file-contents-as-binary)
+
+(defun 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]"
+  (let (kanji-flag)
+    (insert-file-contents-literally filename visit beg end replace)
+    ))
+
+(defun write-region-as-binary (start end filename
+                                    &optional append visit lockname)
+  "Like `write-region', q.v., but don't code conversion. [emu-nemacs.el]"
+  (let (kanji-flag)
+    (write-region start end filename append visit)
+    ))
+
+
 ;;; @ MIME charset
 ;;;
 
 (defvar charsets-mime-charset-alist
-  (list (cons (list charset-ascii) 'us-ascii)))
+  '(((ascii) . us-ascii)))
 
 (defvar default-mime-charset 'iso-2022-jp)
 
@@ -277,37 +318,34 @@ else returns nil. [emu-nemacs.el; Mule emulating function]"
 
 (defun char-charset (chr)
   "Return the character set of char CHR.
-\[emu-nemacs.el; XEmacs 20 emulating function]"
+\[emu-nemacs.el; MULE emulating function]"
   (if (< chr 128)
-      charset-ascii
-    charset-jisx0208))
+      'ascii
+    'japanese-jisx0208))
 
 (defun char-bytes (chr)
   "Return number of bytes CHAR will occupy in a buffer.
 \[emu-nemacs.el; Mule emulating function]"
   (if (< chr 128) 1 2))
 
-(defalias 'char-length 'char-bytes)
-
-(defun char-columns (character)
-  "Return number of columns a CHARACTER occupies when displayed.
+(defun char-width (char)
+  "Return number of columns a CHAR occupies when displayed.
 \[emu-nemacs.el]"
-  (if (< character 128)
+  (if (< char 128)
       1
     2))
 
-;;; @@ for Mule emulation
-;;;
-
-(defalias 'char-leading-char 'char-charset)
+(defalias 'char-length 'char-bytes)
 
-(defalias 'char-width 'char-columns)
+(defmacro char-next-index (char index)
+  "Return index of character succeeding CHAR whose index is INDEX."
+  (` (+ (, index) (char-bytes (, char)))))
 
 
 ;;; @ string
 ;;;
 
-(defalias 'string-columns 'length)
+(defalias 'string-width 'length)
 
 (defun sref (str idx)
   "Return the character in STR at index IDX.
@@ -365,21 +403,22 @@ Optional non-nil arg START-COLUMN specifies the starting column.
            (setq to to-prev)))
       (substring str from to))))
 
-;;; @@ for Mule emulation
+;;; @@ obsoleted aliases
 ;;;
+;;; You should not use them.
 
-(defalias 'string-width 'length)
+(defalias 'string-columns 'length)
 
 
 ;;; @ text property emulation
 ;;;
 
-(setq tl:available-face-attribute-alist
-      '(
-       ;;(bold      . inversed-region)
-       (italic    . underlined-region)
-       (underline . underlined-region)
-       ))
+(defvar emu:available-face-attribute-alist
+  '(
+    ;;(bold      . inversed-region)
+    (italic    . underlined-region)
+    (underline . underlined-region)
+    ))
 
 ;; by YAMATE Keiichirou 1994/10/28
 (defun attribute-add-narrow-attribute (attr from to)
@@ -420,11 +459,11 @@ Optional non-nil arg START-COLUMN specifies the starting column.
       (setcdr (nthcdr posfrom attr-value)
              (nthcdr posto attr-value)))))
 
-(defalias 'tl:make-overlay 'cons)
+(defalias 'make-overlay 'cons)
 
-(defun tl:overlay-put (overlay prop value)
+(defun overlay-put (overlay prop value)
   (let ((ret (and (eq prop 'face)
-                 (assq value tl:available-face-attribute-alist)
+                 (assq value emu:available-face-attribute-alist)
                  )))
     (if ret
        (attribute-add-narrow-attribute (cdr ret)