1 ;;; emu-x20.el --- emu API implementation for XEmacs 20 with mule
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
4 ;; Copyright (C) 1994,1995,1996 MORIOKA Tomohiko
6 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Version: $Id: emu-x20.el,v 7.35 1996/09/15 08:04:02 morioka Exp $
8 ;; Keywords: emulation, compatibility, Mule, XEmacs
10 ;; This file is part of tl (Tiny Library).
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.
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.
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.
32 (defvar xemacs-beta-version
33 (if (string-match "(beta\\([0-9]+\\))" emacs-version)
35 (substring emacs-version (match-beginning 1)(match-end 1))
42 (defalias 'charset-description 'charset-doc-string)
44 (defun find-charset-string (string)
45 "Return a list of charsets in the STRING except ascii.
46 \[emu-x20.el; Mule emulating function]"
47 (delq 'ascii (charsets-in-string string))
50 (defun find-charset-region (start end)
51 "Return a list of charsets except ascii
52 in the region between START and END.
53 \[emu-x20.el; Mule emulating function]"
54 (delq 'ascii (charsets-in-region start end))
57 ;;; @@ for Mule emulation
60 (defconst lc-ascii 'ascii)
61 (defconst lc-ltn1 'latin-1)
62 (defconst lc-ltn2 'latin-2)
63 (defconst lc-ltn3 'latin-3)
64 (defconst lc-ltn4 'latin-4)
65 (defconst lc-crl 'cyrillic)
66 (defconst lc-arb 'arabic)
67 (defconst lc-grk 'greek)
68 (defconst lc-hbw 'hebrew)
69 (defconst lc-ltn5 'latin-5)
70 (defconst lc-jp 'japanese)
71 (defconst lc-jp2 'japanese-2)
72 (defconst lc-kr 'korean)
73 (defconst lc-big5-1 'chinese-big5-1)
74 (defconst lc-big5-2 'chinese-big5-2)
75 (defconst lc-cn 'chinese-gb)
76 (defconst lc-cns1 'chinese-cns-1)
77 (defconst lc-cns2 'chinese-cns-2)
78 (defconst lc-cns3 'chinese-cns-3)
79 (defconst lc-cns4 'chinese-cns-4)
80 (defconst lc-cns5 'chinese-cns-5)
81 (defconst lc-cns6 'chinese-cns-6)
82 (defconst lc-cns7 'chinese-cns-7)
88 (defconst *noconv* 'noconv)
89 (defconst *ctext* 'ctext)
91 (defconst *big5* 'big5)
92 (defconst *euc-kr* 'euc-kr)
93 (defconst *koi8* 'koi8)
95 (defmacro as-binary-process (&rest body)
96 `(let (selective-display ; Disable ^M to nl translation.
97 process-input-coding-system
98 process-output-coding-system)
105 (defvar charsets-mime-charset-alist
106 '(((ascii) . us-ascii)
107 ((ascii latin-1) . iso-8859-1)
108 ((ascii latin-2) . iso-8859-2)
109 ((ascii latin-3) . iso-8859-3)
110 ((ascii latin-4) . iso-8859-4)
111 ;;; ((ascii cyrillic) . iso-8859-5)
112 ((ascii cyrillic) . koi8-r)
113 ((ascii arabic) . iso-8859-6)
114 ((ascii greek) . iso-8859-7)
115 ((ascii hebrew) . iso-8859-8)
116 ((ascii latin-5) . iso-8859-9)
117 ((ascii japanese-old japanese) . iso-2022-jp)
118 ((ascii korean) . euc-kr)
119 ((ascii chinese-big5-1 chinese-big5-2) . big5)
120 ((ascii japanese-old chinese-gb japanese korean
121 japanese-2 latin-1 greek) . iso-2022-jp-2)
122 ((ascii japanese-old chinese-gb japanese korean
123 japanese-2 chinese-cns-1 chinese-cns-2
124 latin-1 greek) . iso-2022-int-1)
127 (defvar default-mime-charset 'iso-2022-int-1)
129 (defvar mime-charset-coding-system-alist
130 '((iso-8859-1 . ctext)
133 (iso-2022-jp-2 . iso-2022-ss2-7)
134 (x-iso-2022-jp-2 . iso-2022-ss2-7)
139 (defun mime-charset-to-coding-system (charset)
140 "Return coding-system by MIME charset. [emu-x20.el]"
141 (if (stringp charset)
142 (setq charset (intern (downcase charset)))
144 (or (cdr (assq charset mime-charset-coding-system-alist))
145 (and (memq charset (coding-system-list)) charset)
148 (defun detect-mime-charset-region (start end)
149 "Return MIME charset for region between START and END.
151 (charsets-to-mime-charset (charsets-in-region start end)))
153 (defun encode-mime-charset-region (start end charset)
154 "Encode the text between START and END as MIME CHARSET.
156 (let ((cs (mime-charset-to-coding-system charset)))
158 (encode-coding-region start end cs)
161 (defun decode-mime-charset-region (start end charset)
162 "Decode the text between START and END as MIME CHARSET.
164 (let ((cs (mime-charset-to-coding-system charset)))
166 (decode-coding-region start end cs)
169 (defun encode-mime-charset-string (string charset)
170 "Encode the STRING as MIME CHARSET. [emu-x20.el]"
171 (let ((cs (mime-charset-to-coding-system charset)))
173 (encode-coding-string string cs)
176 (defun decode-mime-charset-string (string charset)
177 "Decode the STRING as MIME CHARSET. [emu-x20.el]"
178 (let ((cs (mime-charset-to-coding-system charset)))
180 (decode-coding-string string cs)
187 (defun char-bytes (chr) 1)
189 (defun char-length (character)
190 "Return number of elements a CHARACTER occupies in a string or buffer.
194 (defun char-columns (character)
195 "Return number of columns a CHARACTER occupies when displayed.
197 (charset-columns (char-charset character))
200 ;;; @@ Mule emulating aliases
202 ;;; You should not use them.
204 (defalias 'char-width 'char-columns)
206 (defalias 'char-leading-char 'char-charset)
208 (defun char-category (character)
209 "Return string of category mnemonics for CHAR in TABLE.
210 CHAR can be any multilingual character
211 TABLE defaults to the current buffer's category table.
212 \[emu-x20.el; Mule emulating function]"
213 (mapconcat (lambda (chr)
214 (char-to-string (int-char chr))
216 (char-category-list character)
223 (defun string-columns (string)
224 "Return number of columns STRING occupies when displayed.
227 (len (length string))
230 (setq col (+ col (char-columns (aref string i))))
235 (defalias 'string-width 'string-column)
237 (defun string-to-int-list (str)
238 (mapcar #'char-int str)
241 (defalias 'sref 'aref)
243 (defun truncate-string (str width &optional start-column)
244 "Truncate STR to fit in WIDTH columns.
245 Optional non-nil arg START-COLUMN specifies the starting column.
246 \[emu-x20.el; Mule 2.3 emulating function]"
248 (setq start-column 0))
249 (substring str start-column width)
258 ;;; emu-x20.el ends here