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.15 1997/07/13 06:23:00 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 ;; This module requires Emacs 20.0.90 or later.
32 ;;; @ version specific features
37 (defun fontset-pixel-size (fontset)
38 (let* ((info (fontset-info fontset))
39 (height (aref info 1))
41 (cond ((> height 0) height)
42 ((string-match "-\\([0-9]+\\)-" fontset)
44 (substring fontset (match-beginning 1)(match-end 1))
54 ;; (defalias 'charset-columns 'charset-width)
56 (defun find-non-ascii-charset-string (string)
57 "Return a list of charsets in the STRING except ascii."
58 (delq 'ascii (find-charset-string string))
61 (defun find-non-ascii-charset-region (start end)
62 "Return a list of charsets except ascii
63 in the region between START and END."
64 (delq '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.
76 (coding-system-for-read 'no-conversion)
77 (coding-system-for-write 'no-conversion)
81 (defmacro as-binary-input-file (&rest body)
82 `(let ((coding-system-for-read 'no-conversion))
85 (defmacro as-binary-output-file (&rest body)
86 `(let ((coding-system-for-write 'no-conversion))
89 (defalias 'set-process-input-coding-system 'set-process-coding-system)
95 (defun insert-binary-file-contents-literally
96 (filename &optional visit beg end replace)
97 "Like `insert-file-contents-literally', q.v., but don't code conversion.
98 A buffer may be modified in several ways after reading into the buffer due
99 to advanced Emacs features, such as file-name-handlers, format decoding,
100 find-file-hooks, etc.
101 This function ensures that none of these modifications will take place."
102 (let ((coding-system-for-read 'no-conversion))
103 (insert-file-contents-literally filename visit beg end replace)
110 (defvar charsets-mime-charset-alist
111 '(((ascii) . us-ascii)
112 ((ascii latin-iso8859-1) . iso-8859-1)
113 ((ascii latin-iso8859-2) . iso-8859-2)
114 ((ascii latin-iso8859-3) . iso-8859-3)
115 ((ascii latin-iso8859-4) . iso-8859-4)
116 ;;; ((ascii cyrillic-iso8859-5) . iso-8859-5)
117 ((ascii cyrillic-iso8859-5) . koi8-r)
118 ((ascii arabic-iso8859-6) . iso-8859-6)
119 ((ascii greek-iso8859-7) . iso-8859-7)
120 ((ascii hebrew-iso8859-8) . iso-8859-8)
121 ((ascii latin-iso8859-9) . iso-8859-9)
122 ((ascii latin-jisx0201
123 japanese-jisx0208-1978 japanese-jisx0208) . iso-2022-jp)
124 ((ascii korean-ksc5601) . euc-kr)
125 ((ascii chinese-gb2312) . cn-gb-2312)
126 ((ascii chinese-big5-1 chinese-big5-2) . cn-big5)
127 ((ascii latin-iso8859-1 greek-iso8859-7
128 latin-jisx0201 japanese-jisx0208-1978
129 chinese-gb2312 japanese-jisx0208
130 korean-ksc5601 japanese-jisx0212) . iso-2022-jp-2)
131 ((ascii latin-iso8859-1 greek-iso8859-7
132 latin-jisx0201 japanese-jisx0208-1978
133 chinese-gb2312 japanese-jisx0208
134 korean-ksc5601 japanese-jisx0212
135 chinese-cns11643-1 chinese-cns11643-2) . iso-2022-int-1)
136 ((ascii latin-iso8859-1 latin-iso8859-2
137 cyrillic-iso8859-5 greek-iso8859-7
138 latin-jisx0201 japanese-jisx0208-1978
139 chinese-gb2312 japanese-jisx0208
140 korean-ksc5601 japanese-jisx0212
141 chinese-cns11643-1 chinese-cns11643-2
142 chinese-cns11643-3 chinese-cns11643-4
143 chinese-cns11643-5 chinese-cns11643-6
144 chinese-cns11643-7) . iso-2022-int-1)
147 (defvar default-mime-charset 'x-ctext)
149 (defvar mime-charset-coding-system-alist
151 (gb2312 . cn-gb-2312)
152 (iso-2022-jp-2 . iso-2022-7bit-ss2)
155 (defun mime-charset-to-coding-system (charset &optional lbt)
156 "Return coding-system corresponding with charset.
157 If optional argument LBT (`unix', `dos' or `mac') is specified, it is
158 used as line break code type of coding-system."
159 (if (stringp charset)
160 (setq charset (intern (downcase charset)))
163 (or (cdr (assq charset mime-charset-coding-system-alist))
164 (and (coding-system-p charset) charset)
167 (intern (concat (symbol-name cs) "-" (symbol-name lbt)))
170 (defun detect-mime-charset-region (start end)
171 "Return MIME charset for region between START and END."
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."
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."
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."
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."
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 (defun char-category (character)
218 "Return string of category mnemonics for CHAR in TABLE.
219 CHAR can be any multilingual character
220 TABLE defaults to the current buffer's category table."
221 (category-set-mnemonics (char-category-set character))
228 (defalias 'string-columns 'string-width)
230 (defalias 'sset 'store-substring)
232 (defun string-to-char-list (string)
233 "Return a list of which elements are characters in the STRING."
234 (let* ((len (length string))
238 (setq chr (sref string i))
239 (setq l (cons chr l))
240 (setq i (+ i (char-bytes chr)))
245 (defalias 'string-to-int-list 'string-to-char-list)
253 ;;; emu-e20.el ends here