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.43 1996/12/07 06:07:15 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 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.
32 (defvar xemacs-beta-version
33 (if (string-match "(beta\\([0-9]+\\))" emacs-version)
35 (substring emacs-version (match-beginning 1)(match-end 1))
39 ;;; @ graphic character set
42 (defalias 'charset-description 'charset-doc-string)
44 (defalias 'find-charset-string 'charsets-in-string)
45 (defalias 'find-charset-region 'charsets-in-region)
47 (defun find-non-ascii-charset-string (string)
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))
53 (defun find-non-ascii-charset-region (start end)
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))
64 (defconst *noconv* 'no-conversion)
65 (defconst *ctext* 'ctext)
67 (defconst *big5* 'big5)
68 (defconst *euc-kr* 'euc-kr)
69 (defconst *koi8* 'koi8)
71 (defalias 'set-buffer-file-coding-system 'set-file-coding-system)
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)
79 (defmacro as-binary-input-file (&rest body)
80 `(let ((file-coding-system-for-read 'no-conversion))
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
109 chinese-cns11643-1 chinese-cns11643-2
110 latin-iso8859-1 greek-iso8859-7) . iso-2022-int-1)
113 (defvar default-mime-charset 'iso-2022-int-1)
115 (defvar mime-charset-coding-system-alist
116 '((iso-8859-1 . ctext)
119 (iso-2022-jp-2 . iso-2022-ss2-7)
120 (x-iso-2022-jp-2 . iso-2022-ss2-7)
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)))
130 (or (cdr (assq charset mime-charset-coding-system-alist))
131 (and (memq charset (coding-system-list)) charset)
134 (defun detect-mime-charset-region (start end)
135 "Return MIME charset for region between START and END.
137 (charsets-to-mime-charset (charsets-in-region start end)))
139 (defun encode-mime-charset-region (start end charset)
140 "Encode the text between START and END as MIME CHARSET.
142 (let ((cs (mime-charset-to-coding-system charset)))
144 (encode-coding-region start end cs)
147 (defun decode-mime-charset-region (start end charset)
148 "Decode the text between START and END as MIME CHARSET.
150 (let ((cs (mime-charset-to-coding-system charset)))
152 (decode-coding-region start end cs)
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)))
159 (encode-coding-string string cs)
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)))
166 (decode-coding-string string cs)
173 (defun char-bytes (chr) 1)
175 (defun char-length (character)
176 "Return number of elements a CHARACTER occupies in a string or buffer.
180 (defun char-columns (character)
181 "Return number of columns a CHARACTER occupies when displayed.
183 (charset-columns (char-charset character))
186 ;;; @@ Mule emulating aliases
188 ;;; You should not use them.
190 (defalias 'char-width 'char-columns)
192 (defalias 'char-leading-char 'char-charset)
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))
202 (char-category-list character)
209 (defun string-columns (string)
210 "Return number of columns STRING occupies when displayed.
213 (len (length string))
216 (setq col (+ col (char-columns (aref string i))))
221 (defalias 'string-width 'string-columns)
223 (defun string-to-int-list (str)
224 (mapcar #'char-int str)
227 (defalias 'sref 'aref)
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]"
234 (setq start-column 0))
235 (substring str start-column width)
244 ;;; emu-x20.el ends here