tm 7.76.
[elisp/apel.git] / emu-e19.el
1 ;;;
2 ;;; emu-e19.el --- Mule 2 emulation module for Emacs 19 and XEmacs 19
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1994 .. 1996 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Version:
9 ;;;     $Id: emu-e19.el,v 7.30 1996/07/15 08:26:24 morioka Exp $
10 ;;; Keywords: emulation, compatibility, Mule, Latin-1
11 ;;;
12 ;;; This file is part of tl (Tiny Library).
13 ;;;
14 ;;; This program is free software; you can redistribute it and/or
15 ;;; modify it under the terms of the GNU General Public License as
16 ;;; published by the Free Software Foundation; either version 2, or
17 ;;; (at your option) any later version.
18 ;;;
19 ;;; This program is distributed in the hope that it will be useful,
20 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22 ;;; General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with This program.  If not, write to the Free Software
26 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 ;;;
28 ;;; Code:
29
30 ;;; @ version and variant specific features
31 ;;;
32
33 (cond (running-xemacs
34        (require 'emu-xemacs))
35       (running-emacs-19
36        (require 'emu-19)
37        ))
38
39
40 ;;; @ character set
41 ;;;
42
43 (defconst charset-ascii 0 "Character set of ASCII")
44 (defconst charset-latin-1 129 "Character set of ISO-8859-1")
45
46 (defun charset-description (charset)
47   "Return description of CHARSET. [emu-e19.el]"
48   (if (< charset 128)
49       (documentation-property 'charset-ascii 'variable-documentation)
50     (documentation-property 'charset-latin-1 'variable-documentation)
51     ))
52
53 (defun charset-registry (charset)
54   "Return registry name of CHARSET. [emu-e19.el]"
55   (if (< charset 128)
56       "ASCII"
57     "ISO8859-1"))
58
59 (defun charset-columns (charset)
60   "Return number of columns a CHARSET occupies when displayed.
61 \[emu-e19.el]"
62   1)
63
64 (defun charset-direction (charset)
65   "Return the direction of a character of CHARSET by
66   0 (left-to-right) or 1 (right-to-left). [emu-e19.el]"
67   0)
68
69 (defun find-charset-string (str)
70   "Return a list of charsets in the string.
71 \[emu-e19.el; Mule emulating function]"
72   (if (string-match "[\200-\377]" str)
73       (list lc-ltn1)
74     ))
75
76 (defun find-charset-region (start end)
77   "Return a list of charsets in the region between START and END.
78 \[emu-e19.el; Mule emulating function]"
79   (if (save-excursion
80         (save-restriction
81           (narrow-to-region start end)
82           (goto-char start)
83           (re-search-forward "[\200-\377]" nil t)
84           ))
85       (list lc-ltn1)
86     ))
87
88 ;;; @@ for Mule emulation
89 ;;;
90
91 (defconst lc-ascii 0)
92 (defconst lc-ltn1 129)
93
94
95 ;;; @ coding-system
96 ;;;
97
98 (defconst *internal* nil)
99 (defconst *ctext* nil)
100 (defconst *noconv* nil)
101
102 (defun code-convert-string (str ic oc)
103   "Convert code in STRING from SOURCE code to TARGET code,
104 On successful converion, returns the result string,
105 else returns nil. [emu-e19.el; Mule emulating function]"
106   str)
107
108 (defun code-convert-region (beg end ic oc)
109   "Convert code of the text between BEGIN and END from SOURCE
110 to TARGET. On successful conversion returns t,
111 else returns nil. [emu-e19.el; Mule emulating function]"
112   t)
113
114 (defun code-detect-region (beg end)
115   "Detect coding-system of the text in the region
116 between START and END. [emu-e19.el; Mule emulating function]"
117   )
118
119 (defun set-file-coding-system (coding-system &optional force)
120   )
121
122 (defmacro as-binary-process (&rest body)
123   (` (let (selective-display)   ; Disable ^M to nl translation.
124        (,@ body)
125        )))
126
127
128 ;;; @ MIME charset
129 ;;;
130
131 (defvar charsets-mime-charset-alist
132   (list (cons (list charset-ascii) 'us-ascii)))
133
134 (defvar default-mime-charset 'iso-8859-1)
135
136 (defun detect-mime-charset-region (start end)
137   "Return MIME charset for region between START and END.
138 \[emu-e19.el]"
139   (if (save-excursion
140         (save-restriction
141           (narrow-to-region start end)
142           (goto-char start)
143           (re-search-forward "[\200-\377]" nil t)
144           ))
145       default-mime-charset
146     'us-ascii))
147
148 (defun encode-mime-charset-region (start end charset)
149   "Encode the text between START and END as MIME CHARSET.
150 \[emu-e19.el]"
151   )
152
153 (defun decode-mime-charset-region (start end charset)
154   "Decode the text between START and END as MIME CHARSET.
155 \[emu-e19.el]"
156   )
157
158 (defun encode-mime-charset-string (string charset)
159   "Encode the STRING as MIME CHARSET. [emu-e19.el]"
160   string)
161
162 (defun decode-mime-charset-string (string charset)
163   "Decode the STRING as MIME CHARSET. [emu-e19.el]"
164   string)
165
166
167 ;;; @ character
168 ;;;
169
170 (defun char-charset (chr)
171   "Return the character set of char CHR.
172 \[emu-e19.el; XEmacs 20 emulating function]"
173   (if (< chr 128)
174       charset-ascii
175     charset-latin-1))
176
177 (defun char-bytes (char)
178   "Return number of bytes a character in CHAR occupies in a buffer.
179 \[emu-e19.el; Mule emulating function]"
180   1)
181
182 (defalias 'char-length 'char-bytes)
183
184 (defun char-columns (character)
185   "Return number of columns a CHARACTER occupies when displayed.
186 \[emu-nemacs.el]"
187   1)
188
189 ;;; @@ for Mule emulation
190 ;;;
191
192 (defalias 'char-width 'char-columns)
193
194 (defalias 'char-leading-char 'char-charset)
195
196
197 ;;; @ string
198 ;;;
199
200 (defalias 'string-columns 'length)
201
202 (defun string-to-char-list (str)
203   (mapcar (function identity) str)
204   )
205
206 (defalias 'string-to-int-list 'string-to-char-list)
207
208 (defalias 'sref 'aref)
209
210 (defun truncate-string (str width &optional start-column)
211   "Truncate STR to fit in WIDTH columns.
212 Optional non-nil arg START-COLUMN specifies the starting column.
213 \[emu-e19.el; Mule 2.3 emulating function]"
214   (or start-column
215       (setq start-column 0))
216   (substring str start-column width)
217   )
218
219 ;;; @@ for Mule emulation
220 ;;;
221
222 (defalias 'string-width 'length)
223
224
225 ;;; @ end
226 ;;;
227
228 (provide 'emu-e19)
229
230 ;;; emu-e19.el ends here