annotate lisp/international/mule.el @ 33426:62b21497a99f

(flyspell-mode-on): Only output welcome message if interactive.
author Miles Bader <miles@gnu.org>
date Sun, 12 Nov 2000 13:23:23 +0000
parents 9366a16a186b
children 9cbbc1edaba0
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
29692
f79efb8debd9 (mule-version): Change version name to SAKAKI. AOI has already been
Kenichi Handa <handa@m17n.org>
parents: 29659
diff changeset
27 (defconst mule-version "5.0 (SAKAKI)" "\
17052
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
26887
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
30 (defconst mule-version-date "1999.12.7" "\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31 Distribution date of this version of MULE (multilingual environment).")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 (defun load-with-code-conversion (fullname file &optional noerror nomessage)
20405
faf18d58a01b (load-with-code-conversion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20168
diff changeset
34 "Execute a file of Lisp code named FILE whose absolute name is FULLNAME.
faf18d58a01b (load-with-code-conversion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20168
diff changeset
35 The file contents are decoded before evaluation if necessary.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 If optional second arg NOERROR is non-nil,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 report no error if FILE doesn't exist.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 Print messages at start and end of loading unless
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 optional third arg NOMESSAGE is non-nil.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 Return t if file exists."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 (if (null (file-readable-p fullname))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 (and (null noerror)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 (signal 'file-error (list "Cannot open load file" file)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 ;; Read file with code conversion, and then eval.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 (let* ((buffer
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 ;; To avoid any autoloading, set default-major-mode to
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 ;; fundamental-mode.
21675
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
48 ;; So that we don't get completely screwed if the
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
49 ;; file is encoded in some complicated character set,
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
50 ;; read it with real decoding, as a multibyte buffer,
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
51 ;; even if this is a --unibyte Emacs session.
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
52 (let ((default-major-mode 'fundamental-mode)
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
53 (default-enable-multibyte-characters t))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 ;; We can't use `generate-new-buffer' because files.el
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 ;; is not yet loaded.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 (get-buffer-create (generate-new-buffer-name " *load*"))))
20168
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
57 (load-in-progress t)
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
58 (source (save-match-data (string-match "\\.el\\'" fullname))))
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
59 (unless nomessage
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
60 (if source
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
61 (message "Loading %s (source)..." file)
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
62 (message "Loading %s..." file)))
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
63 (when purify-flag
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
64 (setq preloaded-file-list (cons file preloaded-file-list)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 (unwind-protect
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
66 (let ((load-file-name fullname)
22699
754703e243e6 (set-auto-coding-for-load): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22654
diff changeset
67 (set-auto-coding-for-load t)
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
68 (inhibit-file-name-operation nil))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 (set-buffer buffer)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 (insert-file-contents fullname)
23860
2ce75856e89f (load-with-code-conversion): If the loaded
Eli Zaretskii <eliz@gnu.org>
parents: 23770
diff changeset
72 ;; If the loaded file was inserted with no-conversion or
2ce75856e89f (load-with-code-conversion): If the loaded
Eli Zaretskii <eliz@gnu.org>
parents: 23770
diff changeset
73 ;; raw-text coding system, make the buffer unibyte.
2ce75856e89f (load-with-code-conversion): If the loaded
Eli Zaretskii <eliz@gnu.org>
parents: 23770
diff changeset
74 ;; Otherwise, eval-buffer might try to interpret random
2ce75856e89f (load-with-code-conversion): If the loaded
Eli Zaretskii <eliz@gnu.org>
parents: 23770
diff changeset
75 ;; binary junk as multibyte characters.
2ce75856e89f (load-with-code-conversion): If the loaded
Eli Zaretskii <eliz@gnu.org>
parents: 23770
diff changeset
76 (if (and enable-multibyte-characters
2ce75856e89f (load-with-code-conversion): If the loaded
Eli Zaretskii <eliz@gnu.org>
parents: 23770
diff changeset
77 (or (eq (coding-system-type last-coding-system-used) 5)
2ce75856e89f (load-with-code-conversion): If the loaded
Eli Zaretskii <eliz@gnu.org>
parents: 23770
diff changeset
78 (eq last-coding-system-used 'no-conversion)))
2ce75856e89f (load-with-code-conversion): If the loaded
Eli Zaretskii <eliz@gnu.org>
parents: 23770
diff changeset
79 (set-buffer-multibyte nil))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80 ;; Make `kill-buffer' quiet.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 (set-buffer-modified-p nil))
20405
faf18d58a01b (load-with-code-conversion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20168
diff changeset
82 ;; Have the original buffer current while we eval.
21675
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
83 (eval-buffer buffer nil file
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
84 ;; If this Emacs is running with --unibyte,
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
85 ;; convert multibyte strings to unibyte
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
86 ;; after reading them.
21728
ea71ddaad673 (load-with-code-conversion): Don't pass extra arg to eval-buffer.
Richard M. Stallman <rms@gnu.org>
parents: 21675
diff changeset
87 ;; (not default-enable-multibyte-characters)
25198
aaa595530183 (load-with-code-conversion): Pass t to eval-buffer for DO-ALLOW-PRINT.
Richard M. Stallman <rms@gnu.org>
parents: 25144
diff changeset
88 nil t
21728
ea71ddaad673 (load-with-code-conversion): Don't pass extra arg to eval-buffer.
Richard M. Stallman <rms@gnu.org>
parents: 21675
diff changeset
89 ))
18583
66e7a91e32ef (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 18558
diff changeset
90 (let (kill-buffer-hook kill-buffer-query-functions)
66e7a91e32ef (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 18558
diff changeset
91 (kill-buffer buffer)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 (let ((hook (assoc file after-load-alist)))
20168
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
93 (when hook
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
94 (mapcar (function eval) (cdr hook))))
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
95 (unless (or nomessage noninteractive)
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
96 (if source
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
97 (message "Loading %s (source)...done" file)
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
98 (message "Loading %s...done" file)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99 t)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 ;; API (Application Program Interface) for charsets.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
103 ;; Return t if OBJ is a quoted symbol
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
104 ;; and the symbol is the name of a standard charset.
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
105 (defsubst charset-quoted-standard-p (obj)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
106 (and (listp obj) (eq (car obj) 'quote)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
107 (symbolp (car-safe (cdr obj)))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
108 (let ((vector (get (car-safe (cdr obj)) 'charset)))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
109 (and (vectorp vector)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
110 (< (aref vector 0) 160)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112 (defsubst charsetp (object)
26687
c4fb0ef75056 (charsetp): Fix typo in docstring.
Gerd Moellmann <gerd@gnu.org>
parents: 26085
diff changeset
113 "T if OBJECT is a charset."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 (and (symbolp object) (vectorp (get object 'charset))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116 (defsubst charset-info (charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117 "Return a vector of information of CHARSET.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118 The elements of the vector are:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120 LEADING-CODE-BASE, LEADING-CODE-EXT,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123 PLIST,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124 where
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 CHARSET-ID (integer) is the identification number of the charset.
24780
856a475f3fc3 (charset-info): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 24776
diff changeset
126 BYTES (integer) is the length of multi-byte form of a character in
856a475f3fc3 (charset-info): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 24776
diff changeset
127 the charset: one of 1, 2, 3, and 4.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 DIMENSION (integer) is the number of bytes to represent a character of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 the charset: 1 or 2.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 CHARS (integer) is the number of characters in a dimension: 94 or 96.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 WIDTH (integer) is the number of columns a character in the charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 occupies on the screen: one of 0, 1, and 2.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 DIRECTION (integer) is the rendering direction of characters in the
24776
b6836aec7a0c (charset-info): Doc-string for DIRECTION fixed.
Kenichi Handa <handa@m17n.org>
parents: 24681
diff changeset
134 charset when rendering. If 0, render from left to right, else
b6836aec7a0c (charset-info): Doc-string for DIRECTION fixed.
Kenichi Handa <handa@m17n.org>
parents: 24681
diff changeset
135 render from right to left.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 LEADING-CODE-BASE (integer) is the base leading-code for the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 LEADING-CODE-EXT (integer) is the extended leading-code for the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 charset. All charsets of less than 0xA0 has the value 0.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 ISO-FINAL-CHAR (character) is the final character of the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 corresponding ISO 2022 charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 while encoding to variants of ISO 2022 coding system, one of the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145 REVERSE-CHARSET (integer) is the charset which differs only in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 LEFT-TO-RIGHT value from the charset. If there's no such a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 charset, the value is -1.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 SHORT-NAME (string) is the short name to refer to the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 LONG-NAME (string) is the long name to refer to the charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 DESCRIPTION (string) is the description string of the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 PLIST (property list) may contain any type of information a user
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 want to put and get by functions `put-charset-property' and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 `get-charset-property' respectively."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 (get charset 'charset))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
156 ;; It is better not to use backquote in this file,
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
157 ;; because that makes a bootstrapping problem
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
158 ;; if you need to recompile all the Lisp files using interpreted code.
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
159
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 (defmacro charset-id (charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 "Return charset identification number of CHARSET."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
162 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 (aref (charset-info (nth 1 charset)) 0)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
164 (list 'aref (list 'charset-info charset) 0)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 (defmacro charset-bytes (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
167 "Return bytes of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
168 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
169 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 (aref (charset-info (nth 1 charset)) 1)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
171 (list 'aref (list 'charset-info charset) 1)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173 (defmacro charset-dimension (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
174 "Return dimension of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
175 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
176 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 (aref (charset-info (nth 1 charset)) 2)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
178 (list 'aref (list 'charset-info charset) 2)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180 (defmacro charset-chars (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
181 "Return character numbers contained in a dimension of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
182 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
183 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 (aref (charset-info (nth 1 charset)) 3)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
185 (list 'aref (list 'charset-info charset) 3)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
186
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187 (defmacro charset-width (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
188 "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
189 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
190 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 (aref (charset-info (nth 1 charset)) 4)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
192 (list 'aref (list 'charset-info charset) 4)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
193
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194 (defmacro charset-direction (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
195 "Return direction of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
196 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
197 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198 (aref (charset-info (nth 1 charset)) 5)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
199 (list 'aref (list 'charset-info charset) 5)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201 (defmacro charset-iso-final-char (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
202 "Return final char of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
203 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
204 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
205 (aref (charset-info (nth 1 charset)) 8)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
206 (list 'aref (list 'charset-info charset) 8)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
207
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208 (defmacro charset-iso-graphic-plane (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
209 "Return graphic plane of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
210 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
211 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212 (aref (charset-info (nth 1 charset)) 9)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
213 (list 'aref (list 'charset-info charset) 9)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
214
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
215 (defmacro charset-reverse-charset (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
216 "Return reverse charset of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
217 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
218 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
219 (aref (charset-info (nth 1 charset)) 10)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
220 (list 'aref (list 'charset-info charset) 10)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
221
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
222 (defmacro charset-short-name (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
223 "Return short name of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
224 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
225 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
226 (aref (charset-info (nth 1 charset)) 11)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
227 (list 'aref (list 'charset-info charset) 11)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
228
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229 (defmacro charset-long-name (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
230 "Return long name of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
231 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
232 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
233 (aref (charset-info (nth 1 charset)) 12)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
234 (list 'aref (list 'charset-info charset) 12)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
235
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
236 (defmacro charset-description (charset)
23157
896708140990 (charset-description): Doc fix.
Paul Eggert <eggert@twinsun.com>
parents: 23030
diff changeset
237 "Return description of CHARSET.
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
238 See the function `charset-info' for more detail."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
239 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
240 (aref (charset-info (nth 1 charset)) 13)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
241 (list 'aref (list 'charset-info charset) 13)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
242
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
243 (defmacro charset-plist (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
244 "Return list charset property of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
245 See the function `charset-info' for more detail."
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
246 (list 'aref
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
247 (if (charset-quoted-standard-p charset)
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
248 (charset-info (nth 1 charset))
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
249 (list 'charset-info charset))
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
250 14))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
251
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
252 (defun set-charset-plist (charset plist)
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23157
diff changeset
253 "Set CHARSET's property list to PLIST, and return PLIST."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
254 (aset (charset-info charset) 14 plist))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
255
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
256 (defun make-char (charset &optional c1 c2)
24026
8313b191de2c (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 23888
diff changeset
257 "Return a character of CHARSET and position codes CODE1 and CODE2.
17175
3e54eb2d2a57 (make-char): Documented.
Kenichi Handa <handa@m17n.org>
parents: 17094
diff changeset
258 CODE1 and CODE2 are optional, but if you don't supply
24026
8313b191de2c (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 23888
diff changeset
259 sufficient position codes, return a generic character which stands for
8313b191de2c (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 23888
diff changeset
260 all characters or group of characters in the character set.
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
261 A generic character can be used to index a char table (e.g. syntax-table)."
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
262 (make-char-internal (charset-id charset) c1 c2))
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
263
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
264 (put 'make-char 'byte-compile
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
265 (function
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
266 (lambda (form)
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
267 (let ((charset (nth 1 form)))
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
268 (if (charset-quoted-standard-p charset)
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
269 (byte-compile-normal-call
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
270 (cons 'make-char-internal
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
271 (cons (charset-id (nth 1 charset)) (nthcdr 2 form))))
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
272 (byte-compile-normal-call
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
273 (cons 'make-char-internal
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
274 (cons (list 'charset-id charset) (nthcdr 2 form)))))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
275
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
276 (defun charset-list ()
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
277 "Return list of charsets ever defined.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
278
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
279 This function is provided for backward compatibility.
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
280 Now we have the variable `charset-list'."
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
281 charset-list)
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
282
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
283 (defsubst generic-char-p (char)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
284 "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
285 See also the documentation of make-char."
21470
b6c858daa80d (generic-char-p): A character of code 0 is not a generic char.
Kenichi Handa <handa@m17n.org>
parents: 21023
diff changeset
286 (and (>= char 0400)
b6c858daa80d (generic-char-p): A character of code 0 is not a generic char.
Kenichi Handa <handa@m17n.org>
parents: 21023
diff changeset
287 (let ((l (split-char char)))
b6c858daa80d (generic-char-p): A character of code 0 is not a generic char.
Kenichi Handa <handa@m17n.org>
parents: 21023
diff changeset
288 (and (or (= (nth 1 l) 0) (eq (nth 2 l) 0))
b6c858daa80d (generic-char-p): A character of code 0 is not a generic char.
Kenichi Handa <handa@m17n.org>
parents: 21023
diff changeset
289 (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
290
33045
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
291 (defun decode-char (ccs code-point &optional restriction)
33245
9366a16a186b (decode-char, encode-char): Fix doc-string.
Kenichi Handa <handa@m17n.org>
parents: 33045
diff changeset
292 "Return character specified by coded character set CCS and CODE-POINT in it.
33045
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
293 Return nil if such a character is not supported.
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
294 Currently, supported coded character set is `ucs' (ISO/IEC
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
295 10646: Universal Multi-Octet Coded Character Set) only.
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
296
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
297 Optional argument RESTRICTION specifies a way to map the pair of CCS
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
298 and CODE-POINT to a chracter. Currently not supported and just ignored."
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
299 (cond ((eq ccs 'ucs)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
300 (cond ((< code-point 128)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
301 code-point)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
302 ((< code-point 256)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
303 (make-char 'latin-iso8859-1 code-point))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
304 ((< code-point #x2500)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
305 (setq code-point (- code-point #x0100))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
306 (make-char 'mule-unicode-0100-24ff
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
307 (+ (/ code-point 96) 32) (+ (% code-point 96) 32)))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
308 ((< code-point #x33ff)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
309 (setq code-point (- code-point #x2500))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
310 (make-char 'mule-unicode-2500-33ff
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
311 (+ (/ code-point 96) 32) (+ (% code-point 96) 32)))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
312 ((and (>= code-point #xe000) (< code-point #x10000))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
313 (setq code-point (- code-point #xe000))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
314 (make-char 'mule-unicode-e000-ffff
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
315 (+ (/ code-point 96) 32) (+ (% code-point 96) 32)))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
316 ))))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
317
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
318 (defun encode-char (char ccs &optional restriction)
33245
9366a16a186b (decode-char, encode-char): Fix doc-string.
Kenichi Handa <handa@m17n.org>
parents: 33045
diff changeset
319 "Return code-point in coded character set CCS that corresponds to CHAR.
33045
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
320 Return nil if CHAR is not included in CCS.
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
321 Currently, supported coded character set is `ucs' (ISO/IEC
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
322 10646: Universal Multi-Octet Coded Character Set) only.
33245
9366a16a186b (decode-char, encode-char): Fix doc-string.
Kenichi Handa <handa@m17n.org>
parents: 33045
diff changeset
323
9366a16a186b (decode-char, encode-char): Fix doc-string.
Kenichi Handa <handa@m17n.org>
parents: 33045
diff changeset
324 CHAR should be in one of these charsets:
33045
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
325 ascii, latin-iso8859-1, mule-unicode-0100-24ff, mule-unicode-2500-33ff,
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
326 mule-unicode-e000-ffff
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
327 Otherwise, return nil.
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
328
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
329 Optional argument RESTRICTION specifies a way to map CHAR to a
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
330 code-point in CCS. Currently not supported and just ignored."
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
331 (let* ((split (split-char char))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
332 (charset (car split)))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
333 (cond ((eq ccs 'ucs)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
334 (cond ((eq charset 'ascii)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
335 char)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
336 ((eq charset 'latin-iso8859-1)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
337 (+ (nth 1 split) 128))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
338 ((eq charset 'mule-unicode-0100-24ff)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
339 (+ #x0100 (+ (* (- (nth 1 split) 32) 96)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
340 (- (nth 2 split) 32))))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
341 ((eq charset 'mule-unicode-2500-33ff)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
342 (+ #x2500 (+ (* (- (nth 1 split) 32) 96)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
343 (- (nth 2 split) 32))))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
344 ((eq charset 'mule-unicode-e000-ffff)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
345 (+ #xe000 (+ (* (- (nth 1 split) 32) 96)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
346 (- (nth 2 split) 32)))))))))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
347
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
348
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
349 ;; Coding system staffs
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
351 ;; Coding system is a symbol that has the property `coding-system'.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 ;;
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
353 ;; 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
354 ;; following format:
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
355 ;; [TYPE MNEMONIC DOC-STRING PLIST FLAGS]
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
356 ;; We call this vector as coding-spec. See comments in src/coding.c
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
357 ;; for more detail.
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
358
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
359 (defconst coding-spec-type-idx 0)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
360 (defconst coding-spec-mnemonic-idx 1)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
361 (defconst coding-spec-doc-string-idx 2)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
362 (defconst coding-spec-plist-idx 3)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
363 (defconst coding-spec-flags-idx 4)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
364
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
365 ;; PLIST is a property list of a coding system. To share PLIST among
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
366 ;; alias coding systems, a coding system has PLIST in coding-spec
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
367 ;; instead of having it in normal property list of Lisp symbol.
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
368 ;; Here's a list of coding system properties currently being used.
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
369 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
370 ;; o coding-category
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
371 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
372 ;; The value is a coding category the coding system belongs to. The
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
373 ;; function `make-coding-system' sets this value automatically
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
374 ;; unless its argument PROPERTIES specifies this property.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
375 ;;
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
376 ;; o alias-coding-systems
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
377 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
378 ;; The value is a list of coding systems of the same alias group. The
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
379 ;; first element is the coding system made at first, which we call as
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
380 ;; `base coding system'. The function `make-coding-system' sets this
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
381 ;; value automatically and `define-coding-system-alias' updates it.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382 ;;
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
383 ;; o post-read-conversion
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
384 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
385 ;; The value is a function to call after some text is inserted and
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
386 ;; decoded by the coding system itself and before any functions in
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
387 ;; `after-insert-functions' are called. The arguments to this
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
388 ;; function is the same as those of a function in
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
389 ;; `after-insert-functions', i.e. LENGTH of a text while putting point
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
390 ;; at the head of the text to be decoded
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391 ;;
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
392 ;; o pre-write-conversion
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
393 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
394 ;; The value is a function to call after all functions in
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
395 ;; `write-region-annotate-functions' and `buffer-file-format' are
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
396 ;; called, and before the text is encoded by the coding system itself.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
397 ;; The arguments to this function is the same as those of a function
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
398 ;; in `write-region-annotate-functions', i.e. FROM and TO specifying
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
399 ;; region of a text.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
400 ;;
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
401 ;; o translation-table-for-decode
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
402 ;;
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
403 ;; The value is a translation table to be applied on decoding. See
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
404 ;; the function `make-translation-table' for the format of translation
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
405 ;; table.
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
406 ;;
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
407 ;; o translation-table-for-encode
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
408 ;;
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
409 ;; The value is a translation table to be applied on encoding.
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
410 ;;
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
411 ;; o safe-chars
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
412 ;;
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
413 ;; The value is a char table. If a character has non-nil value in it,
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
414 ;; the character is safely supported by the coding system. This
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
415 ;; overrides the specification of safe-charsets.
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
416
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
417 ;; o safe-charsets
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
418 ;;
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
419 ;; The value is a list of charsets safely supported by the coding
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
420 ;; system. The value t means that all charsets Emacs handles are
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
421 ;; supported. Even if some charset is not in this list, it doesn't
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
422 ;; mean that the charset can't be encoded in the coding system,
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
423 ;; instead, it just means that some other receiver of a text encoded
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
424 ;; in the coding system won't be able to handle that charset.
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
425 ;;
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
426 ;; o mime-charset
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
427 ;;
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
428 ;; The value is a symbol of which name is `MIME-charset' parameter of
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
429 ;; the coding system.
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
430 ;;
24299
7604c49c98c3 Comment added for a new coding system
Kenichi Handa <handa@m17n.org>
parents: 24276
diff changeset
431 ;; o charset-origin-alist
7604c49c98c3 Comment added for a new coding system
Kenichi Handa <handa@m17n.org>
parents: 24276
diff changeset
432 ;;
7604c49c98c3 Comment added for a new coding system
Kenichi Handa <handa@m17n.org>
parents: 24276
diff changeset
433 ;; The value is a list of this form:
7604c49c98c3 Comment added for a new coding system
Kenichi Handa <handa@m17n.org>
parents: 24276
diff changeset
434 ;; (CHARSET EXTERNAL-CHARSET-NAME ENCODING-FUNCTION).
7604c49c98c3 Comment added for a new coding system
Kenichi Handa <handa@m17n.org>
parents: 24276
diff changeset
435 ;; ENCODING-FUNCTION is a function to encode a character in CHARSET
7604c49c98c3 Comment added for a new coding system
Kenichi Handa <handa@m17n.org>
parents: 24276
diff changeset
436 ;; to the code in EXTERNAL-CHARSET-NAME. The command what-cursor-position
7604c49c98c3 Comment added for a new coding system
Kenichi Handa <handa@m17n.org>
parents: 24276
diff changeset
437 ;; uses this information of the buffer-file-coding-system.
24373
c9020001e3c5 Modify comment for charset-origin-alist
Kenichi Handa <handa@m17n.org>
parents: 24345
diff changeset
438 ;; ENCODING-FUNCTION may be a translation table or a symbol whose
c9020001e3c5 Modify comment for charset-origin-alist
Kenichi Handa <handa@m17n.org>
parents: 24345
diff changeset
439 ;; property `translation-table' is a translation table. In these case,
c9020001e3c5 Modify comment for charset-origin-alist
Kenichi Handa <handa@m17n.org>
parents: 24345
diff changeset
440 ;; the translation table is used to encode the character.
24299
7604c49c98c3 Comment added for a new coding system
Kenichi Handa <handa@m17n.org>
parents: 24276
diff changeset
441 ;;
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
442 ;; o valid-codes (meaningful only for a coding system based on CCL)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
443 ;;
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
444 ;; The value is a list to indicate valid byte ranges of the encoded
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
445 ;; file. Each element of the list is an integer or a cons of integer.
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
446 ;; In the former case, the integer value is a valid byte code. In the
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23157
diff changeset
447 ;; latter case, the integers specifies the range of valid byte codes.
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
448
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
449
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
450 ;; Return coding-spec of CODING-SYSTEM
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
451 (defsubst coding-system-spec (coding-system)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
452 (get (check-coding-system coding-system) 'coding-system))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
453
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
454 (defun coding-system-type (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
455 "Return the coding type of CODING-SYSTEM.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
456 A coding type is an integer value indicating the encoding method
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
457 of CODING-SYSTEM. See the function `make-coding-system' for more detail."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
458 (aref (coding-system-spec coding-system) coding-spec-type-idx))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
459
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
460 (defun coding-system-mnemonic (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
461 "Return the mnemonic character of CODING-SYSTEM.
22302
fb2d8c0920c6 (coding-system-mnemonic): Don't crash if arg is nil.
Karl Heuer <kwzh@gnu.org>
parents: 22227
diff changeset
462 The mnemonic character of a coding system is used in mode line
fb2d8c0920c6 (coding-system-mnemonic): Don't crash if arg is nil.
Karl Heuer <kwzh@gnu.org>
parents: 22227
diff changeset
463 to indicate the coding system. If the arg is nil, return ?-."
fb2d8c0920c6 (coding-system-mnemonic): Don't crash if arg is nil.
Karl Heuer <kwzh@gnu.org>
parents: 22227
diff changeset
464 (let ((spec (coding-system-spec coding-system)))
fb2d8c0920c6 (coding-system-mnemonic): Don't crash if arg is nil.
Karl Heuer <kwzh@gnu.org>
parents: 22227
diff changeset
465 (if spec (aref spec coding-spec-mnemonic-idx) ?-)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
466
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
467 (defun coding-system-doc-string (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
468 "Return the documentation string for CODING-SYSTEM."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
469 (aref (coding-system-spec coding-system) coding-spec-doc-string-idx))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
470
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
471 (defun coding-system-plist (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
472 "Return the property list of CODING-SYSTEM."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
473 (aref (coding-system-spec coding-system) coding-spec-plist-idx))
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
474
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
475 (defun coding-system-flags (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
476 "Return `flags' of CODING-SYSTEM.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
477 A `flags' of a coding system is a vector of length 32 indicating detailed
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
478 information of a coding system. See the function `make-coding-system'
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
479 for more detail."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
480 (aref (coding-system-spec coding-system) coding-spec-flags-idx))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
481
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
482 (defun coding-system-get (coding-system prop)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
483 "Extract a value from CODING-SYSTEM's property list for property PROP."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
484 (plist-get (coding-system-plist coding-system) prop))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
485
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
486 (defun coding-system-put (coding-system prop val)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
487 "Change value in CODING-SYSTEM's property list PROP to VAL."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
488 (let ((plist (coding-system-plist coding-system)))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
489 (if plist
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
490 (plist-put plist prop val)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
491 (aset (coding-system-spec coding-system) coding-spec-plist-idx
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
492 (list prop val)))))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
493
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
494 (defun coding-system-category (coding-system)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
495 "Return the coding category of CODING-SYSTEM."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
496 (coding-system-get coding-system 'coding-category))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
497
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
498 (defun coding-system-base (coding-system)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
499 "Return the base coding system of CODING-SYSTEM.
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
500 A base coding system is what made by `make-coding-system'.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
501 Any alias nor subsidiary coding systems are not base coding system."
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
502 (car (coding-system-get coding-system 'alias-coding-systems)))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
503
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
504 (defalias 'coding-system-parent 'coding-system-base)
29354
4ed4a700358b Update calls to make-obsolete with a WHEN argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 28457
diff changeset
505 (make-obsolete 'coding-system-parent 'coding-system-base "20.3")
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
506
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
507 ;; Coding system also has a property `eol-type'.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
508 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
509 ;; This property indicates how the coding system handles end-of-line
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
510 ;; format. The value is integer 0, 1, 2, or a vector of three coding
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
511 ;; systems. Each integer value 0, 1, and 2 indicates the format of
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
512 ;; end-of-line LF, CRLF, and CR respectively. A vector value
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
513 ;; indicates that the format of end-of-line should be detected
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
514 ;; automatically. Nth element of the vector is the subsidiary coding
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
515 ;; system whose `eol-type' property is N.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
516
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
517 (defun coding-system-eol-type (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
518 "Return eol-type of CODING-SYSTEM.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
519 An eol-type is integer 0, 1, 2, or a vector of coding systems.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
520
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
521 Integer values 0, 1, and 2 indicate a format of end-of-line; LF,
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
522 CRLF, and CR respectively.
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
523
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
524 A vector value indicates that a format of end-of-line should be
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
525 detected automatically. Nth element of the vector is the subsidiary
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
526 coding system whose eol-type is N."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
527 (get coding-system 'eol-type))
18312
705da3ce58c0 (coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 18298
diff changeset
528
24276
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
529 (defun coding-system-lessp (x y)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
530 (cond ((eq x 'no-conversion) t)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
531 ((eq y 'no-conversion) nil)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
532 ((eq x 'emacs-mule) t)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
533 ((eq y 'emacs-mule) nil)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
534 ((eq x 'undecided) t)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
535 ((eq y 'undecided) nil)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
536 (t (let ((c1 (coding-system-mnemonic x))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
537 (c2 (coding-system-mnemonic y)))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
538 (or (< (downcase c1) (downcase c2))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
539 (and (not (> (downcase c1) (downcase c2)))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
540 (< c1 c2)))))))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
541
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
542 ;; Add CODING-SYSTEM to coding-system-list while keeping it sorted.
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
543 (defun add-to-coding-system-list (coding-system)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
544 (if (or (null coding-system-list)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
545 (coding-system-lessp coding-system (car coding-system-list)))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
546 (setq coding-system-list (cons coding-system coding-system-list))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
547 (let ((len (length coding-system-list))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
548 mid (tem coding-system-list))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
549 (while (> len 1)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
550 (setq mid (nthcdr (/ len 2) tem))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
551 (if (coding-system-lessp (car mid) coding-system)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
552 (setq tem mid
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
553 len (- len (/ len 2)))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
554 (setq len (/ len 2))))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
555 (setcdr tem (cons coding-system (cdr tem))))))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
556
24345
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
557 (defun coding-system-list (&optional base-only)
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
558 "Return a list of all existing non-subsidiary coding systems.
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
559 If optional arg BASE-ONLY is non-nil, only base coding systems are listed.
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
560 The value doesn't include subsidiary coding systems which are what
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
561 made from bases and aliases automatically for various end-of-line
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
562 formats (e.g. iso-latin-1-unix, koi8-r-dos)."
24345
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
563 (let* ((codings (copy-sequence coding-system-list))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
564 (tail (cons nil codings)))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
565 ;; Remove subsidiary coding systems (eol variants) and alias
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
566 ;; coding systems (if necessary).
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
567 (while (cdr tail)
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
568 (let* ((coding (car (cdr tail)))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
569 (aliases (coding-system-get coding 'alias-coding-systems)))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
570 (if (or
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
571 ;; CODING is an eol variant if not in ALIASES.
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
572 (not (memq coding aliases))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
573 ;; CODING is an alias if it is not car of ALIASES.
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
574 (and base-only (not (eq coding (car aliases)))))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
575 (setcdr tail (cdr (cdr tail)))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
576 (setq tail (cdr tail)))))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
577 codings))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
578
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
579 (defun register-char-codings (coding-system safe-chars)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
580 (let ((general (char-table-extra-slot char-coding-system-table 0)))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
581 (if (eq safe-chars t)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
582 (or (memq coding-system general)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
583 (set-char-table-extra-slot char-coding-system-table 0
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
584 (cons coding-system general)))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
585 (map-char-table
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
586 (function
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
587 (lambda (key val)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
588 (if (and (>= key 128) val)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
589 (let ((codings (aref char-coding-system-table key)))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
590 (or (memq coding-system codings)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
591 (aset char-coding-system-table key
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
592 (cons coding-system codings)))))))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
593 safe-chars))))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
594
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
595
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
596 ;; 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
597 (defun make-subsidiary-coding-system (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
598 (let ((coding-spec (coding-system-spec coding-system))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
599 (subsidiaries (vector (intern (format "%s-unix" coding-system))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
600 (intern (format "%s-dos" coding-system))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
601 (intern (format "%s-mac" coding-system))))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
602 (i 0)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
603 temp)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
604 (while (< i 3)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
605 (put (aref subsidiaries i) 'coding-system coding-spec)
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
606 (put (aref subsidiaries i) 'eol-type i)
24276
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
607 (add-to-coding-system-list (aref subsidiaries i))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
608 (setq coding-system-alist
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
609 (cons (list (symbol-name (aref subsidiaries i)))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
610 coding-system-alist))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
611 (setq i (1+ i)))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
612 subsidiaries))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
613
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
614 (defun make-coding-system (coding-system type mnemonic doc-string
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
615 &optional
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
616 flags
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
617 properties
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
618 eol-type)
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
619 "Define a new coding system CODING-SYSTEM (symbol).
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
620 Remaining arguments are TYPE, MNEMONIC, DOC-STRING, FLAGS (optional),
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
621 and PROPERTIES (optional) which construct a coding-spec of CODING-SYSTEM
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
622 in the following format:
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
623 [TYPE MNEMONIC DOC-STRING PLIST FLAGS]
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
624
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
625 TYPE is an integer value indicating the type of the coding system as follows:
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
626 0: Emacs internal format,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
627 1: Shift-JIS (or MS-Kanji) used mainly on Japanese PC,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
628 2: ISO-2022 including many variants,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
629 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
630 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
631 5: Raw-text, which means that text contains random 8-bit codes.
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
632
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
633 MNEMONIC is a character to be displayed on mode line for the coding system.
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
634
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
635 DOC-STRING is a documentation string for the coding system.
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
636
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
637 FLAGS specifies more detailed information of the coding system as follows:
19263
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
638
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
639 If TYPE is 2 (ISO-2022), FLAGS is a list of these elements:
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
640 CHARSET0, CHARSET1, CHARSET2, CHARSET3, SHORT-FORM,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
641 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
642 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
643 SAFE, ACCEPT-LATIN-EXTRA-CODE.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
644 CHARSETn are character sets initially designated to Gn graphic registers.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
645 If CHARSETn is nil, Gn is never used.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
646 If CHARSETn is t, Gn can be used but nothing designated initially.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
647 If CHARSETn is a list of character sets, those character sets are
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
648 designated to Gn on output, but nothing designated to Gn initially.
23281
e07d05f47832 (make-coding-system): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 23196
diff changeset
649 But, character set `ascii' can be designated only to G0.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
650 SHORT-FORM non-nil means use short designation sequence on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
651 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
652 ASCII-CNTL non-nil means designate ASCII to g0 before control codes and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
653 SPACE on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
654 SEVEN non-nil means use 7-bit code only on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
655 LOCKING-SHIFT non-nil means use locking-shift.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
656 SINGLE-SHIFT non-nil means use single-shift.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
657 USE-ROMAN non-nil means designate JIS0201-1976-Roman instead of ASCII.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
658 USE-OLDJIS non-nil means designate JIS0208-1976 instead of JIS0208-1983.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
659 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
660 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
661 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
662 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
663 at beginning of line on output.
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
664 SAFE non-nil means convert unsafe characters to `?' on output.
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
665 Characters not specified in the property `safe-charsets' nor
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
666 `safe-chars' are unsafe.
19395
cf115b0c7458 (make-coding-system): Add a new FLAGS
Richard M. Stallman <rms@gnu.org>
parents: 19263
diff changeset
667 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
668 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
669 code of the coding system.
19263
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
670
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
671 If TYPE is 4 (private), FLAGS should be a cons of CCL programs, for
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
672 decoding and encoding. CCL programs should be specified by their
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
673 symbols.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
674
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
675 PROPERTIES is an alist of properties vs the corresponding values.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
676 These properties are set in PLIST, a property list. This function
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
677 also sets properties `coding-category' and `alias-coding-systems'
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
678 automatically.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
679
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
680 EOL-TYPE specifies the EOL type of the coding-system in one of the
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
681 following formats:
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
682
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
683 o symbol (unix, dos, or mac)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
684
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
685 The symbol `unix' means Unix-like EOL (LF), `dos' means
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
686 DOS-like EOL (CRLF), and `mac' means MAC-like EOL (CR).
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
687
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
688 o number (0, 1, or 2)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
689
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
690 The number 0, 1, and 2 mean UNIX, DOS, and MAC-like EOL
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
691 respectively.
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
692
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
693 o vector of coding-systems of length 3
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
694
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
695 The EOL type is detected automatically for the coding system.
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
696 And, according to the detected EOL type, one of the coding
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
697 systems in the vector is selected. Elements of the vector
30877
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30491
diff changeset
698 corresponds to Unix-like EOL, DOS-like EOL, and Mac-like EOL
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
699 in this order.
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
700
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
701 Kludgy features for backward compatibility:
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
702
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
703 1. If TYPE is 4 and car or cdr of FLAGS is a vector, the vector is
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
704 treated as a compiled CCL code.
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
705
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
706 2. If PROPERTIES is just a list of character sets, the list is set as
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
707 a value of `safe-charsets' in PLIST."
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
708 ;; Set a value of `coding-system' property.
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
709 (let ((coding-spec (make-vector 5 nil))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
710 (no-initial-designation t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
711 (no-alternative-designation t)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
712 coding-category)
19606
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
713 (if (or (not (integerp type)) (< type 0) (> type 5))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
714 (error "TYPE argument must be 0..5"))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
715 (if (or (not (integerp mnemonic)) (<= mnemonic ? ) (> mnemonic 127))
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23157
diff changeset
716 (error "MNEMONIC argument must be an ASCII printable character."))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
717 (aset coding-spec coding-spec-type-idx type)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
718 (aset coding-spec coding-spec-mnemonic-idx mnemonic)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
719 (aset coding-spec coding-spec-doc-string-idx
28457
bbe7b99b5b28 (make-coding-system): Purecopy doc-string.
Dave Love <fx@gnu.org>
parents: 28018
diff changeset
720 (purecopy (if (stringp doc-string) doc-string "")))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
721 (cond ((= type 0)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
722 (setq coding-category 'coding-category-emacs-mule))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
723 ((= type 1)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
724 (setq coding-category 'coding-category-sjis))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
725 ((= type 2) ; ISO2022
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
726 (let ((i 0)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
727 (vec (make-vector 32 nil))
23456
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
728 (g1-designation nil)
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
729 (fl flags))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
730 (while (< i 4)
23456
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
731 (let ((charset (car fl)))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
732 (if (and no-initial-designation
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
733 (> i 0)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
734 (or (charsetp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
735 (and (consp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
736 (charsetp (car charset)))))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
737 (setq no-initial-designation nil))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
738 (if (charsetp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
739 (if (= i 1) (setq g1-designation charset))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
740 (if (consp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
741 (let ((tail charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
742 elt)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
743 (while tail
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
744 (setq elt (car tail))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
745 (if (eq elt t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
746 (setq no-alternative-designation nil)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
747 (if (and elt (not (charsetp elt)))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
748 (error "Invalid charset: %s" elt)))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
749 (setq tail (cdr tail)))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
750 (setq g1-designation (car charset)))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
751 (if charset
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
752 (if (eq charset t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
753 (setq no-alternative-designation nil)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
754 (error "Invalid charset: %s" charset)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
755 (aset vec i charset))
23456
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
756 (setq fl (cdr fl) i (1+ i)))
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
757 (while (and (< i 32) fl)
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
758 (aset vec i (car fl))
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
759 (setq fl (cdr fl) i (1+ i)))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
760 (aset coding-spec 4 vec)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
761 (setq coding-category
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
762 (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
763 (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
764 'coding-category-iso-8-else)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
765 (if (aref vec 7) ; 7-bit only.
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
766 (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
767 'coding-category-iso-7-else
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
768 (if no-alternative-designation
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
769 'coding-category-iso-7-tight
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
770 'coding-category-iso-7))
22160
c1998807c140 (make-coding-system): If ISO2022 based
Kenichi Handa <handa@m17n.org>
parents: 22125
diff changeset
771 (if (or no-initial-designation
c1998807c140 (make-coding-system): If ISO2022 based
Kenichi Handa <handa@m17n.org>
parents: 22125
diff changeset
772 (not no-alternative-designation))
18798
d4c708a5f181 (make-coding-system): Distinguish coding-category-iso-7-else and
Kenichi Handa <handa@m17n.org>
parents: 18583
diff changeset
773 'coding-category-iso-8-else
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
774 (if (and (charsetp g1-designation)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
775 (= (charset-dimension g1-designation) 2))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
776 'coding-category-iso-8-2
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
777 'coding-category-iso-8-1)))))))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
778 ((= type 3)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
779 (setq coding-category 'coding-category-big5))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
780 ((= type 4) ; private
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
781 (setq coding-category 'coding-category-ccl)
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
782 (if (not (consp flags))
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
783 (error "Invalid FLAGS argument for TYPE 4 (CCL)")
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
784 (let ((decoder (check-ccl-program
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
785 (car flags)
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
786 (intern (format "%s-decoder" coding-system))))
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
787 (encoder (check-ccl-program
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
788 (cdr flags)
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
789 (intern (format "%s-encoder" coding-system)))))
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
790 (if (and decoder encoder)
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
791 (aset coding-spec 4 (cons decoder encoder))
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
792 (error "Invalid FLAGS argument for TYPE 4 (CCL)")))))
19606
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
793 (t ; i.e. (= type 5)
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
794 (setq coding-category 'coding-category-raw-text)))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
795
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
796 (let ((plist (list 'coding-category coding-category
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
797 'alias-coding-systems (list coding-system))))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
798 (if no-initial-designation
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
799 (plist-put plist 'no-initial-designation t))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
800 (if (and properties
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
801 (or (eq properties t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
802 (not (consp (car properties)))))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
803 ;; In the old version, the arg PROPERTIES is a list to be
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
804 ;; set in PLIST as a value of property `safe-charsets'.
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
805 (setq properties (list (cons 'safe-charsets properties))))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
806 ;; In the current version PROPERTIES is a property list.
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
807 ;; Reflect it into PLIST one by one while handling safe-chars
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
808 ;; specially.
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
809 (let ((safe-charsets (cdr (assq 'safe-charsets properties)))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
810 (safe-chars (cdr (assq 'safe-chars properties)))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
811 (l properties)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
812 prop val)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
813 ;; If only safe-charsets is specified, make a char-table from
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
814 ;; it, and store that char-table as the value of `safe-chars'.
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
815 (if (and (not safe-chars) safe-charsets)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
816 (let (charset)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
817 (if (eq safe-charsets t)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
818 (setq safe-chars t)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
819 (setq safe-chars (make-char-table 'safe-chars))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
820 (while safe-charsets
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
821 (setq charset (car safe-charsets)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
822 safe-charsets (cdr safe-charsets))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
823 (cond ((eq charset 'ascii)) ; just ignore
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
824 ((eq charset 'eight-bit-control)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
825 (let ((i 128))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
826 (while (< i 160)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
827 (aset safe-chars i t)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
828 (setq i (1+ i)))))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
829 ((eq charset 'eight-bit-graphic)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
830 (let ((i 160))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
831 (while (< i 256)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
832 (aset safe-chars i t)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
833 (setq i (1+ i)))))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
834 (t
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
835 (aset safe-chars (make-char charset) t)))))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
836 (setq l (cons (cons 'safe-chars safe-chars) l))))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
837 (while l
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
838 (setq prop (car (car l)) val (cdr (car l)) l (cdr l))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
839 (if (eq prop 'safe-chars)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
840 (progn
33045
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
841 (if (and (symbolp val)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
842 (get val 'translation-table))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
843 (setq safe-chars (get val 'translation-table)))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
844 (register-char-codings coding-system safe-chars)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
845 (setq val safe-chars)))
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
846 (plist-put plist prop val)))
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
847 ;; The property `coding-category' may have been set differently
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
848 ;; through PROPERTIES.
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
849 (setq coding-category (plist-get plist 'coding-category))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
850 (aset coding-spec coding-spec-plist-idx plist))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
851 (put coding-system 'coding-system coding-spec)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
852 (put coding-category 'coding-systems
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
853 (cons coding-system (get coding-category 'coding-systems))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
854
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
855 ;; Next, set a value of `eol-type' property.
29722
4a60ce7cede2 (make-coding-system): Generate subsidiary coding systems for EOL
Kenichi Handa <handa@m17n.org>
parents: 29692
diff changeset
856 (if (not eol-type)
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
857 ;; If EOL-TYPE is nil, set a vector of subsidiary coding
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
858 ;; systems, each corresponds to a coding system for the detected
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
859 ;; EOL format.
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
860 (setq eol-type (make-subsidiary-coding-system coding-system)))
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
861 (setq eol-type
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
862 (cond ((or (eq eol-type 'unix) (null eol-type))
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
863 0)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
864 ((eq eol-type 'dos)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
865 1)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
866 ((eq eol-type 'mac)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
867 2)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
868 ((or (and (vectorp eol-type)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
869 (= (length eol-type) 3))
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
870 (and (numberp eol-type)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
871 (and (>= eol-type 0)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
872 (<= eol-type 2))))
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
873 eol-type)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
874 (t
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
875 (error "Invalid EOL-TYPE spec:%S" eol-type))))
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
876 (put coding-system 'eol-type eol-type)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
877
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
878 ;; At last, register CODING-SYSTEM in `coding-system-list' and
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
879 ;; `coding-system-alist'.
24276
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
880 (add-to-coding-system-list coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
881 (setq coding-system-alist (cons (list (symbol-name coding-system))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
882 coding-system-alist))
23456
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
883
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
884 ;; For a coding system of cateogory iso-8-1 and iso-8-2, create
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
885 ;; XXX-with-esc variants.
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
886 (let ((coding-category (coding-system-category coding-system)))
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
887 (if (or (eq coding-category 'coding-category-iso-8-1)
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
888 (eq coding-category 'coding-category-iso-8-2))
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
889 (let ((esc (intern (concat (symbol-name coding-system) "-with-esc")))
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
890 (doc (format "Same as %s but can handle any charsets by ISO's escape sequences." coding-system))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
891 (safe-charsets (assq 'safe-charsets properties))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
892 (mime-charset (assq 'mime-charset properties)))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
893 (if safe-charsets
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
894 (setcdr safe-charsets t)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
895 (setq properties (cons (cons 'safe-charsets t) properties)))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
896 (if mime-charset
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
897 (setcdr mime-charset nil))
23456
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
898 (make-coding-system esc type mnemonic doc
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
899 (if (listp (car flags))
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
900 (cons (append (car flags) '(t)) (cdr flags))
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
901 (cons (list (car flags) t) (cdr flags)))
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
902 properties))))
23456
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
903
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
904 coding-system)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
905
18518
425c8fa4227b (define-coding-system-alias): Swap the args.
Richard M. Stallman <rms@gnu.org>
parents: 18457
diff changeset
906 (defun define-coding-system-alias (alias coding-system)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
907 "Define ALIAS as an alias for coding system CODING-SYSTEM."
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
908 (put alias 'coding-system (coding-system-spec coding-system))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
909 (nconc (coding-system-get alias 'alias-coding-systems) (list alias))
24276
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
910 (add-to-coding-system-list alias)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
911 (setq coding-system-alist (cons (list (symbol-name alias))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
912 coding-system-alist))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
913 (let ((eol-type (coding-system-eol-type coding-system)))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
914 (if (vectorp eol-type)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
915 (put alias 'eol-type (make-subsidiary-coding-system alias))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
916 (put alias 'eol-type eol-type))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
917
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
918 (defun set-buffer-file-coding-system (coding-system &optional force)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
919 "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
920 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
921 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
922 use \\[list-coding-systems].
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
923
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
924 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
925 conversion, and CODING-SYSTEM does not specify one, CODING-SYSTEM is
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
926 merged with the already-specified end-of-line conversion.
29544
6f22d585904b (set-buffer-file-coding-system): If one of undecided-XXX is specified,
Kenichi Handa <handa@m17n.org>
parents: 29504
diff changeset
927
6f22d585904b (set-buffer-file-coding-system): If one of undecided-XXX is specified,
Kenichi Handa <handa@m17n.org>
parents: 29504
diff changeset
928 If the buffer's previous file coding-system value specifies text
6f22d585904b (set-buffer-file-coding-system): If one of undecided-XXX is specified,
Kenichi Handa <handa@m17n.org>
parents: 29504
diff changeset
929 conversion, and CODING-SYSTEM does not specify one, CODING-SYSTEM is
6f22d585904b (set-buffer-file-coding-system): If one of undecided-XXX is specified,
Kenichi Handa <handa@m17n.org>
parents: 29504
diff changeset
930 merged with the already-specified text conversion.
6f22d585904b (set-buffer-file-coding-system): If one of undecided-XXX is specified,
Kenichi Handa <handa@m17n.org>
parents: 29504
diff changeset
931
6f22d585904b (set-buffer-file-coding-system): If one of undecided-XXX is specified,
Kenichi Handa <handa@m17n.org>
parents: 29504
diff changeset
932 However, if the optional prefix argument FORCE is non-nil, then
6f22d585904b (set-buffer-file-coding-system): If one of undecided-XXX is specified,
Kenichi Handa <handa@m17n.org>
parents: 29504
diff changeset
933 CODING-SYSTEM is used exactly as specified.
26716
256531a93e10 Docstring modified.
Kenichi Handa <handa@m17n.org>
parents: 26687
diff changeset
934
256531a93e10 Docstring modified.
Kenichi Handa <handa@m17n.org>
parents: 26687
diff changeset
935 This marks the buffer modified so that the succeeding \\[save-buffer]
256531a93e10 Docstring modified.
Kenichi Handa <handa@m17n.org>
parents: 26687
diff changeset
936 surely saves the buffer with CODING-SYSTEM. From a program, if you
256531a93e10 Docstring modified.
Kenichi Handa <handa@m17n.org>
parents: 26687
diff changeset
937 don't want to mark the buffer modified, just set the variable
256531a93e10 Docstring modified.
Kenichi Handa <handa@m17n.org>
parents: 26687
diff changeset
938 `buffer-file-coding-system' directly."
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
939 (interactive "zCoding system for visited file (default, nil): \nP")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
940 (check-coding-system coding-system)
29575
ab979e3b519a (set-buffer-file-coding-system): If CODING-SYSTEM is nil, set
Kenichi Handa <handa@m17n.org>
parents: 29544
diff changeset
941 (if (and coding-system buffer-file-coding-system (null force))
29659
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
942 (let ((base (coding-system-base buffer-file-coding-system))
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
943 (eol (coding-system-eol-type buffer-file-coding-system)))
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
944 ;; If CODING-SYSTEM doesn't specify text conversion, merge
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
945 ;; with that of buffer-file-coding-system.
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
946 (if (eq (coding-system-base coding-system) 'undecided)
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
947 (setq coding-system (coding-system-change-text-conversion
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
948 coding-system base)))
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
949 ;; If CODING-SYSTEM doesn't specify eol conversion, merge with
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
950 ;; that of buffer-file-coding-system.
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
951 (if (and (vectorp (coding-system-eol-type coding-system))
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
952 (numberp eol) (>= eol 0) (<= eol 2))
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
953 (setq coding-system (coding-system-change-eol-conversion
4f79b4ed9ebc (set-buffer-file-coding-system): Almost rewritten to handle
Kenichi Handa <handa@m17n.org>
parents: 29641
diff changeset
954 coding-system eol)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
955 (setq buffer-file-coding-system coding-system)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
956 (set-buffer-modified-p t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
957 (force-mode-line-update))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
958
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
959 (defvar default-terminal-coding-system nil
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
960 "Default value for the terminal coding system.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
961 This is normally set according to the selected language environment.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
962 See also the command `set-terminal-coding-system'.")
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
963
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
964 (defun set-terminal-coding-system (coding-system)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
965 "Set coding system of your terminal to CODING-SYSTEM.
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
966 All text output to the terminal will be encoded
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
967 with the specified coding system.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
968 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
969 The default is determined by the selected language environment
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
970 or by the previous use of this command."
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
971 (interactive
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
972 (list (let ((default (if (and (not (terminal-coding-system))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
973 default-terminal-coding-system)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
974 default-terminal-coding-system)))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
975 (read-coding-system
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
976 (format "Coding system for terminal display (default, %s): "
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
977 default)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
978 default))))
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
979 (if (and (not coding-system)
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
980 (not (terminal-coding-system)))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
981 (setq coding-system default-terminal-coding-system))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
982 (if coding-system
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
983 (setq default-terminal-coding-system coding-system))
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
984 (set-terminal-coding-system-internal coding-system)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
985 (redraw-frame (selected-frame)))
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
986
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
987 (defvar default-keyboard-coding-system nil
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
988 "Default value of the keyboard coding system.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
989 This is normally set according to the selected language environment.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
990 See also the command `set-keyboard-coding-system'.")
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
991
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
992 (defun set-keyboard-coding-system (coding-system)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
993 "Set coding system for keyboard input to CODING-SYSTEM.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
994 In addition, this command enables Encoded-kbd minor mode.
22627
bde21619877b (set-keyboard-coding-system): Doc typo.
Richard M. Stallman <rms@gnu.org>
parents: 22491
diff changeset
995 \(If CODING-SYSTEM is nil, Encoded-kbd mode is turned off.)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
996 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
997 The default is determined by the selected language environment
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
998 or by the previous use of this command."
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
999 (interactive
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1000 (list (let ((default (if (and (not (keyboard-coding-system))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1001 default-keyboard-coding-system)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1002 default-keyboard-coding-system)))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1003 (read-coding-system
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1004 (format "Coding system for keyboard input (default, %s): "
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1005 default)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1006 default))))
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1007 (if (and (not coding-system)
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1008 (not (keyboard-coding-system)))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1009 (setq coding-system default-keyboard-coding-system))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1010 (if coding-system
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1011 (setq default-keyboard-coding-system coding-system))
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1012 (set-keyboard-coding-system-internal coding-system)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1013 (encoded-kbd-mode (if coding-system 1 0)))
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1014
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1015 (defun set-buffer-process-coding-system (decoding encoding)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1016 "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
1017 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
1018 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
1019
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1020 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
1021 (interactive
30965
d3223b7bcd96 (set-buffer-process-coding-system): Make interactive prompt less confusing.
Miles Bader <miles@gnu.org>
parents: 30877
diff changeset
1022 "zCoding-system for output from the process: \nzCoding-system for input to the process: ")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1023 (let ((proc (get-buffer-process (current-buffer))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1024 (if (null proc)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1025 (error "no process")
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1026 (check-coding-system decoding)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1027 (check-coding-system encoding)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1028 (set-process-coding-system proc decoding encoding)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1029 (force-mode-line-update))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1030
22836
f3603840ddbc (set-clipboard-coding-system): Define as alias.
Richard M. Stallman <rms@gnu.org>
parents: 22832
diff changeset
1031 (defalias 'set-clipboard-coding-system 'set-selection-coding-system)
f3603840ddbc (set-clipboard-coding-system): Define as alias.
Richard M. Stallman <rms@gnu.org>
parents: 22832
diff changeset
1032
22741
763e88fd4ca2 (set-selection-coding-system): Renamed from set-clipboard-coding-system.
Richard M. Stallman <rms@gnu.org>
parents: 22700
diff changeset
1033 (defun set-selection-coding-system (coding-system)
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1034 "Make CODING-SYSTEM used for communicating with other X clients .
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1035 When sending or receiving text via cut_buffer, selection, and clipboard,
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1036 the text is encoded or decoded by CODING-SYSTEM."
23030
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1037 (interactive "zCoding system for X selection: ")
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1038 (check-coding-system coding-system)
22741
763e88fd4ca2 (set-selection-coding-system): Renamed from set-clipboard-coding-system.
Richard M. Stallman <rms@gnu.org>
parents: 22700
diff changeset
1039 (setq selection-coding-system coding-system))
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1040
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23157
diff changeset
1041 ;; Coding system lastly specified by the command
23030
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1042 ;; set-next-selection-coding-system.
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1043 (defvar last-next-selection-coding-system nil)
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1044
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1045 (defun set-next-selection-coding-system (coding-system)
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1046 "Make CODING-SYSTEM used for the next communication with other X clients.
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1047 This setting is effective for the next communication only."
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1048 (interactive
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1049 (list (read-coding-system
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1050 (if last-next-selection-coding-system
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1051 (format "Coding system for the next X selection (default, %S): "
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1052 last-next-selection-coding-system)
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1053 "Coding system for the next X selection: ")
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1054 last-next-selection-coding-system)))
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1055 (if coding-system
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1056 (setq last-next-selection-coding-system coding-system)
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1057 (setq coding-system last-next-selection-coding-system))
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1058 (check-coding-system coding-system)
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1059
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1060 (setq next-selection-coding-system coding-system))
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1061
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1062 (defun set-coding-priority (arg)
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1063 "Set priority of coding categories according to LIST.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1064 LIST is a list of coding categories ordered by priority."
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1065 (let ((l arg)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1066 (current-list (copy-sequence coding-category-list)))
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23157
diff changeset
1067 ;; Check the validity of ARG while deleting coding categories in
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1068 ;; ARG from CURRENT-LIST. We assume that CODING-CATEGORY-LIST
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1069 ;; contains all coding categories.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1070 (while l
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1071 (if (or (null (get (car l) 'coding-category-index))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1072 (null (memq (car l) current-list)))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1073 (error "Invalid or duplicated element in argument: %s" arg))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1074 (setq current-list (delq (car l) current-list))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1075 (setq l (cdr l)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1076 ;; Update `coding-category-list' and return it.
22227
e7ac7f644152 (set-coding-priority): Call
Kenichi Handa <handa@m17n.org>
parents: 22225
diff changeset
1077 (setq coding-category-list (append arg current-list))
e7ac7f644152 (set-coding-priority): Call
Kenichi Handa <handa@m17n.org>
parents: 22225
diff changeset
1078 (set-coding-priority-internal)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1079
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1080 ;;; FILE I/O
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1081
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1082 (defvar auto-coding-alist
24681
8187e7ce3c56 (auto-coding-alist): Add .tgz.
Dave Love <fx@gnu.org>
parents: 24610
diff changeset
1083 '(("\\.\\(arc\\|zip\\|lzh\\|zoo\\|jar\\|tar\\|tgz\\)\\'" . no-conversion)
8187e7ce3c56 (auto-coding-alist): Add .tgz.
Dave Love <fx@gnu.org>
parents: 24610
diff changeset
1084 ("\\.\\(ARC\\|ZIP\\|LZH\\|ZOO\\|JAR\\|TAR\\|TGZ\\)\\'" . no-conversion))
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1085 "Alist of filename patterns vs corresponding coding systems.
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1086 Each element looks like (REGEXP . CODING-SYSTEM).
22819
da7ae4205e0b (auto-coding-alist): Docstring fixed.
Kenichi Handa <handa@m17n.org>
parents: 22813
diff changeset
1087 A file whose name matches REGEXP is decoded by CODING-SYSTEM on reading.
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1088
22826
e81f7de474b3 (auto-coding-alist): Another doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22819
diff changeset
1089 The settings in this alist take priority over `coding:' tags
e81f7de474b3 (auto-coding-alist): Another doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22819
diff changeset
1090 in the file (see the function `set-auto-coding')
e81f7de474b3 (auto-coding-alist): Another doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22819
diff changeset
1091 and the contents of `file-coding-system-alist'.")
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1092
22699
754703e243e6 (set-auto-coding-for-load): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22654
diff changeset
1093 (defvar set-auto-coding-for-load nil
754703e243e6 (set-auto-coding-for-load): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22654
diff changeset
1094 "Non-nil means look for `load-coding' property instead of `coding'.
754703e243e6 (set-auto-coding-for-load): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22654
diff changeset
1095 This is used for loading and byte-compiling Emacs Lisp files.")
754703e243e6 (set-auto-coding-for-load): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22654
diff changeset
1096
24602
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1097 (defun auto-coding-alist-lookup (filename)
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1098 "Return the coding system specified by `auto-coding-alist' for FILENAME."
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1099 (let ((alist auto-coding-alist)
24610
66a14155ad78 (auto-coding-alist-lookup): Include ms-dos
Eli Zaretskii <eliz@gnu.org>
parents: 24602
diff changeset
1100 (case-fold-search (memq system-type '(vax-vms windows-nt ms-dos)))
24602
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1101 coding-system)
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1102 (while (and alist (not coding-system))
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1103 (if (string-match (car (car alist)) filename)
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1104 (setq coding-system (cdr (car alist)))
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1105 (setq alist (cdr alist))))
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1106 coding-system))
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1107
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1108 (defun set-auto-coding (filename size)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1109 "Return coding system for a file FILENAME of which SIZE bytes follow point.
22699
754703e243e6 (set-auto-coding-for-load): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22654
diff changeset
1110 These bytes should include at least the first 1k of the file
754703e243e6 (set-auto-coding-for-load): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22654
diff changeset
1111 and the last 3k of the file, but the middle may be omitted.
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
1112
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1113 It checks FILENAME against the variable `auto-coding-alist'.
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1114 If FILENAME doesn't match any entries in the variable,
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1115 it checks for a `coding:' tag in the first one or two lines following
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23157
diff changeset
1116 point. If no `coding:' tag is found, it checks for local variables
22699
754703e243e6 (set-auto-coding-for-load): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22654
diff changeset
1117 list in the last 3K bytes out of the SIZE bytes.
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
1118
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
1119 The return value is the specified coding system,
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
1120 or nil if nothing specified.
19454
5a08bc0f02d3 (make-coding-system): Doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 19395
diff changeset
1121
21728
ea71ddaad673 (load-with-code-conversion): Don't pass extra arg to eval-buffer.
Richard M. Stallman <rms@gnu.org>
parents: 21675
diff changeset
1122 The variable `set-auto-coding-function' (which see) is set to this
19454
5a08bc0f02d3 (make-coding-system): Doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 19395
diff changeset
1123 function by default."
24602
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1124 (let ((coding-system (auto-coding-alist-lookup filename)))
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1125
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1126 (or coding-system
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1127 (let* ((case-fold-search t)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1128 (head-start (point))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1129 (head-end (+ head-start (min size 1024)))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1130 (tail-start (+ head-start (max (- size 3072) 0)))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1131 (tail-end (+ head-start size))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1132 coding-system head-found tail-found pos)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1133 ;; Try a short cut by searching for the string "coding:"
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23157
diff changeset
1134 ;; and for "unibyte:" at the head and tail of SIZE bytes.
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1135 (setq head-found (or (search-forward "coding:" head-end t)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1136 (search-forward "unibyte:" head-end t)))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1137 (if (and head-found (> head-found tail-start))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1138 ;; Head and tail are overlapped.
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1139 (setq tail-found head-found)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1140 (goto-char tail-start)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1141 (setq tail-found (or (search-forward "coding:" tail-end t)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1142 (search-forward "unibyte:" tail-end t))))
19454
5a08bc0f02d3 (make-coding-system): Doc-string fixed.
Kenichi Handa <handa@m17n.org>
parents: 19395
diff changeset
1143
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1144 ;; At first check the head.
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1145 (when head-found
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1146 (goto-char head-start)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1147 (setq pos (re-search-forward "[\n\r]" head-end t))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1148 (if (and pos
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1149 (= (char-after head-start) ?#)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1150 (= (char-after (1+ head-start)) ?!))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1151 ;; If the file begins with "#!" (exec interpreter magic),
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1152 ;; look for coding frobs in the first two lines. You cannot
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1153 ;; necessarily put them in the first line of such a file
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1154 ;; without screwing up the interpreter invocation.
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1155 (setq pos (search-forward "\n" head-end t)))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1156 (if pos (setq head-end pos))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1157 (when (< head-found head-end)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1158 (goto-char head-start)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1159 (when (and set-auto-coding-for-load
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1160 (re-search-forward
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1161 "-\\*-\\(.*;\\)?[ \t]*unibyte:[ \t]*\\([^ ;]+\\)"
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1162 head-end t))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1163 (setq coding-system 'raw-text))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1164 (when (and (not coding-system)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1165 (re-search-forward
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1166 "-\\*-\\(.*;\\)?[ \t]*coding:[ \t]*\\([^ ;]+\\)"
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1167 head-end t))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1168 (setq coding-system (intern (match-string 2)))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1169 (or (coding-system-p coding-system)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1170 (setq coding-system nil)))))
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
1171
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1172 ;; If no coding: tag in the head, check the tail.
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1173 (when (and tail-found (not coding-system))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1174 (goto-char tail-start)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1175 (search-forward "\n\^L" nil t)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1176 (if (re-search-forward
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1177 "^\\(.*\\)[ \t]*Local Variables:[ \t]*\\(.*\\)$" tail-end t)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1178 ;; The prefix is what comes before "local variables:" in its
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1179 ;; line. The suffix is what comes after "local variables:"
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1180 ;; in its line.
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1181 (let* ((prefix (regexp-quote (match-string 1)))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1182 (suffix (regexp-quote (match-string 2)))
25144
edfd929009d5 (set-auto-coding): Allow whitespace before
Eli Zaretskii <eliz@gnu.org>
parents: 24780
diff changeset
1183 (re-coding
edfd929009d5 (set-auto-coding): Allow whitespace before
Eli Zaretskii <eliz@gnu.org>
parents: 24780
diff changeset
1184 (concat
edfd929009d5 (set-auto-coding): Allow whitespace before
Eli Zaretskii <eliz@gnu.org>
parents: 24780
diff changeset
1185 "^" prefix
edfd929009d5 (set-auto-coding): Allow whitespace before
Eli Zaretskii <eliz@gnu.org>
parents: 24780
diff changeset
1186 "[ \t]*coding[ \t]*:[ \t]*\\([^ \t]+\\)[ \t]*"
edfd929009d5 (set-auto-coding): Allow whitespace before
Eli Zaretskii <eliz@gnu.org>
parents: 24780
diff changeset
1187 suffix "$"))
edfd929009d5 (set-auto-coding): Allow whitespace before
Eli Zaretskii <eliz@gnu.org>
parents: 24780
diff changeset
1188 (re-unibyte
edfd929009d5 (set-auto-coding): Allow whitespace before
Eli Zaretskii <eliz@gnu.org>
parents: 24780
diff changeset
1189 (concat
edfd929009d5 (set-auto-coding): Allow whitespace before
Eli Zaretskii <eliz@gnu.org>
parents: 24780
diff changeset
1190 "^" prefix
edfd929009d5 (set-auto-coding): Allow whitespace before
Eli Zaretskii <eliz@gnu.org>
parents: 24780
diff changeset
1191 "[ \t]*unibyte[ \t]*:[ \t]*\\([^ \t]+\\)[ \t]*"
edfd929009d5 (set-auto-coding): Allow whitespace before
Eli Zaretskii <eliz@gnu.org>
parents: 24780
diff changeset
1192 suffix "$"))
edfd929009d5 (set-auto-coding): Allow whitespace before
Eli Zaretskii <eliz@gnu.org>
parents: 24780
diff changeset
1193 (re-end
edfd929009d5 (set-auto-coding): Allow whitespace before
Eli Zaretskii <eliz@gnu.org>
parents: 24780
diff changeset
1194 (concat "^" prefix "[ \t]*end *:[ \t]*" suffix "$"))
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1195 (pos (point)))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1196 (re-search-forward re-end tail-end 'move)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1197 (setq tail-end (point))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1198 (goto-char pos)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1199 (when (and set-auto-coding-for-load
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1200 (re-search-forward re-unibyte tail-end t))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1201 (setq coding-system 'raw-text))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1202 (when (and (not coding-system)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1203 (re-search-forward re-coding tail-end t))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1204 (setq coding-system (intern (match-string 1)))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1205 (or (coding-system-p coding-system)
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1206 (setq coding-system nil))))))
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1207 coding-system))))
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
1208
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
1209 (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
1210
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1211 ;; Set buffer-file-coding-system of the current buffer after some text
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1212 ;; is inserted.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1213 (defun after-insert-file-set-buffer-file-coding-system (inserted)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1214 (if last-coding-system-used
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1215 (let ((coding-system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1216 (find-new-buffer-file-coding-system last-coding-system-used))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1217 (modified-p (buffer-modified-p)))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1218 (when coding-system
29641
703433352fc4 (after-insert-file-set-buffer-file-coding-system): Call
Kenichi Handa <handa@m17n.org>
parents: 29575
diff changeset
1219 (set-buffer-file-coding-system coding-system t)
23717
ad0e76fa89be (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 23456
diff changeset
1220 (if (and enable-multibyte-characters
ad0e76fa89be (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 23456
diff changeset
1221 (or (eq coding-system 'no-conversion)
22041
e977f2414da5 (after-insert-file-set-buffer-file-coding-system):
Richard M. Stallman <rms@gnu.org>
parents: 21728
diff changeset
1222 (eq (coding-system-type coding-system) 5))
29504
09063dfdc92c (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 29428
diff changeset
1223 ;; If buffer was unmodified and the size is the
09063dfdc92c (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 29428
diff changeset
1224 ;; same as INSERTED, we must be visiting it.
09063dfdc92c (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 29428
diff changeset
1225 (not modified-p)
09063dfdc92c (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 29428
diff changeset
1226 (= (buffer-size) inserted))
22041
e977f2414da5 (after-insert-file-set-buffer-file-coding-system):
Richard M. Stallman <rms@gnu.org>
parents: 21728
diff changeset
1227 ;; For coding systems no-conversion and raw-text...,
e977f2414da5 (after-insert-file-set-buffer-file-coding-system):
Richard M. Stallman <rms@gnu.org>
parents: 21728
diff changeset
1228 ;; edit the buffer as unibyte.
23717
ad0e76fa89be (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 23456
diff changeset
1229 (let ((pos-byte (position-bytes (+ (point) inserted))))
ad0e76fa89be (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 23456
diff changeset
1230 (set-buffer-multibyte nil)
ad0e76fa89be (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 23456
diff changeset
1231 (setq inserted (- pos-byte (position-bytes (point))))))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1232 (set-buffer-modified-p modified-p))))
23717
ad0e76fa89be (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 23456
diff changeset
1233 inserted)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1234
21023
bac070da6b6d (load-with-code-conversion):
Karl Heuer <kwzh@gnu.org>
parents: 20940
diff changeset
1235 (add-hook 'after-insert-file-functions
bac070da6b6d (load-with-code-conversion):
Karl Heuer <kwzh@gnu.org>
parents: 20940
diff changeset
1236 'after-insert-file-set-buffer-file-coding-system)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1237
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
1238 ;; The coding-spec and eol-type of coding-system returned is decided
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1239 ;; independently in the following order.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1240 ;; 1. That of buffer-file-coding-system locally bound.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1241 ;; 2. That of CODING.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1242
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1243 (defun find-new-buffer-file-coding-system (coding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1244 "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
1245 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
1246 is set to the returned value.
24575
a95503af9112 (find-new-buffer-file-coding-system): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 24373
diff changeset
1247 Return nil if there's no need to set `buffer-file-coding-system'."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1248 (let (local-coding local-eol
19948
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1249 found-coding found-eol
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1250 new-coding new-eol)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1251 (if (null coding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1252 ;; Nothing found about coding.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1253 nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1254
19948
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1255 ;; Get information of `buffer-file-coding-system' in LOCAL-EOL
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1256 ;; and LOCAL-CODING.
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1257 (setq local-eol (coding-system-eol-type buffer-file-coding-system))
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1258 (if (null (numberp local-eol))
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1259 ;; But eol-type is not yet set.
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1260 (setq local-eol nil))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1261 (if (and buffer-file-coding-system
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1262 (not (eq (coding-system-type buffer-file-coding-system) t)))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1263 ;; This is not `undecided'.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1264 (setq local-coding (coding-system-base buffer-file-coding-system)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1265
19948
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1266 (if (and (local-variable-p 'buffer-file-coding-system)
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1267 local-eol local-coding)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1268 ;; The current buffer has already set full coding-system, we
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1269 ;; had better not change it.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1270 nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1271
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
1272 (setq found-eol (coding-system-eol-type coding))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1273 (if (null (numberp found-eol))
22903
77e68af369b1 (find-new-buffer-file-coding-system): When
Eli Zaretskii <eliz@gnu.org>
parents: 22884
diff changeset
1274 ;; But eol-type is not found.
77e68af369b1 (find-new-buffer-file-coding-system): When
Eli Zaretskii <eliz@gnu.org>
parents: 22884
diff changeset
1275 ;; If EOL conversions are inhibited, force unix eol-type.
77e68af369b1 (find-new-buffer-file-coding-system): When
Eli Zaretskii <eliz@gnu.org>
parents: 22884
diff changeset
1276 (setq found-eol (if inhibit-eol-conversion 0)))
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1277 (if (eq (coding-system-type coding) t)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1278 (setq found-coding 'undecided)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1279 (setq found-coding (coding-system-base coding)))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1280
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1281 (if (and (not found-eol) (eq found-coding 'undecided))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1282 ;; No valid coding information found.
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1283 nil
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1284
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1285 ;; Some coding information (eol or text) found.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1286
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1287 ;; The local setting takes precedence over the found one.
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1288 (setq new-coding (if (local-variable-p 'buffer-file-coding-system)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1289 (or local-coding found-coding)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1290 (or found-coding local-coding)))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1291 (setq new-eol (if (local-variable-p 'buffer-file-coding-system)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1292 (or local-eol found-eol)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1293 (or found-eol local-eol)))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1294
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1295 (let ((eol-type (coding-system-eol-type new-coding)))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1296 (if (and (numberp new-eol) (vectorp eol-type))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1297 (aref eol-type new-eol)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1298 new-coding)))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1299
18874
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1300 (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
1301 "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
1302 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
1303 `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
1304
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1305 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
1306 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
1307 If it is `process', it affects `process-coding-system-alist' (which see).
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23157
diff changeset
1308 If it is `network', it affects `network-coding-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
1309
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1310 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
1311 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
1312 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
1313 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
1314
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1315 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
1316 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
1317 for decoding and encoding respectively,
7333c3179621 (modify-coding-system-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18874
diff changeset
1318 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
1319 (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
1320 (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
1321 (or (stringp regexp)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1322 (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
1323 (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
1324 (if (symbolp coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1325 (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
1326 (progn
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1327 (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
1328 (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
1329 (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
1330 (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
1331 (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
1332 (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
1333 (if slot
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1334 (setcdr slot coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1335 (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
1336 (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
1337 file-coding-system-alist)))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1338 ((eq target-type 'process)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1339 (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
1340 (if slot
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1341 (setcdr slot coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1342 (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
1343 (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
1344 process-coding-system-alist)))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1345 (t
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1346 (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
1347 (if slot
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1348 (setcdr slot coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1349 (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
1350 (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
1351 network-coding-system-alist)))))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1352
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1353 (defun make-translation-table (&rest args)
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
1354 "Make a translation table (char table) from arguments.
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1355 Each argument is a list of the form (FROM . TO),
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1356 where FROM is a character to be translated to TO.
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1357
22225
6f56af1aab96 (make-translation-table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22186
diff changeset
1358 FROM can be a generic character (see `make-char'). In this case, TO is
6f56af1aab96 (make-translation-table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22186
diff changeset
1359 a generic character containing the same number of characters, or a
6f56af1aab96 (make-translation-table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22186
diff changeset
1360 ordinary character. If FROM and TO are both generic characters, all
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1361 characters belonging to FROM are translated to characters belonging to TO
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1362 without changing their position code(s)."
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
1363 (let ((table (make-char-table 'translation-table))
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1364 revlist)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1365 (while args
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1366 (let ((elts (car args)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1367 (while elts
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1368 (let* ((from (car (car elts)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1369 (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
1370 (from-rev (nreverse (split-char from)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1371 (to (cdr (car elts)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1372 (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
1373 (to-rev (nreverse (split-char to))))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1374 ;; 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
1375 (while (eq (car from-rev) 0)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1376 (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
1377 (while (eq (car to-rev) 0)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1378 (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
1379 (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
1380 (error "Invalid character pair (%d . %d)" from to))
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1381 ;; If we have already translated TO to TO-ALT, FROM should
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1382 ;; also be translated to TO-ALT. But, this is only if TO
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1383 ;; is a generic character or TO-ALT is not a generic
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1384 ;; character.
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1385 (let ((to-alt (aref table to)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1386 (if (and to-alt
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1387 (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
1388 (setq to to-alt)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1389 (if (> from-i 0)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
1390 (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
1391 (aset table from to))
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1392 ;; If we have already translated some chars to FROM, they
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1393 ;; should also be translated to TO.
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1394 (let ((l (assq from revlist)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1395 (if l
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1396 (let ((ch (car l)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1397 (setcar l to)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1398 (setq l (cdr l))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1399 (while l
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1400 (aset table ch to)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1401 (setq l (cdr l)) ))))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1402 ;; Now update REVLIST.
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1403 (let ((l (assq to revlist)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1404 (if l
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1405 (setcdr l (cons from (cdr l)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1406 (setq revlist (cons (list to from) revlist)))))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1407 (setq elts (cdr elts))))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1408 (setq args (cdr args)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1409 ;; Return TABLE just created.
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1410 table))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
1411
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1412 (defun make-translation-table-from-vector (vec)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1413 "Make translation table from decoding vector VEC.
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1414 VEC is an array of 256 elements to map unibyte codes to multibyte characters.
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1415 See also the variable `nonascii-translation-table'."
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1416 (let ((table (make-char-table 'translation-table))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1417 (rev-table (make-char-table 'translation-table))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1418 (i 0)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1419 ch)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1420 (while (< i 256)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1421 (setq ch (aref vec i))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1422 (aset table i ch)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1423 (if (>= ch 256)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1424 (aset rev-table ch i))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1425 (setq i (1+ i)))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1426 (set-char-table-extra-slot table 0 rev-table)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1427 table))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1428
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
1429 (defun define-translation-table (symbol &rest args)
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23157
diff changeset
1430 "Define SYMBOL as a name of translation table made by ARGS.
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1431
23770
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
1432 If the first element of ARGS is a char-table of which purpose is
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
1433 translation-table, just define SYMBOL as the name of it.
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
1434
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
1435 In the other case, ARGS are the same as arguments to the function
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
1436 `make-translation-table' (which see).
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1437
22225
6f56af1aab96 (make-translation-table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22186
diff changeset
1438 This function sets properties `translation-table' and
6f56af1aab96 (make-translation-table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22186
diff changeset
1439 `translation-table-id' of SYMBOL to the created table itself and
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
1440 identification number of the table respectively."
23770
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
1441 (let ((table (if (and (char-table-p (car args))
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
1442 (eq (char-table-subtype (car args))
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
1443 'translation-table))
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
1444 (car args)
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
1445 (apply 'make-translation-table args)))
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
1446 (len (length translation-table-vector))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1447 (id 0)
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1448 (done nil))
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
1449 (put symbol 'translation-table table)
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1450 (while (not done)
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1451 (if (>= id len)
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
1452 (setq translation-table-vector
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
1453 (vconcat translation-table-vector (make-vector len nil))))
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
1454 (let ((slot (aref translation-table-vector id)))
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1455 (if (or (not slot)
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1456 (eq (car slot) symbol))
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1457 (progn
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
1458 (aset translation-table-vector id (cons symbol table))
23770
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
1459 (setq done t))
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
1460 (setq id (1+ id)))))
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
1461 (put symbol 'translation-table-id id)
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1462 id))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1463
26887
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
1464 (put 'with-category-table 'lisp-indent-function 1)
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
1465
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
1466 (defmacro with-category-table (category-table &rest body)
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
1467 `(let ((current-category-table (category-table)))
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
1468 (set-category-table ,category-table)
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
1469 (unwind-protect
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
1470 (progn ,@body)
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
1471 (set-category-table current-category-table))))
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
1472
17094
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
1473 ;;; Initialize some variables.
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
1474
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
1475 (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
1476 (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
1477 (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
1478 (setq ignore-relative-composition
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
1479 (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
1480
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
1481 ;;;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1482 (provide 'mule)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1483
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1484 ;;; mule.el ends here