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