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