annotate lisp/international/mule.el @ 19744:b1774d359a3d

(quail-update-translation): Do insert translated char when enable-multibyte-characters is nil.
author Richard M. Stallman <rms@gnu.org>
date Thu, 04 Sep 1997 04:47:34 +0000
parents f523227a99ab
children dec0b076a378
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)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 "Execute a file of Lisp code named FILE whose absolute path is FULLNAME.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35 The FILE is decoded before evaluation if necessary.
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.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 (let ((default-major-mode 'fundamental-mode))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 ;; We can't use `generate-new-buffer' because files.el
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 ;; is not yet loaded.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 (get-buffer-create (generate-new-buffer-name " *load*"))))
19395
cf115b0c7458 (make-coding-system): Add a new FLAGS
Richard M. Stallman <rms@gnu.org>
parents: 19263
diff changeset
52 (enable-multibyte-characters t)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53 (load-in-progress t))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 (or nomessage (message "Loading %s..." file))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 (unwind-protect
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 (set-buffer buffer)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 (insert-file-contents fullname)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 ;; We must set `buffer-file-name' for `eval-buffer' and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 ;; `load-history'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 (setq buffer-file-name file)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 ;; Make `kill-buffer' quiet.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 (set-buffer-modified-p nil))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 ;; Eval in the original buffer.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 (eval-buffer buffer))
18583
66e7a91e32ef (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 18558
diff changeset
67 (let (kill-buffer-hook kill-buffer-query-functions)
66e7a91e32ef (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 18558
diff changeset
68 (kill-buffer buffer)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 (let ((hook (assoc file after-load-alist)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 (if hook
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 (mapcar (function eval) (cdr hook))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 (or nomessage noninteractive
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 (message "Loading %s...done" file))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 t)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76 ;; API (Application Program Interface) for charsets.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78 ;; Return t if OBJ is a quoted symbol.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79 (defsubst quoted-symbol-p (obj)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80 (and (listp obj) (eq (car obj) 'quote)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82 (defsubst charsetp (object)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83 "T is OBJECT is a charset."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84 (and (symbolp object) (vectorp (get object 'charset))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
85
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 (defsubst charset-info (charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87 "Return a vector of information of CHARSET.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 The elements of the vector are:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90 LEADING-CODE-BASE, LEADING-CODE-EXT,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 PLIST,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 where
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 CHARSET-ID (integer) is the identification number of the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 DIMENSION (integer) is the number of bytes to represent a character of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 the charset: 1 or 2.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 CHARS (integer) is the number of characters in a dimension: 94 or 96.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99 BYTE (integer) is the length of multi-byte form of a character in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 the charset: one of 1, 2, 3, and 4.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 WIDTH (integer) is the number of columns a character in the charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 occupies on the screen: one of 0, 1, and 2.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 DIRECTION (integer) is the rendering direction of characters in the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 charset when rendering. If 0, render from right to left, else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 render from left to right.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106 LEADING-CODE-BASE (integer) is the base leading-code for the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108 LEADING-CODE-EXT (integer) is the extended leading-code for the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109 charset. All charsets of less than 0xA0 has the value 0.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
110 ISO-FINAL-CHAR (character) is the final character of the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111 corresponding ISO 2022 charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112 ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113 while encoding to variants of ISO 2022 coding system, one of the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 REVERSE-CHARSET (integer) is the charset which differs only in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116 LEFT-TO-RIGHT value from the charset. If there's no such a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117 charset, the value is -1.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118 SHORT-NAME (string) is the short name to refer to the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 LONG-NAME (string) is the long name to refer to the charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120 DESCRIPTION (string) is the description string of the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 PLIST (property list) may contain any type of information a user
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 want to put and get by functions `put-charset-property' and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123 `get-charset-property' respectively."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124 (get charset 'charset))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 (defmacro charset-id (charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 "Return charset identification number of CHARSET."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 (if (and (listp charset) (eq (car charset) 'quote))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 (aref (charset-info (nth 1 charset)) 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 `(aref (charset-info ,charset) 0)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 (defmacro charset-bytes (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
133 "Return bytes of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
134 See the function `charset-info' for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 (if (quoted-symbol-p charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 (aref (charset-info (nth 1 charset)) 1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 `(aref (charset-info ,charset) 1)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 (defmacro charset-dimension (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
140 "Return dimension of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
141 See the function `charset-info' for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 (if (quoted-symbol-p charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 (aref (charset-info (nth 1 charset)) 2)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 `(aref (charset-info ,charset) 2)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 (defmacro charset-chars (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
147 "Return character numbers contained in a dimension of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
148 See the function `charset-info' for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 (if (quoted-symbol-p charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 (aref (charset-info (nth 1 charset)) 3)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 `(aref (charset-info ,charset) 3)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 (defmacro charset-width (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
154 "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
155 See the function `charset-info' for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 (if (quoted-symbol-p charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 (aref (charset-info (nth 1 charset)) 4)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 `(aref (charset-info ,charset) 4)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 (defmacro charset-direction (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
161 "Return direction of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
162 See the function `charset-info' for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 (if (quoted-symbol-p charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 (aref (charset-info (nth 1 charset)) 5)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 `(aref (charset-info ,charset) 5)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 (defmacro charset-iso-final-char (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
168 "Return final char of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
169 See the function `charset-info' for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 (if (quoted-symbol-p charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 (aref (charset-info (nth 1 charset)) 8)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172 `(aref (charset-info ,charset) 8)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 (defmacro charset-iso-graphic-plane (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
175 "Return graphic plane of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
176 See the function `charset-info' for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 (if (quoted-symbol-p charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 (aref (charset-info (nth 1 charset)) 9)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 `(aref (charset-info ,charset) 9)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 (defmacro charset-reverse-charset (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
182 "Return reverse charset of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
183 See the function `charset-info' for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 (if (quoted-symbol-p charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185 (aref (charset-info (nth 1 charset)) 10)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
186 `(aref (charset-info ,charset) 10)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188 (defmacro charset-short-name (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
189 "Return short name of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
190 See the function `charset-info' for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 (if (quoted-symbol-p charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192 (aref (charset-info (nth 1 charset)) 11)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
193 `(aref (charset-info ,charset) 11)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195 (defmacro charset-long-name (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
196 "Return long name of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
197 See the function `charset-info' for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198 (if (quoted-symbol-p charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
199 (aref (charset-info (nth 1 charset)) 12)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200 `(aref (charset-info ,charset) 12)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
202 (defmacro charset-description (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
203 "Return descriptoin of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
204 See the function `charset-info' for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
205 (if (quoted-symbol-p charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
206 (aref (charset-info (nth 1 charset)) 13)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
207 `(aref (charset-info ,charset) 13)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
209 (defmacro charset-plist (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
210 "Return list charset property of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
211 See the function `charset-info' for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212 (if (quoted-symbol-p charset)
17175
3e54eb2d2a57 (make-char): Documented.
Kenichi Handa <handa@m17n.org>
parents: 17094
diff changeset
213 `(aref ,(charset-info (nth 1 charset)) 14)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
214 `(aref (charset-info ,charset) 14)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
215
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
216 (defun set-charset-plist (charset plist)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
217 "Set CHARSET's property list to PLIST, and retrun PLIST."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 (aset (charset-info charset) 14 plist))
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 make-char (charset &optional c1 c2)
17175
3e54eb2d2a57 (make-char): Documented.
Kenichi Handa <handa@m17n.org>
parents: 17094
diff changeset
221 "Return a character of CHARSET and position-codes CODE1 and CODE2.
3e54eb2d2a57 (make-char): Documented.
Kenichi Handa <handa@m17n.org>
parents: 17094
diff changeset
222 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
223 sufficient position-codes, return a generic character which stands for
17175
3e54eb2d2a57 (make-char): Documented.
Kenichi Handa <handa@m17n.org>
parents: 17094
diff changeset
224 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
225 A generic character can be used to index a char table (e.g. syntax-table)."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
226 (if (quoted-symbol-p charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
227 `(make-char-internal ,(charset-id (nth 1 charset)) ,c1 ,c2)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
228 `(make-char-internal (charset-id ,charset) ,c1 ,c2)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229
17094
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
230 (defmacro charset-list ()
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
231 "Return list of charsets ever defined.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
232
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
233 This macro is provided for backward compatibility.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
234 Now we have the variable `charset-list'."
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
235 'charset-list)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
236
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
237 (defsubst generic-char-p (char)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
238 "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
239 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
240 (let ((l (split-char char)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
241 (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
242 (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
243
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
244 ;; Coding system staffs
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
245
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
246 ;; Coding system is a symbol that has the property `coding-system'.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
247 ;;
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
248 ;; 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
249 ;; following format:
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
250 ;; [TYPE MNEMONIC DOC-STRING NOT-USED-NOW FLAGS]
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
251 ;; We call this vector as coding-spec. See comments in src/coding.c
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
252 ;; for more detail. The property value may be another coding system,
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
253 ;; in which case, the coding-spec should be taken from that
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
254 ;; coding-system. The 4th element NOT-USED-NOW is kept just for
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
255 ;; backward compatibility with old version of Mule.
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
256
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
257 (defconst coding-spec-type-idx 0)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
258 (defconst coding-spec-mnemonic-idx 1)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
259 (defconst coding-spec-doc-string-idx 2)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
260 (defconst coding-spec-flags-idx 4)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
261
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
262 ;; Coding system may have proerpty `eol-type'. The value of the
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
263 ;; property `eol-type' is integer 0..2 or a vector of three coding
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
264 ;; systems. The integer value 0, 1, and 2 indicate the format of
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
265 ;; end-of-line LF, CRLF, and CR respectively. The vector value
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
266 ;; indicates that the format of end-of-line should be detected
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
267 ;; automatically. Nth element of the vector is the subsidiary coding
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
268 ;; system whose `eol-type' property is N.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
269 ;;
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
270 ;; Coding system may also have properties `post-read-conversion' and
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
271 ;; `pre-write-conversion. Values of these properties are functions.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
272 ;;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
273 ;; The function in `post-read-conversion' is called after some text is
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
274 ;; inserted and decoded along the coding system and before any
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
275 ;; functions in `after-insert-functions' are called. The arguments to
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276 ;; this function is the same as those of a function in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
277 ;; `after-insert-functions', i.e. LENGTH of a text while putting point
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278 ;; at the head of the text to be decoded
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
279 ;;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
280 ;; The function in `pre-write-conversion' is called after all
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281 ;; functions in `write-region-annotate-functions' and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
282 ;; `buffer-file-format' are called, and before the text is encoded by
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
283 ;; the coding system. The arguments to this function is the same as
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
284 ;; those of a function in `write-region-annotate-functions', i.e. FROM
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
285 ;; and TO specifying region of a text.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
286
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
287 ;; Return Nth element of coding-spec of CODING-SYSTEM.
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
288 (defun coding-system-spec-ref (coding-system n)
17094
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
289 (check-coding-system coding-system)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
290 (let ((vec (coding-system-spec coding-system)))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
291 (and vec (aref vec n))))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
292
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
293 (defun coding-system-type (coding-system)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
294 "Return TYPE element in coding-spec of CODING-SYSTEM."
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
295 (coding-system-spec-ref coding-system coding-spec-type-idx))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
297 (defun coding-system-mnemonic (coding-system)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
298 "Return MNEMONIC element in coding-spec of CODING-SYSTEM."
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
299 (or (coding-system-spec-ref coding-system coding-spec-mnemonic-idx)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
300 ?-))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
302 (defun coding-system-doc-string (coding-system)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
303 "Return DOC-STRING element in coding-spec of CODING-SYSTEM."
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
304 (coding-system-spec-ref coding-system coding-spec-doc-string-idx))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
305
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 (defun coding-system-flags (coding-system)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
307 "Return FLAGS element in coding-spec of CODING-SYSTEM."
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
308 (coding-system-spec-ref coding-system coding-spec-flags-idx))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
310 (defun coding-system-eol-type (coding-system)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
311 "Return eol-type property of CODING-SYSTEM."
17094
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
312 (check-coding-system coding-system)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
313 (and coding-system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
314 (or (get coding-system 'eol-type)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
315 (coding-system-eol-type (get coding-system 'coding-system)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
316
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
317 (defun coding-system-category (coding-system)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
318 "Return coding category of CODING-SYSTEM."
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
319 (and coding-system
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
320 (symbolp coding-system)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
321 (or (get coding-system 'coding-category)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
322 (coding-system-category (get coding-system 'coding-system)))))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
323
18312
705da3ce58c0 (coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 18298
diff changeset
324 (defun coding-system-parent (coding-system)
705da3ce58c0 (coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 18298
diff changeset
325 "Return parent of CODING-SYSTEM."
705da3ce58c0 (coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 18298
diff changeset
326 (let ((parent (get coding-system 'parent-coding-system)))
705da3ce58c0 (coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 18298
diff changeset
327 (and parent
705da3ce58c0 (coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 18298
diff changeset
328 (or (coding-system-parent parent)
705da3ce58c0 (coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 18298
diff changeset
329 parent))))
705da3ce58c0 (coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 18298
diff changeset
330
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
331 ;; 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
332 (defun make-subsidiary-coding-system (coding-system)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
333 (let ((subsidiaries (vector (intern (format "%s-unix" coding-system))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
334 (intern (format "%s-dos" coding-system))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
335 (intern (format "%s-mac" coding-system))))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
336 (i 0))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
337 (while (< i 3)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
338 (put (aref subsidiaries i) 'coding-system coding-system)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
339 (put (aref subsidiaries i) 'eol-type i)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
340 (put (aref subsidiaries i) 'eol-variant t)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
341 (setq i (1+ i)))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
342 subsidiaries))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
344 (defun make-coding-system (coding-system type mnemonic doc-string
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
345 &optional flags)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 "Define a new CODING-SYSTEM (symbol).
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
347 Remaining arguments are TYPE, MNEMONIC, DOC-STRING, and FLAGS (optional) which
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
348 construct a coding-spec of CODING-SYSTEM in the following format:
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
349 [TYPE MNEMONIC DOC-STRING nil FLAGS]
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350 TYPE is an integer value indicating the type of coding-system as follows:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351 0: Emacs internal format,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 1: Shift-JIS (or MS-Kanji) used mainly on Japanese PC,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353 2: ISO-2022 including many variants,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354 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
355 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
356 5: Raw-text, which means that text contains random 8-bit codes.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
357 MNEMONIC is a character to be displayed on mode line for the coding-system.
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
358 DOC-STRING is a documentation string for the coding-system.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359 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
360
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361 If TYPE is 2 (ISO-2022), FLAGS should be a list of:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362 CHARSET0, CHARSET1, CHARSET2, CHARSET3, SHORT-FORM,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363 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
364 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
365 SAFE, ACCEPT-LATIN-EXTRA-CODE.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366 CHARSETn are character sets initially designated to Gn graphic registers.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367 If CHARSETn is nil, Gn is never used.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
368 If CHARSETn is t, Gn can be used but nothing designated initially.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
369 If CHARSETn is a list of character sets, those character sets are
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
370 designated to Gn on output, but nothing designated to Gn initially.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
371 SHORT-FORM non-nil means use short designation sequence on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
372 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
373 ASCII-CNTL non-nil means designate ASCII to g0 before control codes and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
374 SPACE on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
375 SEVEN non-nil means use 7-bit code only on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376 LOCKING-SHIFT non-nil means use locking-shift.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
377 SINGLE-SHIFT non-nil means use single-shift.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
378 USE-ROMAN non-nil means designate JIS0201-1976-Roman instead of ASCII.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
379 USE-OLDJIS non-nil means designate JIS0208-1976 instead of JIS0208-1983.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
380 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
381 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
382 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
383 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
384 at beginning of line on output.
19263
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
385 SAFE non-nil means convert unexpected characters to `?' on output.
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
386 Unexpected characters are what not specified in CHARSETn directly.
19395
cf115b0c7458 (make-coding-system): Add a new FLAGS
Richard M. Stallman <rms@gnu.org>
parents: 19263
diff changeset
387 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
388 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
389 code of the coding system.
19263
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
390
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391 If TYPE is 4 (private), FLAGS should be a cons of CCL programs,
19454
5a08bc0f02d3 (make-coding-system): Doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 19395
diff changeset
392 for decoding and encoding. See the documentation of CCL for more detail."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
393
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394 ;; At first, set a value of `coding-system' property.
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
395 (let ((coding-spec (make-vector 5 nil))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
396 coding-category)
19606
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
397 (if (or (not (integerp type)) (< type 0) (> type 5))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
398 (error "TYPE argument must be 0..4"))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
399 (if (or (not (integerp mnemonic)) (<= mnemonic ? ) (> mnemonic 127))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
400 (error "MNEMONIC arguemnt must be a printable character."))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
401 (aset coding-spec 0 type)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
402 (aset coding-spec 1 mnemonic)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
403 (aset coding-spec 2 (if (stringp doc-string) doc-string ""))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
404 (aset coding-spec 3 nil) ; obsolete element
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
405 (cond ((= type 0)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
406 (setq coding-category 'coding-category-emacs-mule))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
407 ((= type 1)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
408 (setq coding-category 'coding-category-sjis))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
409 ((= type 2) ; ISO2022
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
410 (let ((i 0)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
411 (vec (make-vector 32 nil))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
412 (no-initial-designation t)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
413 (g1-designation nil))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
414 (while (< i 4)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
415 (let ((charset (car flags)))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
416 (if (and no-initial-designation
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
417 (> i 0)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
418 (or (charsetp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
419 (and (consp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
420 (charsetp (car charset)))))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
421 (setq no-initial-designation nil))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
422 (if (charsetp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
423 (if (= i 1) (setq g1-designation charset))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
424 (if (consp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
425 (let ((tail charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
426 elt)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
427 (while tail
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
428 (setq elt (car tail))
17094
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
429 (or (not elt) (eq elt t) (charsetp elt)
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
430 (error "Invalid charset: %s" elt))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
431 (setq tail (cdr tail)))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
432 (setq g1-designation (car charset)))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
433 (if (and charset (not (eq charset t)))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
434 (error "Invalid charset: %s" charset))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
435 (aset vec i charset))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
436 (setq flags (cdr flags) i (1+ i)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
437 (while (and (< i 32) flags)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
438 (aset vec i (car flags))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
439 (setq flags (cdr flags) i (1+ i)))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
440 (aset coding-spec 4 vec)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
441 (if no-initial-designation
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
442 (put coding-system 'no-initial-designation t))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
443 (setq coding-category
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
444 (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
445 (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
446 'coding-category-iso-8-else)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
447 (if (aref vec 7) ; 7-bit only.
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
448 (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
449 'coding-category-iso-7-else
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
450 'coding-category-iso-7)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
451 (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
452 'coding-category-iso-8-else
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
453 (if (and (charsetp g1-designation)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
454 (= (charset-dimension g1-designation) 2))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
455 'coding-category-iso-8-2
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
456 'coding-category-iso-8-1)))))))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
457 ((= type 3)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
458 (setq coding-category 'coding-category-big5))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
459 ((= type 4) ; private
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
460 (setq coding-category 'coding-category-binary)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
461 (if (and (consp flags)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
462 (vectorp (car flags))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
463 (vectorp (cdr flags)))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
464 (aset coding-spec 4 flags)
19606
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
465 (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
466 (t ; i.e. (= type 5)
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
467 (setq coding-category 'coding-category-raw-text)))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
468 (put coding-system 'coding-system coding-spec)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
469 (put coding-system 'coding-category coding-category)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
470 (put coding-category 'coding-systems
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
471 (cons coding-system (get coding-category 'coding-systems))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
472
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
473 ;; 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
474 ;; of subsidiary coding systems, each corresponds to a coding system
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
475 ;; 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
476 (put coding-system 'eol-type
19606
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
477 (if (or (<= type 3) (= type 5))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
478 (make-subsidiary-coding-system coding-system)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
479 0)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
480
18518
425c8fa4227b (define-coding-system-alias): Swap the args.
Richard M. Stallman <rms@gnu.org>
parents: 18457
diff changeset
481 (defun define-coding-system-alias (alias coding-system)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
482 "Define ALIAS as an alias for coding system CODING-SYSTEM."
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
483 (check-coding-system coding-system)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
484 (let ((parent (coding-system-parent coding-system)))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
485 (if parent
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
486 (setq coding-system parent)))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
487 (put alias 'coding-system coding-system)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
488 (put alias 'parent-coding-system coding-system)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
489 (put coding-system 'alias-coding-systems
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
490 (cons alias (get coding-system 'alias-coding-systems)))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
491 (let ((eol-variants (coding-system-eol-type coding-system))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
492 subsidiaries)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
493 (if (vectorp eol-variants)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
494 (let ((i 0))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
495 (setq subsidiaries (make-subsidiary-coding-system alias))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
496 (while (< i 3)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
497 (put (aref subsidiaries i) 'parent-coding-system
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
498 (aref eol-variants i))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
499 (put (aref eol-variants i) 'alias-coding-systems
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
500 (cons (aref subsidiaries i) (get (aref eol-variants i)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
501 'alias-coding-systems)))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
502 (setq i (1+ i)))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
503
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
504 (defun set-buffer-file-coding-system (coding-system &optional force)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
505 "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
506 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
507 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
508 use \\[list-coding-systems].
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
509
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
510 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
511 conversion, and CODING-SYSTEM does not specify one, CODING-SYSTEM is
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
512 merged with the already-specified end-of-line conversion.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
513 However, if the optional prefix argument FORCE is non-nil,
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
514 them CODING-SYSTEM is used exactly as specified."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
515 (interactive "zBuffer-file-coding-system: \nP")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
516 (check-coding-system coding-system)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
517 (if (null force)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
518 (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
519 (y (coding-system-eol-type coding-system)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
520 (if (and (numberp x) (>= x 0) (<= x 2) (vectorp y))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
521 (setq coding-system (aref y x)))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
522 (setq buffer-file-coding-system coding-system)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
523 (set-buffer-modified-p t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
524 (force-mode-line-update))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
525
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
526 (defvar default-terminal-coding-system nil
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
527 "Default value for the terminal coding system.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
528 This is normally set according to the selected language environment.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
529 See also the command `set-terminal-coding-system'.")
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
530
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
531 (defun set-terminal-coding-system (coding-system)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
532 "Set coding system of your terminal to CODING-SYSTEM.
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
533 All text output to the terminal will be encoded
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
534 with the specified coding system.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
535 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
536 The default is determined by the selected language environment
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
537 or by the previous use of this command."
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
538 (interactive
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
539 (list (read-coding-system
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
540 (format "Coding system for terminal display (default, %s): "
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
541 (if (and (not (terminal-coding-system))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
542 default-terminal-coding-system)
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
543 default-terminal-coding-system)))))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
544 (if (and (not coding-system)
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
545 (not (terminal-coding-system)))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
546 (setq coding-system default-terminal-coding-system))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
547 (if coding-system
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
548 (setq default-terminal-coding-system coding-system))
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
549 (set-terminal-coding-system-internal coding-system)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
550 (redraw-frame (selected-frame)))
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
551
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
552 (defvar default-keyboard-coding-system nil
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
553 "Default value of the keyboard coding system.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
554 This is normally set according to the selected language environment.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
555 See also the command `set-keyboard-coding-system'.")
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
556
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
557 (defun set-keyboard-coding-system (coding-system)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
558 "Set coding system for keyboard input to CODING-SYSTEM.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
559 In addition, this command enables Encoded-kbd minor mode.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
560 \(If CODING-SYSTEM is nil, Encoded-bkd mode is turned off.)
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
561 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
562 The default is determined by the selected language environment
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
563 or by the previous use of this command."
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
564 (interactive
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
565 (list (read-coding-system
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
566 (format "Coding system for keyboard input (default, %s): "
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
567 (if (and (not (keyboard-coding-system))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
568 default-keyboard-coding-system)
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
569 default-keyboard-coding-system)))))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
570 (if (and (not coding-system)
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
571 (not (keyboard-coding-system)))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
572 (setq coding-system default-keyboard-coding-system))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
573 (if coding-system
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
574 (setq default-keyboard-coding-system coding-system))
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
575 (set-keyboard-coding-system-internal coding-system)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
576 (encoded-kbd-mode (if coding-system 1 0)))
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
577
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
578 (defun set-buffer-process-coding-system (decoding encoding)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
579 "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
580 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
581 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
582
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
583 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
584 (interactive
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
585 "zCoding-system for process input: \nzCoding-system for process output: ")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
586 (let ((proc (get-buffer-process (current-buffer))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
587 (if (null proc)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
588 (error "no process")
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
589 (check-coding-system decoding)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
590 (check-coding-system encoding)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
591 (set-process-coding-system proc decoding encoding)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
592 (force-mode-line-update))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
593
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
594 (defun set-coding-priority (arg)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
595 "Set priority of coding-category according to LIST.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
596 LIST is a list of coding-categories ordered by priority."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
597 (let (l)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
598 ;; Put coding-categories listed in ARG to L while checking the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
599 ;; validity. We assume that `coding-category-list' contains whole
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
600 ;; coding-categories.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
601 (while arg
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
602 (if (null (memq (car arg) coding-category-list))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
603 (error "Invalid element in argument: %s" (car arg)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
604 (setq l (cons (car arg) l))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
605 (setq arg (cdr arg)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
606 ;; Put coding-category not listed in ARG to L.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
607 (while coding-category-list
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
608 (if (null (memq (car coding-category-list) l))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
609 (setq l (cons (car coding-category-list) l)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
610 (setq coding-category-list (cdr coding-category-list)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
611 ;; Update `coding-category-list' and return it.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
612 (setq coding-category-list (nreverse l))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
613
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
614 ;;; FILE I/O
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
615
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
616 (defun set-auto-coding (string)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
617 "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
618 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
619 the last 3K-byte of the file.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
620
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
621 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
622 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
623 in the tailing 3K-byte oof STRING.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
624
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
625 The return value is the specified coding system,
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
626 or nil if nothing specified.
19454
5a08bc0f02d3 (make-coding-system): Doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 19395
diff changeset
627
5a08bc0f02d3 (make-coding-system): Doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 19395
diff changeset
628 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
629 function by default."
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
630 (condition-case nil
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
631 (let ((case-fold-search t)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
632 (len (length string))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
633 (limit (string-match "\n" string))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
634 (coding-system nil))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
635
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
636 ;; At first check the head.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
637 (if limit
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
638 (when (string-match "^#!" string)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
639 ;; If the file begins with "#!" (exec interpreter
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
640 ;; 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
641 ;; 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
642 ;; such a file without screwing up the interpreter
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
643 ;; invocation.
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
644 (setq limit (string-match "\n" string limit))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
645 (or limit
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
646 (setq limit len)))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
647 (setq limit len))
19665
f523227a99ab (set-auto-coding): Recognize coding: in first
Richard M. Stallman <rms@gnu.org>
parents: 19648
diff changeset
648 (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
649 (< (match-beginning 2) limit))
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
650 (setq coding-system
19665
f523227a99ab (set-auto-coding): Recognize coding: in first
Richard M. Stallman <rms@gnu.org>
parents: 19648
diff changeset
651 (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
652 (if (not (coding-system-p coding-system))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
653 (setq coding-system nil)))
19454
5a08bc0f02d3 (make-coding-system): Doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 19395
diff changeset
654
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
655 ;; 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
656 (when (and (not coding-system)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
657 (let ((idx (if (> len 3000) (- len 3000) 0))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
658 start)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
659 (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
660 (setq idx (+ start 2)))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
661 (string-match
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
662 "^\\(.*\\)[ \t]*Local Variables:[ \t]*\\(.*\\)$"
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
663 string idx)))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
664 ;; 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
665 ;; 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
666 (let* ((idx (1+ (match-end 0)))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
667 (prefix (regexp-quote
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
668 (substring string
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
669 (match-beginning 1) (match-end 1))))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
670 (suffix (regexp-quote
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
671 (substring string
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
672 (match-beginning 2) (match-end 2))))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
673 (re-coding (concat "^" prefix
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
674 "coding[ \t]*:[ \t]*\\([^ \t]+\\)[ \t]*"
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
675 suffix "$"))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
676 (re-end (concat "^" prefix "end *:[ \t]*" suffix "$"))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
677 (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
678 (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
679 (< idx limit))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
680 (setq coding-system
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
681 (intern (substring string
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
682 (match-beginning 1) (match-end 1))))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
683 (or (coding-system-p coding-system)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
684 (setq coding-system nil)))))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
685
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
686 coding-system)
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
687 (error nil)))
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
688
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
689 (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
690
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
691 ;; Set buffer-file-coding-system of the current buffer after some text
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
692 ;; is inserted.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
693 (defun after-insert-file-set-buffer-file-coding-system (inserted)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
694 (if last-coding-system-used
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
695 (let ((coding-system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
696 (find-new-buffer-file-coding-system last-coding-system-used))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
697 (modified-p (buffer-modified-p)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
698 (if coding-system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
699 (set-buffer-file-coding-system coding-system))
19606
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
700 (if (or (eq coding-system 'no-conversion)
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
701 (eq (coding-system-type coding-system) 5))
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
702 ;; It seems that random 8-bit codes are read. We had
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
703 ;; better edit this buffer without multibyte character
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
704 ;; facility.
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
705 (setq enable-multibyte-characters nil))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
706 (set-buffer-modified-p modified-p)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
707 nil)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
708
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
709 (setq after-insert-file-functions
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
710 (cons 'after-insert-file-set-buffer-file-coding-system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
711 after-insert-file-functions))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
712
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
713 ;; The coding-spec and eol-type of coding-system returned is decided
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
714 ;; independently in the following order.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
715 ;; 1. That of buffer-file-coding-system locally bound.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
716 ;; 2. That of CODING.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
717
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
718 (defun find-new-buffer-file-coding-system (coding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
719 "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
720 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
721 is set to the returned value.
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
722 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
723 (let (local-coding local-eol
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
724 found-eol
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
725 new-coding new-eol)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
726 (if (null coding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
727 ;; Nothing found about coding.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
728 nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
729
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
730 ;; Get information of the current local value of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
731 ;; `buffer-file-coding-system' in LOCAL-EOL and LOCAL-CODING.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
732 (if (local-variable-p 'buffer-file-coding-system)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
733 ;; Something already set locally.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
734 (progn
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
735 (setq local-eol (coding-system-eol-type buffer-file-coding-system))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
736 (if (null (numberp local-eol))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
737 ;; But eol-type is not yet set.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
738 (setq local-eol nil))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
739 (if (null (eq (coding-system-type buffer-file-coding-system) t))
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
740 ;; This is not `undecided'.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
741 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
742 (setq local-coding buffer-file-coding-system)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
743 (while (symbolp (get local-coding 'coding-system))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
744 (setq local-coding (get local-coding 'coding-system))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
745 )))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
746
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
747 (if (and local-eol local-coding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
748 ;; The current buffer has already set full coding-system, we
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
749 ;; had better not change it.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
750 nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
751
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
752 (setq found-eol (coding-system-eol-type coding))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
753 (if (null (numberp found-eol))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
754 ;; But eol-type is not found.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
755 (setq found-eol nil))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
756
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
757 ;; The local setting takes precedence over the found one.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
758 (setq new-coding (or local-coding coding))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
759 (setq new-eol (or local-eol found-eol))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
760 (if (and (numberp new-eol)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
761 (vectorp (coding-system-eol-type new-coding)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
762 (setq new-coding
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
763 (aref (coding-system-eol-type new-coding) new-eol)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
764 new-coding))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
765
18874
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
766 (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
767 "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
768 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
769 `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
770
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
771 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
772 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
773 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
774 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
775
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
776 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
777 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
778 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
779 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
780
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
781 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
782 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
783 for decoding and encoding respectively,
7333c3179621 (modify-coding-system-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18874
diff changeset
784 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
785 (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
786 (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
787 (or (stringp regexp)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
788 (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
789 (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
790 (if (symbolp coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
791 (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
792 (progn
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
793 (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
794 (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
795 (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
796 (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
797 (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
798 (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
799 (if slot
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
800 (setcdr slot coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
801 (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
802 (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
803 file-coding-system-alist)))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
804 ((eq target-type 'process)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
805 (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
806 (if slot
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
807 (setcdr slot coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
808 (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
809 (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
810 process-coding-system-alist)))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
811 (t
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
812 (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
813 (if slot
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
814 (setcdr slot coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
815 (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
816 (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
817 network-coding-system-alist)))))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
818
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
819 (defun make-unification-table (&rest args)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
820 "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
821 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
822 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
823
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
824 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
825 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
826 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
827 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
828 without changing their position code(s)."
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
829 (let ((table (make-char-table 'character-unification-table))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
830 revlist)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
831 (while args
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
832 (let ((elts (car args)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
833 (while elts
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
834 (let* ((from (car (car elts)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
835 (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
836 (from-rev (nreverse (split-char from)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
837 (to (cdr (car elts)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
838 (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
839 (to-rev (nreverse (split-char to))))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
840 ;; 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
841 (while (eq (car from-rev) 0)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
842 (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
843 (while (eq (car to-rev) 0)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
844 (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
845 (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
846 (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
847 ;; 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
848 ;; 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
849 ;; 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
850 ;; character.
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
851 (let ((to-alt (aref table to)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
852 (if (and to-alt
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
853 (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
854 (setq to to-alt)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
855 (if (> from-i 0)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
856 (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
857 (aset table from to))
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
858 ;; 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
859 ;; should also be unified to TO.
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
860 (let ((l (assq from revlist)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
861 (if l
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
862 (let ((ch (car l)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
863 (setcar l to)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
864 (setq l (cdr l))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
865 (while l
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
866 (aset table ch to)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
867 (setq l (cdr l)) ))))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
868 ;; Now update REVLIST.
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
869 (let ((l (assq to revlist)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
870 (if l
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
871 (setcdr l (cons from (cdr l)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
872 (setq revlist (cons (list to from) revlist)))))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
873 (setq elts (cdr elts))))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
874 (setq args (cdr args)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
875 ;; Return TABLE just created.
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
876 table))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
877
17094
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
878 ;;; Initialize some variables.
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
879
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
880 (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
881 (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
882 (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
883 (setq ignore-relative-composition
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
884 (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
885
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
886 ;;;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
887 (provide 'mule)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
888
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
889 ;;; mule.el ends here