1 ;;; emu-e20.el --- emu API implementation for Emacs/mule (delta)
3 ;; Copyright (C) 1996 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version: $Id: emu-e20.el,v 5.0 1996/10/23 06:37:13 morioka Exp $
7 ;; Keywords: emulation, compatibility, Mule
9 ;; This file is part of tl (Tiny Library).
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.
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.
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.
28 ;;; @ version specific features
33 (defun fontset-height (fontset)
34 (let* ((info (fontset-info fontset))
35 (height (aref info 1))
40 (car (aref (aref info 2) 0))
42 (if (string-match "--\\([0-9]+\\)-\\*-\\*-\\*-\\*-\\*-ISO8859-1" str)
44 (substring str (match-beginning 1)(match-end 1))
52 (defalias 'charset-columns 'charset-width)
54 (defun charset-iso-class (charset)
55 "Return ISO-class of CHARSET.
56 \(0/CLASS94, 1/CLASS96, 2/CLASS94x94, 3/CLASS96x96) [emu-e20.el]"
57 (aref (charset-info charset) 5)
60 (defun find-non-ascii-charset-string (string)
61 "Return a list of charsets in the STRING except ascii.
62 \[emu-e20.el; Mule emulating function]"
63 (delq charset-ascii (find-charset-string string))
66 (defun find-non-ascii-charset-region (start end)
67 "Return a list of charsets except ascii
68 in the region between START and END.
69 \[emu-e20.el; Mule emulating function]"
70 (delq charset-ascii (find-charset-string (buffer-substring start end)))
77 (defconst *noconv* 'no-conversion)
79 (defmacro as-binary-process (&rest body)
80 `(let (selective-display ; Disable ^M to nl translation.
82 (default-process-coding-system 'no-conversion)
86 (defmacro as-binary-input-file (&rest body)
87 `(let ((coding-system-for-read 'no-conversion))
90 (defalias 'set-process-input-coding-system 'set-process-coding-system)
96 (defvar charsets-mime-charset-alist
98 (cons (list charset-ascii) 'us-ascii)
99 (cons (list charset-ascii charset-latin-iso8859-1) 'iso-8859-1)
100 (cons (list charset-ascii charset-latin-iso8859-2) 'iso-8859-2)
101 (cons (list charset-ascii charset-latin-iso8859-3) 'iso-8859-3)
102 (cons (list charset-ascii charset-latin-iso8859-4) 'iso-8859-4)
103 ;;;(cons (list charset-ascii
104 ;;; charset-cyrillic-iso8859-5) 'iso-8859-5)
105 (cons (list charset-ascii
106 charset-cyrillic-iso8859-5) 'koi8-r)
107 (cons (list charset-ascii charset-arabic-iso8859-6) 'iso-8859-6)
108 (cons (list charset-ascii charset-greek-iso8859-7) 'iso-8859-7)
109 (cons (list charset-ascii charset-hebrew-iso8859-8) 'iso-8859-8)
110 (cons (list charset-ascii charset-latin-iso8859-9) 'iso-8859-9)
111 (cons (list charset-ascii
112 charset-latin-jisx0201
113 charset-japanese-jisx0208-1978
114 charset-japanese-jisx0208) 'iso-2022-jp)
115 (cons (list charset-ascii charset-korean-ksc5601) 'euc-kr)
116 (cons (list charset-ascii charset-chinese-gb2312) 'cn-gb-2312)
117 (cons (list charset-ascii
118 charset-chinese-big5-1
119 charset-chinese-big5-2) 'cn-big5)
120 (cons (list charset-ascii charset-latin-iso8859-1
121 charset-greek-iso8859-7
122 charset-latin-jisx0201
123 charset-japanese-jisx0208-1978
124 charset-chinese-gb2312
125 charset-japanese-jisx0208
126 charset-korean-ksc5601
127 charset-japanese-jisx0212) 'iso-2022-jp-2)
128 (cons (list charset-ascii charset-latin-iso8859-1
129 charset-greek-iso8859-7
130 charset-latin-jisx0201
131 charset-japanese-jisx0208-1978
132 charset-chinese-gb2312
133 charset-japanese-jisx0208
134 charset-korean-ksc5601
135 charset-japanese-jisx0212
136 charset-chinese-cns11643-1
137 charset-chinese-cns11643-2) 'iso-2022-int-1)
138 (cons (list charset-ascii charset-latin-iso8859-1
139 charset-latin-iso8859-2
140 charset-cyrillic-iso8859-5
141 charset-greek-iso8859-7
142 charset-latin-jisx0201
143 charset-japanese-jisx0208-1978
144 charset-chinese-gb2312
145 charset-japanese-jisx0208
146 charset-korean-ksc5601
147 charset-japanese-jisx0212
148 charset-chinese-cns11643-1
149 charset-chinese-cns11643-2
150 charset-chinese-cns11643-3
151 charset-chinese-cns11643-4
152 charset-chinese-cns11643-5
153 charset-chinese-cns11643-6
154 charset-chinese-cns11643-7) 'iso-2022-int-1)
157 (defvar default-mime-charset 'x-ctext)
159 (defvar mime-charset-coding-system-alist
160 '((x-ctext . coding-system-ctext)
161 (hz-gb-2312 . coding-system-hz)
162 (cn-gb-2312 . coding-system-euc-china)
163 (gb2312 . coding-system-euc-china)
164 (cn-big5 . coding-system-big5)
165 (iso-2022-jp-2 . coding-system-iso-2022-ss2-7)
166 (iso-2022-int-1 . coding-system-iso-2022-int)
167 (shift_jis . coding-system-sjis)
170 (defun mime-charset-to-coding-system (charset &optional lbt)
171 (if (stringp charset)
172 (setq charset (intern (downcase charset)))
175 (or (cdr (assq charset mime-charset-coding-system-alist))
176 (let ((cs (intern (concat "coding-system-"
177 (symbol-name charset)))))
178 (and (coding-system-p cs) cs)
181 (intern (concat (symbol-name cs) "-" (symbol-name lbt)))
184 (defun detect-mime-charset-region (start end)
185 "Return MIME charset for region between START and END. [emu-e20.el]"
186 (charsets-to-mime-charset
187 (find-charset-string (buffer-substring start end))
190 (defun encode-mime-charset-region (start end charset)
191 "Encode the text between START and END as MIME CHARSET. [emu-e20.el]"
192 (let ((cs (mime-charset-to-coding-system charset)))
194 (encode-coding-region start end cs)
197 (defun decode-mime-charset-region (start end charset)
198 "Decode the text between START and END as MIME CHARSET. [emu-e20.el]"
199 (let ((cs (mime-charset-to-coding-system charset)))
201 (decode-coding-region start end cs)
204 (defun encode-mime-charset-string (string charset)
205 "Encode the STRING as MIME CHARSET. [emu-e20.el]"
206 (let ((cs (mime-charset-to-coding-system charset)))
208 (encode-coding-string string cs)
211 (defun decode-mime-charset-string (string charset)
212 "Decode the STRING as MIME CHARSET. [emu-e20.el]"
213 (let ((cs (mime-charset-to-coding-system charset)))
215 (decode-coding-string string cs)
222 (defalias 'char-length 'char-bytes)
224 (defalias 'char-columns 'char-width)
227 ;;; @@ Mule emulating aliases
229 ;;; You should not use them.
231 (defalias 'make-character 'make-char)
233 (defun char-category (character)
234 "Return string of category mnemonics for CHAR in TABLE.
235 CHAR can be any multilingual character
236 TABLE defaults to the current buffer's category table.
237 \[emu-e20.el; Mule emulating function]"
238 (category-set-mnemonics (char-category-set character))
245 (defalias 'string-columns 'string-width)
247 (defalias 'sset 'string-embed-string)
249 (defun string-to-char-list (string)
250 "Return a list of which elements are characters in the STRING.
251 \[emu-e20.el; Mule 2.3 emulating function]"
252 (let* ((len (length string))
256 (setq chr (sref string i))
257 (setq l (cons chr l))
258 (setq i (+ i (char-bytes chr)))
263 (defalias 'string-to-int-list 'string-to-char-list)
269 (defun regulate-latin-char (chr)
270 (cond ((and (<= ?
\e$B#A
\e(B chr)(<= chr ?
\e$B#Z
\e(B))
271 (+ (- chr ?
\e$B#A
\e(B) ?A)
273 ((and (<= ?
\e$B#a
\e(B chr)(<= chr ?
\e$B#z
\e(B))
274 (+ (- chr ?
\e$B#a
\e(B) ?a)
276 ((eq chr ?
\e$B!%
\e(B) ?.)
277 ((eq chr ?
\e$B!$
\e(B) ?,)
281 (defun regulate-latin-string (str)
282 (let ((len (length str))
286 (setq chr (sref str i))
287 (setq dest (concat dest
288 (char-to-string (regulate-latin-char chr))))
289 (setq i (+ i (char-bytes chr)))
299 ;;; emu-e20.el ends here