8
|
1 ;;; emu-x20.el --- emu API implementation for XEmacs 20 with mule
|
|
2
|
|
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1994,1995,1996 MORIOKA Tomohiko
|
|
5
|
|
6 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
|
16
|
7 ;; Version: $Id: emu-x20.el,v 1.3 1997/02/02 05:06:17 steve Exp $
|
8
|
8 ;; Keywords: emulation, compatibility, Mule, XEmacs
|
|
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 GNU XEmacs; see the file COPYING. If not, write to the
|
|
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
25 ;; Boston, MA 02111-1307, USA.
|
|
26
|
4
|
27 ;;; Code:
|
|
28
|
8
|
29 (require 'cyrillic)
|
|
30 (require 'emu-xemacs)
|
|
31
|
4
|
32 (defvar xemacs-beta-version
|
|
33 (if (string-match "(beta\\([0-9]+\\))" emacs-version)
|
|
34 (string-to-number
|
|
35 (substring emacs-version (match-beginning 1)(match-end 1))
|
|
36 )))
|
|
37
|
|
38
|
8
|
39 ;;; @ graphic character set
|
4
|
40 ;;;
|
|
41
|
8
|
42 (defalias 'charset-description 'charset-doc-string)
|
4
|
43
|
8
|
44 (defalias 'find-charset-string 'charsets-in-string)
|
|
45 (defalias 'find-charset-region 'charsets-in-region)
|
|
46
|
|
47 (defun find-non-ascii-charset-string (string)
|
4
|
48 "Return a list of charsets in the STRING except ascii.
|
|
49 \[emu-x20.el; Mule emulating function]"
|
|
50 (delq 'ascii (charsets-in-string string))
|
|
51 )
|
|
52
|
8
|
53 (defun find-non-ascii-charset-region (start end)
|
4
|
54 "Return a list of charsets except ascii
|
|
55 in the region between START and END.
|
|
56 \[emu-x20.el; Mule emulating function]"
|
|
57 (delq 'ascii (charsets-in-region start end))
|
|
58 )
|
|
59
|
|
60
|
|
61 ;;; @ coding-system
|
|
62 ;;;
|
|
63
|
8
|
64 (defconst *noconv* 'no-conversion)
|
4
|
65 (defconst *ctext* 'ctext)
|
|
66 (defconst *hz* 'hz)
|
|
67 (defconst *big5* 'big5)
|
|
68 (defconst *euc-kr* 'euc-kr)
|
8
|
69 (defconst *koi8* 'koi8)
|
4
|
70
|
8
|
71 (defalias 'set-buffer-file-coding-system 'set-file-coding-system)
|
4
|
72
|
8
|
73 (defmacro as-binary-process (&rest body)
|
|
74 `(let (selective-display ; Disable ^M to nl translation.
|
|
75 process-input-coding-system
|
|
76 process-output-coding-system)
|
|
77 ,@body))
|
4
|
78
|
8
|
79 (defmacro as-binary-input-file (&rest body)
|
|
80 `(let ((file-coding-system-for-read 'no-conversion))
|
|
81 ,@body))
|
4
|
82
|
|
83
|
8
|
84 ;;; @ MIME charset
|
|
85 ;;;
|
|
86
|
|
87 (defvar charsets-mime-charset-alist
|
|
88 '(((ascii) . us-ascii)
|
|
89 ((ascii latin-iso8859-1) . iso-8859-1)
|
|
90 ((ascii latin-iso8859-2) . iso-8859-2)
|
|
91 ((ascii latin-iso8859-3) . iso-8859-3)
|
|
92 ((ascii latin-iso8859-4) . iso-8859-4)
|
|
93 ;;; ((ascii cyrillic-iso8859-5) . iso-8859-5)
|
|
94 ((ascii cyrillic-iso8859-5) . koi8-r)
|
|
95 ((ascii arabic-iso8859-6) . iso-8859-6)
|
|
96 ((ascii greek-iso8859-7) . iso-8859-7)
|
|
97 ((ascii hebrew-iso8859-8) . iso-8859-8)
|
|
98 ((ascii latin-iso8859-9) . iso-8859-9)
|
|
99 ((ascii japanese-jisx0208-1978 japanese-jisx0208) . iso-2022-jp)
|
|
100 ((ascii korean-ksc5601) . euc-kr)
|
|
101 ((ascii chinese-big5-1 chinese-big5-2) . big5)
|
|
102 ((ascii japanese-jisx0208-1978 chinese-gb
|
|
103 japanese-jisx0208 korean-ksc5601
|
|
104 japanese-jisx0212 latin-iso8859-1
|
|
105 greek-iso8859-7) . iso-2022-jp-2)
|
|
106 ((ascii japanese-jisx0208-1978 chinese-gb2312
|
|
107 japanese-jisx0208 korean-ksc5601
|
|
108 japanese-jisx0212
|
|
109 chinese-cns11643-1 chinese-cns11643-2
|
|
110 latin-iso8859-1 greek-iso8859-7) . iso-2022-int-1)
|
|
111 ))
|
|
112
|
|
113 (defvar default-mime-charset 'iso-2022-int-1)
|
|
114
|
|
115 (defvar mime-charset-coding-system-alist
|
|
116 '((iso-8859-1 . ctext)
|
|
117 (gb2312 . euc-china)
|
|
118 (koi8-r . koi8)
|
|
119 (iso-2022-jp-2 . iso-2022-ss2-7)
|
|
120 (x-iso-2022-jp-2 . iso-2022-ss2-7)
|
|
121 (shift_jis . sjis)
|
|
122 (x-shiftjis . sjis)
|
|
123 ))
|
|
124
|
|
125 (defun mime-charset-to-coding-system (charset)
|
|
126 "Return coding-system by MIME charset. [emu-x20.el]"
|
|
127 (if (stringp charset)
|
|
128 (setq charset (intern (downcase charset)))
|
|
129 )
|
|
130 (or (cdr (assq charset mime-charset-coding-system-alist))
|
|
131 (and (memq charset (coding-system-list)) charset)
|
|
132 ))
|
|
133
|
|
134 (defun detect-mime-charset-region (start end)
|
|
135 "Return MIME charset for region between START and END.
|
|
136 \[emu-x20.el]"
|
|
137 (charsets-to-mime-charset (charsets-in-region start end)))
|
|
138
|
|
139 (defun encode-mime-charset-region (start end charset)
|
|
140 "Encode the text between START and END as MIME CHARSET.
|
|
141 \[emu-x20.el]"
|
|
142 (let ((cs (mime-charset-to-coding-system charset)))
|
|
143 (if cs
|
|
144 (encode-coding-region start end cs)
|
|
145 )))
|
|
146
|
|
147 (defun decode-mime-charset-region (start end charset)
|
|
148 "Decode the text between START and END as MIME CHARSET.
|
|
149 \[emu-x20.el]"
|
|
150 (let ((cs (mime-charset-to-coding-system charset)))
|
|
151 (if cs
|
|
152 (decode-coding-region start end cs)
|
|
153 )))
|
|
154
|
|
155 (defun encode-mime-charset-string (string charset)
|
|
156 "Encode the STRING as MIME CHARSET. [emu-x20.el]"
|
|
157 (let ((cs (mime-charset-to-coding-system charset)))
|
|
158 (if cs
|
|
159 (encode-coding-string string cs)
|
|
160 string)))
|
|
161
|
|
162 (defun decode-mime-charset-string (string charset)
|
|
163 "Decode the STRING as MIME CHARSET. [emu-x20.el]"
|
|
164 (let ((cs (mime-charset-to-coding-system charset)))
|
|
165 (if cs
|
|
166 (decode-coding-string string cs)
|
|
167 string)))
|
|
168
|
|
169
|
|
170 ;;; @ character
|
4
|
171 ;;;
|
|
172
|
16
|
173 ;(defun char-bytes (chr) 1)
|
8
|
174
|
16
|
175 ;(defun char-length (character)
|
|
176 ; "Return number of elements a CHARACTER occupies in a string or buffer.
|
|
177 ;\[emu-x20.el]"
|
|
178 ; 1)
|
8
|
179
|
16
|
180 ;(defun char-columns (character)
|
|
181 ; "Return number of columns a CHARACTER occupies when displayed.
|
|
182 ;\[emu-x20.el]"
|
|
183 ; (charset-columns (char-charset character))
|
|
184 ; )
|
8
|
185
|
|
186 ;;; @@ Mule emulating aliases
|
|
187 ;;;
|
|
188 ;;; You should not use them.
|
|
189
|
16
|
190 ;(defalias 'char-width 'char-columns)
|
8
|
191
|
|
192 (defalias 'char-leading-char 'char-charset)
|
4
|
193
|
8
|
194 (defun char-category (character)
|
|
195 "Return string of category mnemonics for CHAR in TABLE.
|
|
196 CHAR can be any multilingual character
|
|
197 TABLE defaults to the current buffer's category table.
|
|
198 \[emu-x20.el; Mule emulating function]"
|
|
199 (mapconcat (lambda (chr)
|
|
200 (char-to-string (int-char chr))
|
|
201 )
|
|
202 (char-category-list character)
|
|
203 ""))
|
|
204
|
|
205
|
|
206 ;;; @ string
|
|
207 ;;;
|
|
208
|
16
|
209 ;(defun string-columns (string)
|
|
210 ; "Return number of columns STRING occupies when displayed.
|
|
211 ;\[emu-x20.el]"
|
|
212 ; (let ((col 0)
|
|
213 ; (len (length string))
|
|
214 ; (i 0))
|
|
215 ; (while (< i len)
|
|
216 ; (setq col (+ col (char-columns (aref string i))))
|
|
217 ; (setq i (1+ i))
|
|
218 ; )
|
|
219 ; col))
|
8
|
220
|
16
|
221 ;(defalias 'string-width 'string-columns)
|
8
|
222
|
|
223 (defun string-to-int-list (str)
|
|
224 (mapcar #'char-int str)
|
|
225 )
|
4
|
226
|
16
|
227 ;(defalias 'sref 'aref)
|
4
|
228
|
16
|
229 ;(defun truncate-string (str width &optional start-column)
|
|
230 ; "Truncate STR to fit in WIDTH columns.
|
|
231 ;Optional non-nil arg START-COLUMN specifies the starting column.
|
|
232 ;\[emu-x20.el; Mule 2.3 emulating function]"
|
|
233 ; (or start-column
|
|
234 ; (setq start-column 0))
|
|
235 ; (substring str start-column width)
|
|
236 ; )
|
4
|
237
|
|
238
|
|
239 ;;; @ end
|
|
240 ;;;
|
|
241
|
|
242 (provide 'emu-x20)
|
|
243
|
|
244 ;;; emu-x20.el ends here
|