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 7.0 1996/11/27 13:40:42 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-pixel-size (fontset)
35 (let* ((info (fontset-info fontset))
36 (height (aref info 1))
40 (let ((str (car (find-if (function identity) (aref info 2)))))
41 (if (string-match "--\\([0-9]+\\)-\\*-\\*-\\*-\\*-\\*-ISO8859-1" str)
43 (substring str (match-beginning 1)(match-end 1))
51 (defalias 'charset-columns 'charset-width)
53 (defun charset-iso-class (charset)
54 "Return ISO-class of CHARSET.
55 \(0/CLASS94, 1/CLASS96, 2/CLASS94x94, 3/CLASS96x96) [emu-e20.el]"
56 (aref (charset-info charset) 5)
59 (defun find-non-ascii-charset-string (string)
60 "Return a list of charsets in the STRING except ascii.
61 \[emu-e20.el; Mule emulating function]"
62 (delq charset-ascii (find-charset-string string))
65 (defun find-non-ascii-charset-region (start end)
66 "Return a list of charsets except ascii
67 in the region between START and END.
68 \[emu-e20.el; Mule emulating function]"
69 (delq charset-ascii (find-charset-string (buffer-substring start end)))
76 (defconst *noconv* 'no-conversion)
78 (defmacro as-binary-process (&rest body)
79 `(let (selective-display ; Disable ^M to nl translation.
81 (default-process-coding-system 'no-conversion)
85 (defmacro as-binary-input-file (&rest body)
86 `(let ((coding-system-for-read 'no-conversion))
89 (defalias 'set-process-input-coding-system 'set-process-coding-system)
95 (defvar charsets-mime-charset-alist
97 (cons (list charset-ascii) 'us-ascii)
98 (cons (list charset-ascii charset-latin-iso8859-1) 'iso-8859-1)
99 (cons (list charset-ascii charset-latin-iso8859-2) 'iso-8859-2)
100 (cons (list charset-ascii charset-latin-iso8859-3) 'iso-8859-3)
101 (cons (list charset-ascii charset-latin-iso8859-4) 'iso-8859-4)
102 ;;;(cons (list charset-ascii
103 ;;; charset-cyrillic-iso8859-5) 'iso-8859-5)
104 (cons (list charset-ascii
105 charset-cyrillic-iso8859-5) 'koi8-r)
106 (cons (list charset-ascii charset-arabic-iso8859-6) 'iso-8859-6)
107 (cons (list charset-ascii charset-greek-iso8859-7) 'iso-8859-7)
108 (cons (list charset-ascii charset-hebrew-iso8859-8) 'iso-8859-8)
109 (cons (list charset-ascii charset-latin-iso8859-9) 'iso-8859-9)
110 (cons (list charset-ascii
111 charset-latin-jisx0201
112 charset-japanese-jisx0208-1978
113 charset-japanese-jisx0208) 'iso-2022-jp)
114 (cons (list charset-ascii charset-korean-ksc5601) 'euc-kr)
115 (cons (list charset-ascii charset-chinese-gb2312) 'cn-gb-2312)
116 (cons (list charset-ascii
117 charset-chinese-big5-1
118 charset-chinese-big5-2) 'cn-big5)
119 (cons (list charset-ascii charset-latin-iso8859-1
120 charset-greek-iso8859-7
121 charset-latin-jisx0201
122 charset-japanese-jisx0208-1978
123 charset-chinese-gb2312
124 charset-japanese-jisx0208
125 charset-korean-ksc5601
126 charset-japanese-jisx0212) 'iso-2022-jp-2)
127 (cons (list charset-ascii charset-latin-iso8859-1
128 charset-greek-iso8859-7
129 charset-latin-jisx0201
130 charset-japanese-jisx0208-1978
131 charset-chinese-gb2312
132 charset-japanese-jisx0208
133 charset-korean-ksc5601
134 charset-japanese-jisx0212
135 charset-chinese-cns11643-1
136 charset-chinese-cns11643-2) 'iso-2022-int-1)
137 (cons (list charset-ascii charset-latin-iso8859-1
138 charset-latin-iso8859-2
139 charset-cyrillic-iso8859-5
140 charset-greek-iso8859-7
141 charset-latin-jisx0201
142 charset-japanese-jisx0208-1978
143 charset-chinese-gb2312
144 charset-japanese-jisx0208
145 charset-korean-ksc5601
146 charset-japanese-jisx0212
147 charset-chinese-cns11643-1
148 charset-chinese-cns11643-2
149 charset-chinese-cns11643-3
150 charset-chinese-cns11643-4
151 charset-chinese-cns11643-5
152 charset-chinese-cns11643-6
153 charset-chinese-cns11643-7) 'iso-2022-int-1)
156 (defvar default-mime-charset 'x-ctext)
158 (defvar mime-charset-coding-system-alist
159 '((x-ctext . coding-system-ctext)
160 (hz-gb-2312 . coding-system-hz)
161 (cn-gb-2312 . coding-system-euc-china)
162 (gb2312 . coding-system-euc-china)
163 (cn-big5 . coding-system-big5)
164 (iso-2022-jp-2 . coding-system-iso-2022-ss2-7)
165 (iso-2022-int-1 . coding-system-iso-2022-int)
166 (shift_jis . coding-system-sjis)
169 (defun mime-charset-to-coding-system (charset &optional lbt)
170 (if (stringp charset)
171 (setq charset (intern (downcase charset)))
174 (or (cdr (assq charset mime-charset-coding-system-alist))
175 (let ((cs (intern (concat "coding-system-"
176 (symbol-name charset)))))
177 (and (coding-system-p cs) cs)
180 (intern (concat (symbol-name cs) "-" (symbol-name lbt)))
183 (defun detect-mime-charset-region (start end)
184 "Return MIME charset for region between START and END. [emu-e20.el]"
185 (charsets-to-mime-charset
186 (find-charset-string (buffer-substring start end))
189 (defun encode-mime-charset-region (start end charset)
190 "Encode the text between START and END as MIME CHARSET. [emu-e20.el]"
191 (let ((cs (mime-charset-to-coding-system charset)))
193 (encode-coding-region start end cs)
196 (defun decode-mime-charset-region (start end charset)
197 "Decode the text between START and END as MIME CHARSET. [emu-e20.el]"
198 (let ((cs (mime-charset-to-coding-system charset)))
200 (decode-coding-region start end cs)
203 (defun encode-mime-charset-string (string charset)
204 "Encode the STRING as MIME CHARSET. [emu-e20.el]"
205 (let ((cs (mime-charset-to-coding-system charset)))
207 (encode-coding-string string cs)
210 (defun decode-mime-charset-string (string charset)
211 "Decode the STRING as MIME CHARSET. [emu-e20.el]"
212 (let ((cs (mime-charset-to-coding-system charset)))
214 (decode-coding-string string cs)
221 (defalias 'char-length 'char-bytes)
223 (defalias 'char-columns 'char-width)
226 ;;; @@ Mule emulating aliases
228 ;;; You should not use them.
230 (defalias 'make-character 'make-char)
232 (defun char-category (character)
233 "Return string of category mnemonics for CHAR in TABLE.
234 CHAR can be any multilingual character
235 TABLE defaults to the current buffer's category table.
236 \[emu-e20.el; Mule emulating function]"
237 (category-set-mnemonics (char-category-set character))
244 (defalias 'string-columns 'string-width)
246 (defalias 'sset 'string-embed-string)
248 (defun string-to-char-list (string)
249 "Return a list of which elements are characters in the STRING.
250 \[emu-e20.el; Mule 2.3 emulating function]"
251 (let* ((len (length string))
255 (setq chr (sref string i))
256 (setq l (cons chr l))
257 (setq i (+ i (char-bytes chr)))
262 (defalias 'string-to-int-list 'string-to-char-list)
268 (defun regulate-latin-char (chr)
269 (cond ((and (<= ?
\e$B#A
\e(B chr)(<= chr ?
\e$B#Z
\e(B))
270 (+ (- chr ?
\e$B#A
\e(B) ?A)
272 ((and (<= ?
\e$B#a
\e(B chr)(<= chr ?
\e$B#z
\e(B))
273 (+ (- chr ?
\e$B#a
\e(B) ?a)
275 ((eq chr ?
\e$B!%
\e(B) ?.)
276 ((eq chr ?
\e$B!$
\e(B) ?,)
280 (defun regulate-latin-string (str)
281 (let ((len (length str))
285 (setq chr (sref str i))
286 (setq dest (concat dest
287 (char-to-string (regulate-latin-char chr))))
288 (setq i (+ i (char-bytes chr)))
298 ;;; emu-e20.el ends here