3933e14d140a12e8e52c71bc061e43efb8eb5550
[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.39 1996/09/23 20:33:19 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 (defun find-charset-region (start end)
75   "Return a list of charsets in the region between START and END.
76 \[emu-e19.el; Mule emulating function]"
77   (if (save-excursion
78         (save-restriction
79           (narrow-to-region start end)
80           (goto-char start)
81           (re-search-forward "[\200-\377]" nil t)
82           ))
83       (list lc-ltn1)
84     ))
85
86 ;;; @@ for old MULE emulation
87 ;;;
88
89 (defconst lc-ascii 0)
90 (defconst lc-ltn1 129)
91
92
93 ;;; @ coding-system
94 ;;;
95
96 (defconst *internal* nil)
97 (defconst *ctext* nil)
98 (defconst *noconv* nil)
99
100 (defun decode-coding-string (string coding-system)
101   "Decode the STRING which is encoded in CODING-SYSTEM.
102 \[emu-e19.el; Emacs 20 emulating function]"
103   string)
104
105 (defun encode-coding-string (string coding-system)
106   "Encode the STRING as CODING-SYSTEM.
107 \[emu-e19.el; Emacs 20 emulating function]"
108   string)
109
110 (defun decode-coding-region (start end coding-system)
111   "Decode the text between START and END which is encoded in CODING-SYSTEM.
112 \[emu-e19.el; Emacs 20 emulating function]"
113   0)
114
115 (defun encode-coding-region (start end coding-system)
116   "Encode the text between START and END to CODING-SYSTEM.
117 \[emu-e19.el; Emacs 20 emulating function]"
118   0)
119
120 (defun detect-coding-region (start end)
121   "Detect coding-system of the text in the region between START and END.
122 \[emu-e19.el; Emacs 20 emulating function]"
123   )
124
125 (defun set-buffer-file-coding-system (coding-system &optional force)
126   "Set buffer-file-coding-system of the current buffer to CODING-SYSTEM.
127 \[emu-e19.el; Emacs 20 emulating function]"
128   )
129
130 (defmacro as-binary-process (&rest body)
131   (` (let (selective-display)   ; Disable ^M to nl translation.
132        (,@ body)
133        )))
134
135 (defmacro as-binary-input-file (&rest body)
136   (` (let ((emx-binary-mode t)) ; Stop CRLF to LF conversion in OS/2
137        (,@ body)
138        )))
139
140
141 ;;; @@ for old MULE emulation
142 ;;;
143
144 (defun code-convert-string (str ic oc)
145   "Convert code in STRING from SOURCE code to TARGET code,
146 On successful converion, returns the result string,
147 else returns nil. [emu-e19.el; old MULE emulating function]"
148   str)
149
150 (defun code-convert-region (beg end ic oc)
151   "Convert code of the text between BEGIN and END from SOURCE
152 to TARGET. On successful conversion returns t,
153 else returns nil. [emu-e19.el; old MULE emulating function]"
154   t)
155
156
157 ;;; @ MIME charset
158 ;;;
159
160 (defvar charsets-mime-charset-alist
161   (list (cons (list charset-ascii) 'us-ascii)))
162
163 (defvar default-mime-charset 'iso-8859-1)
164
165 (defun mime-charset-to-coding-system (charset)
166   (if (stringp charset)
167       (setq charset (intern (downcase charset)))
168     )
169   (and (memq charset (list 'us-ascii default-mime-charset))
170        charset)
171   )
172
173 (defun detect-mime-charset-region (start end)
174   "Return MIME charset for region between START and END.
175 \[emu-e19.el]"
176   (if (save-excursion
177         (save-restriction
178           (narrow-to-region start end)
179           (goto-char start)
180           (re-search-forward "[\200-\377]" nil t)
181           ))
182       default-mime-charset
183     'us-ascii))
184
185 (defun encode-mime-charset-region (start end charset)
186   "Encode the text between START and END as MIME CHARSET.
187 \[emu-e19.el]"
188   )
189
190 (defun decode-mime-charset-region (start end charset)
191   "Decode the text between START and END as MIME CHARSET.
192 \[emu-e19.el]"
193   )
194
195 (defun encode-mime-charset-string (string charset)
196   "Encode the STRING as MIME CHARSET. [emu-e19.el]"
197   string)
198
199 (defun decode-mime-charset-string (string charset)
200   "Decode the STRING as MIME CHARSET. [emu-e19.el]"
201   string)
202
203
204 ;;; @ character
205 ;;;
206
207 (defun char-charset (chr)
208   "Return the character set of char CHR.
209 \[emu-e19.el; XEmacs 20 emulating function]"
210   (if (< chr 128)
211       charset-ascii
212     charset-latin-1))
213
214 (defun char-bytes (char)
215   "Return number of bytes a character in CHAR occupies in a buffer.
216 \[emu-e19.el; MULE emulating function]"
217   1)
218
219 (defalias 'char-length 'char-bytes)
220
221 (defun char-columns (character)
222   "Return number of columns a CHARACTER occupies when displayed.
223 \[emu-e19.el]"
224   1)
225
226 ;;; @@ for old MULE emulation
227 ;;;
228
229 (defalias 'char-width 'char-columns)
230
231 (defalias 'char-leading-char 'char-charset)
232
233
234 ;;; @ string
235 ;;;
236
237 (defalias 'string-columns 'length)
238
239 (defun string-to-char-list (str)
240   (mapcar (function identity) str)
241   )
242
243 (defalias 'string-to-int-list 'string-to-char-list)
244
245 (defalias 'sref 'aref)
246
247 (defun truncate-string (str width &optional start-column)
248   "Truncate STR to fit in WIDTH columns.
249 Optional non-nil arg START-COLUMN specifies the starting column.
250 \[emu-e19.el; MULE 2.3 emulating function]"
251   (or start-column
252       (setq start-column 0))
253   (substring str start-column width)
254   )
255
256 ;;; @@ for old MULE emulation
257 ;;;
258
259 (defalias 'string-width 'length)
260
261
262 ;;; @ end
263 ;;;
264
265 (provide 'emu-e19)
266
267 ;;; emu-e19.el ends here