annotate lisp/international/mule.el @ 21374:456146137d23

(Fstring_as_unibyte): Set size_byte field to -1.
author Kenichi Handa <handa@m17n.org>
date Mon, 06 Apr 1998 05:06:12 +0000
parents bac070da6b6d
children b6c858daa80d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1 ;;; mule.el --- basic commands for mulitilingual environment
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
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
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6 ;; Keywords: mule, multilingual, character set, coding system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; any later version.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
23 ;; Boston, MA 02111-1307, USA.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25 ;;; Code:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27 (defconst mule-version "3.0 (MOMIJINOGA)" "\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 Version number and name of this version of MULE (multilingual environment).")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 (defconst mule-version-date "1998.1.1" "\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31 Distribution date of this version of MULE (multilingual environment).")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 (defun load-with-code-conversion (fullname file &optional noerror nomessage)
20405
faf18d58a01b (load-with-code-conversion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20168
diff changeset
34 "Execute a file of Lisp code named FILE whose absolute name is FULLNAME.
faf18d58a01b (load-with-code-conversion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20168
diff changeset
35 The file contents are decoded before evaluation if necessary.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 If optional second arg NOERROR is non-nil,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 report no error if FILE doesn't exist.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 Print messages at start and end of loading unless
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 optional third arg NOMESSAGE is non-nil.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 Return t if file exists."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 (if (null (file-readable-p fullname))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 (and (null noerror)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 (signal 'file-error (list "Cannot open load file" file)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 ;; Read file with code conversion, and then eval.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 (let* ((buffer
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 ;; To avoid any autoloading, set default-major-mode to
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 ;; fundamental-mode.
21023
bac070da6b6d (load-with-code-conversion):
Karl Heuer <kwzh@gnu.org>
parents: 20940
diff changeset
48 (let ((default-major-mode 'fundamental-mode)
bac070da6b6d (load-with-code-conversion):
Karl Heuer <kwzh@gnu.org>
parents: 20940
diff changeset
49 (default-enable-multibyte-characters t))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 ;; We can't use `generate-new-buffer' because files.el
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 ;; is not yet loaded.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 (get-buffer-create (generate-new-buffer-name " *load*"))))
20168
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
53 (load-in-progress t)
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
54 (source (save-match-data (string-match "\\.el\\'" fullname))))
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
55 (unless nomessage
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
56 (if source
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
57 (message "Loading %s (source)..." file)
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
58 (message "Loading %s..." file)))
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
59 (when purify-flag
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
60 (setq preloaded-file-list (cons file preloaded-file-list)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 (unwind-protect
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
62 (let ((load-file-name fullname)
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
63 (inhibit-file-name-operation nil))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 (set-buffer buffer)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 (insert-file-contents fullname)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 ;; Make `kill-buffer' quiet.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 (set-buffer-modified-p nil))
20405
faf18d58a01b (load-with-code-conversion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20168
diff changeset
69 ;; Have the original buffer current while we eval.
19802
2e277f643555 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 19768
diff changeset
70 (eval-buffer buffer nil file))
18583
66e7a91e32ef (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 18558
diff changeset
71 (let (kill-buffer-hook kill-buffer-query-functions)
66e7a91e32ef (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 18558
diff changeset
72 (kill-buffer buffer)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 (let ((hook (assoc file after-load-alist)))
20168
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
74 (when hook
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
75 (mapcar (function eval) (cdr hook))))
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
76 (unless (or nomessage noninteractive)
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
77 (if source
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
78 (message "Loading %s (source)...done" file)
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
79 (message "Loading %s...done" file)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80 t)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82 ;; API (Application Program Interface) for charsets.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
84 ;; Return t if OBJ is a quoted symbol
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
85 ;; and the symbol is the name of a standard charset.
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
86 (defsubst charset-quoted-standard-p (obj)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
87 (and (listp obj) (eq (car obj) 'quote)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
88 (symbolp (car-safe (cdr obj)))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
89 (let ((vector (get (car-safe (cdr obj)) 'charset)))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
90 (and (vectorp vector)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
91 (< (aref vector 0) 160)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 (defsubst charsetp (object)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 "T is OBJECT is a charset."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 (and (symbolp object) (vectorp (get object 'charset))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 (defsubst charset-info (charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 "Return a vector of information of CHARSET.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99 The elements of the vector are:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 LEADING-CODE-BASE, LEADING-CODE-EXT,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 PLIST,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 where
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106 CHARSET-ID (integer) is the identification number of the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 DIMENSION (integer) is the number of bytes to represent a character of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108 the charset: 1 or 2.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109 CHARS (integer) is the number of characters in a dimension: 94 or 96.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
110 BYTE (integer) is the length of multi-byte form of a character in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111 the charset: one of 1, 2, 3, and 4.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112 WIDTH (integer) is the number of columns a character in the charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113 occupies on the screen: one of 0, 1, and 2.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 DIRECTION (integer) is the rendering direction of characters in the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 charset when rendering. If 0, render from right to left, else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116 render from left to right.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117 LEADING-CODE-BASE (integer) is the base leading-code for the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118 charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 LEADING-CODE-EXT (integer) is the extended leading-code for the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120 charset. All charsets of less than 0xA0 has the value 0.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 ISO-FINAL-CHAR (character) is the final character of the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 corresponding ISO 2022 charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123 ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124 while encoding to variants of ISO 2022 coding system, one of the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 REVERSE-CHARSET (integer) is the charset which differs only in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 LEFT-TO-RIGHT value from the charset. If there's no such a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 charset, the value is -1.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 SHORT-NAME (string) is the short name to refer to the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 LONG-NAME (string) is the long name to refer to the charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 DESCRIPTION (string) is the description string of the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 PLIST (property list) may contain any type of information a user
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 want to put and get by functions `put-charset-property' and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 `get-charset-property' respectively."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 (get charset 'charset))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 (defmacro charset-id (charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 "Return charset identification number of CHARSET."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
139 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 (aref (charset-info (nth 1 charset)) 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 `(aref (charset-info ,charset) 0)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 (defmacro charset-bytes (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
144 "Return bytes of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
145 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
146 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 (aref (charset-info (nth 1 charset)) 1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 `(aref (charset-info ,charset) 1)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 (defmacro charset-dimension (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
151 "Return dimension of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
152 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
153 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 (aref (charset-info (nth 1 charset)) 2)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155 `(aref (charset-info ,charset) 2)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 (defmacro charset-chars (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
158 "Return character numbers contained in a dimension of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
159 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
160 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 (aref (charset-info (nth 1 charset)) 3)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 `(aref (charset-info ,charset) 3)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 (defmacro charset-width (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
165 "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
166 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
167 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 (aref (charset-info (nth 1 charset)) 4)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 `(aref (charset-info ,charset) 4)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 (defmacro charset-direction (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
172 "Return direction of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
173 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
174 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175 (aref (charset-info (nth 1 charset)) 5)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 `(aref (charset-info ,charset) 5)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 (defmacro charset-iso-final-char (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
179 "Return final char of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
180 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
181 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182 (aref (charset-info (nth 1 charset)) 8)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 `(aref (charset-info ,charset) 8)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185 (defmacro charset-iso-graphic-plane (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
186 "Return graphic plane of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
187 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
188 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189 (aref (charset-info (nth 1 charset)) 9)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190 `(aref (charset-info ,charset) 9)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192 (defmacro charset-reverse-charset (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
193 "Return reverse charset of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
194 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
195 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
196 (aref (charset-info (nth 1 charset)) 10)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
197 `(aref (charset-info ,charset) 10)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
199 (defmacro charset-short-name (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
200 "Return short name of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
201 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
202 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203 (aref (charset-info (nth 1 charset)) 11)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
204 `(aref (charset-info ,charset) 11)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
205
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
206 (defmacro charset-long-name (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
207 "Return long name of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
208 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
209 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
210 (aref (charset-info (nth 1 charset)) 12)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 `(aref (charset-info ,charset) 12)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
213 (defmacro charset-description (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
214 "Return descriptoin of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
215 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
216 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
217 (aref (charset-info (nth 1 charset)) 13)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 `(aref (charset-info ,charset) 13)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
219
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
220 (defmacro charset-plist (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
221 "Return list charset property of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
222 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
223 (if (charset-quoted-standard-p charset)
17175
3e54eb2d2a57 (make-char): Documented.
Kenichi Handa <handa@m17n.org>
parents: 17094
diff changeset
224 `(aref ,(charset-info (nth 1 charset)) 14)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
225 `(aref (charset-info ,charset) 14)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
226
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
227 (defun set-charset-plist (charset plist)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
228 "Set CHARSET's property list to PLIST, and retrun PLIST."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229 (aset (charset-info charset) 14 plist))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
230
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
231 (defun make-char (charset &optional c1 c2)
17175
3e54eb2d2a57 (make-char): Documented.
Kenichi Handa <handa@m17n.org>
parents: 17094
diff changeset
232 "Return a character of CHARSET and position-codes CODE1 and CODE2.
3e54eb2d2a57 (make-char): Documented.
Kenichi Handa <handa@m17n.org>
parents: 17094
diff changeset
233 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
234 sufficient position-codes, return a generic character which stands for
17175
3e54eb2d2a57 (make-char): Documented.
Kenichi Handa <handa@m17n.org>
parents: 17094
diff changeset
235 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
236 A generic character can be used to index a char table (e.g. syntax-table)."
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
237 (make-char-internal (charset-id charset) c1 c2))
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
238
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
239 (put 'make-char 'byte-compile
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
240 (function
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
241 (lambda (form)
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
242 (let ((charset (nth 1 form)))
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
243 (if (charset-quoted-standard-p charset)
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
244 (byte-compile-normal-call
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
245 (cons 'make-char-internal
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
246 (cons (charset-id (nth 1 charset)) (nthcdr 2 form))))
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
247 (byte-compile-normal-call
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
248 (cons 'make-char-internal
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
249 (cons (list 'charset-id charset) (nthcdr 2 form)))))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
250
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
251 (defun charset-list ()
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
252 "Return list of charsets ever defined.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
253
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
254 This function is provided for backward compatibility.
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
255 Now we have the variable `charset-list'."
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
256 charset-list)
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
257
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
258 (make-obsolete 'charset-list
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
259 "Use the variable charset-list instead.")
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
260
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
261 (defsubst generic-char-p (char)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
262 "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
263 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
264 (let ((l (split-char char)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
265 (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
266 (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
267
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
268
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
269 ;; Coding system staffs
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
270
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
271 ;; Coding system is a symbol that has the property `coding-system'.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
272 ;;
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
273 ;; 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
274 ;; following format:
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
275 ;; [TYPE MNEMONIC DOC-STRING PLIST FLAGS]
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
276 ;; We call this vector as coding-spec. See comments in src/coding.c
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
277 ;; for more detail.
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
278
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
279 (defconst coding-spec-type-idx 0)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
280 (defconst coding-spec-mnemonic-idx 1)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
281 (defconst coding-spec-doc-string-idx 2)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
282 (defconst coding-spec-plist-idx 3)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
283 (defconst coding-spec-flags-idx 4)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
284
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
285 ;; PLIST is a property list of a coding system. To share PLIST among
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
286 ;; alias coding systems, a coding system has PLIST in coding-spec
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
287 ;; instead of having it in normal property list of Lisp symbol.
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
288 ;; Here's a list of coding system properties currently being used.
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
289 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
290 ;; o coding-category
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
291 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
292 ;; The value is a coding category the coding system belongs to. The
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
293 ;; function `make-coding-system' and `define-coding-system-alias' sets
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
294 ;; this value automatically.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295 ;;
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
296 ;; o alias-coding-systems
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
297 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
298 ;; The value is a list of coding systems of the same alias group. The
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
299 ;; first element is the coding system made at first, which we call as
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
300 ;; `base coding system'. The function `make-coding-system' and
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
301 ;; `define-coding-system-alias' set this value automatically.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
302 ;;
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
303 ;; o post-read-conversion
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
304 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
305 ;; The value is a function to call after some text is inserted and
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
306 ;; decoded by the coding system itself and before any functions in
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
307 ;; `after-insert-functions' are called. The arguments to this
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
308 ;; function is the same as those of a function in
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309 ;; `after-insert-functions', i.e. LENGTH of a text while putting point
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
310 ;; at the head of the text to be decoded
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
311 ;;
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
312 ;; o pre-write-conversion
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
313 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
314 ;; The value is a function to call after all functions in
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
315 ;; `write-region-annotate-functions' and `buffer-file-format' are
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
316 ;; called, and before the text is encoded by the coding system itself.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
317 ;; The arguments to this function is the same as those of a function
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
318 ;; in `write-region-annotate-functions', i.e. FROM and TO specifying
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
319 ;; region of a text.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
320 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
321 ;; o character-unification-table-for-decode
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
322 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
323 ;; The value is a unification table to be applied on decoding. See
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
324 ;; the function `make-unification-table' for the format of unification
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
325 ;; table.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
326 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
327 ;; o character-unification-table-for-encode
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
328 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
329 ;; The value is a unification table to be applied on encoding.
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
330 ;;
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
331 ;; o safe-charsets
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
332 ;;
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
333 ;; The value is a list of charsets safely supported by the coding
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
334 ;; system. The value t means that all charsets Emacs handles are
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
335 ;; supported. Even if some charset is not in this list, it doesn't
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
336 ;; mean that the charset can't be encoded in the coding system,
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
337 ;; instead, it just means that some other receiver of a text encoded
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
338 ;; in the coding system won't be able to handle that charset.
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
339
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
341 ;; Return coding-spec of CODING-SYSTEM
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
342 (defsubst coding-system-spec (coding-system)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
343 (get (check-coding-system coding-system) 'coding-system))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
344
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
345 (defun coding-system-type (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
346 "Return the coding type of CODING-SYSTEM.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
347 A coding type is an integer value indicating the encoding method
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
348 of CODING-SYSTEM. See the function `make-coding-system' for more detail."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
349 (aref (coding-system-spec coding-system) coding-spec-type-idx))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
351 (defun coding-system-mnemonic (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
352 "Return the mnemonic character of CODING-SYSTEM.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
353 A mnemonic character of a coding system is used in mode line
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
354 to indicate the coding system."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
355 (or (aref (coding-system-spec coding-system) coding-spec-mnemonic-idx)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
356 ?-))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
357
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
358 (defun coding-system-doc-string (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
359 "Return the documentation string for CODING-SYSTEM."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
360 (aref (coding-system-spec coding-system) coding-spec-doc-string-idx))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
361
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
362 (defun coding-system-plist (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
363 "Return the property list of CODING-SYSTEM."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
364 (aref (coding-system-spec coding-system) coding-spec-plist-idx))
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
365
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366 (defun coding-system-flags (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
367 "Return `flags' of CODING-SYSTEM.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
368 A `flags' of a coding system is a vector of length 32 indicating detailed
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
369 information of a coding system. See the function `make-coding-system'
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
370 for more detail."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
371 (aref (coding-system-spec coding-system) coding-spec-flags-idx))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
372
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
373 (defun coding-system-get (coding-system prop)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
374 "Extract a value from CODING-SYSTEM's property list for property PROP."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
375 (plist-get (coding-system-plist coding-system) prop))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
376
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
377 (defun coding-system-put (coding-system prop val)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
378 "Change value in CODING-SYSTEM's property list PROP to VAL."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
379 (let ((plist (coding-system-plist coding-system)))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
380 (if plist
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
381 (plist-put plist prop val)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
382 (aset (coding-system-spec coding-system) coding-spec-plist-idx
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
383 (list prop val)))))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
384
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
385 (defun coding-system-category (coding-system)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
386 "Return the coding category of CODING-SYSTEM."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
387 (coding-system-get coding-system 'coding-category))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
388
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
389 (defun coding-system-base (coding-system)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
390 "Return the base coding system of CODING-SYSTEM.
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
391 A base coding system is what made by `make-coding-system'.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
392 Any alias nor subsidiary coding systems are not base coding system."
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
393 (car (coding-system-get coding-system 'alias-coding-systems)))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
394
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
395 (defalias 'coding-system-parent 'coding-system-base)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
396 (make-obsolete 'coding-system-parent 'coding-system-base)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
397
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
398 ;; Coding system also has a property `eol-type'.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
399 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
400 ;; This property indicates how the coding system handles end-of-line
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
401 ;; format. The value is integer 0, 1, 2, or a vector of three coding
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
402 ;; systems. Each integer value 0, 1, and 2 indicates the format of
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
403 ;; end-of-line LF, CRLF, and CR respectively. A vector value
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
404 ;; indicates that the format of end-of-line should be detected
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
405 ;; automatically. Nth element of the vector is the subsidiary coding
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
406 ;; system whose `eol-type' property is N.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
407
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
408 (defun coding-system-eol-type (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
409 "Return eol-type of CODING-SYSTEM.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
410 An eol-type is integer 0, 1, 2, or a vector of coding systems.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
411
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
412 Integer values 0, 1, and 2 indicate a format of end-of-line; LF,
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
413 CRLF, and CR respectively.
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
414
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
415 A vector value indicates that a format of end-of-line should be
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
416 detected automatically. Nth element of the vector is the subsidiary
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
417 coding system whose eol-type is N."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
418 (get coding-system 'eol-type))
18312
705da3ce58c0 (coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 18298
diff changeset
419
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
420 ;; 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
421 (defun make-subsidiary-coding-system (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
422 (let ((coding-spec (coding-system-spec coding-system))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
423 (subsidiaries (vector (intern (format "%s-unix" coding-system))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
424 (intern (format "%s-dos" coding-system))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
425 (intern (format "%s-mac" coding-system))))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
426 (i 0)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
427 temp)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
428 (while (< i 3)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
429 (put (aref subsidiaries i) 'coding-system coding-spec)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
430 (put (aref subsidiaries i) 'eol-type i)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
431 (setq coding-system-list
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
432 (cons (aref subsidiaries i) coding-system-list))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
433 (setq coding-system-alist
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
434 (cons (list (symbol-name (aref subsidiaries i)))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
435 coding-system-alist))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
436 (setq i (1+ i)))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
437 subsidiaries))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
438
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
439 (defun make-coding-system (coding-system type mnemonic doc-string
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
440 &optional flags properties)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
441 "Define a new CODING-SYSTEM (symbol).
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
442 Remaining arguments are TYPE, MNEMONIC, DOC-STRING, FLAGS (optional),
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
443 and PROPERTIES (optional) which construct a coding-spec of CODING-SYSTEM
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
444 in the following format:
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
445 [TYPE MNEMONIC DOC-STRING PLIST FLAGS]
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
446 TYPE is an integer value indicating the type of coding-system as follows:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
447 0: Emacs internal format,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
448 1: Shift-JIS (or MS-Kanji) used mainly on Japanese PC,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
449 2: ISO-2022 including many variants,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
450 3: Big5 used mainly on Chinese PC,
19606
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
451 4: private, CCL programs provide encoding/decoding algorithm,
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
452 5: Raw-text, which means that text contains random 8-bit codes.
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
453
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
454 MNEMONIC is a character to be displayed on mode line for the coding-system.
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
455
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
456 DOC-STRING is a documentation string for the coding-system.
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
457
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
458 FLAGS specifies more precise information of each TYPE.
19263
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
459
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
460 If TYPE is 2 (ISO-2022), FLAGS should be a list of:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
461 CHARSET0, CHARSET1, CHARSET2, CHARSET3, SHORT-FORM,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
462 ASCII-EOL, ASCII-CNTL, SEVEN, LOCKING-SHIFT, SINGLE-SHIFT,
19263
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
463 USE-ROMAN, USE-OLDJIS, NO-ISO6429, INIT-BOL, DESIGNATION-BOL,
19395
cf115b0c7458 (make-coding-system): Add a new FLAGS
Richard M. Stallman <rms@gnu.org>
parents: 19263
diff changeset
464 SAFE, ACCEPT-LATIN-EXTRA-CODE.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
465 CHARSETn are character sets initially designated to Gn graphic registers.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
466 If CHARSETn is nil, Gn is never used.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
467 If CHARSETn is t, Gn can be used but nothing designated initially.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
468 If CHARSETn is a list of character sets, those character sets are
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
469 designated to Gn on output, but nothing designated to Gn initially.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
470 SHORT-FORM non-nil means use short designation sequence on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
471 ASCII-EOL non-nil means designate ASCII to g0 at end of line on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
472 ASCII-CNTL non-nil means designate ASCII to g0 before control codes and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
473 SPACE on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
474 SEVEN non-nil means use 7-bit code only on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
475 LOCKING-SHIFT non-nil means use locking-shift.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
476 SINGLE-SHIFT non-nil means use single-shift.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
477 USE-ROMAN non-nil means designate JIS0201-1976-Roman instead of ASCII.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
478 USE-OLDJIS non-nil means designate JIS0208-1976 instead of JIS0208-1983.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
479 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
480 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
481 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
482 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
483 at beginning of line on output.
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
484 SAFE non-nil means convert unsafe characters to `?' on output.
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
485 Unsafe characters are what not specified in SAFE-CHARSET.
19395
cf115b0c7458 (make-coding-system): Add a new FLAGS
Richard M. Stallman <rms@gnu.org>
parents: 19263
diff changeset
486 ACCEPT-LATIN-EXTRA-CODE non-nil means code-detection routine accepts
cf115b0c7458 (make-coding-system): Add a new FLAGS
Richard M. Stallman <rms@gnu.org>
parents: 19263
diff changeset
487 a code specified in `latin-extra-code-table' (which see) as a valid
cf115b0c7458 (make-coding-system): Add a new FLAGS
Richard M. Stallman <rms@gnu.org>
parents: 19263
diff changeset
488 code of the coding system.
19263
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
489
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
490 If TYPE is 4 (private), FLAGS should be a cons of CCL programs,
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
491 for decoding and encoding. See the documentation of CCL for more detail.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
492
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
493 PROPERTIES is an alist of properties vs the corresponding values.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
494 These properties are set in PLIST, a property list. This function
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
495 also sets properties `coding-category' and `alias-coding-systems'
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
496 automatically.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
497
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
498 Kludgy feature: For backward compatibility, if PROPERTIES is a list of
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
499 character sets, the list is set as a value of `safe-charsets' in
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
500 PLIST."
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
501 (if (memq coding-system coding-system-list)
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
502 (error "Coding system %s already exists" coding-system))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
503
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
504 ;; Set a value of `coding-system' property.
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
505 (let ((coding-spec (make-vector 5 nil))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
506 (no-initial-designation t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
507 (no-alternative-designation t)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
508 coding-category)
19606
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
509 (if (or (not (integerp type)) (< type 0) (> type 5))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
510 (error "TYPE argument must be 0..5"))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
511 (if (or (not (integerp mnemonic)) (<= mnemonic ? ) (> mnemonic 127))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
512 (error "MNEMONIC arguemnt must be an ASCII printable character."))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
513 (aset coding-spec coding-spec-type-idx type)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
514 (aset coding-spec coding-spec-mnemonic-idx mnemonic)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
515 (aset coding-spec coding-spec-doc-string-idx
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
516 (if (stringp doc-string) doc-string ""))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
517 (cond ((= type 0)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
518 (setq coding-category 'coding-category-emacs-mule))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
519 ((= type 1)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
520 (setq coding-category 'coding-category-sjis))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
521 ((= type 2) ; ISO2022
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
522 (let ((i 0)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
523 (vec (make-vector 32 nil))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
524 (g1-designation nil))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
525 (while (< i 4)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
526 (let ((charset (car flags)))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
527 (if (and no-initial-designation
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
528 (> i 0)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
529 (or (charsetp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
530 (and (consp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
531 (charsetp (car charset)))))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
532 (setq no-initial-designation nil))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
533 (if (charsetp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
534 (if (= i 1) (setq g1-designation charset))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
535 (if (consp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
536 (let ((tail charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
537 elt)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
538 (while tail
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
539 (setq elt (car tail))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
540 (if (eq elt t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
541 (setq no-alternative-designation nil)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
542 (if (and elt (not (charsetp elt)))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
543 (error "Invalid charset: %s" elt)))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
544 (setq tail (cdr tail)))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
545 (setq g1-designation (car charset)))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
546 (if charset
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
547 (if (eq charset t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
548 (setq no-alternative-designation nil)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
549 (error "Invalid charset: %s" charset)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
550 (aset vec i charset))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
551 (setq flags (cdr flags) i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
552 (while (and (< i 32) flags)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
553 (aset vec i (car flags))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
554 (setq flags (cdr flags) i (1+ i)))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
555 (aset coding-spec 4 vec)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
556 (setq coding-category
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
557 (if (aref vec 8) ; Use locking-shift.
18798
d4c708a5f181 (make-coding-system): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents: 18583
diff changeset
558 (or (and (aref vec 7) 'coding-category-iso-7-else)
d4c708a5f181 (make-coding-system): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents: 18583
diff changeset
559 'coding-category-iso-8-else)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
560 (if (aref vec 7) ; 7-bit only.
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
561 (if (aref vec 9) ; Use single-shift.
18798
d4c708a5f181 (make-coding-system): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents: 18583
diff changeset
562 'coding-category-iso-7-else
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
563 (if no-alternative-designation
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
564 'coding-category-iso-7-tight
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
565 'coding-category-iso-7))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
566 (if no-initial-designation
18798
d4c708a5f181 (make-coding-system): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents: 18583
diff changeset
567 'coding-category-iso-8-else
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
568 (if (and (charsetp g1-designation)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
569 (= (charset-dimension g1-designation) 2))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
570 'coding-category-iso-8-2
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
571 'coding-category-iso-8-1)))))))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
572 ((= type 3)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
573 (setq coding-category 'coding-category-big5))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
574 ((= type 4) ; private
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
575 (setq coding-category 'coding-category-binary)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
576 (if (and (consp flags)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
577 (vectorp (car flags))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
578 (vectorp (cdr flags)))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
579 (aset coding-spec 4 flags)
19606
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
580 (error "Invalid FLAGS argument for TYPE 4 (CCL)")))
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
581 (t ; i.e. (= type 5)
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
582 (setq coding-category 'coding-category-raw-text)))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
583
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
584 (let ((plist (list 'coding-category coding-category
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
585 'alias-coding-systems (list coding-system))))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
586 (if no-initial-designation
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
587 (plist-put plist 'no-initial-designation t))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
588 (if (and properties
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
589 (or (eq properties t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
590 (not (consp (car properties)))))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
591 ;; In the old version, the arg PROPERTIES is a list to be
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
592 ;; set in PLIST as a value of property `safe-charsets'.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
593 (plist-put plist 'safe-charsets properties)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
594 (while properties
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
595 (plist-put plist (car (car properties)) (cdr (car properties)))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
596 (setq properties (cdr properties))))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
597 (aset coding-spec coding-spec-plist-idx plist))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
598 (put coding-system 'coding-system coding-spec)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
599 (put coding-category 'coding-systems
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
600 (cons coding-system (get coding-category 'coding-systems))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
601
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
602 ;; 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
603 ;; of subsidiary coding systems, each corresponds to a coding system
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
604 ;; 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
605 (put coding-system 'eol-type
19606
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
606 (if (or (<= type 3) (= type 5))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
607 (make-subsidiary-coding-system coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
608 0))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
609
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
610 ;; At last, register CODING-SYSTEM in `coding-system-list' and
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
611 ;; `coding-system-alist'.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
612 (setq coding-system-list (cons coding-system coding-system-list))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
613 (setq coding-system-alist (cons (list (symbol-name coding-system))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
614 coding-system-alist))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
615 coding-system)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
616
18518
425c8fa4227b (define-coding-system-alias): Swap the args.
Richard M. Stallman <rms@gnu.org>
parents: 18457
diff changeset
617 (defun define-coding-system-alias (alias coding-system)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
618 "Define ALIAS as an alias for coding system CODING-SYSTEM."
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
619 (put alias 'coding-system (coding-system-spec coding-system))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
620 (nconc (coding-system-get alias 'alias-coding-systems) (list alias))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
621 (setq coding-system-list (cons alias coding-system-list))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
622 (setq coding-system-alist (cons (list (symbol-name alias))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
623 coding-system-alist))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
624 (let ((eol-type (coding-system-eol-type coding-system)))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
625 (if (vectorp eol-type)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
626 (put alias 'eol-type (make-subsidiary-coding-system alias))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
627 (put alias 'eol-type eol-type))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
628
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
629 (defun set-buffer-file-coding-system (coding-system &optional force)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
630 "Set the file coding-system of the current buffer to CODING-SYSTEM.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
631 This means that when you save the buffer, it will be converted
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
632 according to CODING-SYSTEM. For a list of possible values of CODING-SYSTEM,
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
633 use \\[list-coding-systems].
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
634
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
635 If the buffer's previous file coding-system value specifies end-of-line
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
636 conversion, and CODING-SYSTEM does not specify one, CODING-SYSTEM is
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
637 merged with the already-specified end-of-line conversion.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
638 However, if the optional prefix argument FORCE is non-nil,
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
639 then CODING-SYSTEM is used exactly as specified."
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
640 (interactive "zCoding system for visited file (default, nil): \nP")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
641 (check-coding-system coding-system)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
642 (if (null force)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
643 (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
644 (y (coding-system-eol-type coding-system)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
645 (if (and (numberp x) (>= x 0) (<= x 2) (vectorp y))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
646 (setq coding-system (aref y x)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
647 (setq buffer-file-coding-system coding-system)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
648 (set-buffer-modified-p t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
649 (force-mode-line-update))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
650
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
651 (defvar default-terminal-coding-system nil
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
652 "Default value for the terminal coding system.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
653 This is normally set according to the selected language environment.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
654 See also the command `set-terminal-coding-system'.")
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
655
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
656 (defun set-terminal-coding-system (coding-system)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
657 "Set coding system of your terminal to CODING-SYSTEM.
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
658 All text output to the terminal will be encoded
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
659 with the specified coding system.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
660 For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
661 The default is determined by the selected language environment
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
662 or by the previous use of this command."
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
663 (interactive
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
664 (list (let ((default (if (and (not (terminal-coding-system))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
665 default-terminal-coding-system)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
666 default-terminal-coding-system)))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
667 (read-coding-system
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
668 (format "Coding system for terminal display (default, %s): "
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
669 default)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
670 default))))
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
671 (if (and (not coding-system)
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
672 (not (terminal-coding-system)))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
673 (setq coding-system default-terminal-coding-system))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
674 (if coding-system
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
675 (setq default-terminal-coding-system coding-system))
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
676 (set-terminal-coding-system-internal coding-system)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
677 (redraw-frame (selected-frame)))
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
678
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
679 (defvar default-keyboard-coding-system nil
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
680 "Default value of the keyboard coding system.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
681 This is normally set according to the selected language environment.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
682 See also the command `set-keyboard-coding-system'.")
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
683
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
684 (defun set-keyboard-coding-system (coding-system)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
685 "Set coding system for keyboard input to CODING-SYSTEM.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
686 In addition, this command enables Encoded-kbd minor mode.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
687 \(If CODING-SYSTEM is nil, Encoded-bkd mode is turned off.)
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
688 For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
689 The default is determined by the selected language environment
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
690 or by the previous use of this command."
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
691 (interactive
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
692 (list (let ((default (if (and (not (keyboard-coding-system))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
693 default-keyboard-coding-system)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
694 default-keyboard-coding-system)))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
695 (read-coding-system
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
696 (format "Coding system for keyboard input (default, %s): "
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
697 default)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
698 default))))
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
699 (if (and (not coding-system)
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
700 (not (keyboard-coding-system)))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
701 (setq coding-system default-keyboard-coding-system))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
702 (if coding-system
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
703 (setq default-keyboard-coding-system coding-system))
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
704 (set-keyboard-coding-system-internal coding-system)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
705 (encoded-kbd-mode (if coding-system 1 0)))
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
706
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
707 (defun set-buffer-process-coding-system (decoding encoding)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
708 "Set coding systems for the process associated with the current buffer.
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
709 DECODING is the coding system to be used to decode input from the process,
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
710 ENCODING is the coding system to be used to encode output to the process.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
711
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
712 For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems]."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
713 (interactive
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
714 "zCoding-system for process input: \nzCoding-system for process output: ")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
715 (let ((proc (get-buffer-process (current-buffer))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
716 (if (null proc)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
717 (error "no process")
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
718 (check-coding-system decoding)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
719 (check-coding-system encoding)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
720 (set-process-coding-system proc decoding encoding)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
721 (force-mode-line-update))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
722
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
723 (defun set-coding-priority (arg)
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
724 "Set priority of coding categories according to LIST.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
725 LIST is a list of coding categories ordered by priority."
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
726 (let ((l arg)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
727 (current-list (copy-sequence coding-category-list)))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
728 ;; Check the varidity of ARG while deleting coding categories in
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
729 ;; ARG from CURRENT-LIST. We assume that CODING-CATEGORY-LIST
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
730 ;; contains all coding categories.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
731 (while l
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
732 (if (or (null (get (car l) 'coding-category-index))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
733 (null (memq (car l) current-list)))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
734 (error "Invalid or duplicated element in argument: %s" arg))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
735 (setq current-list (delq (car l) current-list))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
736 (setq l (cdr l)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
737 ;; Update `coding-category-list' and return it.
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
738 (setq coding-category-list (append arg current-list))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
739
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
740 ;;; FILE I/O
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
741
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
742 (defun set-auto-coding (string)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
743 "Return coding system for a file which has STRING at the head and tail.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
744 STRING is a concatination of the first 1K-byte and
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
745 the last 3K-byte of the file.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
746
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
747 It checks for a -*- coding: tag in the first one or two lines of STRING.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
748 If there's no coding: tag in the head, it checks local variables spec
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
749 in the tailing 3K-byte oof STRING.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
750
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
751 The return value is the specified coding system,
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
752 or nil if nothing specified.
19454
5a08bc0f02d3 (make-coding-system): Doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 19395
diff changeset
753
5a08bc0f02d3 (make-coding-system): Doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 19395
diff changeset
754 The variable `auto-file-coding-system' (which see) is set to this
5a08bc0f02d3 (make-coding-system): Doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 19395
diff changeset
755 function by default."
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
756 (condition-case nil
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
757 (let ((case-fold-search t)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
758 (len (length string))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
759 (limit (string-match "\n" string))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
760 (coding-system nil))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
761
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
762 ;; At first check the head.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
763 (if limit
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
764 (when (string-match "^#!" string)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
765 ;; If the file begins with "#!" (exec interpreter
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
766 ;; magic), look for coding frobs in the first two lines.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
767 ;; You cannot necessarily put them in the first line of
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
768 ;; such a file without screwing up the interpreter
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
769 ;; invocation.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
770 (setq limit (string-match "\n" string limit))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
771 (or limit
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
772 (setq limit len)))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
773 (setq limit len))
19665
f523227a99ab (set-auto-coding): Recognize coding: in first
Richard M. Stallman <rms@gnu.org>
parents: 19648
diff changeset
774 (when (and (string-match "-\\*-\\(.*;\\)?[ \t]*coding:[ \t]*\\([^ ;]+\\)" string)
f523227a99ab (set-auto-coding): Recognize coding: in first
Richard M. Stallman <rms@gnu.org>
parents: 19648
diff changeset
775 (< (match-beginning 2) limit))
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
776 (setq coding-system
19665
f523227a99ab (set-auto-coding): Recognize coding: in first
Richard M. Stallman <rms@gnu.org>
parents: 19648
diff changeset
777 (intern (substring string (match-beginning 2) (match-end 2))))
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
778 (if (not (coding-system-p coding-system))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
779 (setq coding-system nil)))
19454
5a08bc0f02d3 (make-coding-system): Doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 19395
diff changeset
780
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
781 ;; If no coding system is specified in the head, check the tail.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
782 (when (and (not coding-system)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
783 (let ((idx (if (> len 3000) (- len 3000) 0))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
784 start)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
785 (while (setq start (string-match "\n\^L" string idx))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
786 (setq idx (+ start 2)))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
787 (string-match
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
788 "^\\(.*\\)[ \t]*Local Variables:[ \t]*\\(.*\\)$"
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
789 string idx)))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
790 ;; The prefix is what comes before "local variables:" in its line.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
791 ;; The suffix is what comes after "local variables:" in its line.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
792 (let* ((idx (1+ (match-end 0)))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
793 (prefix (regexp-quote
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
794 (substring string
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
795 (match-beginning 1) (match-end 1))))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
796 (suffix (regexp-quote
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
797 (substring string
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
798 (match-beginning 2) (match-end 2))))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
799 (re-coding (concat "^" prefix
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
800 "coding[ \t]*:[ \t]*\\([^ \t]+\\)[ \t]*"
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
801 suffix "$"))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
802 (re-end (concat "^" prefix "end *:[ \t]*" suffix "$"))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
803 (limit (or (string-match re-end string idx) len)))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
804 (when (and (setq idx (string-match re-coding string idx))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
805 (< idx limit))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
806 (setq coding-system
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
807 (intern (substring string
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
808 (match-beginning 1) (match-end 1))))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
809 (or (coding-system-p coding-system)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
810 (setq coding-system nil)))))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
811
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
812 coding-system)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
813 (error nil)))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
814
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
815 (setq set-auto-coding-function 'set-auto-coding)
19454
5a08bc0f02d3 (make-coding-system): Doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 19395
diff changeset
816
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
817 ;; Set buffer-file-coding-system of the current buffer after some text
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
818 ;; is inserted.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
819 (defun after-insert-file-set-buffer-file-coding-system (inserted)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
820 (if last-coding-system-used
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
821 (let ((coding-system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
822 (find-new-buffer-file-coding-system last-coding-system-used))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
823 (modified-p (buffer-modified-p)))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
824 (when coding-system
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
825 (set-buffer-file-coding-system coding-system)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
826 (if (or (eq coding-system 'no-conversion)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
827 (eq (coding-system-type coding-system) 5))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
828 ;; It seems that random 8-bit codes are read. We had
21023
bac070da6b6d (load-with-code-conversion):
Karl Heuer <kwzh@gnu.org>
parents: 20940
diff changeset
829 ;; better edit this buffer without multibyte characters.
20940
7c906916c8ae (after-insert-file-set-buffer-file-coding-system): Call set-buffer-multibyte
Kenichi Handa <handa@m17n.org>
parents: 20729
diff changeset
830 (set-buffer-multibyte nil))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
831 (set-buffer-modified-p modified-p))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
832 nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
833
21023
bac070da6b6d (load-with-code-conversion):
Karl Heuer <kwzh@gnu.org>
parents: 20940
diff changeset
834 (add-hook 'after-insert-file-functions
bac070da6b6d (load-with-code-conversion):
Karl Heuer <kwzh@gnu.org>
parents: 20940
diff changeset
835 'after-insert-file-set-buffer-file-coding-system)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
836
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
837 ;; The coding-spec and eol-type of coding-system returned is decided
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
838 ;; independently in the following order.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
839 ;; 1. That of buffer-file-coding-system locally bound.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
840 ;; 2. That of CODING.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
841
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
842 (defun find-new-buffer-file-coding-system (coding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
843 "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
844 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
845 is set to the returned value.
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
846 Return nil if there's no need of setting new buffer-file-coding-system."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
847 (let (local-coding local-eol
19948
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
848 found-coding found-eol
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
849 new-coding new-eol)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
850 (if (null coding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
851 ;; Nothing found about coding.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
852 nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
853
19948
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
854 ;; Get information of `buffer-file-coding-system' in LOCAL-EOL
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
855 ;; and LOCAL-CODING.
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
856 (setq local-eol (coding-system-eol-type buffer-file-coding-system))
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
857 (if (null (numberp local-eol))
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
858 ;; But eol-type is not yet set.
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
859 (setq local-eol nil))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
860 (if (and buffer-file-coding-system
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
861 (not (eq (coding-system-type buffer-file-coding-system) t)))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
862 ;; This is not `undecided'.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
863 (setq local-coding (coding-system-base buffer-file-coding-system)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
864
19948
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
865 (if (and (local-variable-p 'buffer-file-coding-system)
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
866 local-eol local-coding)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
867 ;; The current buffer has already set full coding-system, we
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
868 ;; had better not change it.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
869 nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
870
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
871 (setq found-eol (coding-system-eol-type coding))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
872 (if (null (numberp found-eol))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
873 ;; But eol-type is not found.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
874 (setq found-eol nil))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
875 (if (not (eq (coding-system-type coding) t))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
876 ;; This is not `undecided'.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
877 (setq found-coding (coding-system-base coding)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
878
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
879 ;; The local setting takes precedence over the found one.
19948
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
880 (setq new-coding (or (and (local-variable-p 'buffer-file-coding-system)
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
881 local-coding)
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
882 found-coding
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
883 local-coding))
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
884 (setq new-eol (or (and (local-variable-p 'buffer-file-coding-system)
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
885 local-eol)
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
886 found-eol
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
887 local-eol))
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
888 (when (numberp new-eol)
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
889 (or new-coding
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
890 (setq new-coding 'undecided))
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
891 (if (vectorp (coding-system-eol-type new-coding))
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
892 (setq new-coding
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
893 (aref (coding-system-eol-type new-coding) new-eol))))
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
894 ;; Return a new coding system only when it is different from
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
895 ;; the current one.
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
896 (if (not (eq buffer-file-coding-system new-coding))
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
897 new-coding)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
898
18874
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
899 (defun modify-coding-system-alist (target-type regexp coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
900 "Modify one of look up tables for finding a coding system on I/O operation.
18913
7333c3179621 (modify-coding-system-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18874
diff changeset
901 There are three of such tables, `file-coding-system-alist',
7333c3179621 (modify-coding-system-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18874
diff changeset
902 `process-coding-system-alist', and `network-coding-system-alist'.
18874
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
903
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
904 TARGET-TYPE specifies which of them to modify.
18913
7333c3179621 (modify-coding-system-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18874
diff changeset
905 If it is `file', it affects `file-coding-system-alist' (which see).
7333c3179621 (modify-coding-system-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18874
diff changeset
906 If it is `process', it affects `process-coding-system-alist' (which see).
7333c3179621 (modify-coding-system-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18874
diff changeset
907 If it is `network', it affects `network-codign-system-alist' (which see).
18874
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
908
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
909 REGEXP is a regular expression matching a target of I/O operation.
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
910 The target is a file name if TARGET-TYPE is `file', a program name if
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
911 TARGET-TYPE is `process', or a network service name or a port number
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
912 to connect to if TARGET-TYPE is `network'.
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
913
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
914 CODING-SYSTEM is a coding system to perform code conversion on the I/O
18913
7333c3179621 (modify-coding-system-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18874
diff changeset
915 operation, or a cons cell (DECODING . ENCODING) specifying the coding systems
7333c3179621 (modify-coding-system-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18874
diff changeset
916 for decoding and encoding respectively,
7333c3179621 (modify-coding-system-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18874
diff changeset
917 or a function symbol which, when called, returns such a cons cell."
18874
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
918 (or (memq target-type '(file process network))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
919 (error "Invalid target type: %s" target-type))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
920 (or (stringp regexp)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
921 (and (eq target-type 'network) (integerp regexp))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
922 (error "Invalid regular expression: %s" regexp))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
923 (if (symbolp coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
924 (if (not (fboundp coding-system))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
925 (progn
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
926 (check-coding-system coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
927 (setq coding-system (cons coding-system coding-system))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
928 (check-coding-system (car coding-system))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
929 (check-coding-system (cdr coding-system)))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
930 (cond ((eq target-type 'file)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
931 (let ((slot (assoc regexp file-coding-system-alist)))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
932 (if slot
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
933 (setcdr slot coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
934 (setq file-coding-system-alist
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
935 (cons (cons regexp coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
936 file-coding-system-alist)))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
937 ((eq target-type 'process)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
938 (let ((slot (assoc regexp process-coding-system-alist)))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
939 (if slot
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
940 (setcdr slot coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
941 (setq process-coding-system-alist
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
942 (cons (cons regexp coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
943 process-coding-system-alist)))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
944 (t
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
945 (let ((slot (assoc regexp network-coding-system-alist)))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
946 (if slot
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
947 (setcdr slot coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
948 (setq network-coding-system-alist
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
949 (cons (cons regexp coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
950 network-coding-system-alist)))))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
951
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
952 (defun make-unification-table (&rest args)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
953 "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
954 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
955 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
956
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
957 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
958 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
959 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
960 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
961 without changing their position code(s)."
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
962 (let ((table (make-char-table 'character-unification-table))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
963 revlist)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
964 (while args
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
965 (let ((elts (car args)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
966 (while elts
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
967 (let* ((from (car (car elts)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
968 (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
969 (from-rev (nreverse (split-char from)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
970 (to (cdr (car elts)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
971 (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
972 (to-rev (nreverse (split-char to))))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
973 ;; 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
974 (while (eq (car from-rev) 0)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
975 (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
976 (while (eq (car to-rev) 0)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
977 (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
978 (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
979 (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
980 ;; 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
981 ;; 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
982 ;; 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
983 ;; character.
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
984 (let ((to-alt (aref table to)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
985 (if (and to-alt
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
986 (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
987 (setq to to-alt)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
988 (if (> from-i 0)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
989 (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
990 (aset table from to))
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
991 ;; 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
992 ;; should also be unified to TO.
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
993 (let ((l (assq from revlist)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
994 (if l
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
995 (let ((ch (car l)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
996 (setcar l to)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
997 (setq l (cdr l))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
998 (while l
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
999 (aset table ch to)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1000 (setq l (cdr l)) ))))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1001 ;; Now update REVLIST.
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1002 (let ((l (assq to revlist)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1003 (if l
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1004 (setcdr l (cons from (cdr l)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1005 (setq revlist (cons (list to from) revlist)))))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1006 (setq elts (cdr elts))))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1007 (setq args (cdr args)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1008 ;; Return TABLE just created.
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1009 table))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1010
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1011 (defun define-character-unification-table (symbol &rest args)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1012 "define character unification table. This function call make-unification-table,
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1013 store a returned table to character-unification-table-vector.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1014 And then set the table as SYMBOL's unification-table property,
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1015 the index of the vector as SYMBOL's unification-table-id."
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1016 (let ((table (apply 'make-unification-table args))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1017 (len (length character-unification-table-vector))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1018 (id 0)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1019 slot)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1020 (or (symbolp symbol)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1021 (signal 'wrong-type-argument symbol))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1022 (put symbol 'unification-table table)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1023 (while (and (< id len)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1024 (if (consp (setq slot (aref character-unification-table-vector id)))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1025 (if (eq (car slot) symbol) nil t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1026 (aset character-unification-table-vector id (cons symbol table))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1027 nil))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1028 (setq id (1+ id)))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1029 (if (= id len)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1030 (progn
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1031 (setq character-unification-table-vector
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1032 (vconcat character-unification-table-vector (make-vector len nil)))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1033 (aset character-unification-table-vector id (cons symbol table))))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1034 (put symbol 'unification-table-id id)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1035 id))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1036
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1037
17094
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
1038 ;;; Initialize some variables.
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
1039
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
1040 (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
1041 (setq use-default-ascent (make-char-table 'use-default-ascent))
19263
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
1042 (put 'ignore-relative-composition 'char-table-extra-slots 0)
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
1043 (setq ignore-relative-composition
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
1044 (make-char-table 'ignore-relative-composition))
17094
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
1045
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
1046 ;;;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1047 (provide 'mule)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1048
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1049 ;;; mule.el ends here