Mercurial > emacs
annotate lisp/international/mule.el @ 18603:525fb9a7cc96
(overlay_strings): Finish up previous change.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 04 Jul 1997 18:36:58 +0000 |
parents | 66e7a91e32ef |
children | d4c708a5f181 |
rev | line source |
---|---|
17052 | 1 ;;; mule.el --- basic commands for mulitilingual environment |
2 | |
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
18457
615e9654bf59
Finish previous change.
Richard M. Stallman <rms@gnu.org>
parents:
18377
diff
changeset
|
4 ;; Licensed to the Free Software Foundation. |
17052 | 5 |
6 ;; Keywords: mule, multilingual, character set, coding system | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
17071 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
17052 | 24 |
25 ;;; Code: | |
26 | |
27 (defconst mule-version "3.0 (MOMIJINOGA)" "\ | |
28 Version number and name of this version of MULE (multilingual environment).") | |
29 | |
30 (defconst mule-version-date "1998.1.1" "\ | |
31 Distribution date of this version of MULE (multilingual environment).") | |
32 | |
33 (defun load-with-code-conversion (fullname file &optional noerror nomessage) | |
34 "Execute a file of Lisp code named FILE whose absolute path is FULLNAME. | |
35 The FILE is decoded before evaluation if necessary. | |
36 If optional second arg NOERROR is non-nil, | |
37 report no error if FILE doesn't exist. | |
38 Print messages at start and end of loading unless | |
39 optional third arg NOMESSAGE is non-nil. | |
40 Return t if file exists." | |
41 (if (null (file-readable-p fullname)) | |
42 (and (null noerror) | |
43 (signal 'file-error (list "Cannot open load file" file))) | |
44 ;; Read file with code conversion, and then eval. | |
45 (let* ((buffer | |
46 ;; To avoid any autoloading, set default-major-mode to | |
47 ;; fundamental-mode. | |
48 (let ((default-major-mode 'fundamental-mode)) | |
49 ;; We can't use `generate-new-buffer' because files.el | |
50 ;; is not yet loaded. | |
51 (get-buffer-create (generate-new-buffer-name " *load*")))) | |
52 (load-in-progress t)) | |
53 (or nomessage (message "Loading %s..." file)) | |
54 (unwind-protect | |
55 (progn | |
56 (save-excursion | |
57 (set-buffer buffer) | |
58 (insert-file-contents fullname) | |
59 ;; We must set `buffer-file-name' for `eval-buffer' and | |
60 ;; `load-history'. | |
61 (setq buffer-file-name file) | |
62 ;; Make `kill-buffer' quiet. | |
63 (set-buffer-modified-p nil)) | |
64 ;; Eval in the original buffer. | |
65 (eval-buffer buffer)) | |
18583
66e7a91e32ef
(load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents:
18558
diff
changeset
|
66 (let (kill-buffer-hook kill-buffer-query-functions) |
66e7a91e32ef
(load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents:
18558
diff
changeset
|
67 (kill-buffer buffer))) |
17052 | 68 (let ((hook (assoc file after-load-alist))) |
69 (if hook | |
70 (mapcar (function eval) (cdr hook)))) | |
71 (or nomessage noninteractive | |
72 (message "Loading %s...done" file)) | |
73 t))) | |
74 | |
75 ;; API (Application Program Interface) for charsets. | |
76 | |
77 ;; Return t if OBJ is a quoted symbol. | |
78 (defsubst quoted-symbol-p (obj) | |
79 (and (listp obj) (eq (car obj) 'quote))) | |
80 | |
81 (defsubst charsetp (object) | |
82 "T is OBJECT is a charset." | |
83 (and (symbolp object) (vectorp (get object 'charset)))) | |
84 | |
85 (defsubst charset-info (charset) | |
86 "Return a vector of information of CHARSET. | |
87 The elements of the vector are: | |
88 CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION, | |
89 LEADING-CODE-BASE, LEADING-CODE-EXT, | |
90 ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE, | |
91 REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION, | |
92 PLIST, | |
93 where | |
94 CHARSET-ID (integer) is the identification number of the charset. | |
95 DIMENSION (integer) is the number of bytes to represent a character of | |
96 the charset: 1 or 2. | |
97 CHARS (integer) is the number of characters in a dimension: 94 or 96. | |
98 BYTE (integer) is the length of multi-byte form of a character in | |
99 the charset: one of 1, 2, 3, and 4. | |
100 WIDTH (integer) is the number of columns a character in the charset | |
101 occupies on the screen: one of 0, 1, and 2. | |
102 DIRECTION (integer) is the rendering direction of characters in the | |
103 charset when rendering. If 0, render from right to left, else | |
104 render from left to right. | |
105 LEADING-CODE-BASE (integer) is the base leading-code for the | |
106 charset. | |
107 LEADING-CODE-EXT (integer) is the extended leading-code for the | |
108 charset. All charsets of less than 0xA0 has the value 0. | |
109 ISO-FINAL-CHAR (character) is the final character of the | |
110 corresponding ISO 2022 charset. | |
111 ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked | |
112 while encoding to variants of ISO 2022 coding system, one of the | |
113 following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR). | |
114 REVERSE-CHARSET (integer) is the charset which differs only in | |
115 LEFT-TO-RIGHT value from the charset. If there's no such a | |
116 charset, the value is -1. | |
117 SHORT-NAME (string) is the short name to refer to the charset. | |
118 LONG-NAME (string) is the long name to refer to the charset | |
119 DESCRIPTION (string) is the description string of the charset. | |
120 PLIST (property list) may contain any type of information a user | |
121 want to put and get by functions `put-charset-property' and | |
122 `get-charset-property' respectively." | |
123 (get charset 'charset)) | |
124 | |
125 (defmacro charset-id (charset) | |
126 "Return charset identification number of CHARSET." | |
127 (if (and (listp charset) (eq (car charset) 'quote)) | |
128 (aref (charset-info (nth 1 charset)) 0) | |
129 `(aref (charset-info ,charset) 0))) | |
130 | |
131 (defmacro charset-bytes (charset) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
132 "Return bytes of CHARSET. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
133 See the function `charset-info' for more detail." |
17052 | 134 (if (quoted-symbol-p charset) |
135 (aref (charset-info (nth 1 charset)) 1) | |
136 `(aref (charset-info ,charset) 1))) | |
137 | |
138 (defmacro charset-dimension (charset) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
139 "Return dimension of CHARSET. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
140 See the function `charset-info' for more detail." |
17052 | 141 (if (quoted-symbol-p charset) |
142 (aref (charset-info (nth 1 charset)) 2) | |
143 `(aref (charset-info ,charset) 2))) | |
144 | |
145 (defmacro charset-chars (charset) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
146 "Return character numbers contained in a dimension of CHARSET. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
147 See the function `charset-info' for more detail." |
17052 | 148 (if (quoted-symbol-p charset) |
149 (aref (charset-info (nth 1 charset)) 3) | |
150 `(aref (charset-info ,charset) 3))) | |
151 | |
152 (defmacro charset-width (charset) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
153 "Return width (how many column occupied on a screen) of CHARSET. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
154 See the function `charset-info' for more detail." |
17052 | 155 (if (quoted-symbol-p charset) |
156 (aref (charset-info (nth 1 charset)) 4) | |
157 `(aref (charset-info ,charset) 4))) | |
158 | |
159 (defmacro charset-direction (charset) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
160 "Return direction of CHARSET. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
161 See the function `charset-info' for more detail." |
17052 | 162 (if (quoted-symbol-p charset) |
163 (aref (charset-info (nth 1 charset)) 5) | |
164 `(aref (charset-info ,charset) 5))) | |
165 | |
166 (defmacro charset-iso-final-char (charset) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
167 "Return final char of CHARSET. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
168 See the function `charset-info' for more detail." |
17052 | 169 (if (quoted-symbol-p charset) |
170 (aref (charset-info (nth 1 charset)) 8) | |
171 `(aref (charset-info ,charset) 8))) | |
172 | |
173 (defmacro charset-iso-graphic-plane (charset) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
174 "Return graphic plane of CHARSET. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
175 See the function `charset-info' for more detail." |
17052 | 176 (if (quoted-symbol-p charset) |
177 (aref (charset-info (nth 1 charset)) 9) | |
178 `(aref (charset-info ,charset) 9))) | |
179 | |
180 (defmacro charset-reverse-charset (charset) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
181 "Return reverse charset of CHARSET. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
182 See the function `charset-info' for more detail." |
17052 | 183 (if (quoted-symbol-p charset) |
184 (aref (charset-info (nth 1 charset)) 10) | |
185 `(aref (charset-info ,charset) 10))) | |
186 | |
187 (defmacro charset-short-name (charset) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
188 "Return short name of CHARSET. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
189 See the function `charset-info' for more detail." |
17052 | 190 (if (quoted-symbol-p charset) |
191 (aref (charset-info (nth 1 charset)) 11) | |
192 `(aref (charset-info ,charset) 11))) | |
193 | |
194 (defmacro charset-long-name (charset) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
195 "Return long name of CHARSET. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
196 See the function `charset-info' for more detail." |
17052 | 197 (if (quoted-symbol-p charset) |
198 (aref (charset-info (nth 1 charset)) 12) | |
199 `(aref (charset-info ,charset) 12))) | |
200 | |
201 (defmacro charset-description (charset) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
202 "Return descriptoin of CHARSET. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
203 See the function `charset-info' for more detail." |
17052 | 204 (if (quoted-symbol-p charset) |
205 (aref (charset-info (nth 1 charset)) 13) | |
206 `(aref (charset-info ,charset) 13))) | |
207 | |
208 (defmacro charset-plist (charset) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
209 "Return list charset property of CHARSET. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
210 See the function `charset-info' for more detail." |
17052 | 211 (if (quoted-symbol-p charset) |
17175 | 212 `(aref ,(charset-info (nth 1 charset)) 14) |
17052 | 213 `(aref (charset-info ,charset) 14))) |
214 | |
215 (defun set-charset-plist (charset plist) | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
216 "Set CHARSET's property list to PLIST, and retrun PLIST." |
17052 | 217 (aset (charset-info charset) 14 plist)) |
218 | |
219 (defmacro make-char (charset &optional c1 c2) | |
17175 | 220 "Return a character of CHARSET and position-codes CODE1 and CODE2. |
221 CODE1 and CODE2 are optional, but if you don't supply | |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
222 sufficient position-codes, return a generic character which stands for |
17175 | 223 all characters or group of characters in the character sets. |
17761
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
224 A generic character can be used to index a char table (e.g. syntax-table)." |
17052 | 225 (if (quoted-symbol-p charset) |
226 `(make-char-internal ,(charset-id (nth 1 charset)) ,c1 ,c2) | |
227 `(make-char-internal (charset-id ,charset) ,c1 ,c2))) | |
228 | |
17094
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
229 (defmacro charset-list () |
18558
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
230 "Return list of charsets ever defined. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
231 |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
232 This macro is provided for backward compatibility. |
09cc19f19722
(charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents:
18518
diff
changeset
|
233 Now we have the variable `charset-list'." |
17837
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
234 'charset-list) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
235 |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
236 (defsubst generic-char-p (char) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
237 "Return t if and only if CHAR is a generic character. |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
238 See also the documentation of make-char." |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
239 (let ((l (split-char char))) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
240 (and (or (= (nth 1 l) 0) (eq (nth 2 l) 0)) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
241 (not (eq (car l) 'composition))))) |
17094
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
242 |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
243 ;; Coding system staffs |
17052 | 244 |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
245 ;; Coding system is a symbol that has the property `coding-system'. |
17052 | 246 ;; |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
247 ;; The value of the property `coding-system' is a vector of the |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
248 ;; following format: |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
249 ;; [TYPE MNEMONIC DOC-STRING NOT-USED-NOW FLAGS] |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
250 ;; We call this vector as coding-spec. See comments in src/coding.c |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
251 ;; for more detail. The property value may be another coding system, |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
252 ;; in which case, the coding-spec should be taken from that |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
253 ;; coding-system. The 4th element NOT-USED-NOW is kept just for |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
254 ;; backward compatibility with old version of Mule. |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
255 |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
256 (defconst coding-spec-type-idx 0) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
257 (defconst coding-spec-mnemonic-idx 1) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
258 (defconst coding-spec-doc-string-idx 2) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
259 (defconst coding-spec-flags-idx 4) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
260 |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
261 ;; Coding system may have proerpty `eol-type'. The value of the |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
262 ;; property `eol-type' is integer 0..2 or a vector of three coding |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
263 ;; systems. The integer value 0, 1, and 2 indicate the format of |
17052 | 264 ;; end-of-line LF, CRLF, and CR respectively. The vector value |
265 ;; indicates that the format of end-of-line should be detected | |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
266 ;; automatically. Nth element of the vector is the subsidiary coding |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
267 ;; system whose `eol-type' property is N. |
17052 | 268 ;; |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
269 ;; Coding system may also have properties `post-read-conversion' and |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
270 ;; `pre-write-conversion. Values of these properties are functions. |
17052 | 271 ;; |
272 ;; The function in `post-read-conversion' is called after some text is | |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
273 ;; inserted and decoded along the coding system and before any |
17052 | 274 ;; functions in `after-insert-functions' are called. The arguments to |
275 ;; this function is the same as those of a function in | |
276 ;; `after-insert-functions', i.e. LENGTH of a text while putting point | |
277 ;; at the head of the text to be decoded | |
278 ;; | |
279 ;; The function in `pre-write-conversion' is called after all | |
280 ;; functions in `write-region-annotate-functions' and | |
281 ;; `buffer-file-format' are called, and before the text is encoded by | |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
282 ;; the coding system. The arguments to this function is the same as |
17052 | 283 ;; those of a function in `write-region-annotate-functions', i.e. FROM |
284 ;; and TO specifying region of a text. | |
285 | |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
286 ;; Return Nth element of coding-spec of CODING-SYSTEM. |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
287 (defun coding-system-spec-ref (coding-system n) |
17094
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
288 (check-coding-system coding-system) |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
289 (let ((vec (coding-system-spec coding-system))) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
290 (and vec (aref vec n)))) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
291 |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
292 (defun coding-system-type (coding-system) |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
293 "Return TYPE element in coding-spec of CODING-SYSTEM." |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
294 (coding-system-spec-ref coding-system coding-spec-type-idx)) |
17052 | 295 |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
296 (defun coding-system-mnemonic (coding-system) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
297 "Return MNEMONIC element in coding-spec of CODING-SYSTEM." |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
298 (or (coding-system-spec-ref coding-system coding-spec-mnemonic-idx) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
299 ?-)) |
17052 | 300 |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
301 (defun coding-system-doc-string (coding-system) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
302 "Return DOC-STRING element in coding-spec of CODING-SYSTEM." |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
303 (coding-system-spec-ref coding-system coding-spec-doc-string-idx)) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
304 |
17052 | 305 (defun coding-system-flags (coding-system) |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
306 "Return FLAGS element in coding-spec of CODING-SYSTEM." |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
307 (coding-system-spec-ref coding-system coding-spec-flags-idx)) |
17052 | 308 |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
309 (defun coding-system-eol-type (coding-system) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
310 "Return eol-type property of CODING-SYSTEM." |
17094
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
311 (check-coding-system coding-system) |
17052 | 312 (and coding-system |
313 (or (get coding-system 'eol-type) | |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
314 (coding-system-eol-type (get coding-system 'coding-system))))) |
17052 | 315 |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
316 (defun coding-system-category (coding-system) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
317 "Return coding category of CODING-SYSTEM." |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
318 (and coding-system |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
319 (symbolp coding-system) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
320 (or (get coding-system 'coding-category) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
321 (coding-system-category (get coding-system 'coding-system))))) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
322 |
18312
705da3ce58c0
(coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents:
18298
diff
changeset
|
323 (defun coding-system-parent (coding-system) |
705da3ce58c0
(coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents:
18298
diff
changeset
|
324 "Return parent of CODING-SYSTEM." |
705da3ce58c0
(coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents:
18298
diff
changeset
|
325 (let ((parent (get coding-system 'parent-coding-system))) |
705da3ce58c0
(coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents:
18298
diff
changeset
|
326 (and parent |
705da3ce58c0
(coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents:
18298
diff
changeset
|
327 (or (coding-system-parent parent) |
705da3ce58c0
(coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents:
18298
diff
changeset
|
328 parent)))) |
705da3ce58c0
(coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents:
18298
diff
changeset
|
329 |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
330 ;; Make subsidiary coding systems (eol-type variants) of CODING-SYSTEM. |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
331 (defun make-subsidiary-coding-system (coding-system) |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
332 (let ((subsidiaries (vector (intern (format "%s-unix" coding-system)) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
333 (intern (format "%s-dos" coding-system)) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
334 (intern (format "%s-mac" coding-system)))) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
335 (i 0)) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
336 (while (< i 3) |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
337 (put (aref subsidiaries i) 'coding-system coding-system) |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
338 (put (aref subsidiaries i) 'eol-type i) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
339 (put (aref subsidiaries i) 'eol-variant t) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
340 (setq i (1+ i))) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
341 subsidiaries)) |
17052 | 342 |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
343 (defun make-coding-system (coding-system type mnemonic doc-string |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
344 &optional flags) |
17052 | 345 "Define a new CODING-SYSTEM (symbol). |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
346 Remaining arguments are TYPE, MNEMONIC, DOC-STRING, and FLAGS (optional) which |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
347 construct a coding-spec of CODING-SYSTEM in the following format: |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
348 [TYPE MNEMONIC DOC-STRING nil FLAGS] |
17052 | 349 TYPE is an integer value indicating the type of coding-system as follows: |
350 0: Emacs internal format, | |
351 1: Shift-JIS (or MS-Kanji) used mainly on Japanese PC, | |
352 2: ISO-2022 including many variants, | |
353 3: Big5 used mainly on Chinese PC, | |
354 4: private, CCL programs provide encoding/decoding algorithm. | |
355 MNEMONIC is a character to be displayed on mode line for the coding-system. | |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
356 DOC-STRING is a documentation string for the coding-system. |
17052 | 357 FLAGS specifies more precise information of each TYPE. |
358 If TYPE is 2 (ISO-2022), FLAGS should be a list of: | |
359 CHARSET0, CHARSET1, CHARSET2, CHARSET3, SHORT-FORM, | |
360 ASCII-EOL, ASCII-CNTL, SEVEN, LOCKING-SHIFT, SINGLE-SHIFT, | |
17761
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
361 USE-ROMAN, USE-OLDJIS, NO-ISO6429, INIT-BOL, DESIGNATION-BOL. |
17052 | 362 CHARSETn are character sets initially designated to Gn graphic registers. |
363 If CHARSETn is nil, Gn is never used. | |
364 If CHARSETn is t, Gn can be used but nothing designated initially. | |
365 If CHARSETn is a list of character sets, those character sets are | |
366 designated to Gn on output, but nothing designated to Gn initially. | |
367 SHORT-FORM non-nil means use short designation sequence on output. | |
368 ASCII-EOL non-nil means designate ASCII to g0 at end of line on output. | |
369 ASCII-CNTL non-nil means designate ASCII to g0 before control codes and | |
370 SPACE on output. | |
371 SEVEN non-nil means use 7-bit code only on output. | |
372 LOCKING-SHIFT non-nil means use locking-shift. | |
373 SINGLE-SHIFT non-nil means use single-shift. | |
374 USE-ROMAN non-nil means designate JIS0201-1976-Roman instead of ASCII. | |
375 USE-OLDJIS non-nil means designate JIS0208-1976 instead of JIS0208-1983. | |
376 NO-ISO6429 non-nil means not use ISO6429's direction specification. | |
17094
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
377 INIT-BOL non-nil means any designation state is assumed to be reset |
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
378 to initial at each beginning of line on output. |
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
379 DESIGNATION-BOL non-nil means designation sequences should be placed |
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
380 at beginning of line on output. |
17052 | 381 If TYPE is 4 (private), FLAGS should be a cons of CCL programs, |
382 for encoding and decoding. See the documentation of CCL for more detail." | |
383 | |
384 ;; At first, set a value of `coding-system' property. | |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
385 (let ((coding-spec (make-vector 5 nil)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
386 coding-category) |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
387 (if (or (not (integerp type)) (< type 0) (> type 4)) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
388 (error "TYPE argument must be 0..4")) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
389 (if (or (not (integerp mnemonic)) (<= mnemonic ? ) (> mnemonic 127)) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
390 (error "MNEMONIC arguemnt must be a printable character.")) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
391 (aset coding-spec 0 type) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
392 (aset coding-spec 1 mnemonic) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
393 (aset coding-spec 2 (if (stringp doc-string) doc-string "")) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
394 (aset coding-spec 3 nil) ; obsolete element |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
395 (cond ((= type 0) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
396 (setq coding-category 'coding-category-emacs-mule)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
397 ((= type 1) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
398 (setq coding-category 'coding-category-sjis)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
399 ((= type 2) ; ISO2022 |
17052 | 400 (let ((i 0) |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
401 (vec (make-vector 32 nil)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
402 (no-initial-designation t) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
403 (g1-designation nil)) |
17052 | 404 (while (< i 4) |
405 (let ((charset (car flags))) | |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
406 (if (and no-initial-designation |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
407 (> i 0) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
408 (or (charsetp charset) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
409 (and (consp charset) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
410 (charsetp (car charset))))) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
411 (setq no-initial-designation nil)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
412 (if (charsetp charset) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
413 (if (= i 1) (setq g1-designation charset)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
414 (if (consp charset) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
415 (let ((tail charset) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
416 elt) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
417 (while tail |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
418 (setq elt (car tail)) |
17094
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
419 (or (not elt) (eq elt t) (charsetp elt) |
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
420 (error "Invalid charset: %s" elt)) |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
421 (setq tail (cdr tail))) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
422 (setq g1-designation (car charset))) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
423 (if (and charset (not (eq charset t))) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
424 (error "Invalid charset: %s" charset)))) |
17052 | 425 (aset vec i charset)) |
426 (setq flags (cdr flags) i (1+ i))) | |
427 (while (and (< i 32) flags) | |
428 (aset vec i (car flags)) | |
429 (setq flags (cdr flags) i (1+ i))) | |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
430 (aset coding-spec 4 vec) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
431 (if no-initial-designation |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
432 (put coding-system 'no-initial-designation t)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
433 (setq coding-category |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
434 (if (aref vec 8) ; Use locking-shift. |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
435 'coding-category-iso-else |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
436 (if (aref vec 7) ; 7-bit only. |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
437 (if (aref vec 9) ; Use single-shift. |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
438 'coding-category-iso-else |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
439 'coding-category-iso-7) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
440 (if no-initial-designation |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
441 'coding-category-iso-else |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
442 (if (and (charsetp g1-designation) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
443 (= (charset-dimension g1-designation) 2)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
444 'coding-category-iso-8-2 |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
445 'coding-category-iso-8-1))))))) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
446 ((= type 3) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
447 (setq coding-category 'coding-category-big5)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
448 ((= type 4) ; private |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
449 (setq coding-category 'coding-category-binary) |
17052 | 450 (if (and (consp flags) |
451 (vectorp (car flags)) | |
452 (vectorp (cdr flags))) | |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
453 (aset coding-spec 4 flags) |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
454 (error "Invalid FLAGS argument for TYPE 4 (CCL)")))) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
455 (put coding-system 'coding-system coding-spec) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
456 (put coding-system 'coding-category coding-category) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
457 (put coding-category 'coding-systems |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
458 (cons coding-system (get coding-category 'coding-systems)))) |
17052 | 459 |
460 ;; Next, set a value of `eol-type' property. The value is a vector | |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
461 ;; of subsidiary coding systems, each corresponds to a coding system |
17052 | 462 ;; for the detected end-of-line format. |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
463 (put coding-system 'eol-type |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
464 (if (<= type 3) |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
465 (make-subsidiary-coding-system coding-system) |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
466 0))) |
17052 | 467 |
18518
425c8fa4227b
(define-coding-system-alias): Swap the args.
Richard M. Stallman <rms@gnu.org>
parents:
18457
diff
changeset
|
468 (defun define-coding-system-alias (alias coding-system) |
425c8fa4227b
(define-coding-system-alias): Swap the args.
Richard M. Stallman <rms@gnu.org>
parents:
18457
diff
changeset
|
469 "Define ALIAS as an alias for coding system |
425c8fa4227b
(define-coding-system-alias): Swap the args.
Richard M. Stallman <rms@gnu.org>
parents:
18457
diff
changeset
|
470 CODING-SYSTEM." |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
471 (check-coding-system coding-system) |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
472 (let ((parent (coding-system-parent coding-system))) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
473 (if parent |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
474 (setq coding-system parent))) |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
475 (put alias 'coding-system coding-system) |
18298
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
476 (put alias 'parent-coding-system coding-system) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
477 (put coding-system 'alias-coding-systems |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
478 (cons alias (get coding-system 'alias-coding-systems))) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
479 (let ((eol-variants (coding-system-eol-type coding-system)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
480 subsidiaries) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
481 (if (vectorp eol-variants) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
482 (let ((i 0)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
483 (setq subsidiaries (make-subsidiary-coding-system alias)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
484 (while (< i 3) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
485 (put (aref subsidiaries i) 'parent-coding-system |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
486 (aref eol-variants i)) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
487 (put (aref eol-variants i) 'alias-coding-systems |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
488 (cons (aref subsidiaries i) (get (aref eol-variants i) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
489 'alias-coding-systems))) |
3d036a21fc93
(coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
18195
diff
changeset
|
490 (setq i (1+ i))))))) |
17052 | 491 |
492 (defun set-buffer-file-coding-system (coding-system &optional force) | |
493 "Set buffer-file-coding-system of the current buffer to CODING-SYSTEM. | |
494 If eol-type of the current buffer-file-coding-system is an integer value N, and | |
17761
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
495 eol-type of CODING-SYSTEM is a vector, the Nth element of the vector is used |
17052 | 496 instead of CODING-SYSTEM itself. |
497 Optional prefix argument FORCE non-nil means CODING-SYSTEM is set | |
498 regardless of eol-type of the current buffer-file-coding-system." | |
499 (interactive "zBuffer-file-coding-system: \nP") | |
500 (check-coding-system coding-system) | |
501 (if (null force) | |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
502 (let ((x (coding-system-eol-type buffer-file-coding-system)) |
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
503 (y (coding-system-eol-type coding-system))) |
17052 | 504 (if (and (numberp x) (>= x 0) (<= x 2) (vectorp y)) |
505 (setq coding-system (aref y x))))) | |
506 (setq buffer-file-coding-system coding-system) | |
507 (set-buffer-modified-p t) | |
508 (force-mode-line-update)) | |
509 | |
17984
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
510 (defun set-terminal-coding-system (coding-system) |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
511 "Set coding system of your terminal to CODING-SYSTEM. |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
512 All outputs to terminal are encoded by the specified coding system." |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
513 (interactive "zCoding-system for terminal display: ") |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
514 (set-terminal-coding-system-internal coding-system) |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
515 (redraw-frame (selected-frame))) |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
516 |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
517 (defun set-keyboard-coding-system (coding-system) |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
518 "Set coding system of codes sent from terminal keyboard to CODING-SYSTEM. |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
519 In addition, this command toggles Encoded-kbd minor mode. |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
520 If the specified coding system is nil, Encoded-bkd mode is turned off, |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
521 else it is turned on so that user inputs are decoded by the |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
522 specified coding system." |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
523 (interactive "zCoding-system for keyboard input: ") |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
524 (set-keyboard-coding-system-internal coding-system) |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
525 (encoded-kbd-mode (if coding-system 1 0))) |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
526 |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
527 (defun set-buffer-process-coding-system (decoding encoding) |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
528 "Set coding systems to the process associated with the current buffer. |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
529 DECODING is the coding system to be used to decode input from the process, |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
530 ENCODING is to be used to encode output to the process." |
17052 | 531 (interactive |
532 "zCoding-system for process input: \nzCoding-system for process output: ") | |
533 (let ((proc (get-buffer-process (current-buffer)))) | |
534 (if (null proc) | |
535 (error "no process") | |
17984
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
536 (check-coding-system decoding) |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
537 (check-coding-system encoding) |
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
538 (set-process-coding-system proc decoding encoding))) |
17052 | 539 (force-mode-line-update)) |
540 | |
541 (defun set-coding-priority (arg) | |
542 "Set priority of coding-category according to LIST. | |
543 LIST is a list of coding-categories ordered by priority." | |
544 (let (l) | |
545 ;; Put coding-categories listed in ARG to L while checking the | |
546 ;; validity. We assume that `coding-category-list' contains whole | |
547 ;; coding-categories. | |
548 (while arg | |
549 (if (null (memq (car arg) coding-category-list)) | |
550 (error "Invalid element in argument: %s" (car arg))) | |
551 (setq l (cons (car arg) l)) | |
552 (setq arg (cdr arg))) | |
553 ;; Put coding-category not listed in ARG to L. | |
554 (while coding-category-list | |
555 (if (null (memq (car coding-category-list) l)) | |
556 (setq l (cons (car coding-category-list) l))) | |
557 (setq coding-category-list (cdr coding-category-list))) | |
558 ;; Update `coding-category-list' and return it. | |
559 (setq coding-category-list (nreverse l)))) | |
560 | |
561 ;;; FILE I/O | |
562 | |
563 ;; Set buffer-file-coding-system of the current buffer after some text | |
564 ;; is inserted. | |
565 (defun after-insert-file-set-buffer-file-coding-system (inserted) | |
566 (if last-coding-system-used | |
567 (let ((coding-system | |
568 (find-new-buffer-file-coding-system last-coding-system-used)) | |
569 (modified-p (buffer-modified-p))) | |
570 (if coding-system | |
571 (set-buffer-file-coding-system coding-system)) | |
572 (set-buffer-modified-p modified-p))) | |
573 nil) | |
574 | |
575 (setq after-insert-file-functions | |
576 (cons 'after-insert-file-set-buffer-file-coding-system | |
577 after-insert-file-functions)) | |
578 | |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
579 ;; The coding-spec and eol-type of coding-system returned is decided |
17052 | 580 ;; independently in the following order. |
581 ;; 1. That of buffer-file-coding-system locally bound. | |
582 ;; 2. That of CODING. | |
583 | |
584 (defun find-new-buffer-file-coding-system (coding) | |
585 "Return a coding system for a buffer when a file of CODING is inserted. | |
17761
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
586 The local variable `buffer-file-coding-system' of the current buffer |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
587 is set to the returned value. |
17984
4882d58acf01
(set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents:
17837
diff
changeset
|
588 Return nil if there's no need of setting new buffer-file-coding-system." |
17052 | 589 (let (local-coding local-eol |
590 found-eol | |
591 new-coding new-eol) | |
592 (if (null coding) | |
593 ;; Nothing found about coding. | |
594 nil | |
595 | |
596 ;; Get information of the current local value of | |
597 ;; `buffer-file-coding-system' in LOCAL-EOL and LOCAL-CODING. | |
598 (if (local-variable-p 'buffer-file-coding-system) | |
599 ;; Something already set locally. | |
600 (progn | |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
601 (setq local-eol (coding-system-eol-type buffer-file-coding-system)) |
17052 | 602 (if (null (numberp local-eol)) |
603 ;; But eol-type is not yet set. | |
604 (setq local-eol nil)) | |
605 (if (null (eq (coding-system-type buffer-file-coding-system) t)) | |
17837
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
606 ;; This is not `undecided'. |
17052 | 607 (progn |
608 (setq local-coding buffer-file-coding-system) | |
609 (while (symbolp (get local-coding 'coding-system)) | |
610 (setq local-coding (get local-coding 'coding-system)))) | |
611 ))) | |
612 | |
613 (if (and local-eol local-coding) | |
614 ;; The current buffer has already set full coding-system, we | |
615 ;; had better not change it. | |
616 nil | |
617 | |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
618 (setq found-eol (coding-system-eol-type coding)) |
17052 | 619 (if (null (numberp found-eol)) |
620 ;; But eol-type is not found. | |
621 (setq found-eol nil)) | |
622 | |
623 ;; The local setting takes precedence over the found one. | |
624 (setq new-coding (or local-coding coding)) | |
625 (setq new-eol (or local-eol found-eol)) | |
626 (if (and (numberp new-eol) | |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
627 (vectorp (coding-system-eol-type new-coding))) |
17052 | 628 (setq new-coding |
18195
9650375d0a68
Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents:
17984
diff
changeset
|
629 (aref (coding-system-eol-type new-coding) new-eol))) |
17052 | 630 new-coding)))) |
631 | |
17761
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
632 (defun make-unification-table (&rest args) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
633 "Make a unification table (char table) from arguments. |
17837
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
634 Each argument is a list of the form (FROM . TO), |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
635 where FROM is a character to be unified to TO. |
17761
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
636 |
17837
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
637 FROM can be a generic character (see make-char). In this case, TO is |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
638 a generic character containing the same number of charcters or a |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
639 oridinal character. If FROM and TO are both generic characters, all |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
640 characters belonging to FROM are unified to characters belonging to TO |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
641 without changing their position code(s)." |
17761
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
642 (let ((table (make-char-table 'character-unification-table)) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
643 revlist) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
644 (while args |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
645 (let ((elts (car args))) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
646 (while elts |
17837
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
647 (let* ((from (car (car elts))) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
648 (from-i 0) ; degree of freedom of FROM |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
649 (from-rev (nreverse (split-char from))) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
650 (to (cdr (car elts))) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
651 (to-i 0) ; degree of freedom of TO |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
652 (to-rev (nreverse (split-char to)))) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
653 ;; Check numbers of heading 0s in FROM-REV and TO-REV. |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
654 (while (eq (car from-rev) 0) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
655 (setq from-i (1+ from-i) from-rev (cdr from-rev))) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
656 (while (eq (car to-rev) 0) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
657 (setq to-i (1+ to-i) to-rev (cdr to-rev))) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
658 (if (and (/= from-i to-i) (/= to-i 0)) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
659 (error "Invalid character pair (%d . %d)" from to)) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
660 ;; If we have already unified TO to TO-ALT, FROM should |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
661 ;; also be unified to TO-ALT. But, this is only if TO is |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
662 ;; a generic character or TO-ALT is not a generic |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
663 ;; character. |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
664 (let ((to-alt (aref table to))) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
665 (if (and to-alt |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
666 (or (> to-i 0) (not (generic-char-p to-alt)))) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
667 (setq to to-alt))) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
668 (if (> from-i 0) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
669 (set-char-table-default table from to) |
a4d3078a83e9
(make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents:
17761
diff
changeset
|
670 (aset table from to)) |
17761
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
671 ;; If we have already unified some chars to FROM, they |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
672 ;; should also be unified to TO. |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
673 (let ((l (assq from revlist))) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
674 (if l |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
675 (let ((ch (car l))) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
676 (setcar l to) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
677 (setq l (cdr l)) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
678 (while l |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
679 (aset table ch to) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
680 (setq l (cdr l)) )))) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
681 ;; Now update REVLIST. |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
682 (let ((l (assq to revlist))) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
683 (if l |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
684 (setcdr l (cons from (cdr l))) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
685 (setq revlist (cons (list to from) revlist))))) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
686 (setq elts (cdr elts)))) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
687 (setq args (cdr args))) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
688 ;; Return TABLE just created. |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
689 table)) |
c5f430853301
(make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents:
17175
diff
changeset
|
690 |
17094
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
691 ;;; Initialize some variables. |
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
692 |
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
693 (put 'use-default-ascent 'char-table-extra-slots 0) |
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
694 (setq use-default-ascent (make-char-table 'use-default-ascent)) |
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
695 |
c237252970e5
(make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
696 ;;; |
17052 | 697 (provide 'mule) |
698 | |
699 ;;; mule.el ends here |