tm 7.61.
[elisp/apel.git] / emu-x20.el
1 ;;;
2 ;;; emu-x20.el --- Mule 2 emulation module for XEmacs 20 with Mule
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1994 .. 1996 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Version:
9 ;;;     $Id: emu-x20.el,v 7.2 1996/05/15 14:02:54 morioka Exp morioka $
10 ;;; Keywords: emulation, compatibility, Mule, XEmacs
11 ;;;
12 ;;; This file is part of tl (Tiny Library).
13 ;;;
14 ;;; This program is free software; you can redistribute it and/or
15 ;;; modify it under the terms of the GNU General Public License as
16 ;;; published by the Free Software Foundation; either version 2, or
17 ;;; (at your option) any later version.
18 ;;;
19 ;;; This program is distributed in the hope that it will be useful,
20 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22 ;;; General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with This program.  If not, write to the Free Software
26 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 ;;;
28 ;;; Code:
29
30 (require 'emu-xemacs)
31
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
39 ;;; @ character set
40 ;;;
41
42 (defalias 'char-leading-char 'char-charset)
43
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))
48   )
49
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))
55   )
56
57 (defconst lc-ascii  'ascii)
58 (defconst lc-ltn1   'latin-1)
59 (defconst lc-ltn2   'latin-2)
60 (defconst lc-ltn3   'latin-3)
61 (defconst lc-ltn4   'latin-4)
62 (defconst lc-crl    'cyrillic)
63 (defconst lc-arb    'arabic)
64 (defconst lc-grk    'greek)
65 (defconst lc-hbw    'hebrew)
66 (defconst lc-ltn5   'latin-5)
67 (defconst lc-jp     'japanese)
68 (defconst lc-jp2    'japanese-2)
69 (defconst lc-kr     'korean)
70 (defconst lc-big5-1 'chinese-big5-1)
71 (defconst lc-big5-2 'chinese-big5-2)
72 (defconst lc-cn     'chinese-gb)
73 (defconst lc-cns1   'chinese-cns-1)
74 (defconst lc-cns2   'chinese-cns-2)
75 (defconst lc-cns3   'chinese-cns-3)
76 (defconst lc-cns4   'chinese-cns-4)
77 (defconst lc-cns5   'chinese-cns-5)
78 (defconst lc-cns6   'chinese-cns-6)
79 (defconst lc-cns7   'chinese-cns-7)
80
81
82 ;;; @ coding-system
83 ;;;
84
85 (defconst *noconv* 'noconv)
86 (defconst *ctext*  'ctext)
87 (defconst *hz*     'hz)
88 (defconst *big5*   'big5)
89 (defconst *euc-kr* 'euc-kr)
90 (defconst *koi8*   nil)
91
92 (defvar code-converter-is-broken
93   (and xemacs-beta-version (<= xemacs-beta-version 19)))
94
95 (if code-converter-is-broken
96 (progn
97 ;;;
98 (defun decode-coding-region (start end coding-system &optional buffer)
99   "Decode the text between START and END which is encoded in CODING-SYSTEM.
100 \[emu-x20.el; XEmacs 20 emulating function]"
101   (save-excursion
102     (if buffer
103         (set-buffer buffer)
104       )
105     (save-restriction
106       (narrow-to-region start end)
107       (let ((process-output-coding-system 'noconv)
108             (process-input-coding-system coding-system))
109         (call-process-region start end "cat" t t nil)
110         ))))
111
112 (defun encode-coding-region (start end coding-system &optional buffer)
113   "Encode the text between START and END which is encoded in CODING-SYSTEM.
114 \[emu-x20.el; XEmacs 20 emulating function]"
115   (save-excursion
116     (if buffer
117         (set-buffer buffer)
118       )
119     (save-restriction
120       (narrow-to-region start end)
121       (let ((process-output-coding-system coding-system)
122             (process-input-coding-system 'noconv))
123         (call-process-region start end "cat" t t nil)
124         ))))
125 ;;;
126 ))
127
128 (defalias 'character-encode-string 'encode-coding-string)
129 (defalias 'character-decode-string 'decode-coding-string)
130 (defalias 'character-encode-region 'encode-coding-region)
131 (defalias 'character-decode-region 'decode-coding-region)
132
133
134 ;;; @ character and string
135 ;;;
136
137 (defun char-bytes (chr) 1)
138 (defun char-width (chr) 1)
139
140 (defalias 'string-width 'length)
141
142 (defun string-to-int-list (str)
143   (mapcar #'char-int str)
144   )
145
146 (defalias 'sref 'aref)
147
148 (defun truncate-string (str width &optional start-column)
149   "Truncate STR to fit in WIDTH columns.
150 Optional non-nil arg START-COLUMN specifies the starting column.
151 \[emu-x20.el; Mule 2.3 emulating function]"
152   (or start-column
153       (setq start-column 0))
154   (substring str start-column width)
155   )
156
157
158 ;;; @ end
159 ;;;
160
161 (provide 'emu-x20)
162
163 ;;; emu-x20.el ends here