annotate lisp/international/mule.el @ 68892:93b583aac002

* wid-edit.el (widget-button-click): Use :pressed-face property for overlay face, if it exists. * cus-edit.el (custom-manual, custom-add-see-also) (custom-add-parent-links, custom-group-link): Add :pressed-face property to links.
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 14 Feb 2006 20:16:04 +0000
parents 2ed18bf835e1
children f4bef16905cb 9b150bc96d33
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
62274
c36561fe0657 Fix copyrights.
Kenichi Handa <handa@m17n.org>
parents: 62154
diff changeset
3 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
c36561fe0657 Fix copyrights.
Kenichi Handa <handa@m17n.org>
parents: 62154
diff changeset
4 ;; Free Software Foundation, Inc.
c36561fe0657 Fix copyrights.
Kenichi Handa <handa@m17n.org>
parents: 62154
diff changeset
5 ;; Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
c36561fe0657 Fix copyrights.
Kenichi Handa <handa@m17n.org>
parents: 62154
diff changeset
6 ;; National Institute of Advanced Industrial Science and Technology (AIST)
c36561fe0657 Fix copyrights.
Kenichi Handa <handa@m17n.org>
parents: 62154
diff changeset
7 ;; Registration Number H14PRO021
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9 ;; Keywords: mule, multilingual, character set, coding system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; any later version.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
22
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
23 ;; 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
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62274
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62274
diff changeset
26 ;; Boston, MA 02110-1301, USA.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37995
diff changeset
28 ;;; Commentary:
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37995
diff changeset
29
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 ;;; Code:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31
29692
f79efb8debd9 (mule-version): Change version name to SAKAKI. AOI has already been
Kenichi Handa <handa@m17n.org>
parents: 29659
diff changeset
32 (defconst mule-version "5.0 (SAKAKI)" "\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 Version number and name of this version of MULE (multilingual environment).")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34
26887
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
35 (defconst mule-version-date "1999.12.7" "\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 Distribution date of this version of MULE (multilingual environment).")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 (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
39 "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
40 The file contents are decoded before evaluation if necessary.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 If optional second arg NOERROR is non-nil,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 report no error if FILE doesn't exist.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 Print messages at start and end of loading unless
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 optional third arg NOMESSAGE is non-nil.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 Return t if file exists."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 (if (null (file-readable-p fullname))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 (and (null noerror)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 (signal 'file-error (list "Cannot open load file" file)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 ;; Read file with code conversion, and then eval.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 (let* ((buffer
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 ;; To avoid any autoloading, set default-major-mode to
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 ;; fundamental-mode.
21675
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
53 ;; 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
54 ;; file is encoded in some complicated character set,
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
55 ;; read it with real decoding, as a multibyte buffer,
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
56 ;; even if this is a --unibyte Emacs session.
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
57 (let ((default-major-mode 'fundamental-mode)
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
58 (default-enable-multibyte-characters t))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 ;; We can't use `generate-new-buffer' because files.el
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 ;; is not yet loaded.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 (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
62 (load-in-progress t)
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
63 (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
64 (unless nomessage
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
65 (if source
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
66 (message "Loading %s (source)..." file)
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
67 (message "Loading %s..." file)))
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
68 (when purify-flag
49693
ae8bfbc6d9ef (load-with-code-conversion): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49549
diff changeset
69 (push file preloaded-file-list))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 (unwind-protect
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
71 (let ((load-file-name fullname)
22699
754703e243e6 (set-auto-coding-for-load): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22654
diff changeset
72 (set-auto-coding-for-load t)
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
73 (inhibit-file-name-operation nil))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 (save-excursion
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75 (set-buffer buffer)
67517
527e6fc032c7 (load-with-code-conversion): Bind deactivate-mark.
Richard M. Stallman <rms@gnu.org>
parents: 66345
diff changeset
76 ;; Don't let deactivate-mark remain set.
527e6fc032c7 (load-with-code-conversion): Bind deactivate-mark.
Richard M. Stallman <rms@gnu.org>
parents: 66345
diff changeset
77 (let (deactivate-mark)
527e6fc032c7 (load-with-code-conversion): Bind deactivate-mark.
Richard M. Stallman <rms@gnu.org>
parents: 66345
diff changeset
78 (insert-file-contents fullname))
23860
2ce75856e89f (load-with-code-conversion): If the loaded
Eli Zaretskii <eliz@gnu.org>
parents: 23770
diff changeset
79 ;; 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
80 ;; 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
81 ;; 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
82 ;; binary junk as multibyte characters.
2ce75856e89f (load-with-code-conversion): If the loaded
Eli Zaretskii <eliz@gnu.org>
parents: 23770
diff changeset
83 (if (and enable-multibyte-characters
2ce75856e89f (load-with-code-conversion): If the loaded
Eli Zaretskii <eliz@gnu.org>
parents: 23770
diff changeset
84 (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
85 (eq last-coding-system-used 'no-conversion)))
2ce75856e89f (load-with-code-conversion): If the loaded
Eli Zaretskii <eliz@gnu.org>
parents: 23770
diff changeset
86 (set-buffer-multibyte nil))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87 ;; Make `kill-buffer' quiet.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 (set-buffer-modified-p nil))
20405
faf18d58a01b (load-with-code-conversion): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20168
diff changeset
89 ;; Have the original buffer current while we eval.
66345
27a95070b049 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 65680
diff changeset
90 (eval-buffer buffer nil
27a95070b049 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 65680
diff changeset
91 ;; This is compatible with what `load' does.
27a95070b049 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 65680
diff changeset
92 (if purify-flag file fullname)
21675
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
93 ;; If this Emacs is running with --unibyte,
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
94 ;; convert multibyte strings to unibyte
f000ba659241 (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 21660
diff changeset
95 ;; 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
96 ;; (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
97 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
98 ))
18583
66e7a91e32ef (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 18558
diff changeset
99 (let (kill-buffer-hook kill-buffer-query-functions)
66e7a91e32ef (load-with-code-conversion):
Richard M. Stallman <rms@gnu.org>
parents: 18558
diff changeset
100 (kill-buffer buffer)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 (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
102 (when hook
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
103 (mapcar (function eval) (cdr hook))))
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
104 (unless (or nomessage noninteractive)
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
105 (if source
13074c25ab06 Indicate in messages if source code is being loaded.
Simon Marshall <simon@gnu.org>
parents: 20161
diff changeset
106 (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
107 (message "Loading %s...done" file)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108 t)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
110 ;; API (Application Program Interface) for charsets.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
112 (defsubst charset-quoted-standard-p (obj)
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
113 "Return t if OBJ is a quoted symbol, and is the name of a standard charset."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
114 (and (listp obj) (eq (car obj) 'quote)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
115 (symbolp (car-safe (cdr obj)))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
116 (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
117 (and (vectorp vector)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
118 (< (aref vector 0) 160)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120 (defsubst charsetp (object)
26687
c4fb0ef75056 (charsetp): Fix typo in docstring.
Gerd Moellmann <gerd@gnu.org>
parents: 26085
diff changeset
121 "T if OBJECT is a charset."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 (and (symbolp object) (vectorp (get object 'charset))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124 (defsubst charset-info (charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 "Return a vector of information of CHARSET.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 The elements of the vector are:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 LEADING-CODE-BASE, LEADING-CODE-EXT,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 PLIST,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 where
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 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
134 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
135 the charset: one of 1, 2, 3, and 4.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 DIMENSION (integer) is the number of bytes to represent a character of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 the charset: 1 or 2.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 CHARS (integer) is the number of characters in a dimension: 94 or 96.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 WIDTH (integer) is the number of columns a character in the charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 occupies on the screen: one of 0, 1, and 2.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 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
142 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
143 render from right to left.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 LEADING-CODE-BASE (integer) is the base leading-code for the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145 charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 LEADING-CODE-EXT (integer) is the extended leading-code for the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 charset. All charsets of less than 0xA0 has the value 0.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 ISO-FINAL-CHAR (character) is the final character of the
35750
fbb4712321dd (charset-info): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents: 35553
diff changeset
149 corresponding ISO 2022 charset. If the charset is not assigned
fbb4712321dd (charset-info): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents: 35553
diff changeset
150 any final character, the value is -1.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 while encoding to variants of ISO 2022 coding system, one of the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR).
35750
fbb4712321dd (charset-info): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents: 35553
diff changeset
154 If the charset is not assigned any final character, the value is -1.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155 REVERSE-CHARSET (integer) is the charset which differs only in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 LEFT-TO-RIGHT value from the charset. If there's no such a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 charset, the value is -1.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 SHORT-NAME (string) is the short name to refer to the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 LONG-NAME (string) is the long name to refer to the charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 DESCRIPTION (string) is the description string of the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 PLIST (property list) may contain any type of information a user
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 want to put and get by functions `put-charset-property' and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 `get-charset-property' respectively."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 (get charset 'charset))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
166 ;; 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
167 ;; because that makes a bootstrapping problem
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
168 ;; 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
169
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 (defmacro charset-id (charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 "Return charset identification number of CHARSET."
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
172 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173 (aref (charset-info (nth 1 charset)) 0)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
174 (list 'aref (list 'charset-info charset) 0)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 (defmacro charset-bytes (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
177 "Return bytes of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
178 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
179 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180 (aref (charset-info (nth 1 charset)) 1)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
181 (list 'aref (list 'charset-info charset) 1)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 (defmacro charset-dimension (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
184 "Return dimension of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
185 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
186 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187 (aref (charset-info (nth 1 charset)) 2)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
188 (list 'aref (list 'charset-info charset) 2)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190 (defmacro charset-chars (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
191 "Return character numbers contained in a dimension of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
192 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
193 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194 (aref (charset-info (nth 1 charset)) 3)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
195 (list 'aref (list 'charset-info charset) 3)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
196
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
197 (defmacro charset-width (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
198 "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
199 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
200 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201 (aref (charset-info (nth 1 charset)) 4)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
202 (list 'aref (list 'charset-info charset) 4)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
204 (defmacro charset-direction (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
205 "Return direction of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
206 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
207 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208 (aref (charset-info (nth 1 charset)) 5)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
209 (list 'aref (list 'charset-info charset) 5)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
210
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 (defmacro charset-iso-final-char (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
212 "Return final char of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
213 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
214 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
215 (aref (charset-info (nth 1 charset)) 8)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
216 (list 'aref (list 'charset-info charset) 8)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
217
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 (defmacro charset-iso-graphic-plane (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
219 "Return graphic plane of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
220 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
221 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
222 (aref (charset-info (nth 1 charset)) 9)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
223 (list 'aref (list 'charset-info charset) 9)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
224
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
225 (defmacro charset-reverse-charset (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
226 "Return reverse charset of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
227 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
228 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229 (aref (charset-info (nth 1 charset)) 10)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
230 (list 'aref (list 'charset-info charset) 10)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
231
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
232 (defmacro charset-short-name (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
233 "Return short name of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
234 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
235 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
236 (aref (charset-info (nth 1 charset)) 11)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
237 (list 'aref (list 'charset-info charset) 11)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
238
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
239 (defmacro charset-long-name (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
240 "Return long name of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
241 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
242 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
243 (aref (charset-info (nth 1 charset)) 12)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
244 (list 'aref (list 'charset-info charset) 12)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
245
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
246 (defmacro charset-description (charset)
23157
896708140990 (charset-description): Doc fix.
Paul Eggert <eggert@twinsun.com>
parents: 23030
diff changeset
247 "Return description of CHARSET.
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
248 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
249 (if (charset-quoted-standard-p charset)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
250 (aref (charset-info (nth 1 charset)) 13)
26085
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
251 (list 'aref (list 'charset-info charset) 13)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
252
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
253 (defmacro charset-plist (charset)
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
254 "Return list charset property of CHARSET.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
255 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
256 (list 'aref
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
257 (if (charset-quoted-standard-p charset)
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
258 (charset-info (nth 1 charset))
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
259 (list 'charset-info charset))
2473e4ca59b3 * international/mule-cmds.el (global-map):
Paul Eggert <eggert@twinsun.com>
parents: 25198
diff changeset
260 14))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
261
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
262 (defun set-charset-plist (charset plist)
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23157
diff changeset
263 "Set CHARSET's property list to PLIST, and return PLIST."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
264 (aset (charset-info charset) 14 plist))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
265
34117
9cbbc1edaba0 (make-char): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 33245
diff changeset
266 (defun make-char (charset &optional code1 code2)
9cbbc1edaba0 (make-char): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 33245
diff changeset
267 "Return a character of CHARSET whose position codes are CODE1 and CODE2.
17175
3e54eb2d2a57 (make-char): Documented.
Kenichi Handa <handa@m17n.org>
parents: 17094
diff changeset
268 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
269 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
270 all characters or group of characters in the character set.
34117
9cbbc1edaba0 (make-char): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 33245
diff changeset
271 A generic character can be used to index a char table (e.g. syntax-table).
34759
31e8fba26248 (make-char): Docstring adjusted for the change of make-char-internal.
Kenichi Handa <handa@m17n.org>
parents: 34688
diff changeset
272
31e8fba26248 (make-char): Docstring adjusted for the change of make-char-internal.
Kenichi Handa <handa@m17n.org>
parents: 34688
diff changeset
273 Such character sets as ascii, eight-bit-control, and eight-bit-graphic
31e8fba26248 (make-char): Docstring adjusted for the change of make-char-internal.
Kenichi Handa <handa@m17n.org>
parents: 34688
diff changeset
274 don't have corresponding generic characters. If CHARSET is one of
31e8fba26248 (make-char): Docstring adjusted for the change of make-char-internal.
Kenichi Handa <handa@m17n.org>
parents: 34688
diff changeset
275 them and you don't supply CODE1, return the character of the smallest
31e8fba26248 (make-char): Docstring adjusted for the change of make-char-internal.
Kenichi Handa <handa@m17n.org>
parents: 34688
diff changeset
276 code in CHARSET.
31e8fba26248 (make-char): Docstring adjusted for the change of make-char-internal.
Kenichi Handa <handa@m17n.org>
parents: 34688
diff changeset
277
41677
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
278 If CODE1 or CODE2 are invalid (out of range), this function signals an
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
279 error. However, the eighth bit of both CODE1 and CODE2 is zeroed
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
280 before they are used to index CHARSET. Thus you may use, say, the
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
281 actual ISO 8859 character code rather than subtracting 128, as you
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
282 would need to index the corresponding Emacs charset."
34123
3c1b837399d9 (make-char): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 34117
diff changeset
283 (make-char-internal (charset-id charset) code1 code2))
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
284
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
285 (put 'make-char 'byte-compile
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
286 (function
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
287 (lambda (form)
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
288 (let ((charset (nth 1 form)))
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
289 (if (charset-quoted-standard-p charset)
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
290 (byte-compile-normal-call
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
291 (cons 'make-char-internal
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
292 (cons (charset-id (nth 1 charset)) (nthcdr 2 form))))
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
293 (byte-compile-normal-call
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
294 (cons 'make-char-internal
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
295 (cons (list 'charset-id charset) (nthcdr 2 form)))))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
297 (defun charset-list ()
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
298 "Return list of charsets ever defined.
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
299
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
300 This function is provided for backward compatibility.
18558
09cc19f19722 (charset-bytes, charset-dimension,
Kenichi Handa <handa@m17n.org>
parents: 18518
diff changeset
301 Now we have the variable `charset-list'."
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
302 charset-list)
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
303
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
304 (defsubst generic-char-p (char)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
305 "Return t if and only if CHAR is a generic character.
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
306 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
307 (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
308 (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
309 (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
310 (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
311
33045
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
312 (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
313 "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
314 Return nil if such a character is not supported.
34297
8fffee49b42e (decode-char, encode-char): Doc fix.
Dave Love <fx@gnu.org>
parents: 34123
diff changeset
315 Currently the only supported coded character set is `ucs' (ISO/IEC
46505
005d282a48ed (decode-char): Use utf-8-translation-table-for-decode.
Dave Love <fx@gnu.org>
parents: 46504
diff changeset
316 10646: Universal Multi-Octet Coded Character Set), and the result is
47708
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
317 translated through the translation-table named
68381
2ed18bf835e1 (decode-char): Avoid the overhead of
Kenichi Handa <handa@m17n.org>
parents: 68331
diff changeset
318 `utf-translation-table-for-decode', or through the
2ed18bf835e1 (decode-char): Avoid the overhead of
Kenichi Handa <handa@m17n.org>
parents: 68331
diff changeset
319 translation-hash-table named `utf-subst-table-for-decode'
2ed18bf835e1 (decode-char): Avoid the overhead of
Kenichi Handa <handa@m17n.org>
parents: 68331
diff changeset
320 \(if `utf-translate-cjk-mode' is non-nil).
33045
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
321
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
322 Optional argument RESTRICTION specifies a way to map the pair of CCS
47260
b0b872e61fc5 (decode-char): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents: 47232
diff changeset
323 and CODE-POINT to a character. Currently not supported and just ignored."
46505
005d282a48ed (decode-char): Use utf-8-translation-table-for-decode.
Dave Love <fx@gnu.org>
parents: 46504
diff changeset
324 (cond
005d282a48ed (decode-char): Use utf-8-translation-table-for-decode.
Dave Love <fx@gnu.org>
parents: 46504
diff changeset
325 ((eq ccs 'ucs)
68381
2ed18bf835e1 (decode-char): Avoid the overhead of
Kenichi Handa <handa@m17n.org>
parents: 68331
diff changeset
326 (or (and utf-translate-cjk-mode
2ed18bf835e1 (decode-char): Avoid the overhead of
Kenichi Handa <handa@m17n.org>
parents: 68331
diff changeset
327 (utf-lookup-subst-table-for-decode code-point))
47708
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
328 (let ((c (cond
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
329 ((< code-point 160)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
330 code-point)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
331 ((< code-point 256)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
332 (make-char 'latin-iso8859-1 code-point))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
333 ((< code-point #x2500)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
334 (setq code-point (- code-point #x0100))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
335 (make-char 'mule-unicode-0100-24ff
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
336 (+ (/ code-point 96) 32) (+ (% code-point 96) 32)))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
337 ((< code-point #x3400)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
338 (setq code-point (- code-point #x2500))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
339 (make-char 'mule-unicode-2500-33ff
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
340 (+ (/ code-point 96) 32) (+ (% code-point 96) 32)))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
341 ((and (>= code-point #xe000) (< code-point #x10000))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
342 (setq code-point (- code-point #xe000))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
343 (make-char 'mule-unicode-e000-ffff
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
344 (+ (/ code-point 96) 32)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
345 (+ (% code-point 96) 32))))))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
346 (when c
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
347 (or (aref (get 'utf-translation-table-for-decode
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
348 'translation-table) c)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
349 c)))))))
33045
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
350
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
351 (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
352 "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
353 Return nil if CHAR is not included in CCS.
34297
8fffee49b42e (decode-char, encode-char): Doc fix.
Dave Love <fx@gnu.org>
parents: 34123
diff changeset
354 Currently the only supported coded character set is `ucs' (ISO/IEC
46505
005d282a48ed (decode-char): Use utf-8-translation-table-for-decode.
Dave Love <fx@gnu.org>
parents: 46504
diff changeset
355 10646: Universal Multi-Octet Coded Character Set), and CHAR is first
47708
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
356 translated through the translation-table named
68381
2ed18bf835e1 (decode-char): Avoid the overhead of
Kenichi Handa <handa@m17n.org>
parents: 68331
diff changeset
357 `utf-translation-table-for-encode', or through the
2ed18bf835e1 (decode-char): Avoid the overhead of
Kenichi Handa <handa@m17n.org>
parents: 68331
diff changeset
358 translation-hash-table named `utf-subst-table-for-encode' \(if
2ed18bf835e1 (decode-char): Avoid the overhead of
Kenichi Handa <handa@m17n.org>
parents: 68331
diff changeset
359 `utf-translate-cjk-mode' is non-nil).
33245
9366a16a186b (decode-char, encode-char): Fix doc-string.
Kenichi Handa <handa@m17n.org>
parents: 33045
diff changeset
360
9366a16a186b (decode-char, encode-char): Fix doc-string.
Kenichi Handa <handa@m17n.org>
parents: 33045
diff changeset
361 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
362 ascii, latin-iso8859-1, mule-unicode-0100-24ff, mule-unicode-2500-33ff,
35320
aa8df54873a9 (decode-char): Fix conditions.
Kenichi Handa <handa@m17n.org>
parents: 35154
diff changeset
363 mule-unicode-e000-ffff, eight-bit-control
33045
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
364 Otherwise, return nil.
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
365
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
366 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
367 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
368 (let* ((split (split-char char))
46505
005d282a48ed (decode-char): Use utf-8-translation-table-for-decode.
Dave Love <fx@gnu.org>
parents: 46504
diff changeset
369 (charset (car split))
005d282a48ed (decode-char): Use utf-8-translation-table-for-decode.
Dave Love <fx@gnu.org>
parents: 46504
diff changeset
370 trans)
33045
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
371 (cond ((eq ccs 'ucs)
68381
2ed18bf835e1 (decode-char): Avoid the overhead of
Kenichi Handa <handa@m17n.org>
parents: 68331
diff changeset
372 (or (and utf-translate-cjk-mode
2ed18bf835e1 (decode-char): Avoid the overhead of
Kenichi Handa <handa@m17n.org>
parents: 68331
diff changeset
373 (utf-lookup-subst-table-for-encode char))
47708
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
374 (let ((table (get 'utf-translation-table-for-encode
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
375 'translation-table)))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
376 (setq trans (aref table char))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
377 (if trans
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
378 (setq split (split-char trans)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
379 charset (car split)))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
380 (cond ((eq charset 'ascii)
52234
8430ee3561fa (encode-char): Fix for the ASCII case.
Kenichi Handa <handa@m17n.org>
parents: 51978
diff changeset
381 (or trans char))
47708
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
382 ((eq charset 'latin-iso8859-1)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
383 (+ (nth 1 split) 128))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
384 ((eq charset 'mule-unicode-0100-24ff)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
385 (+ #x0100 (+ (* (- (nth 1 split) 32) 96)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
386 (- (nth 2 split) 32))))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
387 ((eq charset 'mule-unicode-2500-33ff)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
388 (+ #x2500 (+ (* (- (nth 1 split) 32) 96)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
389 (- (nth 2 split) 32))))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
390 ((eq charset 'mule-unicode-e000-ffff)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
391 (+ #xe000 (+ (* (- (nth 1 split) 32) 96)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
392 (- (nth 2 split) 32))))
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
393 ((eq charset 'eight-bit-control)
b9d7faa08e87 (decode-char): Refer to the translation
Kenichi Handa <handa@m17n.org>
parents: 47417
diff changeset
394 char))))))))
33045
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
395
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
396
34297
8fffee49b42e (decode-char, encode-char): Doc fix.
Dave Love <fx@gnu.org>
parents: 34123
diff changeset
397 ;; Coding system stuff
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
398
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
399 ;; Coding system is a symbol that has the property `coding-system'.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
400 ;;
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
401 ;; 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
402 ;; following format:
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
403 ;; [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
404 ;; We call this vector as coding-spec. See comments in src/coding.c
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
405 ;; for more detail.
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
406
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
407 (defconst coding-spec-type-idx 0)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
408 (defconst coding-spec-mnemonic-idx 1)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
409 (defconst coding-spec-doc-string-idx 2)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
410 (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
411 (defconst coding-spec-flags-idx 4)
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
412
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
413 ;; 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
414 ;; 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
415 ;; 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
416 ;; 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
417 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
418 ;; o coding-category
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
419 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
420 ;; The value is a coding category the coding system belongs to. The
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
421 ;; function `make-coding-system' sets this value automatically
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
422 ;; unless its argument PROPERTIES specifies this property.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
423 ;;
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
424 ;; o alias-coding-systems
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
425 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
426 ;; 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
427 ;; 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
428 ;; `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
429 ;; value automatically and `define-coding-system-alias' updates it.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
430 ;;
35808
3507e0283ebb *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 35807
diff changeset
431 ;; See the documentation of make-coding-system for the meanings of the
3507e0283ebb *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 35807
diff changeset
432 ;; following properties.
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
433 ;;
35808
3507e0283ebb *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 35807
diff changeset
434 ;; o post-read-conversion
3507e0283ebb *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 35807
diff changeset
435 ;; o pre-write-conversion
3507e0283ebb *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 35807
diff changeset
436 ;; o translation-table-for-decode
3507e0283ebb *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 35807
diff changeset
437 ;; o translation-table-for-encode
3507e0283ebb *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 35807
diff changeset
438 ;; o safe-chars
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
439 ;; o safe-charsets
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
440 ;; o mime-charset
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
441 ;; 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
442
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
443
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
444 (defsubst coding-system-spec (coding-system)
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
445 "Return coding-spec of CODING-SYSTEM."
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
446 (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
447
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
448 (defun coding-system-type (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
449 "Return the coding type of CODING-SYSTEM.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
450 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
451 of CODING-SYSTEM. See the function `make-coding-system' for more detail."
46728
bd4c1ae5d8e7 Fix previous unexpected change.
Kenichi Handa <handa@m17n.org>
parents: 46727
diff changeset
452 (aref (coding-system-spec coding-system) coding-spec-type-idx))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
453
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
454 (defun coding-system-mnemonic (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
455 "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
456 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
457 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
458 (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
459 (if spec (aref spec coding-spec-mnemonic-idx) ?-)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
460
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
461 (defun coding-system-doc-string (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
462 "Return the documentation string for CODING-SYSTEM."
46728
bd4c1ae5d8e7 Fix previous unexpected change.
Kenichi Handa <handa@m17n.org>
parents: 46727
diff changeset
463 (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
464
19985
930e7515c033 (charset-list): Change it to function.
Kenichi Handa <handa@m17n.org>
parents: 19948
diff changeset
465 (defun coding-system-plist (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
466 "Return the property list of CODING-SYSTEM."
46728
bd4c1ae5d8e7 Fix previous unexpected change.
Kenichi Handa <handa@m17n.org>
parents: 46727
diff changeset
467 (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
468
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
469 (defun coding-system-flags (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
470 "Return `flags' of CODING-SYSTEM.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
471 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
472 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
473 for more detail."
46728
bd4c1ae5d8e7 Fix previous unexpected change.
Kenichi Handa <handa@m17n.org>
parents: 46727
diff changeset
474 (aref (coding-system-spec coding-system) coding-spec-flags-idx))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
475
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
476 (defun coding-system-get (coding-system prop)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
477 "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
478 (plist-get (coding-system-plist coding-system) prop))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
479
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
480 (defun coding-system-put (coding-system prop val)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
481 "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
482 (let ((plist (coding-system-plist coding-system)))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
483 (if plist
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
484 (plist-put plist prop val)
46728
bd4c1ae5d8e7 Fix previous unexpected change.
Kenichi Handa <handa@m17n.org>
parents: 46727
diff changeset
485 (aset (coding-system-spec coding-system) coding-spec-plist-idx
bd4c1ae5d8e7 Fix previous unexpected change.
Kenichi Handa <handa@m17n.org>
parents: 46727
diff changeset
486 (list prop val)))))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
487
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
488 (defun coding-system-category (coding-system)
36466
42097c412119 (ccl-compile): Doc fix.
Dave Love <fx@gnu.org>
parents: 36262
diff changeset
489 "Return the coding category of CODING-SYSTEM.
42097c412119 (ccl-compile): Doc fix.
Dave Love <fx@gnu.org>
parents: 36262
diff changeset
490 See also `coding-category-list'."
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
491 (coding-system-get coding-system 'coding-category))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
492
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
493 (defun coding-system-base (coding-system)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
494 "Return the base coding system of CODING-SYSTEM.
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
495 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
496 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
497 (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
498
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
499 ;; Coding system also has a property `eol-type'.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
500 ;;
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
501 ;; 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
502 ;; 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
503 ;; 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
504 ;; 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
505 ;; 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
506 ;; 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
507 ;; system whose `eol-type' property is N.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
508
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
509 (defun coding-system-eol-type (coding-system)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
510 "Return eol-type of CODING-SYSTEM.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
511 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
512
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
513 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
514 CRLF, and CR respectively.
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
515
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
516 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
517 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
518 coding system whose eol-type is N."
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
519 (get coding-system 'eol-type))
18312
705da3ce58c0 (coding-system-parent): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 18298
diff changeset
520
48155
f1434b395146 (coding-system-eol-type-mnemonic): Move from mule-util.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 47874
diff changeset
521 (defun coding-system-eol-type-mnemonic (coding-system)
f1434b395146 (coding-system-eol-type-mnemonic): Move from mule-util.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 47874
diff changeset
522 "Return the string indicating end-of-line format of CODING-SYSTEM."
f1434b395146 (coding-system-eol-type-mnemonic): Move from mule-util.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 47874
diff changeset
523 (let* ((eol-type (coding-system-eol-type coding-system))
48164
e2f230bb8acc (coding-system-eol-type-mnemonic): Use
Kenichi Handa <handa@m17n.org>
parents: 48155
diff changeset
524 (val (cond ((eq eol-type 0) eol-mnemonic-unix)
48155
f1434b395146 (coding-system-eol-type-mnemonic): Move from mule-util.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 47874
diff changeset
525 ((eq eol-type 1) eol-mnemonic-dos)
f1434b395146 (coding-system-eol-type-mnemonic): Move from mule-util.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 47874
diff changeset
526 ((eq eol-type 2) eol-mnemonic-mac)
48164
e2f230bb8acc (coding-system-eol-type-mnemonic): Use
Kenichi Handa <handa@m17n.org>
parents: 48155
diff changeset
527 (t eol-mnemonic-undecided))))
48155
f1434b395146 (coding-system-eol-type-mnemonic): Move from mule-util.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 47874
diff changeset
528 (if (stringp val)
f1434b395146 (coding-system-eol-type-mnemonic): Move from mule-util.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 47874
diff changeset
529 val
f1434b395146 (coding-system-eol-type-mnemonic): Move from mule-util.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 47874
diff changeset
530 (char-to-string val))))
f1434b395146 (coding-system-eol-type-mnemonic): Move from mule-util.el.
Juanma Barranquero <lekktu@gmail.com>
parents: 47874
diff changeset
531
24276
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
532 (defun coding-system-lessp (x y)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
533 (cond ((eq x 'no-conversion) t)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
534 ((eq y 'no-conversion) nil)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
535 ((eq x 'emacs-mule) t)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
536 ((eq y 'emacs-mule) nil)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
537 ((eq x 'undecided) t)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
538 ((eq y 'undecided) nil)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
539 (t (let ((c1 (coding-system-mnemonic x))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
540 (c2 (coding-system-mnemonic y)))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
541 (or (< (downcase c1) (downcase c2))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
542 (and (not (> (downcase c1) (downcase c2)))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
543 (< c1 c2)))))))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
544
57444
5af5500fd1de (coding-system-equal): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 56345
diff changeset
545 (defun coding-system-equal (coding-system-1 coding-system-2)
5af5500fd1de (coding-system-equal): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 56345
diff changeset
546 "Return t if and only if CODING-SYSTEM-1 and CODING-SYSTEM-2 are identical.
5af5500fd1de (coding-system-equal): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 56345
diff changeset
547 Two coding systems are identical if two symbols are equal
5af5500fd1de (coding-system-equal): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 56345
diff changeset
548 or one is an alias of the other."
5af5500fd1de (coding-system-equal): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 56345
diff changeset
549 (or (eq coding-system-1 coding-system-2)
5af5500fd1de (coding-system-equal): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 56345
diff changeset
550 (and (equal (coding-system-spec coding-system-1)
5af5500fd1de (coding-system-equal): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 56345
diff changeset
551 (coding-system-spec coding-system-2))
5af5500fd1de (coding-system-equal): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 56345
diff changeset
552 (let ((eol-type-1 (coding-system-eol-type coding-system-1))
5af5500fd1de (coding-system-equal): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 56345
diff changeset
553 (eol-type-2 (coding-system-eol-type coding-system-2)))
5af5500fd1de (coding-system-equal): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 56345
diff changeset
554 (or (eq eol-type-1 eol-type-2)
5af5500fd1de (coding-system-equal): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 56345
diff changeset
555 (and (vectorp eol-type-1) (vectorp eol-type-2)))))))
5af5500fd1de (coding-system-equal): Moved from mule-util.el.
Kenichi Handa <handa@m17n.org>
parents: 56345
diff changeset
556
24276
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
557 (defun add-to-coding-system-list (coding-system)
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
558 "Add CODING-SYSTEM to `coding-system-list' while keeping it sorted."
24276
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
559 (if (or (null coding-system-list)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
560 (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
561 (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
562 (let ((len (length coding-system-list))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
563 mid (tem coding-system-list))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
564 (while (> len 1)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
565 (setq mid (nthcdr (/ len 2) tem))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
566 (if (coding-system-lessp (car mid) coding-system)
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
567 (setq tem mid
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
568 len (- len (/ len 2)))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
569 (setq len (/ len 2))))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
570 (setcdr tem (cons coding-system (cdr tem))))))
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
571
24345
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
572 (defun coding-system-list (&optional base-only)
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
573 "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
574 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
575 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
576 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
577 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
578 (let* ((codings (copy-sequence coding-system-list))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
579 (tail (cons nil codings)))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
580 ;; Remove subsidiary coding systems (eol variants) and alias
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
581 ;; coding systems (if necessary).
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
582 (while (cdr tail)
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
583 (let* ((coding (car (cdr tail)))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
584 (aliases (coding-system-get coding 'alias-coding-systems)))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
585 (if (or
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
586 ;; 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
587 (not (memq coding aliases))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
588 ;; 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
589 (and base-only (not (eq coding (car aliases)))))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
590 (setcdr tail (cdr (cdr tail)))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
591 (setq tail (cdr tail)))))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
592 codings))
26fcfef41d24 (coding-system-list): Moved here from
Kenichi Handa <handa@m17n.org>
parents: 24299
diff changeset
593
41677
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
594 (defun map-charset-chars (func charset)
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
595 "Use FUNC to map over all characters in CHARSET for side effects.
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
596 FUNC is a function of two args, the start and end (inclusive) of a
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
597 character code range. Thus FUNC should iterate over [START, END]."
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
598 (let* ((dim (charset-dimension charset))
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
599 (chars (charset-chars charset))
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
600 (start (if (= chars 94)
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
601 33
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
602 32)))
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
603 (if (= dim 1)
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
604 (funcall func
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
605 (make-char charset start)
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
606 (make-char charset (+ start chars -1)))
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
607 (dotimes (i chars)
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
608 (funcall func
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
609 (make-char charset (+ i start) start)
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
610 (make-char charset (+ i start) (+ start chars -1)))))))
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
611
55885
9d46d8e2e70b (register-char-codings): Make alias for `ignore'. Move docstring to
Juanma Barranquero <lekktu@gmail.com>
parents: 55048
diff changeset
612 (defalias 'register-char-codings 'ignore "")
50181
b88623fccdf1 * international/mule.el (optimize-char-coding-system-table):
Kenichi Handa <handa@m17n.org>
parents: 50168
diff changeset
613 (make-obsolete 'register-char-codings
55885
9d46d8e2e70b (register-char-codings): Make alias for `ignore'. Move docstring to
Juanma Barranquero <lekktu@gmail.com>
parents: 55048
diff changeset
614 "it exists just for backward compatibility, and does nothing."
50181
b88623fccdf1 * international/mule.el (optimize-char-coding-system-table):
Kenichi Handa <handa@m17n.org>
parents: 50168
diff changeset
615 "21.3")
48891
49c591ef85fb (optimize-char-coding-system-table): New.
Dave Love <fx@gnu.org>
parents: 48880
diff changeset
616
50181
b88623fccdf1 * international/mule.el (optimize-char-coding-system-table):
Kenichi Handa <handa@m17n.org>
parents: 50168
diff changeset
617 (defconst char-coding-system-table nil
b88623fccdf1 * international/mule.el (optimize-char-coding-system-table):
Kenichi Handa <handa@m17n.org>
parents: 50168
diff changeset
618 "This is an obsolete variable.
b88623fccdf1 * international/mule.el (optimize-char-coding-system-table):
Kenichi Handa <handa@m17n.org>
parents: 50168
diff changeset
619 It exists just for backward compatibility, and the value is always nil.")
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
620
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
621 (defun make-subsidiary-coding-system (coding-system)
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
622 "Make subsidiary coding systems (eol-type variants) of CODING-SYSTEM."
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
623 (let ((coding-spec (coding-system-spec coding-system))
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
624 (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
625 (intern (format "%s-dos" coding-system))
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
626 (intern (format "%s-mac" coding-system))))
68331
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
627 elt)
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
628 (dotimes (i 3)
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
629 (setq elt (aref subsidiaries i))
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
630 (put elt 'coding-system coding-spec)
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
631 (put elt 'eol-type i)
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
632 (put elt 'coding-system-define-form nil)
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
633 (add-to-coding-system-list elt)
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
634 (or (assoc (symbol-name elt) coding-system-alist)
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
635 (setq coding-system-alist
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
636 (cons (list (symbol-name elt)) coding-system-alist))))
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
637 subsidiaries))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
638
35324
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
639 (defun transform-make-coding-system-args (name type &optional doc-string props)
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
640 "For internal use only.
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
641 Transform XEmacs style args for `make-coding-system' to Emacs style.
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
642 Value is a list of transformed arguments."
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
643 (let ((mnemonic (string-to-char (or (plist-get props 'mnemonic) "?")))
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
644 (eol-type (plist-get props 'eol-type))
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
645 properties tmp)
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
646 (cond
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
647 ((eq eol-type 'lf) (setq eol-type 'unix))
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
648 ((eq eol-type 'crlf) (setq eol-type 'dos))
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
649 ((eq eol-type 'cr) (setq eol-type 'mac)))
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
650 (if (setq tmp (plist-get props 'post-read-conversion))
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
651 (setq properties (plist-put properties 'post-read-conversion tmp)))
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
652 (if (setq tmp (plist-get props 'pre-write-conversion))
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
653 (setq properties (plist-put properties 'pre-write-conversion tmp)))
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
654 (cond
35946
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
655 ((eq type 'shift-jis)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
656 `(,name 1 ,mnemonic ,doc-string () ,properties ,eol-type))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
657 ((eq type 'iso2022) ; This is not perfect.
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
658 (if (plist-get props 'escape-quoted)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
659 (error "escape-quoted is not supported: %S"
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
660 `(,name ,type ,doc-string ,props)))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
661 (let ((g0 (plist-get props 'charset-g0))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
662 (g1 (plist-get props 'charset-g1))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
663 (g2 (plist-get props 'charset-g2))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
664 (g3 (plist-get props 'charset-g3))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
665 (use-roman
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
666 (and
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
667 (eq (cadr (assoc 'latin-jisx0201
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
668 (plist-get props 'input-charset-conversion)))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
669 'ascii)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
670 (eq (cadr (assoc 'ascii
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
671 (plist-get props 'output-charset-conversion)))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
672 'latin-jisx0201)))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
673 (use-oldjis
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
674 (and
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
675 (eq (cadr (assoc 'japanese-jisx0208-1978
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
676 (plist-get props 'input-charset-conversion)))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
677 'japanese-jisx0208)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
678 (eq (cadr (assoc 'japanese-jisx0208
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
679 (plist-get props 'output-charset-conversion)))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
680 'japanese-jisx0208-1978))))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
681 (if (charsetp g0)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
682 (if (plist-get props 'force-g0-on-output)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
683 (setq g0 `(nil ,g0))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
684 (setq g0 `(,g0 t))))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
685 (if (charsetp g1)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
686 (if (plist-get props 'force-g1-on-output)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
687 (setq g1 `(nil ,g1))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
688 (setq g1 `(,g1 t))))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
689 (if (charsetp g2)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
690 (if (plist-get props 'force-g2-on-output)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
691 (setq g2 `(nil ,g2))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
692 (setq g2 `(,g2 t))))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
693 (if (charsetp g3)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
694 (if (plist-get props 'force-g3-on-output)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
695 (setq g3 `(nil ,g3))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
696 (setq g3 `(,g3 t))))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
697 `(,name 2 ,mnemonic ,doc-string
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
698 (,g0 ,g1 ,g2 ,g3
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
699 ,(plist-get props 'short)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
700 ,(not (plist-get props 'no-ascii-eol))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
701 ,(not (plist-get props 'no-ascii-cntl))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
702 ,(plist-get props 'seven)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
703 t
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
704 ,(not (plist-get props 'lock-shift))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
705 ,use-roman
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
706 ,use-oldjis
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
707 ,(plist-get props 'no-iso6429)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
708 nil nil nil nil)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
709 ,properties ,eol-type)))
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
710 ((eq type 'big5)
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
711 `(,name 3 ,mnemonic ,doc-string () ,properties ,eol-type))
35324
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
712 ((eq type 'ccl)
35946
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
713 `(,name 4 ,mnemonic ,doc-string
35324
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
714 (,(plist-get props 'decode) . ,(plist-get props 'encode))
35946
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
715 ,properties ,eol-type))
35324
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
716 (t
35946
c5fa4e9ce635 (transform-make-coding-system-args): Make
Kenichi Handa <handa@m17n.org>
parents: 35808
diff changeset
717 (error "unsupported XEmacs style make-coding-style arguments: %S"
35324
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
718 `(,name ,type ,doc-string ,props))))))
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
719
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
720 (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
721 &optional
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
722 flags
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
723 properties
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
724 eol-type)
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
725 "Define a new coding system CODING-SYSTEM (symbol).
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
726 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
727 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
728 in the following format:
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
729 [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
730
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
731 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
732 0: Emacs internal format,
45450
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
733 1: Shift-JIS (or MS-Kanji) used mainly on Japanese PCs,
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
734 2: ISO-2022 including many variants,
45450
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
735 3: Big5 used mainly on Chinese PCs,
19606
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
736 4: private, CCL programs provide encoding/decoding algorithm,
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
737 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
738
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
739 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
740
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
741 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
742
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
743 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
744
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
745 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
746 CHARSET0, CHARSET1, CHARSET2, CHARSET3, SHORT-FORM,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
747 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
748 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
749 SAFE, ACCEPT-LATIN-EXTRA-CODE.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
750 CHARSETn are character sets initially designated to Gn graphic registers.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
751 If CHARSETn is nil, Gn is never used.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
752 If CHARSETn is t, Gn can be used but nothing designated initially.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
753 If CHARSETn is a list of character sets, those character sets are
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
754 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
755 But, character set `ascii' can be designated only to G0.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
756 SHORT-FORM non-nil means use short designation sequence on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
757 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
758 ASCII-CNTL non-nil means designate ASCII to g0 before control codes and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
759 SPACE on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
760 SEVEN non-nil means use 7-bit code only on output.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
761 LOCKING-SHIFT non-nil means use locking-shift.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
762 SINGLE-SHIFT non-nil means use single-shift.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
763 USE-ROMAN non-nil means designate JIS0201-1976-Roman instead of ASCII.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
764 USE-OLDJIS non-nil means designate JIS0208-1976 instead of JIS0208-1983.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
765 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
766 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
767 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
768 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
769 at beginning of line on output.
20161
0d9c6ccdc45c (load-with-code-conversion): Update
Kenichi Handa <handa@m17n.org>
parents: 20112
diff changeset
770 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
771 Characters not specified in the property `safe-charsets' nor
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
772 `safe-chars' are unsafe.
19395
cf115b0c7458 (make-coding-system): Add a new FLAGS
Richard M. Stallman <rms@gnu.org>
parents: 19263
diff changeset
773 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
774 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
775 code of the coding system.
19263
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
776
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
777 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
778 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
779 symbols.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
780
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
781 PROPERTIES is an alist of properties vs the corresponding values. The
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
782 following properties are recognized:
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
783
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
784 o post-read-conversion
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
785
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
786 The value is a function to call after some text is inserted and
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
787 decoded by the coding system itself and before any functions in
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
788 `after-insert-functions' are called. The argument of this
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
789 function is the same as for a function in
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
790 `after-insert-file-functions', i.e. LENGTH of the text inserted,
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
791 with point at the head of the text to be decoded.
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
792
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
793 o pre-write-conversion
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
794
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
795 The value is a function to call after all functions in
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
796 `write-region-annotate-functions' and `buffer-file-format' are
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
797 called, and before the text is encoded by the coding system itself.
36262
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
798 The arguments to this function are the same as those of a function
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
799 in `write-region-annotate-functions', i.e. FROM and TO, specifying
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
800 a region of text.
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
801
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
802 o translation-table-for-decode
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
803
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
804 The value is a translation table to be applied on decoding. See
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
805 the function `make-translation-table' for the format of translation
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
806 table. This is not applicable to type 4 (CCL-based) coding systems.
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
807
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
808 o translation-table-for-encode
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
809
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
810 The value is a translation table to be applied on encoding. This is
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
811 not applicable to type 4 (CCL-based) coding systems.
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
812
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
813 o safe-chars
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
814
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
815 The value is a char table. If a character has non-nil value in it,
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
816 the character is safely supported by the coding system. This
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
817 overrides the specification of safe-charsets.
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
818
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
819 o safe-charsets
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
820
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
821 The value is a list of charsets safely supported by the coding
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
822 system. The value t means that all charsets Emacs handles are
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
823 supported. Even if some charset is not in this list, it doesn't
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
824 mean that the charset can't be encoded in the coding system;
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
825 it just means that some other receiver of text encoded
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
826 in the coding system won't be able to handle that charset.
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
827
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
828 o mime-charset
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
829
45450
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
830 The value is a symbol whose name is the `MIME-charset' parameter of
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
831 the coding system.
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
832
52289
63ea67e10c27 (make-coding-system)
Dave Love <fx@gnu.org>
parents: 52234
diff changeset
833 o mime-text-unsuitable
63ea67e10c27 (make-coding-system)
Dave Love <fx@gnu.org>
parents: 52234
diff changeset
834
63ea67e10c27 (make-coding-system)
Dave Love <fx@gnu.org>
parents: 52234
diff changeset
835 A non-nil value means the `mime-charset' property names a charset
63ea67e10c27 (make-coding-system)
Dave Love <fx@gnu.org>
parents: 52234
diff changeset
836 which is unsuitable for the top-level media type \"text\".
63ea67e10c27 (make-coding-system)
Dave Love <fx@gnu.org>
parents: 52234
diff changeset
837
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
838 o valid-codes (meaningful only for a coding system based on CCL)
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
839
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
840 The value is a list to indicate valid byte ranges of the encoded
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
841 file. Each element of the list is an integer or a cons of integer.
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
842 In the former case, the integer value is a valid byte code. In the
41677
4c982f51020c Doc fixes.
Dave Love <fx@gnu.org>
parents: 40826
diff changeset
843 latter case, the integers specify the range of valid byte codes.
35807
8e8e96ebe639 (make-coding-system): Add description
Kenichi Handa <handa@m17n.org>
parents: 35750
diff changeset
844
47223
2af8e323b449 (decode-char): Translate a character by
Kenichi Handa <handa@m17n.org>
parents: 46944
diff changeset
845 o composition (meaningful only when TYPE is 0 or 2)
2af8e323b449 (decode-char): Translate a character by
Kenichi Handa <handa@m17n.org>
parents: 46944
diff changeset
846
48183
06be0e8df068 (set-buffer-file-coding-system): Call
Dave Love <fx@gnu.org>
parents: 48164
diff changeset
847 If the value is non-nil, the coding system preserves composition
06be0e8df068 (set-buffer-file-coding-system): Call
Dave Love <fx@gnu.org>
parents: 48164
diff changeset
848 information.
47223
2af8e323b449 (decode-char): Translate a character by
Kenichi Handa <handa@m17n.org>
parents: 46944
diff changeset
849
64125
9f966287a535 (make-coding-system): Describe
Kenichi Handa <handa@m17n.org>
parents: 64085
diff changeset
850 o ascii-incompatible
9f966287a535 (make-coding-system): Describe
Kenichi Handa <handa@m17n.org>
parents: 64085
diff changeset
851
9f966287a535 (make-coding-system): Describe
Kenichi Handa <handa@m17n.org>
parents: 64085
diff changeset
852 If the value is non-nil, the coding system is not compatible
9f966287a535 (make-coding-system): Describe
Kenichi Handa <handa@m17n.org>
parents: 64085
diff changeset
853 with ASCII, which means it encodes or decodes ASCII character
9f966287a535 (make-coding-system): Describe
Kenichi Handa <handa@m17n.org>
parents: 64085
diff changeset
854 string to the different byte sequence.
9f966287a535 (make-coding-system): Describe
Kenichi Handa <handa@m17n.org>
parents: 64085
diff changeset
855
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
856 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
857 also sets properties `coding-category' and `alias-coding-systems'
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
858 automatically.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
859
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
860 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
861 following formats:
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
862
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
863 o symbol (unix, dos, or mac)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
864
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
865 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
866 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
867
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
868 o number (0, 1, or 2)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
869
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
870 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
871 respectively.
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
872
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
873 o vector of coding-systems of length 3
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
874
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
875 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
876 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
877 systems in the vector is selected. Elements of the vector
30877
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30491
diff changeset
878 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
879 in this order.
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
880
21660
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
881 Kludgy features for backward compatibility:
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
882
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
883 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
884 treated as a compiled CCL code.
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
885
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
886 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
887 a value of `safe-charsets' in PLIST."
35324
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
888
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
889 ;; For compatiblity with XEmacs, we check the type of TYPE. If it
35553
79eb2dc0229e Fix a typo in a comment.
Eli Zaretskii <eliz@gnu.org>
parents: 35491
diff changeset
890 ;; is a symbol, perhaps, this function is called with XEmacs-style
79eb2dc0229e Fix a typo in a comment.
Eli Zaretskii <eliz@gnu.org>
parents: 35491
diff changeset
891 ;; arguments. Here, try to transform that kind of arguments to
35324
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
892 ;; Emacs style.
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
893 (if (symbolp type)
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
894 (let ((args (transform-make-coding-system-args coding-system type
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
895 mnemonic doc-string)))
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
896 (setq coding-system (car args)
35491
888971e7d606 (make-coding-system): Fix typo.
Dave Love <fx@gnu.org>
parents: 35481
diff changeset
897 type (nth 1 args)
35324
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
898 mnemonic (nth 2 args)
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
899 doc-string (nth 3 args)
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
900 flags (nth 4 args)
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
901 properties (nth 5 args)
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
902 eol-type (nth 6 args))))
dcbb79777f94 (transform-make-coding-system-args): New function.
Kenichi Handa <handa@m17n.org>
parents: 35320
diff changeset
903
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
904 ;; Set a value of `coding-system' property.
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
905 (let ((coding-spec (make-vector 5 nil))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
906 (no-initial-designation t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
907 (no-alternative-designation t)
35154
e459e9bee789 (make-coding-system): If the coding system
Kenichi Handa <handa@m17n.org>
parents: 34759
diff changeset
908 (accept-latin-extra-code nil)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
909 coding-category)
19606
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
910 (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
911 (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
912 (if (or (not (integerp mnemonic)) (<= mnemonic ? ) (> mnemonic 127))
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
913 (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
914 (aset coding-spec coding-spec-type-idx type)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
915 (aset coding-spec coding-spec-mnemonic-idx mnemonic)
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
916 (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
917 (purecopy (if (stringp doc-string) doc-string "")))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
918 (cond ((= type 0)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
919 (setq coding-category 'coding-category-emacs-mule))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
920 ((= type 1)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
921 (setq coding-category 'coding-category-sjis))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
922 ((= type 2) ; ISO2022
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
923 (let ((i 0)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
924 (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
925 (g1-designation nil)
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
926 (fl flags))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
927 (while (< i 4)
23456
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
928 (let ((charset (car fl)))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
929 (if (and no-initial-designation
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
930 (> i 0)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
931 (or (charsetp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
932 (and (consp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
933 (charsetp (car charset)))))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
934 (setq no-initial-designation nil))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
935 (if (charsetp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
936 (if (= i 1) (setq g1-designation charset))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
937 (if (consp charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
938 (let ((tail charset)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
939 elt)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
940 (while tail
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
941 (setq elt (car tail))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
942 (if (eq elt t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
943 (setq no-alternative-designation nil)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
944 (if (and elt (not (charsetp elt)))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
945 (error "Invalid charset: %s" elt)))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
946 (setq tail (cdr tail)))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
947 (setq g1-designation (car charset)))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
948 (if charset
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
949 (if (eq charset t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
950 (setq no-alternative-designation nil)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
951 (error "Invalid charset: %s" charset)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
952 (aset vec i charset))
23456
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
953 (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
954 (while (and (< i 32) fl)
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
955 (aset vec i (car fl))
35154
e459e9bee789 (make-coding-system): If the coding system
Kenichi Handa <handa@m17n.org>
parents: 34759
diff changeset
956 (if (and (= i 16) ; ACCEPT-LATIN-EXTRA-CODE
e459e9bee789 (make-coding-system): If the coding system
Kenichi Handa <handa@m17n.org>
parents: 34759
diff changeset
957 (car fl))
e459e9bee789 (make-coding-system): If the coding system
Kenichi Handa <handa@m17n.org>
parents: 34759
diff changeset
958 (setq accept-latin-extra-code t))
23456
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
959 (setq fl (cdr fl) i (1+ i)))
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
960 (aset coding-spec 4 vec)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
961 (setq coding-category
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
962 (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
963 (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
964 'coding-category-iso-8-else)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
965 (if (aref vec 7) ; 7-bit only.
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
966 (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
967 'coding-category-iso-7-else
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
968 (if no-alternative-designation
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
969 'coding-category-iso-7-tight
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
970 'coding-category-iso-7))
22160
c1998807c140 (make-coding-system): If ISO2022 based
Kenichi Handa <handa@m17n.org>
parents: 22125
diff changeset
971 (if (or no-initial-designation
c1998807c140 (make-coding-system): If ISO2022 based
Kenichi Handa <handa@m17n.org>
parents: 22125
diff changeset
972 (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
973 'coding-category-iso-8-else
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
974 (if (and (charsetp g1-designation)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
975 (= (charset-dimension g1-designation) 2))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
976 'coding-category-iso-8-2
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
977 'coding-category-iso-8-1)))))))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
978 ((= type 3)
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
979 (setq coding-category 'coding-category-big5))
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
980 ((= type 4) ; private
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
981 (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
982 (if (not (consp flags))
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
983 (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
984 (let ((decoder (check-ccl-program
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
985 (car flags)
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
986 (intern (format "%s-decoder" coding-system))))
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
987 (encoder (check-ccl-program
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
988 (cdr flags)
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
989 (intern (format "%s-encoder" coding-system)))))
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
990 (if (and decoder encoder)
9e5b579ba4f9 (make-coding-system): If TYPE is 4, FLAGS
Kenichi Handa <handa@m17n.org>
parents: 21639
diff changeset
991 (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
992 (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
993 (t ; i.e. (= type 5)
0fbb8f15450e (make-coding-system): Make TYPE 5 means
Kenichi Handa <handa@m17n.org>
parents: 19454
diff changeset
994 (setq coding-category 'coding-category-raw-text)))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
995
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
996 (let ((plist (list 'coding-category coding-category
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
997 'alias-coding-systems (list coding-system))))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
998 (if no-initial-designation
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
999 (plist-put plist 'no-initial-designation t))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1000 (if (and properties
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1001 (or (eq properties t)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1002 (not (consp (car properties)))))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1003 ;; 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
1004 ;; 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
1005 (setq properties (list (cons 'safe-charsets properties))))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1006 ;; In the current version PROPERTIES is a property list.
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1007 ;; 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
1008 ;; specially.
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1009 (let ((safe-charsets (cdr (assq 'safe-charsets properties)))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1010 (safe-chars (cdr (assq 'safe-chars properties)))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1011 (l properties)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1012 prop val)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1013 ;; 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
1014 ;; 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
1015 (if (and (not safe-chars) safe-charsets)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1016 (let (charset)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1017 (if (eq safe-charsets t)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1018 (setq safe-chars t)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1019 (setq safe-chars (make-char-table 'safe-chars))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1020 (while safe-charsets
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1021 (setq charset (car safe-charsets)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1022 safe-charsets (cdr safe-charsets))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1023 (cond ((eq charset 'ascii)) ; just ignore
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1024 ((eq charset 'eight-bit-control)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1025 (let ((i 128))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1026 (while (< i 160)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1027 (aset safe-chars i t)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1028 (setq i (1+ i)))))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1029 ((eq charset 'eight-bit-graphic)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1030 (let ((i 160))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1031 (while (< i 256)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1032 (aset safe-chars i t)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1033 (setq i (1+ i)))))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1034 (t
35154
e459e9bee789 (make-coding-system): If the coding system
Kenichi Handa <handa@m17n.org>
parents: 34759
diff changeset
1035 (aset safe-chars (make-char charset) t))))
e459e9bee789 (make-coding-system): If the coding system
Kenichi Handa <handa@m17n.org>
parents: 34759
diff changeset
1036 (if accept-latin-extra-code
e459e9bee789 (make-coding-system): If the coding system
Kenichi Handa <handa@m17n.org>
parents: 34759
diff changeset
1037 (let ((i 128))
e459e9bee789 (make-coding-system): If the coding system
Kenichi Handa <handa@m17n.org>
parents: 34759
diff changeset
1038 (while (< i 160)
e459e9bee789 (make-coding-system): If the coding system
Kenichi Handa <handa@m17n.org>
parents: 34759
diff changeset
1039 (if (aref latin-extra-code-table i)
e459e9bee789 (make-coding-system): If the coding system
Kenichi Handa <handa@m17n.org>
parents: 34759
diff changeset
1040 (aset safe-chars i t))
e459e9bee789 (make-coding-system): If the coding system
Kenichi Handa <handa@m17n.org>
parents: 34759
diff changeset
1041 (setq i (1+ i))))))
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1042 (setq l (cons (cons 'safe-chars safe-chars) l))))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1043 (while l
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1044 (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
1045 (if (eq prop 'safe-chars)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1046 (progn
33045
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
1047 (if (and (symbolp val)
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
1048 (get val 'translation-table))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
1049 (setq safe-chars (get val 'translation-table)))
694e6396dc8b (decode-char, encode-char): New functions.
Kenichi Handa <handa@m17n.org>
parents: 30965
diff changeset
1050 (setq val safe-chars)))
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1051 (plist-put plist prop val)))
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1052 ;; The property `coding-category' may have been set differently
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1053 ;; through PROPERTIES.
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1054 (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
1055 (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
1056 (put coding-system 'coding-system coding-spec)
60564
8e3e5150cf9e (make-coding-system): Set property
Kenichi Handa <handa@m17n.org>
parents: 60188
diff changeset
1057 (put coding-system 'coding-system-define-form nil)
18298
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
1058 (put coding-category 'coding-systems
3d036a21fc93 (coding-system-type): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 18195
diff changeset
1059 (cons coding-system (get coding-category 'coding-systems))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1060
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1061 ;; 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
1062 (if (not eol-type)
28018
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1063 ;; 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
1064 ;; 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
1065 ;; EOL format.
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1066 (setq eol-type (make-subsidiary-coding-system coding-system)))
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1067 (setq eol-type
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1068 (cond ((or (eq eol-type 'unix) (null eol-type))
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1069 0)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1070 ((eq eol-type 'dos)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1071 1)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1072 ((eq eol-type 'mac)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1073 2)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1074 ((or (and (vectorp eol-type)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1075 (= (length eol-type) 3))
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1076 (and (numberp eol-type)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1077 (and (>= eol-type 0)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1078 (<= eol-type 2))))
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1079 eol-type)
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1080 (t
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1081 (error "Invalid EOL-TYPE spec:%S" eol-type))))
dade22d104f2 Modify comment about coding system
Kenichi Handa <handa@m17n.org>
parents: 26887
diff changeset
1082 (put coding-system 'eol-type eol-type)
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1083
50181
b88623fccdf1 * international/mule.el (optimize-char-coding-system-table):
Kenichi Handa <handa@m17n.org>
parents: 50168
diff changeset
1084 (define-coding-system-internal coding-system)
b88623fccdf1 * international/mule.el (optimize-char-coding-system-table):
Kenichi Handa <handa@m17n.org>
parents: 50168
diff changeset
1085
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1086 ;; 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
1087 ;; `coding-system-alist'.
24276
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
1088 (add-to-coding-system-list coding-system)
68331
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
1089 (or (assoc (symbol-name coding-system) coding-system-alist)
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
1090 (setq coding-system-alist (cons (list (symbol-name coding-system))
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
1091 coding-system-alist)))
23456
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
1092
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
1093 ;; 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
1094 ;; XXX-with-esc variants.
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
1095 (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
1096 (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
1097 (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
1098 (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
1099 (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
1100 (safe-charsets (assq 'safe-charsets properties))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1101 (mime-charset (assq 'mime-charset properties)))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1102 (if safe-charsets
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1103 (setcdr safe-charsets t)
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1104 (setq properties (cons (cons 'safe-charsets t) properties)))
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1105 (if mime-charset
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1106 (setcdr mime-charset nil))
23456
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
1107 (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
1108 (if (listp (car flags))
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
1109 (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
1110 (cons (list (car flags) t) (cdr flags)))
30491
7b4fadfac0c8 (register-char-codings): New function.
Kenichi Handa <handa@m17n.org>
parents: 29722
diff changeset
1111 properties))))
23456
934152e1b9a4 (make-coding-system): Create -with-esc variant coding system.
Kenichi Handa <handa@m17n.org>
parents: 23281
diff changeset
1112
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1113 coding-system)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1114
46742
8f29b98466a8 (safe-chars): Put `char-table-extra-slots' property with value 0.
Kenichi Handa <handa@m17n.org>
parents: 46728
diff changeset
1115 (put 'safe-chars 'char-table-extra-slots 0)
8f29b98466a8 (safe-chars): Put `char-table-extra-slots' property with value 0.
Kenichi Handa <handa@m17n.org>
parents: 46728
diff changeset
1116
18518
425c8fa4227b (define-coding-system-alias): Swap the args.
Richard M. Stallman <rms@gnu.org>
parents: 18457
diff changeset
1117 (defun define-coding-system-alias (alias coding-system)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1118 "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
1119 (put alias 'coding-system (coding-system-spec coding-system))
60564
8e3e5150cf9e (make-coding-system): Set property
Kenichi Handa <handa@m17n.org>
parents: 60188
diff changeset
1120 (put alias 'coding-system-define-form nil)
24276
ec0195eb2657 (coding-system-lessp): Moved here from
Andreas Schwab <schwab@suse.de>
parents: 24026
diff changeset
1121 (add-to-coding-system-list alias)
68331
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
1122 (or (assoc (symbol-name alias) coding-system-alist)
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
1123 (setq coding-system-alist (cons (list (symbol-name alias))
a7c2303e1399 (make-subsidiary-coding-system): Reset
Kenichi Handa <handa@m17n.org>
parents: 68209
diff changeset
1124 coding-system-alist)))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1125 (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
1126 (if (vectorp eol-type)
46489
e429a944355d (define-coding-system-alias): Don't append ALIAS in the property
Kenichi Handa <handa@m17n.org>
parents: 46190
diff changeset
1127 (progn
e429a944355d (define-coding-system-alias): Don't append ALIAS in the property
Kenichi Handa <handa@m17n.org>
parents: 46190
diff changeset
1128 (nconc (coding-system-get alias 'alias-coding-systems) (list alias))
e429a944355d (define-coding-system-alias): Don't append ALIAS in the property
Kenichi Handa <handa@m17n.org>
parents: 46190
diff changeset
1129 (put alias 'eol-type (make-subsidiary-coding-system alias)))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1130 (put alias 'eol-type eol-type))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1131
46785
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1132 (defun merge-coding-systems (first second)
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1133 "Fill in any unspecified aspects of coding system FIRST from SECOND.
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1134 Return the resulting coding system."
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1135 (let ((base (coding-system-base second))
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1136 (eol (coding-system-eol-type second)))
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1137 ;; If FIRST doesn't specify text conversion, merge with that of SECOND.
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1138 (if (eq (coding-system-base first) 'undecided)
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1139 (setq first (coding-system-change-text-conversion first base)))
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1140 ;; If FIRST doesn't specify eol conversion, merge with that of SECOND.
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1141 (if (and (vectorp (coding-system-eol-type first))
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1142 (numberp eol) (>= eol 0) (<= eol 2))
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1143 (setq first (coding-system-change-eol-conversion
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1144 first eol)))
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1145 first))
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1146
52795
2e3d2f94a2ba (autoload-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 52660
diff changeset
1147 (defun autoload-coding-system (symbol form)
2e3d2f94a2ba (autoload-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 52660
diff changeset
1148 "Define SYMBOL as a coding-system that is defined on demand.
2e3d2f94a2ba (autoload-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 52660
diff changeset
1149
2e3d2f94a2ba (autoload-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 52660
diff changeset
1150 FROM is a form to evaluate to define the coding-system."
52799
482664d12a27 (autoload-coding-system): Add SYMBOL to coding-system-alist.
Kenichi Handa <handa@m17n.org>
parents: 52795
diff changeset
1151 (put symbol 'coding-system-define-form form)
482664d12a27 (autoload-coding-system): Add SYMBOL to coding-system-alist.
Kenichi Handa <handa@m17n.org>
parents: 52795
diff changeset
1152 (setq coding-system-alist (cons (list (symbol-name symbol))
68209
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1153 coding-system-alist))
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1154 (dolist (elt '("-unix" "-dos" "-mac"))
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1155 (let ((name (concat (symbol-name symbol) elt)))
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1156 (put (intern name) 'coding-system-define-form form)
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1157 (setq coding-system-alist (cons (list name) coding-system-alist)))))
52795
2e3d2f94a2ba (autoload-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 52660
diff changeset
1158
58277
a8baec933fd4 (set-buffer-file-coding-system): New arg NOMODIFY.
Richard M. Stallman <rms@gnu.org>
parents: 58149
diff changeset
1159 (defun set-buffer-file-coding-system (coding-system &optional force nomodify)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1160 "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
1161 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
1162 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
1163 use \\[list-coding-systems].
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1164
46785
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1165 If CODING-SYSTEM leaves the text conversion unspecified, or if it
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1166 leaves the end-of-line conversion unspecified, FORCE controls what to
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1167 do. If FORCE is nil, get the unspecified aspect (or aspects) from the
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1168 buffer's previous `buffer-file-coding-system' value (if it is
52289
63ea67e10c27 (make-coding-system)
Dave Love <fx@gnu.org>
parents: 52234
diff changeset
1169 specified there). Otherwise, leave it unspecified.
26716
256531a93e10 Docstring modified.
Kenichi Handa <handa@m17n.org>
parents: 26687
diff changeset
1170
256531a93e10 Docstring modified.
Kenichi Handa <handa@m17n.org>
parents: 26687
diff changeset
1171 This marks the buffer modified so that the succeeding \\[save-buffer]
256531a93e10 Docstring modified.
Kenichi Handa <handa@m17n.org>
parents: 26687
diff changeset
1172 surely saves the buffer with CODING-SYSTEM. From a program, if you
58277
a8baec933fd4 (set-buffer-file-coding-system): New arg NOMODIFY.
Richard M. Stallman <rms@gnu.org>
parents: 58149
diff changeset
1173 don't want to mark the buffer modified, specify t for NOMODIFY.
a8baec933fd4 (set-buffer-file-coding-system): New arg NOMODIFY.
Richard M. Stallman <rms@gnu.org>
parents: 58149
diff changeset
1174 If you know exactly what coding system you want to use,
a8baec933fd4 (set-buffer-file-coding-system): New arg NOMODIFY.
Richard M. Stallman <rms@gnu.org>
parents: 58149
diff changeset
1175 just set the variable `buffer-file-coding-system' directly."
65680
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64482
diff changeset
1176 (interactive "zCoding system for saving file (default nil): \nP")
46785
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1177 (check-coding-system coding-system)
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1178 (if (and coding-system buffer-file-coding-system (null force))
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1179 (setq coding-system
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1180 (merge-coding-systems coding-system buffer-file-coding-system)))
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1181 (setq buffer-file-coding-system coding-system)
48354
63020c84491a (set-buffer-file-coding-system): Redo prev chg.
Richard M. Stallman <rms@gnu.org>
parents: 48339
diff changeset
1182 ;; This is in case of an explicit call. Normally, `normal-mode' and
63020c84491a (set-buffer-file-coding-system): Redo prev chg.
Richard M. Stallman <rms@gnu.org>
parents: 48339
diff changeset
1183 ;; `set-buffer-major-mode-hook' take care of setting the table.
63020c84491a (set-buffer-file-coding-system): Redo prev chg.
Richard M. Stallman <rms@gnu.org>
parents: 48339
diff changeset
1184 (if (fboundp 'ucs-set-table-for-input) ; don't lose when building
63020c84491a (set-buffer-file-coding-system): Redo prev chg.
Richard M. Stallman <rms@gnu.org>
parents: 48339
diff changeset
1185 (ucs-set-table-for-input))
58285
34e39dcb6763 (set-buffer-file-coding-system): Finish previous change.
Richard M. Stallman <rms@gnu.org>
parents: 58277
diff changeset
1186 (unless nomodify
34e39dcb6763 (set-buffer-file-coding-system): Finish previous change.
Richard M. Stallman <rms@gnu.org>
parents: 58277
diff changeset
1187 (set-buffer-modified-p t))
46785
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1188 (force-mode-line-update))
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1189
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1190 (defun revert-buffer-with-coding-system (coding-system &optional force)
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1191 "Visit the current buffer's file again using coding system CODING-SYSTEM.
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1192 For a list of possible values of CODING-SYSTEM, use \\[list-coding-systems].
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1193
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1194 If CODING-SYSTEM leaves the text conversion unspecified, or if it
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1195 leaves the end-of-line conversion unspecified, FORCE controls what to
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1196 do. If FORCE is nil, get the unspecified aspect (or aspects) from the
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1197 buffer's previous `buffer-file-coding-system' value (if it is
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1198 specified there). Otherwise, determine it from the file contents as
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1199 usual for visiting a file."
65680
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64482
diff changeset
1200 (interactive "zCoding system for visited file (default nil): \nP")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1201 (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
1202 (if (and coding-system buffer-file-coding-system (null force))
46785
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1203 (setq coding-system
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1204 (merge-coding-systems coding-system buffer-file-coding-system)))
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1205 (let ((coding-system-for-read coding-system))
28581ef4c224 (merge-coding-systems): New function.
Richard M. Stallman <rms@gnu.org>
parents: 46761
diff changeset
1206 (revert-buffer)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1207
48880
669a7bd630a8 (set-file-name-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 48354
diff changeset
1208 (defun set-file-name-coding-system (coding-system)
669a7bd630a8 (set-file-name-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 48354
diff changeset
1209 "Set coding system for decoding and encoding file names to CODING-SYSTEM.
669a7bd630a8 (set-file-name-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 48354
diff changeset
1210 It actually just set the variable `file-name-coding-system' (which
669a7bd630a8 (set-file-name-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 48354
diff changeset
1211 see) to CODING-SYSTEM."
65680
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64482
diff changeset
1212 (interactive "zCoding system for file names (default nil): ")
48880
669a7bd630a8 (set-file-name-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 48354
diff changeset
1213 (check-coding-system coding-system)
64125
9f966287a535 (make-coding-system): Describe
Kenichi Handa <handa@m17n.org>
parents: 64085
diff changeset
1214 (if (and coding-system
9f966287a535 (make-coding-system): Describe
Kenichi Handa <handa@m17n.org>
parents: 64085
diff changeset
1215 (coding-system-get coding-system 'ascii-incompatible))
9f966287a535 (make-coding-system): Describe
Kenichi Handa <handa@m17n.org>
parents: 64085
diff changeset
1216 (error "%s is not ASCII-compatible" coding-system))
48880
669a7bd630a8 (set-file-name-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 48354
diff changeset
1217 (setq file-name-coding-system coding-system))
669a7bd630a8 (set-file-name-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 48354
diff changeset
1218
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1219 (defvar default-terminal-coding-system nil
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1220 "Default value for the terminal coding system.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1221 This is normally set according to the selected language environment.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1222 See also the command `set-terminal-coding-system'.")
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1223
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1224 (defun set-terminal-coding-system (coding-system)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1225 "Set coding system of your terminal to CODING-SYSTEM.
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1226 All text output to the terminal will be encoded
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1227 with the specified coding system.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1228 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
1229 The default is determined by the selected language environment
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1230 or by the previous use of this command."
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1231 (interactive
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1232 (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
1233 default-terminal-coding-system)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1234 default-terminal-coding-system)))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1235 (read-coding-system
65680
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64482
diff changeset
1236 (format "Coding system for terminal display (default %s): "
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1237 default)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1238 default))))
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1239 (if (and (not coding-system)
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1240 (not (terminal-coding-system)))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1241 (setq coding-system default-terminal-coding-system))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1242 (if coding-system
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
1243 (setq default-terminal-coding-system coding-system))
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1244 (set-terminal-coding-system-internal coding-system)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1245 (redraw-frame (selected-frame)))
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1246
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1247 (defvar default-keyboard-coding-system nil
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1248 "Default value of the keyboard coding system.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1249 This is normally set according to the selected language environment.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1250 See also the command `set-keyboard-coding-system'.")
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1251
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1252 (defun set-keyboard-coding-system (coding-system)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1253 "Set coding system for keyboard input to CODING-SYSTEM.
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1254 In addition, this command enables Encoded-kbd minor mode.
34688
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1255 \(If CODING-SYSTEM is nil, Encoded-kbd mode is turned off -- see
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1256 `encoded-kbd-mode'.)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1257 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
1258 The default is determined by the selected language environment
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1259 or by the previous use of this command."
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1260 (interactive
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1261 (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
1262 default-keyboard-coding-system)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1263 default-keyboard-coding-system)))
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1264 (read-coding-system
65680
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64482
diff changeset
1265 (format "Coding system for keyboard input (default %s): "
19760
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1266 default)
ad4989a73bf0 (charset-quoted-standard-p): New function.
Richard M. Stallman <rms@gnu.org>
parents: 19749
diff changeset
1267 default))))
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1268 (if (and (not coding-system)
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1269 (not (keyboard-coding-system)))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1270 (setq coding-system default-keyboard-coding-system))
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1271 (if coding-system
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1272 (setq default-keyboard-coding-system coding-system))
64125
9f966287a535 (make-coding-system): Describe
Kenichi Handa <handa@m17n.org>
parents: 64085
diff changeset
1273 (if (and coding-system
9f966287a535 (make-coding-system): Describe
Kenichi Handa <handa@m17n.org>
parents: 64085
diff changeset
1274 (coding-system-get coding-system 'ascii-incompatible))
9f966287a535 (make-coding-system): Describe
Kenichi Handa <handa@m17n.org>
parents: 64085
diff changeset
1275 (error "%s is not ASCII-compatible" coding-system))
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1276 (set-keyboard-coding-system-internal coding-system)
38614
2be878396f1e (set-keyboard-coding-system): Set
Gerd Moellmann <gerd@gnu.org>
parents: 38414
diff changeset
1277 (setq keyboard-coding-system coding-system)
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1278 (encoded-kbd-mode (if coding-system 1 0)))
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1279
34688
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1280 (defcustom keyboard-coding-system nil
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1281 "Specify coding system for keyboard input.
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1282 If you set this on a terminal which can't distinguish Meta keys from
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1283 8-bit characters, you will have to use ESC to type Meta characters.
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1284 See Info node `Specify Coding' and Info node `Single-Byte Character Support'.
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1285
49026
4ecab4bfe0cd (register-char-codings): Don't call
Dave Love <fx@gnu.org>
parents: 48891
diff changeset
1286 On non-windowing terminals, this is set from the locale by default.
4ecab4bfe0cd (register-char-codings): Don't call
Dave Love <fx@gnu.org>
parents: 48891
diff changeset
1287
34688
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1288 Setting this variable directly does not take effect;
54546
f357f325cc85 * international/mule.el (keyboard-coding-system): Fix docstring.
Juri Linkov <juri@jurta.org>
parents: 53526
diff changeset
1289 use either \\[customize] or \\[set-keyboard-coding-system]."
34688
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1290 :type '(coding-system :tag "Coding system")
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1291 :link '(info-link "(emacs)Specify Coding")
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1292 :link '(info-link "(emacs)Single-Byte Character Support")
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1293 :set (lambda (symbol value)
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1294 ;; Don't load encoded-kbd-mode unnecessarily.
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1295 (if (or value (boundp 'encoded-kbd-mode))
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1296 (set-keyboard-coding-system value)
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1297 (set-default 'keyboard-coding-system nil))) ; must initialize
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59226
diff changeset
1298 :version "22.1"
34688
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1299 :group 'keyboard
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1300 :group 'mule)
8f397d03b992 (set-keyboard-coding-system): Doc fix.
Dave Love <fx@gnu.org>
parents: 34297
diff changeset
1301
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1302 (defun set-buffer-process-coding-system (decoding encoding)
19162
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1303 "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
1304 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
1305 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
1306
c53a142e847a Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18913
diff changeset
1307 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
1308 (interactive
30965
d3223b7bcd96 (set-buffer-process-coding-system): Make interactive prompt less confusing.
Miles Bader <miles@gnu.org>
parents: 30877
diff changeset
1309 "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
1310 (let ((proc (get-buffer-process (current-buffer))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1311 (if (null proc)
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
1312 (error "No process")
17984
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1313 (check-coding-system decoding)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1314 (check-coding-system encoding)
4882d58acf01 (set-terminal-coding-system): New function.
Kenichi Handa <handa@m17n.org>
parents: 17837
diff changeset
1315 (set-process-coding-system proc decoding encoding)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1316 (force-mode-line-update))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1317
22836
f3603840ddbc (set-clipboard-coding-system): Define as alias.
Richard M. Stallman <rms@gnu.org>
parents: 22832
diff changeset
1318 (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
1319
22741
763e88fd4ca2 (set-selection-coding-system): Renamed from set-clipboard-coding-system.
Richard M. Stallman <rms@gnu.org>
parents: 22700
diff changeset
1320 (defun set-selection-coding-system (coding-system)
47874
4c9cbf50a76c (set-selection-coding-system): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents: 47708
diff changeset
1321 "Make CODING-SYSTEM used for communicating with other X clients.
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1322 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
1323 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
1324 (interactive "zCoding system for X selection: ")
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1325 (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
1326 (setq selection-coding-system coding-system))
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
1327
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23157
diff changeset
1328 ;; Coding system lastly specified by the command
23030
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1329 ;; set-next-selection-coding-system.
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1330 (defvar last-next-selection-coding-system nil)
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1331
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1332 (defun set-next-selection-coding-system (coding-system)
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1333 "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
1334 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
1335 (interactive
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1336 (list (read-coding-system
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1337 (if last-next-selection-coding-system
65680
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64482
diff changeset
1338 (format "Coding system for the next X selection (default %S): "
23030
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1339 last-next-selection-coding-system)
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1340 "Coding system for the next X selection: ")
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1341 last-next-selection-coding-system)))
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1342 (if coding-system
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1343 (setq last-next-selection-coding-system coding-system)
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1344 (setq coding-system last-next-selection-coding-system))
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1345 (check-coding-system coding-system)
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1346
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1347 (setq next-selection-coding-system coding-system))
d2ceee5cd572 (set-selection-coding-system): Make it
Kenichi Handa <handa@m17n.org>
parents: 22903
diff changeset
1348
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1349 (defun set-coding-priority (arg)
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
1350 "Set priority of coding categories according to ARG.
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
1351 ARG is a list of coding categories ordered by priority."
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1352 (let ((l arg)
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1353 (current-list (copy-sequence coding-category-list)))
23196
30beacf88b75 Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 23157
diff changeset
1354 ;; 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
1355 ;; 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
1356 ;; contains all coding categories.
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1357 (while l
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1358 (if (or (null (get (car l) 'coding-category-index))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1359 (null (memq (car l) current-list)))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1360 (error "Invalid or duplicated element in argument: %s" arg))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1361 (setq current-list (delq (car l) current-list))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
1362 (setq l (cdr l)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1363 ;; Update `coding-category-list' and return it.
22227
e7ac7f644152 (set-coding-priority): Call
Kenichi Handa <handa@m17n.org>
parents: 22225
diff changeset
1364 (setq coding-category-list (append arg current-list))
e7ac7f644152 (set-coding-priority): Call
Kenichi Handa <handa@m17n.org>
parents: 22225
diff changeset
1365 (set-coding-priority-internal)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1366
43457
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1367 ;;; X selections
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1368
51313
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1369 (defvar ctext-non-standard-encodings-alist
53240
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1370 '(("big5-0" big5 2 (chinese-big5-1 chinese-big5-2))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1371 ("ISO8859-14" iso-8859-14 1 latin-iso8859-14)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1372 ("ISO8859-15" iso-8859-15 1 latin-iso8859-15))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1373 "Alist of non-standard encoding names vs the corresponding usages in CTEXT.
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1374
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1375 It controls how extended segments of a compound text are handled
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1376 by the coding system `compound-text-with-extensions'.
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1377
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1378 Each element has the form (ENCODING-NAME CODING-SYSTEM N-OCTET CHARSET).
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1379
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1380 ENCODING-NAME is an encoding name of an \"extended segments\".
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1381
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1382 CODING-SYSTEM is the coding-system to encode (or decode) the
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1383 characters into (or from) the extended segment.
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1384
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1385 N-OCTET is the number of octets (bytes) that encodes a character
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1386 in the segment. It can be 0 (meaning the number of octets per
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1387 character is variable), 1, 2, 3, or 4.
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1388
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1389 CHARSET is a charater set containing characters that are encoded
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1390 in the segment. It can be a list of character sets. It can also
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1391 be a char-table, in which case characters that have non-nil value
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1392 in the char-table are the target.
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1393
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1394 On decoding CTEXT, all encoding names listed here are recognized.
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1395
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1396 On encoding CTEXT, encoding names in the variable
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1397 `ctext-non-standard-encodings' (which see) and in the information
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1398 listed for the current language environment under the key
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1399 `ctext-non-standard-encodings' are used.")
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1400
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1401 (defvar ctext-non-standard-encodings
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1402 '("big5-0")
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1403 "List of non-standard encoding names used in extended segments of CTEXT.
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1404 Each element must be one of the names listed in the variable
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1405 `ctext-non-standard-encodings-alist' (which see).")
51313
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1406
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1407 (defvar ctext-non-standard-encodings-regexp
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1408 (string-to-multibyte
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1409 (concat
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1410 ;; For non-standard encodings.
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1411 "\\(\e%/[0-4][\200-\377][\200-\377]\\([^\002]+\\)\002\\)"
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1412 "\\|"
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1413 ;; For UTF-8 encoding.
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1414 "\\(\e%G[^\e]*\e%@\\)")))
43457
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1415
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1416 ;; Functions to support "Non-Standard Character Set Encodings" defined
53240
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1417 ;; by the COMPOUND-TEXT spec. They also support "The UTF-8 encoding"
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1418 ;; described in the section 7 of the documentation of COMPOUND-TEXT
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1419 ;; distributed with XFree86.
46727
ef296b0ffe50 (ctext-post-read-conversion): Add support for emboded utf-8 encodng
Kenichi Handa <handa@m17n.org>
parents: 46675
diff changeset
1420
43457
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1421 (defun ctext-post-read-conversion (len)
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1422 "Decode LEN characters encoded as Compound Text with Extended Segments."
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1423 (save-match-data
51313
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1424 (save-restriction
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1425 (let ((case-fold-search nil)
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1426 (in-workbuf (string= (buffer-name) " *code-converting-work*"))
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1427 last-coding-system-used
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1428 pos bytes)
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1429 (or in-workbuf
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1430 (narrow-to-region (point) (+ (point) len)))
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1431 (if in-workbuf
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1432 (set-buffer-multibyte t))
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1433 (while (re-search-forward ctext-non-standard-encodings-regexp
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1434 nil 'move)
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1435 (setq pos (match-beginning 0))
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1436 (if (match-beginning 1)
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1437 ;; ESC % / [0-4] M L --ENCODING-NAME-- \002 --BYTES--
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1438 (let* ((M (char-after (+ pos 4)))
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1439 (L (char-after (+ pos 5)))
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1440 (encoding (match-string 2))
55885
9d46d8e2e70b (register-char-codings): Make alias for `ignore'. Move docstring to
Juanma Barranquero <lekktu@gmail.com>
parents: 55048
diff changeset
1441 (encoding-info (assoc-string
53240
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1442 encoding
55048
e703f6cf2d7f (ctext-post-read-conversion): Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 54546
diff changeset
1443 ctext-non-standard-encodings-alist t))
53240
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1444 (coding (if encoding-info
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1445 (nth 1 encoding-info)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1446 (setq encoding (intern (downcase encoding)))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1447 (and (coding-system-p encoding)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1448 encoding))))
51313
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1449 (setq bytes (- (+ (* (- M 128) 128) (- L 128))
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1450 (- (point) (+ pos 6))))
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1451 (when coding
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1452 (delete-region pos (point))
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1453 (forward-char bytes)
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1454 (decode-coding-region (- (point) bytes) (point) coding)))
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1455 ;; ESC % G --UTF-8-BYTES-- ESC % @
53240
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1456 (delete-char -3)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1457 (delete-region pos (+ pos 3))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1458 (decode-coding-region pos (point) 'utf-8))))
51313
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1459 (goto-char (point-min))
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1460 (- (point-max) (point)))))
43457
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1461
53240
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1462 ;; Return a char table of extended segment usage for each character.
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1463 ;; Each value of the char table is nil, one of the elements of
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1464 ;; `ctext-non-standard-encodings-alist', or the symbol `utf-8'.
52289
63ea67e10c27 (make-coding-system)
Dave Love <fx@gnu.org>
parents: 52234
diff changeset
1465
53240
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1466 (defun ctext-non-standard-encodings-table ()
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1467 (let ((table (make-char-table 'translation-table)))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1468 (aset table (make-char 'mule-unicode-0100-24ff) 'utf-8)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1469 (aset table (make-char 'mule-unicode-2500-33ff) 'utf-8)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1470 (aset table (make-char 'mule-unicode-e000-ffff) 'utf-8)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1471 (dolist (encoding (reverse
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1472 (append
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1473 (get-language-info current-language-environment
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1474 'ctext-non-standard-encodings)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1475 ctext-non-standard-encodings)))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1476 (let* ((slot (assoc encoding ctext-non-standard-encodings-alist))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1477 (charset (nth 3 slot)))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1478 (if charset
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1479 (cond ((charsetp charset)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1480 (aset table (make-char charset) slot))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1481 ((listp charset)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1482 (dolist (elt charset)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1483 (aset table (make-char elt) slot)))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1484 ((char-table-p charset)
55885
9d46d8e2e70b (register-char-codings): Make alias for `ignore'. Move docstring to
Juanma Barranquero <lekktu@gmail.com>
parents: 55048
diff changeset
1485 (map-char-table #'(lambda (k v)
53240
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1486 (if (and v (> k 128)) (aset table k slot)))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1487 charset))))))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1488 table))
43457
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1489
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1490 (defun ctext-pre-write-conversion (from to)
43558
5ee62a93032e (ctext-pre-write-conversion): Handle the
Eli Zaretskii <eliz@gnu.org>
parents: 43457
diff changeset
1491 "Encode characters between FROM and TO as Compound Text w/Extended Segments.
5ee62a93032e (ctext-pre-write-conversion): Handle the
Eli Zaretskii <eliz@gnu.org>
parents: 43457
diff changeset
1492
5ee62a93032e (ctext-pre-write-conversion): Handle the
Eli Zaretskii <eliz@gnu.org>
parents: 43457
diff changeset
1493 If FROM is a string, or if the current buffer is not the one set up for us
51313
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1494 by encode-coding-string, generate a new temp buffer, insert the
43558
5ee62a93032e (ctext-pre-write-conversion): Handle the
Eli Zaretskii <eliz@gnu.org>
parents: 43457
diff changeset
1495 text, and convert it in the temporary buffer. Otherwise, convert in-place."
43457
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1496 (save-match-data
60188
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1497 (let ((workbuf (get-buffer-create " *code-conversion-work*")))
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1498 ;; Setup a working buffer if necessary.
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1499 (cond ((stringp from)
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1500 (set-buffer workbuf)
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1501 (erase-buffer)
51313
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1502 (set-buffer-multibyte (multibyte-string-p from))
60188
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1503 (insert from))
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1504 ((not (eq (current-buffer) workbuf))
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1505 (let ((buf (current-buffer))
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1506 (multibyte enable-multibyte-characters))
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1507 (set-buffer workbuf)
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1508 (erase-buffer)
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1509 (set-buffer-multibyte multibyte)
d9ca15a0952c (ctext-pre-write-conversion): Always use
Kenichi Handa <handa@m17n.org>
parents: 59996
diff changeset
1510 (insert-buffer-substring buf from to)))))
51313
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1511
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1512 ;; Now we can encode the whole buffer.
53240
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1513 (let ((encoding-table (ctext-non-standard-encodings-table))
51313
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1514 last-coding-system-used
53240
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1515 last-pos last-encoding-info
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1516 encoding-info end-pos)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1517 (goto-char (setq last-pos (point-min)))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1518 (setq end-pos (point-marker))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1519 (while (re-search-forward "[^\000-\177]+" nil t)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1520 ;; Found a sequence of non-ASCII characters.
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1521 (setq last-pos (match-beginning 0)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1522 last-encoding-info (aref encoding-table (char-after last-pos)))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1523 (set-marker end-pos (match-end 0))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1524 (goto-char (1+ last-pos))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1525 (catch 'tag
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1526 (while t
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1527 (setq encoding-info
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1528 (if (< (point) end-pos)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1529 (aref encoding-table (following-char))))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1530 (unless (eq last-encoding-info encoding-info)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1531 (cond ((consp last-encoding-info)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1532 ;; Encode the previous range using an extended
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1533 ;; segment.
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1534 (let ((encoding-name (car last-encoding-info))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1535 (coding-system (nth 1 last-encoding-info))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1536 (noctets (nth 2 last-encoding-info))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1537 len)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1538 (encode-coding-region last-pos (point) coding-system)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1539 (setq len (+ (length encoding-name) 1
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1540 (- (point) last-pos)))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1541 (save-excursion
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1542 (goto-char last-pos)
55885
9d46d8e2e70b (register-char-codings): Make alias for `ignore'. Move docstring to
Juanma Barranquero <lekktu@gmail.com>
parents: 55048
diff changeset
1543 (insert (string-to-multibyte
53240
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1544 (format "\e%%/%d%c%c%s"
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1545 noctets
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1546 (+ (/ len 128) 128)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1547 (+ (% len 128) 128)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1548 encoding-name))))))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1549 ((eq last-encoding-info 'utf-8)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1550 ;; Encode the previous range using UTF-8 encoding
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1551 ;; extention.
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1552 (encode-coding-region last-pos (point) 'mule-utf-8)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1553 (save-excursion
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1554 (goto-char last-pos)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1555 (insert "\e%G"))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1556 (insert "\e%@")))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1557 (setq last-pos (point)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1558 last-encoding-info encoding-info))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1559 (if (< (point) end-pos)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1560 (forward-char 1)
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1561 (throw 'tag nil)))))
ee5206ee4439 (ctext-non-standard-encodings-alist): Change the format.
Kenichi Handa <handa@m17n.org>
parents: 53048
diff changeset
1562 (set-marker end-pos nil)
51313
36fa2cf14d0c (ctext-non-standard-encodings-alist):
Kenichi Handa <handa@m17n.org>
parents: 51080
diff changeset
1563 (goto-char (point-min))))
43558
5ee62a93032e (ctext-pre-write-conversion): Handle the
Eli Zaretskii <eliz@gnu.org>
parents: 43457
diff changeset
1564 ;; Must return nil, as build_annotations_2 expects that.
43457
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1565 nil)
28a141684094 (non-standard-icccm-encodings-alist, non-standard-designations-alist): New
Eli Zaretskii <eliz@gnu.org>
parents: 42011
diff changeset
1566
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1567 ;;; FILE I/O
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1568
34297
8fffee49b42e (decode-char, encode-char): Doc fix.
Dave Love <fx@gnu.org>
parents: 34123
diff changeset
1569 (defcustom auto-coding-alist
60987
57dca1e0aa1b (auto-coding-alist): Add .xpi files.
Eli Zaretskii <eliz@gnu.org>
parents: 60756
diff changeset
1570 '(("\\.\\(arc\\|zip\\|lzh\\|zoo\\|[jew]ar\\|xpi\\)\\'" . no-conversion)
57dca1e0aa1b (auto-coding-alist): Add .xpi files.
Eli Zaretskii <eliz@gnu.org>
parents: 60756
diff changeset
1571 ("\\.\\(ARC\\|ZIP\\|LZH\\|ZOO\\|[JEW]AR\\|XPI\\)\\'" . no-conversion)
60756
0ada90f1db43 (auto-coding-alist): Sync with
Juri Linkov <juri@jurta.org>
parents: 60564
diff changeset
1572 ("\\.\\(sx[dmicw]\\|tar\\|tgz\\)\\'" . no-conversion)
45417
fe2a8cd911d0 (auto-coding-alist): Use no-conversion
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 43558
diff changeset
1573 ("\\.\\(gz\\|Z\\|bz\\|bz2\\|gpg\\)\\'" . no-conversion)
61031
58d0ad735f41 (auto-coding-alist): Associate non-ascii
Juri Linkov <juri@jurta.org>
parents: 60987
diff changeset
1574 ("\\.\\(jpe?g\\|png\\|gif\\|tiff?\\|p[bpgn]m\\)\\'" . no-conversion)
45418
8a2b953f3d6c (auto-coding-alist): Use emacs-mule
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 45417
diff changeset
1575 ("/#[^/]+#\\'" . emacs-mule))
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1576 "Alist of filename patterns vs corresponding coding systems.
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1577 Each element looks like (REGEXP . CODING-SYSTEM).
22819
da7ae4205e0b (auto-coding-alist): Docstring fixed.
Kenichi Handa <handa@m17n.org>
parents: 22813
diff changeset
1578 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
1579
22826
e81f7de474b3 (auto-coding-alist): Another doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22819
diff changeset
1580 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
1581 in the file (see the function `set-auto-coding')
34297
8fffee49b42e (decode-char, encode-char): Doc fix.
Dave Love <fx@gnu.org>
parents: 34123
diff changeset
1582 and the contents of `file-coding-system-alist'."
8fffee49b42e (decode-char, encode-char): Doc fix.
Dave Love <fx@gnu.org>
parents: 34123
diff changeset
1583 :group 'files
8fffee49b42e (decode-char, encode-char): Doc fix.
Dave Love <fx@gnu.org>
parents: 34123
diff changeset
1584 :group 'mule
8fffee49b42e (decode-char, encode-char): Doc fix.
Dave Love <fx@gnu.org>
parents: 34123
diff changeset
1585 :type '(repeat (cons (regexp :tag "File name regexp")
8fffee49b42e (decode-char, encode-char): Doc fix.
Dave Love <fx@gnu.org>
parents: 34123
diff changeset
1586 (symbol :tag "Coding system"))))
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1587
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1588 (defcustom auto-coding-regexp-alist
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1589 '(("^BABYL OPTIONS:[ \t]*-\\*-[ \t]*rmail[ \t]*-\\*-" . no-conversion))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1590 "Alist of patterns vs corresponding coding systems.
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1591 Each element looks like (REGEXP . CODING-SYSTEM).
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1592 A file whose first bytes match REGEXP is decoded by CODING-SYSTEM on reading.
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1593
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1594 The settings in this alist take priority over `coding:' tags
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1595 in the file (see the function `set-auto-coding')
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1596 and the contents of `file-coding-system-alist'."
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1597 :group 'files
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1598 :group 'mule
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1599 :type '(repeat (cons (regexp :tag "Regexp")
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1600 (symbol :tag "Coding system"))))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1601
68209
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1602 (defun auto-coding-regexp-alist-lookup (from to)
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1603 "Lookup `auto-coding-regexp-alist' for the contents of the current buffer.
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1604 The value is a coding system is specified for the region FROM and TO,
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1605 or nil."
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1606 (save-excursion
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1607 (goto-char from)
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1608 (let ((alist auto-coding-regexp-alist)
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1609 coding-system)
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1610 (while (and alist (not coding-system))
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1611 (let ((regexp (car (car alist))))
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1612 (if enable-multibyte-characters
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1613 (setq regexp (string-to-multibyte regexp)))
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1614 (if (re-search-forward regexp to t)
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1615 (setq coding-system (cdr (car alist)))
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1616 (setq alist (cdr alist)))))
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1617 coding-system)))
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1618
45450
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
1619 ;; See the bottom of this file for built-in auto coding functions.
45691
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1620 (defcustom auto-coding-functions '(sgml-xml-auto-coding-function
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1621 sgml-html-meta-auto-coding-function)
45450
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
1622 "A list of functions which attempt to determine a coding system.
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
1623
51978
afa6be6a5c62 (auto-coding-functions): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51314
diff changeset
1624 Each function in this list should be written to operate on the
afa6be6a5c62 (auto-coding-functions): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51314
diff changeset
1625 current buffer, but should not modify it in any way. The buffer
afa6be6a5c62 (auto-coding-functions): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51314
diff changeset
1626 will contain undecoded text of parts of the file. Each function
afa6be6a5c62 (auto-coding-functions): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51314
diff changeset
1627 should take one argument, SIZE, which says how many
afa6be6a5c62 (auto-coding-functions): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51314
diff changeset
1628 characters (starting from point) it should look at.
45450
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
1629
51978
afa6be6a5c62 (auto-coding-functions): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51314
diff changeset
1630 If one of these functions succeeds in determining a coding
afa6be6a5c62 (auto-coding-functions): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51314
diff changeset
1631 system, it should return that coding system. Otherwise, it
afa6be6a5c62 (auto-coding-functions): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51314
diff changeset
1632 should return nil.
afa6be6a5c62 (auto-coding-functions): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51314
diff changeset
1633
afa6be6a5c62 (auto-coding-functions): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51314
diff changeset
1634 If a file has a `coding:' tag, that takes precedence over these
afa6be6a5c62 (auto-coding-functions): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 51314
diff changeset
1635 functions, so they won't be called at all."
45450
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
1636 :group 'files
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
1637 :group 'mule
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
1638 :type '(repeat function))
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
1639
22699
754703e243e6 (set-auto-coding-for-load): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22654
diff changeset
1640 (defvar set-auto-coding-for-load nil
754703e243e6 (set-auto-coding-for-load): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22654
diff changeset
1641 "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
1642 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
1643
24602
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1644 (defun auto-coding-alist-lookup (filename)
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1645 "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
1646 (let ((alist auto-coding-alist)
49549
99be3a1e2589 Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents: 49417
diff changeset
1647 (case-fold-search (memq system-type '(vax-vms windows-nt ms-dos cygwin)))
24602
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1648 coding-system)
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1649 (while (and alist (not coding-system))
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1650 (if (string-match (car (car alist)) filename)
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1651 (setq coding-system (cdr (car alist)))
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1652 (setq alist (cdr alist))))
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1653 coding-system))
ca3a341bfd58 (auto-coding-alist-lookup): New function.
Richard M. Stallman <rms@gnu.org>
parents: 24575
diff changeset
1654
64482
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1655 (defun find-auto-coding (filename size)
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1656 "Find a 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
1657 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
1658 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
1659
46675
253e228beb5f (set-auto-coding): Doc fix.
Dave Love <fx@gnu.org>
parents: 46505
diff changeset
1660 The function checks FILENAME against the variable `auto-coding-alist'.
253e228beb5f (set-auto-coding): Doc fix.
Dave Love <fx@gnu.org>
parents: 46505
diff changeset
1661 If FILENAME doesn't match any entries in the variable, it checks the
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1662 contents of the current buffer following point against
45691
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1663 `auto-coding-regexp-alist'. If no match is found, it checks for a
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1664 `coding:' tag in the first one or two lines following point. If no
46675
253e228beb5f (set-auto-coding): Doc fix.
Dave Love <fx@gnu.org>
parents: 46505
diff changeset
1665 `coding:' tag is found, it checks any local variables list in the last
45691
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1666 3K bytes out of the SIZE bytes. Finally, if none of these methods
46675
253e228beb5f (set-auto-coding): Doc fix.
Dave Love <fx@gnu.org>
parents: 46505
diff changeset
1667 succeed, it checks to see if any function in `auto-coding-functions'
253e228beb5f (set-auto-coding): Doc fix.
Dave Love <fx@gnu.org>
parents: 46505
diff changeset
1668 gives a match.
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
1669
64482
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1670 If a coding system is specifed, the return value is a
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1671 cons (CODING . SOURCE), where CODING is the specified coding
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1672 system and SOURCE is a symbol `auto-coding-alist',
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1673 `auto-coding-regexp-alist', `coding:', or `auto-coding-functions'
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1674 indicating by what CODING is specified. Note that the validity
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1675 of CODING is not checked; it's callers responsibility to check
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1676 it.
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1677
68209
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1678 If nothing is specified, the return value is nil."
64482
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1679 (or (let ((coding-system (auto-coding-alist-lookup filename)))
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1680 (if coding-system
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1681 (cons coding-system 'auto-coding-alist)))
45691
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1682 ;; Try using `auto-coding-regexp-alist'.
68209
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1683 (let ((coding-system (auto-coding-regexp-alist-lookup (point)
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1684 (+ (point) size))))
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1685 (if coding-system
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1686 (cons coding-system 'auto-coding-regexp-alist)))
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1687 (let* ((case-fold-search t)
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1688 (head-start (point))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1689 (head-end (+ head-start (min size 1024)))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1690 (tail-start (+ head-start (max (- size 3072) 0)))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1691 (tail-end (+ head-start size))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1692 coding-system head-found tail-found pos)
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1693 ;; Try a short cut by searching for the string "coding:"
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1694 ;; and for "unibyte:" at the head and tail of SIZE bytes.
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1695 (setq head-found (or (search-forward "coding:" head-end t)
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1696 (search-forward "unibyte:" head-end t)))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1697 (if (and head-found (> head-found tail-start))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1698 ;; Head and tail are overlapped.
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1699 (setq tail-found head-found)
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1700 (goto-char tail-start)
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1701 (setq tail-found (or (search-forward "coding:" tail-end t)
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1702 (search-forward "unibyte:" tail-end t))))
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1703
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1704 ;; At first check the head.
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1705 (when head-found
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1706 (goto-char head-start)
41973
903480208cfd (set-auto-coding): Use set-auto-mode-1.
Richard M. Stallman <rms@gnu.org>
parents: 41677
diff changeset
1707 (setq head-end (set-auto-mode-1))
903480208cfd (set-auto-coding): Use set-auto-mode-1.
Richard M. Stallman <rms@gnu.org>
parents: 41677
diff changeset
1708 (setq head-start (point))
42011
235915876f5b (set-auto-coding): Don't search for
Eli Zaretskii <eliz@gnu.org>
parents: 41983
diff changeset
1709 (when (and head-end (< head-found head-end))
22813
b209a00e464e (auto-coding-alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 22741
diff changeset
1710 (goto-char head-start)
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1711 (when (and set-auto-coding-for-load
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1712 (re-search-forward
41973
903480208cfd (set-auto-coding): Use set-auto-mode-1.
Richard M. Stallman <rms@gnu.org>
parents: 41677
diff changeset
1713 "\\(.*;\\)?[ \t]*unibyte:[ \t]*\\([^ ;]+\\)"
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1714 head-end t))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1715 (setq coding-system 'raw-text))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1716 (when (and (not coding-system)
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1717 (re-search-forward
41973
903480208cfd (set-auto-coding): Use set-auto-mode-1.
Richard M. Stallman <rms@gnu.org>
parents: 41677
diff changeset
1718 "\\(.*;\\)?[ \t]*coding:[ \t]*\\([^ ;]+\\)"
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1719 head-end t))
64482
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1720 (setq coding-system (intern (match-string 2))))))
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
1721
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1722 ;; If no coding: tag in the head, check the tail.
53526
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1723 ;; Here we must pay attention to the case that the end-of-line
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1724 ;; is just "\r" and we can't use "^" nor "$" in regexp.
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1725 (when (and tail-found (not coding-system))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1726 (goto-char tail-start)
53526
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1727 (re-search-forward "[\r\n]\^L" nil t)
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1728 (if (re-search-forward
55885
9d46d8e2e70b (register-char-codings): Make alias for `ignore'. Move docstring to
Juanma Barranquero <lekktu@gmail.com>
parents: 55048
diff changeset
1729 "[\r\n]\\([^[\r\n]*\\)[ \t]*Local Variables:[ \t]*\\([^\r\n]*\\)[\r\n]"
53526
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1730 tail-end t)
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1731 ;; The prefix is what comes before "local variables:" in its
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1732 ;; line. The suffix is what comes after "local variables:"
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1733 ;; in its line.
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1734 (let* ((prefix (regexp-quote (match-string 1)))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1735 (suffix (regexp-quote (match-string 2)))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1736 (re-coding
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1737 (concat
53526
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1738 "[\r\n]" prefix
39947
9c7e9fea58dc (set-auto-coding): Fix regexps for local
Gerd Moellmann <gerd@gnu.org>
parents: 38614
diff changeset
1739 ;; N.B. without the \n below, the regexp can
9c7e9fea58dc (set-auto-coding): Fix regexps for local
Gerd Moellmann <gerd@gnu.org>
parents: 38614
diff changeset
1740 ;; eat newlines.
53526
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1741 "[ \t]*coding[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*"
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1742 suffix "[\r\n]"))
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1743 (re-unibyte
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1744 (concat
53526
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1745 "[\r\n]" prefix
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1746 "[ \t]*unibyte[ \t]*:[ \t]*\\([^ \t\r\n]+\\)[ \t]*"
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1747 suffix "[\r\n]"))
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1748 (re-end
55885
9d46d8e2e70b (register-char-codings): Make alias for `ignore'. Move docstring to
Juanma Barranquero <lekktu@gmail.com>
parents: 55048
diff changeset
1749 (concat "[\r\n]" prefix "[ \t]*End *:[ \t]*" suffix
53526
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1750 "[\r\n]?"))
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1751 (pos (1- (point))))
5c66f1de4907 (set-auto-coding): Fix for the case that end-of-line is only CR.
Kenichi Handa <handa@m17n.org>
parents: 53240
diff changeset
1752 (forward-char -1) ; skip back \r or \n.
37746
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1753 (re-search-forward re-end tail-end 'move)
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1754 (setq tail-end (point))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1755 (goto-char pos)
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1756 (when (and set-auto-coding-for-load
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1757 (re-search-forward re-unibyte tail-end t))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1758 (setq coding-system 'raw-text))
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1759 (when (and (not coding-system)
0204bb9ccc1e (auto-coding-regexp-alist): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 36466
diff changeset
1760 (re-search-forward re-coding tail-end t))
64482
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1761 (setq coding-system (intern (match-string 1)))))))
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1762 (if coding-system
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1763 (cons coding-system :coding)))
45691
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1764 ;; Finally, try all the `auto-coding-functions'.
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1765 (let ((funcs auto-coding-functions)
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1766 (coding-system nil))
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1767 (while (and funcs (not coding-system))
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1768 (setq coding-system (condition-case e
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1769 (save-excursion
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1770 (goto-char (point-min))
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1771 (funcall (pop funcs) size))
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
1772 (error nil))))
64482
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1773 (if coding-system
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1774 (cons coding-system 'auto-coding-functions)))))
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1775
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1776 (defun set-auto-coding (filename size)
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1777 "Return coding system for a file FILENAME of which SIZE bytes follow point.
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1778 See `find-auto-coding' for how the coding system is found.
68209
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1779 Return nil if an invalid coding system is found.
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1780
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1781 The variable `set-auto-coding-function' (which see) is set to this
ac1d7b21ddfc (autoload-coding-system): Prepare for EOL variants.
Kenichi Handa <handa@m17n.org>
parents: 67517
diff changeset
1782 function by default."
64482
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1783 (let ((found (find-auto-coding filename size)))
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1784 (if (and found (coding-system-p (car found)))
62fe32ed4496 (find-auto-coding): New function created
Kenichi Handa <handa@m17n.org>
parents: 64125
diff changeset
1785 (car found))))
19648
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
1786
e9031152e052 (set-auto-coding): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19606
diff changeset
1787 (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
1788
59208
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1789 ;; This variable is set in these two cases:
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1790 ;; (1) A file is read by a coding system specified explicitly.
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1791 ;; after-insert-file-set-coding sets this value to
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1792 ;; coding-system-for-read.
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1793 ;; (2) A buffer is saved.
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1794 ;; After writing, basic-save-buffer-1 sets this value to
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1795 ;; last-coding-system-used.
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1796 ;; This variable is used for decoding in revert-buffer.
59226
1d3fcf11a9ad (buffer-file-coding-system-explicit):
Kenichi Handa <handa@m17n.org>
parents: 59208
diff changeset
1797 (defvar buffer-file-coding-system-explicit nil
59208
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1798 "The file coding system explicitly specified for the current buffer.
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1799 Internal use only.")
59226
1d3fcf11a9ad (buffer-file-coding-system-explicit):
Kenichi Handa <handa@m17n.org>
parents: 59208
diff changeset
1800 (make-variable-buffer-local 'buffer-file-coding-system-explicit)
1d3fcf11a9ad (buffer-file-coding-system-explicit):
Kenichi Handa <handa@m17n.org>
parents: 59208
diff changeset
1801 (put 'buffer-file-coding-system-explicit 'permanent-local t)
59208
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1802
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1803 (defun after-insert-file-set-coding (inserted &optional visit)
50584
e36ce541f439 (after-insert-file-set-coding): Properly treat INSERTED as number of
Richard M. Stallman <rms@gnu.org>
parents: 50547
diff changeset
1804 "Set `buffer-file-coding-system' of current buffer after text is inserted.
e36ce541f439 (after-insert-file-set-coding): Properly treat INSERTED as number of
Richard M. Stallman <rms@gnu.org>
parents: 50547
diff changeset
1805 INSERTED is the number of characters that were inserted, as figured
e36ce541f439 (after-insert-file-set-coding): Properly treat INSERTED as number of
Richard M. Stallman <rms@gnu.org>
parents: 50547
diff changeset
1806 in the situation before this function. Return the number of characters
e36ce541f439 (after-insert-file-set-coding): Properly treat INSERTED as number of
Richard M. Stallman <rms@gnu.org>
parents: 50547
diff changeset
1807 inserted, as figured in the situation after. The two numbers can be
59208
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1808 different if the buffer has become unibyte.
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1809 The optional second arg VISIT non-nil means that we are visiting a file."
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1810 (if (and visit
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1811 coding-system-for-read
34a8622540ad (explicit-buffer-file-coding-system): New
Kenichi Handa <handa@m17n.org>
parents: 59187
diff changeset
1812 (not (eq coding-system-for-read 'auto-save-coding)))
59226
1d3fcf11a9ad (buffer-file-coding-system-explicit):
Kenichi Handa <handa@m17n.org>
parents: 59208
diff changeset
1813 (setq buffer-file-coding-system-explicit coding-system-for-read))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1814 (if last-coding-system-used
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1815 (let ((coding-system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1816 (find-new-buffer-file-coding-system last-coding-system-used))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1817 (modified-p (buffer-modified-p)))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1818 (when coding-system
58277
a8baec933fd4 (set-buffer-file-coding-system): New arg NOMODIFY.
Richard M. Stallman <rms@gnu.org>
parents: 58149
diff changeset
1819 ;; Tell set-buffer-file-coding-system not to mark the file
a8baec933fd4 (set-buffer-file-coding-system): New arg NOMODIFY.
Richard M. Stallman <rms@gnu.org>
parents: 58149
diff changeset
1820 ;; as modified; we just read it, and it's supposed to be unmodified.
a8baec933fd4 (set-buffer-file-coding-system): New arg NOMODIFY.
Richard M. Stallman <rms@gnu.org>
parents: 58149
diff changeset
1821 ;; Marking it modified would try to lock it, which would
a8baec933fd4 (set-buffer-file-coding-system): New arg NOMODIFY.
Richard M. Stallman <rms@gnu.org>
parents: 58149
diff changeset
1822 ;; check the modtime, and we don't want to do that again now.
a8baec933fd4 (set-buffer-file-coding-system): New arg NOMODIFY.
Richard M. Stallman <rms@gnu.org>
parents: 58149
diff changeset
1823 (set-buffer-file-coding-system coding-system t t)
23717
ad0e76fa89be (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 23456
diff changeset
1824 (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
1825 (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
1826 (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
1827 ;; 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
1828 ;; 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
1829 (not modified-p)
09063dfdc92c (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 29428
diff changeset
1830 (= (buffer-size) inserted))
22041
e977f2414da5 (after-insert-file-set-buffer-file-coding-system):
Richard M. Stallman <rms@gnu.org>
parents: 21728
diff changeset
1831 ;; 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
1832 ;; edit the buffer as unibyte.
58277
a8baec933fd4 (set-buffer-file-coding-system): New arg NOMODIFY.
Richard M. Stallman <rms@gnu.org>
parents: 58149
diff changeset
1833 (let ((pos-marker (copy-marker (+ (point) inserted)))
a8baec933fd4 (set-buffer-file-coding-system): New arg NOMODIFY.
Richard M. Stallman <rms@gnu.org>
parents: 58149
diff changeset
1834 ;; Prevent locking.
a8baec933fd4 (set-buffer-file-coding-system): New arg NOMODIFY.
Richard M. Stallman <rms@gnu.org>
parents: 58149
diff changeset
1835 (buffer-file-name nil))
23717
ad0e76fa89be (after-insert-file-set-buffer-file-coding-system): If the buffer
Kenichi Handa <handa@m17n.org>
parents: 23456
diff changeset
1836 (set-buffer-multibyte nil)
50584
e36ce541f439 (after-insert-file-set-coding): Properly treat INSERTED as number of
Richard M. Stallman <rms@gnu.org>
parents: 50547
diff changeset
1837 (setq inserted (- pos-marker (point)))))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1838 (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
1839 inserted)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1840
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
1841 ;; The coding-spec and eol-type of coding-system returned is decided
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1842 ;; independently in the following order.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1843 ;; 1. That of buffer-file-coding-system locally bound.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1844 ;; 2. That of CODING.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1845
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1846 (defun find-new-buffer-file-coding-system (coding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1847 "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
1848 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
1849 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
1850 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
1851 (let (local-coding local-eol
19948
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1852 found-coding found-eol
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1853 new-coding new-eol)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1854 (if (null coding)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1855 ;; Nothing found about coding.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1856 nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1857
19948
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1858 ;; 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
1859 ;; and LOCAL-CODING.
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1860 (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
1861 (if (null (numberp local-eol))
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1862 ;; 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
1863 (setq local-eol nil))
20112
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1864 (if (and buffer-file-coding-system
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1865 (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
1866 ;; This is not `undecided'.
6e6838a12511 The summary of the following changes:
Kenichi Handa <handa@m17n.org>
parents: 19986
diff changeset
1867 (setq local-coding (coding-system-base buffer-file-coding-system)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1868
19948
46e5df654a35 (find-new-buffer-file-coding-system): Reflect
Richard M. Stallman <rms@gnu.org>
parents: 19802
diff changeset
1869 (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
1870 local-eol local-coding)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1871 ;; The current buffer has already set full coding-system, we
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1872 ;; had better not change it.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1873 nil
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1874
18195
9650375d0a68 Delete declaration for buffer-file-coding-system. It
Kenichi Handa <handa@m17n.org>
parents: 17984
diff changeset
1875 (setq found-eol (coding-system-eol-type coding))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1876 (if (null (numberp found-eol))
22903
77e68af369b1 (find-new-buffer-file-coding-system): When
Eli Zaretskii <eliz@gnu.org>
parents: 22884
diff changeset
1877 ;; But eol-type is not found.
77e68af369b1 (find-new-buffer-file-coding-system): When
Eli Zaretskii <eliz@gnu.org>
parents: 22884
diff changeset
1878 ;; 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
1879 (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
1880 (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
1881 (setq found-coding 'undecided)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1882 (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
1883
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1884 (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
1885 ;; No valid coding information found.
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1886 nil
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1887
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1888 ;; Some coding information (eol or text) found.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1889
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1890 ;; 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
1891 (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
1892 (or local-coding found-coding)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1893 (or found-coding local-coding)))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1894 (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
1895 (or local-eol found-eol)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1896 (or found-eol local-eol)))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1897
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1898 (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
1899 (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
1900 (aref eol-type new-eol)
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
1901 new-coding)))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1902
18874
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1903 (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
1904 "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
1905 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
1906 `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
1907
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1908 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
1909 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
1910 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
1911 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
1912
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1913 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
1914 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
1915 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
1916 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
1917
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1918 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
1919 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
1920 for decoding and encoding respectively,
7333c3179621 (modify-coding-system-alist): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18874
diff changeset
1921 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
1922 (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
1923 (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
1924 (or (stringp regexp)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1925 (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
1926 (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
1927 (if (symbolp coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1928 (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
1929 (progn
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1930 (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
1931 (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
1932 (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
1933 (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
1934 (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
1935 (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
1936 (if slot
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1937 (setcdr slot coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1938 (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
1939 (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
1940 file-coding-system-alist)))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1941 ((eq target-type 'process)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1942 (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
1943 (if slot
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1944 (setcdr slot coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1945 (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
1946 (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
1947 process-coding-system-alist)))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1948 (t
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1949 (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
1950 (if slot
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1951 (setcdr slot coding-system)
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1952 (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
1953 (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
1954 network-coding-system-alist)))))))
e44ac570f54f (modify-coding-system-alist): Moved to mule-util.el.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18798
diff changeset
1955
49417
c0097d579165 (decode-coding-inserted-region): Renamed
Kenichi Handa <handa@m17n.org>
parents: 49376
diff changeset
1956 (defun decode-coding-inserted-region (from to filename
c0097d579165 (decode-coding-inserted-region): Renamed
Kenichi Handa <handa@m17n.org>
parents: 49376
diff changeset
1957 &optional visit beg end replace)
49376
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1958 "Decode the region between FROM and TO as if it is read from file FILENAME.
59119
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1959 The idea is that the text between FROM and TO was just inserted somehow.
49376
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1960 Optional arguments VISIT, BEG, END, and REPLACE are the same as those
59119
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1961 of the function `insert-file-contents'.
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1962 Part of the job of this function is setting `buffer-undo-list' appropriately."
49376
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1963 (save-excursion
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1964 (save-restriction
59119
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1965 (let ((coding coding-system-for-read)
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1966 undo-list-saved)
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1967 (if visit
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1968 ;; Temporarily turn off undo recording, if we're decoding the
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1969 ;; text of a visited file.
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1970 (setq buffer-undo-list t)
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1971 ;; Otherwise, if we can recognize the undo elt for the insertion,
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1972 ;; remove it and get ready to replace it later.
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1973 ;; In the mean time, turn off undo recording.
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59226
diff changeset
1974 (let ((last (car-safe buffer-undo-list)))
59119
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1975 (if (and (consp last) (eql (car last) from) (eql (cdr last) to))
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1976 (setq undo-list-saved (cdr buffer-undo-list)
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1977 buffer-undo-list t))))
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1978 (narrow-to-region from to)
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1979 (goto-char (point-min))
49376
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1980 (or coding
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1981 (setq coding (funcall set-auto-coding-function
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1982 filename (- (point-max) (point-min)))))
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1983 (or coding
52660
99ed1d8cf6da (decode-coding-inserted-region): Use car
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
1984 (setq coding (car (find-operation-coding-system
99ed1d8cf6da (decode-coding-inserted-region): Use car
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
1985 'insert-file-contents
99ed1d8cf6da (decode-coding-inserted-region): Use car
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
1986 filename visit beg end replace))))
49376
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1987 (if (coding-system-p coding)
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1988 (or enable-multibyte-characters
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1989 (setq coding
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1990 (coding-system-change-text-conversion coding 'raw-text)))
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1991 (setq coding nil))
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
1992 (if coding
56345
84f77e8cff58 (decode-coding-inserted-region): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 56344
diff changeset
1993 (decode-coding-region (point-min) (point-max) coding)
59119
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1994 (setq last-coding-system-used coding))
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1995 ;; If we're decoding the text of a visited file,
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1996 ;; the undo list should start out empty.
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1997 (if visit
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1998 (setq buffer-undo-list nil)
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
1999 ;; If we decided to replace the undo entry for the insertion,
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
2000 ;; do so now.
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
2001 (if undo-list-saved
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
2002 (setq buffer-undo-list
803b2fab7ec1 (decode-coding-inserted-region):
Richard M. Stallman <rms@gnu.org>
parents: 58285
diff changeset
2003 (cons (cons from (point-max)) undo-list-saved))))))))
49376
ed922baa8df3 (decode-coding-region-as-inserted-from-file): New function.
Kenichi Handa <handa@m17n.org>
parents: 49252
diff changeset
2004
59175
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2005 (defun recode-region (start end new-coding coding)
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2006 "Re-decode the region (previously decoded by CODING) by NEW-CODING."
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2007 (interactive
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2008 (list (region-beginning) (region-end)
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2009 (read-coding-system "Text was really in: ")
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2010 (let ((coding (or buffer-file-coding-system last-coding-system-used)))
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2011 (read-coding-system
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2012 (concat "But was interpreted as"
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2013 (if coding (format " (default %S): " coding) ": "))
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2014 coding))))
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2015 (or (and new-coding coding)
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2016 (error "Coding system not specified"))
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2017 ;; Check it before we encode the region.
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2018 (check-coding-system new-coding)
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2019 (save-restriction
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2020 (narrow-to-region start end)
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2021 (encode-coding-region (point-min) (point-max) coding)
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2022 (decode-coding-region (point-min) (point-max) new-coding)))
a9efc32867d2 (recode-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 59119
diff changeset
2023
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
2024 (defun make-translation-table (&rest args)
36262
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
2025 "Make a translation table from arguments.
40826
24ea3c263919 (make-translation-table): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 39947
diff changeset
2026 A translation table is a char table intended for character
36262
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
2027 translation in CCL programs.
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
2028
40826
24ea3c263919 (make-translation-table): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 39947
diff changeset
2029 Each argument is a list of elements of the form (FROM . TO), where FROM
36262
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
2030 is a character to be translated to TO.
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2031
22225
6f56af1aab96 (make-translation-table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22186
diff changeset
2032 FROM can be a generic character (see `make-char'). In this case, TO is
40826
24ea3c263919 (make-translation-table): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 39947
diff changeset
2033 a generic character containing the same number of characters, or an
22225
6f56af1aab96 (make-translation-table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22186
diff changeset
2034 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
2035 characters belonging to FROM are translated to characters belonging to TO
35481
df08279e042b (make-translation-table): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents: 35324
diff changeset
2036 without changing their position code(s).
df08279e042b (make-translation-table): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents: 35324
diff changeset
2037
df08279e042b (make-translation-table): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents: 35324
diff changeset
2038 The arguments and forms in each argument are processed in the given
df08279e042b (make-translation-table): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents: 35324
diff changeset
2039 order, and if a previous form already translates TO to some other
df08279e042b (make-translation-table): Fix docstring.
Kenichi Handa <handa@m17n.org>
parents: 35324
diff changeset
2040 character, say TO-ALT, FROM is also translated to TO-ALT."
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
2041 (let ((table (make-char-table 'translation-table))
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2042 revlist)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2043 (while args
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2044 (let ((elts (car args)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2045 (while elts
17837
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
2046 (let* ((from (car (car elts)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
2047 (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
2048 (from-rev (nreverse (split-char from)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
2049 (to (cdr (car elts)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
2050 (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
2051 (to-rev (nreverse (split-char to))))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
2052 ;; 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
2053 (while (eq (car from-rev) 0)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
2054 (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
2055 (while (eq (car to-rev) 0)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
2056 (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
2057 (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
2058 (error "Invalid character pair (%d . %d)" from to))
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
2059 ;; 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
2060 ;; 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
2061 ;; 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
2062 ;; character.
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
2063 (let ((to-alt (aref table to)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
2064 (if (and to-alt
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
2065 (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
2066 (setq to to-alt)))
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
2067 (if (> from-i 0)
a4d3078a83e9 (make-unification-table): Fix handling of a generic
Kenichi Handa <handa@m17n.org>
parents: 17761
diff changeset
2068 (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
2069 (aset table from to))
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
2070 ;; 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
2071 ;; should also be translated to TO.
17761
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2072 (let ((l (assq from revlist)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2073 (if l
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2074 (let ((ch (car l)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2075 (setcar l to)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2076 (setq l (cdr l))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2077 (while l
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2078 (aset table ch to)
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2079 (setq l (cdr l)) ))))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2080 ;; Now update REVLIST.
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2081 (let ((l (assq to revlist)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2082 (if l
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2083 (setcdr l (cons from (cdr l)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2084 (setq revlist (cons (list to from) revlist)))))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2085 (setq elts (cdr elts))))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2086 (setq args (cdr args)))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2087 ;; Return TABLE just created.
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2088 table))
c5f430853301 (make-char): Doc-string modified.
Kenichi Handa <handa@m17n.org>
parents: 17175
diff changeset
2089
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
2090 (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
2091 "Make translation table from decoding vector VEC.
41983
8acbb96a91c3 (make-translation-table-from-vector):
Dave Love <fx@gnu.org>
parents: 41973
diff changeset
2092 VEC is an array of 256 elements to map unibyte codes to multibyte
8acbb96a91c3 (make-translation-table-from-vector):
Dave Love <fx@gnu.org>
parents: 41973
diff changeset
2093 characters. Elements may be nil for undefined code points.
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
2094 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
2095 (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
2096 (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
2097 ch)
41983
8acbb96a91c3 (make-translation-table-from-vector):
Dave Love <fx@gnu.org>
parents: 41973
diff changeset
2098 (dotimes (i 256)
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
2099 (setq ch (aref vec i))
41983
8acbb96a91c3 (make-translation-table-from-vector):
Dave Love <fx@gnu.org>
parents: 41973
diff changeset
2100 (when ch
8acbb96a91c3 (make-translation-table-from-vector):
Dave Love <fx@gnu.org>
parents: 41973
diff changeset
2101 (aset table i ch)
8acbb96a91c3 (make-translation-table-from-vector):
Dave Love <fx@gnu.org>
parents: 41973
diff changeset
2102 (if (>= ch 256)
8acbb96a91c3 (make-translation-table-from-vector):
Dave Love <fx@gnu.org>
parents: 41973
diff changeset
2103 (aset rev-table ch i))))
22884
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
2104 (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
2105 table))
e7a1b839f16c (make-coding-system): If the arg TYPE is
Kenichi Handa <handa@m17n.org>
parents: 22836
diff changeset
2106
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
2107 (defun define-translation-table (symbol &rest args)
36262
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
2108 "Define SYMBOL as the name of translation table made by ARGS.
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
2109 This sets up information so that the table can be used for
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
2110 translations in a CCL program.
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
2111
36262
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
2112 If the first element of ARGS is a char-table whose purpose is
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
2113 `translation-table', just define SYMBOL to name it. (Note that this
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
2114 function does not bind SYMBOL.)
23770
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
2115
36262
c2f7a7dc3322 (make-coding-system): Doc fixes.
Dave Love <fx@gnu.org>
parents: 36037
diff changeset
2116 Any other ARGS should be suitable as arguments of the function
23770
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
2117 `make-translation-table' (which see).
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
2118
22225
6f56af1aab96 (make-translation-table): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22186
diff changeset
2119 This function sets properties `translation-table' and
36037
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
2120 `translation-table-id' of SYMBOL to the created table itself and the
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
2121 identification number of the table respectively. It also registers
2710df16c53a *** empty log message ***
Dave Love <fx@gnu.org>
parents: 35946
diff changeset
2122 the table in `translation-table-vector'."
23770
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
2123 (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
2124 (eq (char-table-subtype (car args))
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
2125 'translation-table))
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
2126 (car args)
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
2127 (apply 'make-translation-table args)))
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
2128 (len (length translation-table-vector))
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
2129 (id 0)
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
2130 (done nil))
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
2131 (put symbol 'translation-table table)
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
2132 (while (not done)
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
2133 (if (>= id len)
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
2134 (setq translation-table-vector
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
2135 (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
2136 (let ((slot (aref translation-table-vector id)))
22125
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
2137 (if (or (not slot)
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
2138 (eq (car slot) symbol))
8e8f1bc7f743 Change term unification to translation
Kenichi Handa <handa@m17n.org>
parents: 22083
diff changeset
2139 (progn
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
2140 (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
2141 (setq done t))
45f1d511e726 (define-translation-table): Fix bug of
Kenichi Handa <handa@m17n.org>
parents: 23717
diff changeset
2142 (setq id (1+ id)))))
22186
fc4aaf1b1772 Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents: 22160
diff changeset
2143 (put symbol 'translation-table-id id)
20729
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
2144 id))
821b2167b6c3 (define-character-unification-table): New
Kenichi Handa <handa@m17n.org>
parents: 20405
diff changeset
2145
57645
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2146 (defun translate-region (start end table)
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2147 "From START to END, translate characters according to TABLE.
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2148 TABLE is a string or a char-table.
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2149 If TABLE is a string, the Nth character in it is the mapping
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2150 for the character with code N.
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2151 If TABLE is a char-table, the element for character N is the mapping
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2152 for the character with code N.
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2153 It returns the number of characters changed."
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2154 (interactive
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2155 (list (region-beginning)
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2156 (region-end)
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2157 (let (table l)
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2158 (dotimes (i (length translation-table-vector))
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2159 (if (consp (aref translation-table-vector i))
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2160 (push (list (symbol-name
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2161 (car (aref translation-table-vector i)))) l)))
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2162 (if (not l)
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2163 (error "No translation table defined"))
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2164 (while (not table)
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2165 (setq table (completing-read "Translation table: " l nil t)))
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2166 (intern table))))
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2167 (if (symbolp table)
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2168 (let ((val (get table 'translation-table)))
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2169 (or (char-table-p val)
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2170 (error "Invalid translation table name: %s" table))
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2171 (setq table val)))
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2172 (translate-region-internal start end table))
24ec89bbe7bc (translate-region): Implement it in Lisp
Kenichi Handa <handa@m17n.org>
parents: 57444
diff changeset
2173
26887
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
2174 (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
2175
50336
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2176 (defmacro with-category-table (table &rest body)
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2177 "Evaluate BODY with category table of current buffer set to TABLE.
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2178 The category table of the current buffer is saved, BODY is evaluated,
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2179 then the saved table is restored, even in case of an abnormal exit.
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2180 Value is what BODY returns."
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2181 (let ((old-table (make-symbol "old-table"))
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2182 (old-buffer (make-symbol "old-buffer")))
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2183 `(let ((,old-table (category-table))
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2184 (,old-buffer (current-buffer)))
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2185 (unwind-protect
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2186 (progn
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2187 (set-category-table ,table)
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2188 ,@body)
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2189 (save-current-buffer
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2190 (set-buffer ,old-buffer)
15141bb6dc1f (with-category-table): Use `make-symbol' to avoid variable capture.
John Paul Wallington <jpw@pobox.com>
parents: 50181
diff changeset
2191 (set-category-table ,old-table))))))
26887
2f284b9ec711 (mule-version): Updated to 5.0 (AOI).
Kenichi Handa <handa@m17n.org>
parents: 26716
diff changeset
2192
46504
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2193 (defun define-translation-hash-table (symbol table)
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2194 "Define SYMBOL as the name of the hash translation TABLE for use in CCL.
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2195
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2196 Analogous to `define-translation-table', but updates
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2197 `translation-hash-table-vector' and the table is for use in the CCL
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2198 `lookup-integer' and `lookup-character' functions."
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2199 (unless (and (symbolp symbol)
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2200 (hash-table-p table))
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2201 (error "Bad args to define-translation-hash-table"))
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2202 (let ((len (length translation-hash-table-vector))
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2203 (id 0)
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2204 done)
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2205 (put symbol 'translation-hash-table table)
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2206 (while (not done)
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2207 (if (>= id len)
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2208 (setq translation-hash-table-vector
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2209 (vconcat translation-hash-table-vector [nil])))
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2210 (let ((slot (aref translation-hash-table-vector id)))
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2211 (if (or (not slot)
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2212 (eq (car slot) symbol))
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2213 (progn
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2214 (aset translation-hash-table-vector id (cons symbol table))
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2215 (setq done t))
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2216 (setq id (1+ id)))))
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2217 (put symbol 'translation-hash-table-id id)
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2218 id))
2d28ee240bd7 (define-translation-hash-table): New.
Dave Love <fx@gnu.org>
parents: 46489
diff changeset
2219
17094
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
2220 ;;; Initialize some variables.
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
2221
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
2222 (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
2223 (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
2224 (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
2225 (setq ignore-relative-composition
9d34beb088bf (make-coding-system): Add a new FLAGS
Kenichi Handa <handa@m17n.org>
parents: 19162
diff changeset
2226 (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
2227
45450
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
2228
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
2229 ;;; Built-in auto-coding-functions:
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
2230
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
2231 (defun sgml-xml-auto-coding-function (size)
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
2232 "Determine whether the buffer is XML, and if so, its encoding.
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
2233 This function is intended to be added to `auto-coding-functions'."
51080
e5124f8f4dc9 (sgml-xml-auto-coding-function, sgml-html-meta-auto-coding-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50584
diff changeset
2234 (setq size (+ (point) size))
e5124f8f4dc9 (sgml-xml-auto-coding-function, sgml-html-meta-auto-coding-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50584
diff changeset
2235 (when (re-search-forward "\\`[[:space:]\n]*<\\?xml" size t)
45450
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
2236 (let ((end (save-excursion
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
2237 ;; This is a hack.
62154
2d0b029e8560 (sgml-xml-auto-coding-function): Recognize encoding='FOO'
Eli Zaretskii <eliz@gnu.org>
parents: 61995
diff changeset
2238 (re-search-forward "[\"']\\s-*\\?>" size t))))
45450
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
2239 (when end
62154
2d0b029e8560 (sgml-xml-auto-coding-function): Recognize encoding='FOO'
Eli Zaretskii <eliz@gnu.org>
parents: 61995
diff changeset
2240 (if (re-search-forward "encoding=[\"']\\(.+?\\)[\"']" end t)
45691
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2241 (let* ((match (match-string 1))
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2242 (sym (intern (downcase match))))
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2243 (if (coding-system-p sym)
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2244 sym
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2245 (message "Warning: unknown coding system \"%s\"" match)
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2246 nil))
45450
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
2247 'utf-8)))))
3b83834d8f74 (make-coding-system): Doc fixes.
Colin Walters <walters@gnu.org>
parents: 45418
diff changeset
2248
45691
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2249 (defun sgml-html-meta-auto-coding-function (size)
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2250 "If the buffer has an HTML meta tag, use it to determine encoding.
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2251 This function is intended to be added to `auto-coding-functions'."
51080
e5124f8f4dc9 (sgml-xml-auto-coding-function, sgml-html-meta-auto-coding-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50584
diff changeset
2252 (setq size (min (+ (point) size)
45691
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2253 ;; Only search forward 10 lines
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2254 (save-excursion
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2255 (forward-line 10)
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2256 (point))))
58149
a469fda36737 (sgml-html-meta-auto-coding-function):
Juri Linkov <juri@jurta.org>
parents: 57645
diff changeset
2257 (when (and (search-forward "<html" size t)
45691
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2258 (re-search-forward "<meta\\s-+http-equiv=\"content-type\"\\s-+content=\"text/\\sw+;\\s-*charset=\\(.+?\\)\"" size t))
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2259 (let* ((match (match-string 1))
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2260 (sym (intern (downcase match))))
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2261 (if (coding-system-p sym)
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2262 sym
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2263 (message "Warning: unknown coding system \"%s\"" match)
febc3fe8ff9b (sgml-html-meta-auto-coding-function): New function.
Colin Walters <walters@gnu.org>
parents: 45479
diff changeset
2264 nil))))
46190
dabcd09794f7 (auto-coding-alist): Add knowledge of .sx[dmicw] file
Francesco Potortì <pot@gnu.org>
parents: 45857
diff changeset
2265
17094
c237252970e5 (make-coding-system): For ISO-2022 type conding systems,
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
2266 ;;;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2267 (provide 'mule)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2268
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52289
diff changeset
2269 ;;; arch-tag: 9aebaa6e-0e8a-40a9-b857-cb5d04a39e7c
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2270 ;;; mule.el ends here