(char-next-index): New macro.
[elisp/apel.git] / emu-e19.el
index c861349..f4f22ab 100644 (file)
@@ -1,12 +1,11 @@
-;;; emu-e19.el --- emu module for Emacs 19 and XEmacs 19
+;;; emu-e19.el --- emu module for Emacs 19 and XEmacs without MULE
 
-;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
+;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Id: emu-e19.el,v 7.37 1996/09/18 13:50:09 morioka Exp $
 ;; Keywords: emulation, compatibility, mule, Latin-1
 
-;; 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
@@ -19,8 +18,8 @@
 ;; General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with this program; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
 ;;; Code:
 ;;;
 
 (defconst charset-ascii 0 "Character set of ASCII")
-(defconst charset-latin-1 129 "Character set of ISO-8859-1")
+(defconst charset-latin-iso8859-1 129 "Character set of ISO-8859-1")
 
 (defun charset-description (charset)
   "Return description of CHARSET. [emu-e19.el]"
   (if (< charset 128)
       (documentation-property 'charset-ascii 'variable-documentation)
-    (documentation-property 'charset-latin-1 'variable-documentation)
+    (documentation-property 'charset-latin-iso8859-1 'variable-documentation)
     ))
 
 (defun charset-registry (charset)
   "Return a list of charsets in the string.
 \[emu-e19.el; Mule emulating function]"
   (if (string-match "[\200-\377]" str)
-      (list lc-ltn1)
+      (list charset-latin-iso8859-1)
     ))
 
+(defalias 'find-non-ascii-charset-string 'find-charset-string)
+
 (defun find-charset-region (start end)
   "Return a list of charsets in the region between START and END.
 \[emu-e19.el; Mule emulating function]"
          (goto-char start)
          (re-search-forward "[\200-\377]" nil t)
          ))
-      (list lc-ltn1)
+      (list charset-latin-iso8859-1)
     ))
 
-;;; @@ for old MULE emulation
-;;;
-
-(defconst lc-ascii 0)
-(defconst lc-ltn1 129)
+(defalias 'find-non-ascii-charset-region 'find-charset-region)
 
 
 ;;; @ coding-system
 \[emu-e19.el; Emacs 20 emulating function]"
   0)
 
-(defun code-detect-region (beg end)
-  "Detect coding-system of the text in the region
-between START and END. [emu-e19.el; Mule emulating function]"
+(defun detect-coding-region (start end)
+  "Detect coding-system of the text in the region between START and END.
+\[emu-e19.el; Emacs 20 emulating function]"
   )
 
-(defun set-file-coding-system (coding-system &optional force)
+(defun set-buffer-file-coding-system (coding-system &optional force)
+  "Set buffer-file-coding-system of the current buffer to CODING-SYSTEM.
+\[emu-e19.el; Emacs 20 emulating function]"
   )
 
 (defmacro as-binary-process (&rest body)
@@ -135,6 +134,11 @@ between START and END. [emu-e19.el; Mule emulating function]"
        (,@ body)
        )))
 
+(defmacro as-binary-output-file (&rest body)
+  (` (let ((emx-binary-mode t)) ; Stop CRLF to LF conversion in OS/2
+       (,@ body)
+       )))
+
 
 ;;; @@ for old MULE emulation
 ;;;
@@ -152,6 +156,43 @@ else returns nil. [emu-e19.el; old MULE emulating function]"
   t)
 
 
+;;; @ 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 ((emx-binary-mode t))
+    (insert-file-contents filename visit beg end replace)
+    ))
+
+(defalias 'insert-binary-file-contents 'insert-file-contents-as-binary)
+(make-obsolete '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."
+  (let ((emx-binary-mode t))
+    (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."
+  (let ((emx-binary-mode t))
+    (write-region start end filename append visit lockname)
+    ))
+
+
 ;;; @ MIME charset
 ;;;
 
@@ -202,32 +243,37 @@ else returns nil. [emu-e19.el; old MULE emulating function]"
 ;;; @ character
 ;;;
 
-(defun char-charset (chr)
-  "Return the character set of char CHR.
-\[emu-e19.el; XEmacs 20 emulating function]"
+(defun char-charset (char)
+  "Return the character set of char CHAR."
   (if (< chr 128)
       charset-ascii
-    charset-latin-1))
+    charset-latin-iso8859-1))
 
 (defun char-bytes (char)
-  "Return number of bytes a character in CHAR occupies in a buffer.
-\[emu-e19.el; MULE emulating function]"
+  "Return number of bytes a character in CHAR occupies in a buffer."
   1)
 
-(defalias 'char-length 'char-bytes)
-
-(defun char-columns (character)
-  "Return number of columns a CHARACTER occupies when displayed.
-\[emu-e19.el]"
+(defun char-width (char)
+  "Return number of columns a CHAR occupies when displayed."
   1)
 
-;;; @@ for old MULE emulation
-;;;
+(defmacro char-next-index (char index)
+  "Return index of character succeeding CHAR whose index is INDEX."
+  (` (1+ index)))
 
-(defalias 'char-width 'char-columns)
+;;; @@ Mule emulating aliases
+;;;
+;;; You should not use them.
 
 (defalias 'char-leading-char 'char-charset)
 
+;;; @@ obsoleted aliases
+;;;
+;;; You should not use them.
+
+(defalias 'char-length 'char-bytes)
+(defalias 'char-columns 'char-width)
+
 
 ;;; @ string
 ;;;