4
|
1 ;;; emu-e19.el --- emu module for Emacs 19 and XEmacs 19
|
|
2
|
16
|
3 ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
|
4
|
4
|
|
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
|
22
|
6 ;; Version: $Id: emu-e19.el,v 1.4 1997/02/16 01:29:29 steve Exp $
|
4
|
7 ;; Keywords: emulation, compatibility, mule, Latin-1
|
|
8
|
10
|
9 ;; This file is part of emu.
|
4
|
10
|
|
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.
|
|
15
|
|
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.
|
|
20
|
|
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.
|
|
25
|
|
26 ;;; Code:
|
|
27
|
|
28 ;;; @ version and variant specific features
|
|
29 ;;;
|
|
30
|
|
31 (cond (running-xemacs
|
|
32 (require 'emu-xemacs))
|
|
33 (running-emacs-19
|
|
34 (require 'emu-19)
|
|
35 ))
|
|
36
|
|
37
|
|
38 ;;; @ character set
|
|
39 ;;;
|
|
40
|
|
41 (defconst charset-ascii 0 "Character set of ASCII")
|
10
|
42 (defconst charset-latin-iso8859-1 129 "Character set of ISO-8859-1")
|
4
|
43
|
|
44 (defun charset-description (charset)
|
|
45 "Return description of CHARSET. [emu-e19.el]"
|
|
46 (if (< charset 128)
|
|
47 (documentation-property 'charset-ascii 'variable-documentation)
|
10
|
48 (documentation-property 'charset-latin-iso8859-1 'variable-documentation)
|
4
|
49 ))
|
|
50
|
|
51 (defun charset-registry (charset)
|
|
52 "Return registry name of CHARSET. [emu-e19.el]"
|
|
53 (if (< charset 128)
|
|
54 "ASCII"
|
|
55 "ISO8859-1"))
|
|
56
|
|
57 (defun charset-columns (charset)
|
|
58 "Return number of columns a CHARSET occupies when displayed.
|
|
59 \[emu-e19.el]"
|
|
60 1)
|
|
61
|
|
62 (defun charset-direction (charset)
|
|
63 "Return the direction of a character of CHARSET by
|
|
64 0 (left-to-right) or 1 (right-to-left). [emu-e19.el]"
|
|
65 0)
|
|
66
|
|
67 (defun find-charset-string (str)
|
|
68 "Return a list of charsets in the string.
|
|
69 \[emu-e19.el; Mule emulating function]"
|
|
70 (if (string-match "[\200-\377]" str)
|
10
|
71 (list charset-latin-iso8859-1)
|
4
|
72 ))
|
|
73
|
|
74 (defalias 'find-non-ascii-charset-string 'find-charset-string)
|
|
75
|
|
76 (defun find-charset-region (start end)
|
|
77 "Return a list of charsets in the region between START and END.
|
|
78 \[emu-e19.el; Mule emulating function]"
|
|
79 (if (save-excursion
|
|
80 (save-restriction
|
|
81 (narrow-to-region start end)
|
|
82 (goto-char start)
|
|
83 (re-search-forward "[\200-\377]" nil t)
|
|
84 ))
|
10
|
85 (list charset-latin-iso8859-1)
|
4
|
86 ))
|
|
87
|
|
88 (defalias 'find-non-ascii-charset-region 'find-charset-region)
|
|
89
|
|
90
|
|
91 ;;; @ coding-system
|
|
92 ;;;
|
|
93
|
|
94 (defconst *internal* nil)
|
|
95 (defconst *ctext* nil)
|
|
96 (defconst *noconv* nil)
|
|
97
|
|
98 (defun decode-coding-string (string coding-system)
|
|
99 "Decode the STRING which is encoded in CODING-SYSTEM.
|
|
100 \[emu-e19.el; Emacs 20 emulating function]"
|
|
101 string)
|
|
102
|
|
103 (defun encode-coding-string (string coding-system)
|
|
104 "Encode the STRING as CODING-SYSTEM.
|
|
105 \[emu-e19.el; Emacs 20 emulating function]"
|
|
106 string)
|
|
107
|
|
108 (defun decode-coding-region (start end coding-system)
|
|
109 "Decode the text between START and END which is encoded in CODING-SYSTEM.
|
|
110 \[emu-e19.el; Emacs 20 emulating function]"
|
|
111 0)
|
|
112
|
|
113 (defun encode-coding-region (start end coding-system)
|
|
114 "Encode the text between START and END to CODING-SYSTEM.
|
|
115 \[emu-e19.el; Emacs 20 emulating function]"
|
|
116 0)
|
|
117
|
|
118 (defun detect-coding-region (start end)
|
|
119 "Detect coding-system of the text in the region between START and END.
|
|
120 \[emu-e19.el; Emacs 20 emulating function]"
|
|
121 )
|
|
122
|
|
123 (defun set-buffer-file-coding-system (coding-system &optional force)
|
|
124 "Set buffer-file-coding-system of the current buffer to CODING-SYSTEM.
|
|
125 \[emu-e19.el; Emacs 20 emulating function]"
|
|
126 )
|
|
127
|
|
128 (defmacro as-binary-process (&rest body)
|
|
129 (` (let (selective-display) ; Disable ^M to nl translation.
|
|
130 (,@ body)
|
|
131 )))
|
|
132
|
|
133 (defmacro as-binary-input-file (&rest body)
|
|
134 (` (let ((emx-binary-mode t)) ; Stop CRLF to LF conversion in OS/2
|
|
135 (,@ body)
|
|
136 )))
|
|
137
|
16
|
138 (defmacro as-binary-output-file (&rest body)
|
|
139 (` (let ((emx-binary-mode t)) ; Stop CRLF to LF conversion in OS/2
|
|
140 (,@ body)
|
|
141 )))
|
|
142
|
4
|
143
|
|
144 ;;; @@ for old MULE emulation
|
|
145 ;;;
|
|
146
|
|
147 (defun code-convert-string (str ic oc)
|
|
148 "Convert code in STRING from SOURCE code to TARGET code,
|
|
149 On successful converion, returns the result string,
|
|
150 else returns nil. [emu-e19.el; old MULE emulating function]"
|
|
151 str)
|
|
152
|
|
153 (defun code-convert-region (beg end ic oc)
|
|
154 "Convert code of the text between BEGIN and END from SOURCE
|
|
155 to TARGET. On successful conversion returns t,
|
|
156 else returns nil. [emu-e19.el; old MULE emulating function]"
|
|
157 t)
|
|
158
|
|
159
|
22
|
160 ;;; @ binary access
|
|
161 ;;;
|
|
162
|
|
163 (defun insert-binary-file-contents-literally
|
|
164 (filename &optional visit beg end replace)
|
|
165 "Like `insert-file-contents-literally', q.v., but don't code conversion.
|
|
166 A buffer may be modified in several ways after reading into the buffer due
|
|
167 to advanced Emacs features, such as file-name-handlers, format decoding,
|
|
168 find-file-hooks, etc.
|
|
169 This function ensures that none of these modifications will take place."
|
|
170 (let ((emx-binary-mode t))
|
|
171 (insert-file-contents-literally filename visit beg end replace)
|
|
172 ))
|
|
173
|
|
174
|
4
|
175 ;;; @ MIME charset
|
|
176 ;;;
|
|
177
|
|
178 (defvar charsets-mime-charset-alist
|
|
179 (list (cons (list charset-ascii) 'us-ascii)))
|
|
180
|
|
181 (defvar default-mime-charset 'iso-8859-1)
|
|
182
|
|
183 (defun mime-charset-to-coding-system (charset)
|
|
184 (if (stringp charset)
|
|
185 (setq charset (intern (downcase charset)))
|
|
186 )
|
|
187 (and (memq charset (list 'us-ascii default-mime-charset))
|
|
188 charset)
|
|
189 )
|
|
190
|
|
191 (defun detect-mime-charset-region (start end)
|
|
192 "Return MIME charset for region between START and END.
|
|
193 \[emu-e19.el]"
|
|
194 (if (save-excursion
|
|
195 (save-restriction
|
|
196 (narrow-to-region start end)
|
|
197 (goto-char start)
|
|
198 (re-search-forward "[\200-\377]" nil t)
|
|
199 ))
|
|
200 default-mime-charset
|
|
201 'us-ascii))
|
|
202
|
|
203 (defun encode-mime-charset-region (start end charset)
|
|
204 "Encode the text between START and END as MIME CHARSET.
|
|
205 \[emu-e19.el]"
|
|
206 )
|
|
207
|
|
208 (defun decode-mime-charset-region (start end charset)
|
|
209 "Decode the text between START and END as MIME CHARSET.
|
|
210 \[emu-e19.el]"
|
|
211 )
|
|
212
|
|
213 (defun encode-mime-charset-string (string charset)
|
|
214 "Encode the STRING as MIME CHARSET. [emu-e19.el]"
|
|
215 string)
|
|
216
|
|
217 (defun decode-mime-charset-string (string charset)
|
|
218 "Decode the STRING as MIME CHARSET. [emu-e19.el]"
|
|
219 string)
|
|
220
|
|
221
|
|
222 ;;; @ character
|
|
223 ;;;
|
|
224
|
|
225 (defun char-charset (chr)
|
|
226 "Return the character set of char CHR.
|
|
227 \[emu-e19.el; XEmacs 20 emulating function]"
|
|
228 (if (< chr 128)
|
|
229 charset-ascii
|
10
|
230 charset-latin-iso8859-1))
|
4
|
231
|
|
232 (defun char-bytes (char)
|
|
233 "Return number of bytes a character in CHAR occupies in a buffer.
|
|
234 \[emu-e19.el; MULE emulating function]"
|
|
235 1)
|
|
236
|
|
237 (defalias 'char-length 'char-bytes)
|
|
238
|
|
239 (defun char-columns (character)
|
|
240 "Return number of columns a CHARACTER occupies when displayed.
|
|
241 \[emu-e19.el]"
|
|
242 1)
|
|
243
|
|
244 ;;; @@ for old MULE emulation
|
|
245 ;;;
|
|
246
|
|
247 (defalias 'char-width 'char-columns)
|
|
248
|
|
249 (defalias 'char-leading-char 'char-charset)
|
|
250
|
|
251
|
|
252 ;;; @ string
|
|
253 ;;;
|
|
254
|
|
255 (defalias 'string-columns 'length)
|
|
256
|
|
257 (defun string-to-char-list (str)
|
|
258 (mapcar (function identity) str)
|
|
259 )
|
|
260
|
|
261 (defalias 'string-to-int-list 'string-to-char-list)
|
|
262
|
|
263 (defalias 'sref 'aref)
|
|
264
|
|
265 (defun truncate-string (str width &optional start-column)
|
|
266 "Truncate STR to fit in WIDTH columns.
|
|
267 Optional non-nil arg START-COLUMN specifies the starting column.
|
|
268 \[emu-e19.el; MULE 2.3 emulating function]"
|
|
269 (or start-column
|
|
270 (setq start-column 0))
|
|
271 (substring str start-column width)
|
|
272 )
|
|
273
|
|
274 ;;; @@ for old MULE emulation
|
|
275 ;;;
|
|
276
|
|
277 (defalias 'string-width 'length)
|
|
278
|
|
279
|
|
280 ;;; @ end
|
|
281 ;;;
|
|
282
|
|
283 (provide 'emu-e19)
|
|
284
|
|
285 ;;; emu-e19.el ends here
|