1 ;;; emu-e20.el --- emu API implementation for Emacs/mule (19.34.91-delta)
3 ;; Copyright (C) 1996,1997 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version: $Id: emu-e20.el,v 7.13 1997/03/10 05:36:04 morioka Exp $
7 ;; Keywords: emulation, compatibility, Mule
9 ;; This file is part of emu.
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)
34 (let* ((info (fontset-info fontset))
35 (height (aref info 1))
37 (cond ((> height 0) height)
38 ((string-match "-\\([0-9]+\\)-" fontset)
40 (substring fontset (match-beginning 1)(match-end 1))
50 ;; (defalias 'charset-columns 'charset-width)
52 (defun find-non-ascii-charset-string (string)
53 "Return a list of charsets in the STRING except ascii.
54 \[emu-e20.el; Mule emulating function]"
55 (delq 'ascii (find-charset-string string))
58 (defun find-non-ascii-charset-region (start end)
59 "Return a list of charsets except ascii
60 in the region between START and END.
61 \[emu-e20.el; Mule emulating function]"
62 (delq 'ascii (find-charset-string (buffer-substring start end)))
69 (defconst *noconv* 'no-conversion)
71 (defmacro as-binary-process (&rest body)
72 `(let (selective-display ; Disable ^M to nl translation.
74 (coding-system-for-read 'no-conversion)
75 (coding-system-for-write 'no-conversion)
79 (defmacro as-binary-input-file (&rest body)
80 `(let ((coding-system-for-read 'no-conversion))
83 (defmacro as-binary-output-file (&rest body)
84 `(let ((coding-system-for-write 'no-conversion))
87 (defalias 'set-process-input-coding-system 'set-process-coding-system)
93 (defun insert-binary-file-contents-literally
94 (filename &optional visit beg end replace)
95 "Like `insert-file-contents-literally', q.v., but don't code conversion.
96 A buffer may be modified in several ways after reading into the buffer due
97 to advanced Emacs features, such as file-name-handlers, format decoding,
99 This function ensures that none of these modifications will take place."
100 (let ((coding-system-for-read 'no-conversion))
101 (insert-file-contents-literally filename visit beg end replace)
108 (defvar charsets-mime-charset-alist
109 '(((ascii) . us-ascii)
110 ((ascii latin-iso8859-1) . iso-8859-1)
111 ((ascii latin-iso8859-2) . iso-8859-2)
112 ((ascii latin-iso8859-3) . iso-8859-3)
113 ((ascii latin-iso8859-4) . iso-8859-4)
114 ;;; ((ascii cyrillic-iso8859-5) . iso-8859-5)
115 ((ascii cyrillic-iso8859-5) . koi8-r)
116 ((ascii arabic-iso8859-6) . iso-8859-6)
117 ((ascii greek-iso8859-7) . iso-8859-7)
118 ((ascii hebrew-iso8859-8) . iso-8859-8)
119 ((ascii latin-iso8859-9) . iso-8859-9)
120 ((ascii latin-jisx0201
121 japanese-jisx0208-1978 japanese-jisx0208) . iso-2022-jp)
122 ((ascii korean-ksc5601) . euc-kr)
123 ((ascii chinese-gb2312) . cn-gb-2312)
124 ((ascii chinese-big5-1 chinese-big5-2) . cn-big5)
125 ((ascii latin-iso8859-1 greek-iso8859-7
126 latin-jisx0201 japanese-jisx0208-1978
127 chinese-gb2312 japanese-jisx0208
128 korean-ksc5601 japanese-jisx0212) . iso-2022-jp-2)
129 ((ascii latin-iso8859-1 greek-iso8859-7
130 latin-jisx0201 japanese-jisx0208-1978
131 chinese-gb2312 japanese-jisx0208
132 korean-ksc5601 japanese-jisx0212
133 chinese-cns11643-1 chinese-cns11643-2) . iso-2022-int-1)
134 ((ascii latin-iso8859-1 latin-iso8859-2
135 cyrillic-iso8859-5 greek-iso8859-7
136 latin-jisx0201 japanese-jisx0208-1978
137 chinese-gb2312 japanese-jisx0208
138 korean-ksc5601 japanese-jisx0212
139 chinese-cns11643-1 chinese-cns11643-2
140 chinese-cns11643-3 chinese-cns11643-4
141 chinese-cns11643-5 chinese-cns11643-6
142 chinese-cns11643-7) . iso-2022-int-1)
145 (defvar default-mime-charset 'x-ctext)
147 (defvar mime-charset-coding-system-alist
149 (gb2312 . cn-gb-2312)
150 (iso-2022-jp-2 . iso-2022-ss2-7)
153 (defun mime-charset-to-coding-system (charset &optional lbt)
154 (if (stringp charset)
155 (setq charset (intern (downcase charset)))
158 (or (cdr (assq charset mime-charset-coding-system-alist))
159 (and (coding-system-p charset) charset)
162 (intern (concat (symbol-name cs) "-" (symbol-name lbt)))
165 (defun detect-mime-charset-region (start end)
166 "Return MIME charset for region between START and END. [emu-e20.el]"
167 (charsets-to-mime-charset
168 (find-charset-string (buffer-substring start end))
171 (defun encode-mime-charset-region (start end charset)
172 "Encode the text between START and END as MIME CHARSET. [emu-e20.el]"
173 (let ((cs (mime-charset-to-coding-system charset)))
175 (encode-coding-region start end cs)
178 (defun decode-mime-charset-region (start end charset)
179 "Decode the text between START and END as MIME CHARSET. [emu-e20.el]"
180 (let ((cs (mime-charset-to-coding-system charset)))
182 (decode-coding-region start end cs)
185 (defun encode-mime-charset-string (string charset)
186 "Encode the STRING as MIME CHARSET. [emu-e20.el]"
187 (let ((cs (mime-charset-to-coding-system charset)))
189 (encode-coding-string string cs)
192 (defun decode-mime-charset-string (string charset)
193 "Decode the STRING as MIME CHARSET. [emu-e20.el]"
194 (let ((cs (mime-charset-to-coding-system charset)))
196 (decode-coding-string string cs)
203 (defalias 'char-length 'char-bytes)
205 (defalias 'char-columns 'char-width)
208 ;;; @@ Mule emulating aliases
210 ;;; You should not use them.
212 (defalias 'make-character 'make-char)
214 (defun char-category (character)
215 "Return string of category mnemonics for CHAR in TABLE.
216 CHAR can be any multilingual character
217 TABLE defaults to the current buffer's category table.
218 \[emu-e20.el; Mule emulating function]"
219 (category-set-mnemonics (char-category-set character))
226 (defalias 'string-columns 'string-width)
228 (defalias 'sset 'store-substring)
230 (defun string-to-char-list (string)
231 "Return a list of which elements are characters in the STRING.
232 \[emu-e20.el; Mule 2.3 emulating function]"
233 (let* ((len (length string))
237 (setq chr (sref string i))
238 (setq l (cons chr l))
239 (setq i (+ i (char-bytes chr)))
244 (defalias 'string-to-int-list 'string-to-char-list)
252 ;;; emu-e20.el ends here