1 ;;; emu-e20.el --- emu API implementation for mule merged Emacs
3 ;; Copyright (C) 1996 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version: $Id: emu-e20.el,v 4.1 1996/10/01 13:18:34 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 find-non-ascii-charset-string (string)
55 "Return a list of charsets in the STRING except ascii.
56 \[emu-e20.el; Mule emulating function]"
57 (delq charset-ascii (find-charset-string string))
60 (defun find-non-ascii-charset-region (start end)
61 "Return a list of charsets except ascii
62 in the region between START and END.
63 \[emu-e20.el; Mule emulating function]"
64 (delq charset-ascii (find-charset-string (buffer-substring start end)))
71 (defconst *noconv* 'no-conversion)
73 (defmacro as-binary-process (&rest body)
74 `(let (selective-display ; Disable ^M to nl translation.
75 ;; for mule merged Emacs
76 (default-process-coding-system 'no-conversion)
80 (defmacro as-binary-input-file (&rest body)
81 `(let ((coding-system-for-read 'no-conversion))
84 (defalias 'set-process-input-coding-system 'set-process-coding-system)
90 (defvar charsets-mime-charset-alist
92 (cons (list charset-ascii) 'us-ascii)
93 (cons (list charset-ascii charset-latin-1) 'iso-8859-1)
94 (cons (list charset-ascii charset-latin-2) 'iso-8859-2)
95 (cons (list charset-ascii charset-latin-3) 'iso-8859-3)
96 (cons (list charset-ascii charset-latin-4) 'iso-8859-4)
97 ;;;(cons (list charset-ascii charset-cyrillic) 'iso-8859-5)
98 (cons (list charset-ascii charset-cyrillic) 'koi8-r)
99 (cons (list charset-ascii charset-arabic) 'iso-8859-6)
100 (cons (list charset-ascii charset-greek) 'iso-8859-7)
101 (cons (list charset-ascii charset-hebrew) 'iso-8859-8)
102 (cons (list charset-ascii charset-latin-5) 'iso-8859-9)
103 (cons (list charset-ascii
104 charset-japanese-jisx0201-roman
105 charset-japanese-jisx0208-1978
106 charset-japanese-jisx0208) 'iso-2022-jp)
107 (cons (list charset-ascii charset-korean-ksc5601) 'euc-kr)
108 (cons (list charset-ascii charset-chinese-gb2312) 'gb2312)
109 (cons (list charset-ascii
110 charset-chinese-big5-1
111 charset-chinese-big5-2) 'big5)
112 (cons (list charset-ascii
113 charset-latin-1 charset-greek
114 charset-japanese-jisx0201-roman
115 charset-japanese-jisx0208-1978
116 charset-chinese-gb2312
117 charset-japanese-jisx0208
118 charset-korean-ksc5601
119 charset-japanese-jisx0212) 'iso-2022-jp-2)
120 (cons (list charset-ascii
121 charset-latin-1 charset-greek
122 charset-japanese-jisx0201-roman
123 charset-japanese-jisx0208-1978
124 charset-chinese-gb2312
125 charset-japanese-jisx0208
126 charset-korean-ksc5601
127 charset-japanese-jisx0212
128 charset-chinese-cns11643-1
129 charset-chinese-cns11643-2) 'iso-2022-int-1)
130 (cons (list charset-ascii
131 charset-latin-1 charset-latin-2
132 charset-cyrillic charset-greek
133 charset-japanese-jisx0201-roman
134 charset-japanese-jisx0208-1978
135 charset-chinese-gb2312
136 charset-japanese-jisx0208
137 charset-korean-ksc5601
138 charset-japanese-jisx0212
139 charset-chinese-cns11643-1
140 charset-chinese-cns11643-2
141 charset-chinese-cns11643-3
142 charset-chinese-cns11643-4
143 charset-chinese-cns11643-5
144 charset-chinese-cns11643-6
145 charset-chinese-cns11643-7) 'iso-2022-int-1)
148 (defvar default-mime-charset 'x-ctext)
150 (defvar mime-charset-coding-system-alist
151 '((x-ctext . coding-system-ctext)
152 (hz-gb-2312 . coding-system-hz)
153 (cn-gb-2312 . coding-system-euc-china)
154 (gb2312 . coding-system-euc-china)
155 (cn-big5 . coding-system-big5)
156 (iso-2022-jp-2 . coding-system-iso-2022-ss2-7)
157 (iso-2022-int-1 . coding-system-iso-2022-int)
158 (shift_jis . coding-system-sjis)
161 (defun mime-charset-to-coding-system (charset)
162 (if (stringp charset)
163 (setq charset (intern (downcase charset)))
165 (or (cdr (assq charset mime-charset-coding-system-alist))
166 (let ((cs (intern (concat "coding-system-" (symbol-name charset)))))
167 (and (coding-system-p cs) cs)
170 (defun detect-mime-charset-region (start end)
171 "Return MIME charset for region between START and END. [emu-e20.el]"
172 (charsets-to-mime-charset
173 (find-charset-string (buffer-substring start end))
176 (defun encode-mime-charset-region (start end charset)
177 "Encode the text between START and END as MIME CHARSET. [emu-e20.el]"
178 (let ((cs (mime-charset-to-coding-system charset)))
180 (encode-coding-region start end cs)
183 (defun decode-mime-charset-region (start end charset)
184 "Decode the text between START and END as MIME CHARSET. [emu-e20.el]"
185 (let ((cs (mime-charset-to-coding-system charset)))
187 (decode-coding-region start end cs)
190 (defun encode-mime-charset-string (string charset)
191 "Encode the STRING as MIME CHARSET. [emu-e20.el]"
192 (let ((cs (mime-charset-to-coding-system charset)))
194 (encode-coding-string string cs)
197 (defun decode-mime-charset-string (string charset)
198 "Decode the STRING as MIME CHARSET. [emu-e20.el]"
199 (let ((cs (mime-charset-to-coding-system charset)))
201 (decode-coding-string string cs)
208 (defalias 'char-length 'char-bytes)
210 (defalias 'char-columns 'char-width)
213 ;;; @@ Mule emulating aliases
215 ;;; You should not use them.
217 (defalias 'make-character 'make-char)
219 (defun char-category (character)
220 "Return string of category mnemonics for CHAR in TABLE.
221 CHAR can be any multilingual character
222 TABLE defaults to the current buffer's category table.
223 \[emu-e20.el; Mule emulating function]"
224 (category-set-mnemonics (char-category-set character))
231 (defalias 'string-columns 'string-width)
233 (defalias 'sset 'string-embed-string)
235 (defun string-to-char-list (string)
236 "Return a list of which elements are characters in the STRING.
237 \[emu-e20.el; Mule 2.3 emulating function]"
238 (let* ((len (length string))
242 (setq chr (sref string i))
243 (setq l (cons chr l))
244 (setq i (+ i (char-bytes chr)))
249 (defalias 'string-to-int-list 'string-to-char-list)
251 (or (fboundp 'truncate-string)
252 (defun truncate-string (string width &optional start-column)
253 "Truncate STRING to fit in WIDTH columns.
254 Optional non-nil arg START-COLUMN specifies the starting column.
255 \[emu-e20.el; MULE 2.3 emulating function]"
257 (setq start-column 0))
258 (let ((max-width (string-width string))
259 (len (length string))
263 (if (>= width max-width)
264 (setq width max-width))
265 (if (>= start-column width)
267 (while (< column start-column)
268 (setq ch (aref string from)
269 column (+ column (char-width ch))
270 from (if (= (setq b (charset-bytes ch)) 0)
275 (if (< width max-width)
278 (while (and (<= column width)
280 (setq ch (aref string to)
281 column (+ column (char-width ch))
283 to (if (= (setq b (charset-bytes ch)) 0)
289 (substring string from to))))
297 (defun regulate-latin-char (chr)
298 (cond ((and (<= ?
\e$B#A
\e(B chr)(<= chr ?
\e$B#Z
\e(B))
299 (+ (- chr ?
\e$B#A
\e(B) ?A)
301 ((and (<= ?
\e$B#a
\e(B chr)(<= chr ?
\e$B#z
\e(B))
302 (+ (- chr ?
\e$B#a
\e(B) ?a)
304 ((eq chr ?
\e$B!%
\e(B) ?.)
305 ((eq chr ?
\e$B!$
\e(B) ?,)
309 (defun regulate-latin-string (str)
310 (let ((len (length str))
314 (setq chr (sref str i))
315 (setq dest (concat dest
316 (char-to-string (regulate-latin-char chr))))
317 (setq i (+ i (char-bytes chr)))
327 ;;; emu-e20.el ends here