Merge from emacs--rel--22
[emacs.git] / lisp / term / internal.el
blob658307d3959f96f5e6679096083e2836c09cda54
1 ;;; internal.el --- support for PC internal terminal -*- coding: raw-text; no-byte-compile: t -*-
3 ;; Copyright (C) 1993, 1994, 1998, 1999, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Author: Morten Welinder <terra@diku.dk>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;;; Code:
27 ;; ---------------------------------------------------------------------------
28 ;; keyboard setup -- that's simple!
29 (set-input-mode nil nil 0)
30 (define-key local-function-key-map [backspace] "\177") ; Normal behaviour for BS
31 (define-key local-function-key-map [delete] "\C-d") ; ... and Delete
32 (define-key local-function-key-map [tab] [?\t])
33 (define-key local-function-key-map [linefeed] [?\n])
34 (define-key local-function-key-map [clear] [11])
35 (define-key local-function-key-map [return] [13])
36 (define-key local-function-key-map [escape] [?\e])
37 (define-key local-function-key-map [M-backspace] [?\M-\d])
38 (define-key local-function-key-map [M-delete] [?\M-d])
39 (define-key local-function-key-map [M-tab] [?\M-\t])
40 (define-key local-function-key-map [M-linefeed] [?\M-\n])
41 (define-key local-function-key-map [M-clear] [?\M-\013])
42 (define-key local-function-key-map [M-return] [?\M-\015])
43 (define-key local-function-key-map [M-escape] [?\M-\e]))
44 (put 'backspace 'ascii-character 127)
45 (put 'delete 'ascii-character 127)
46 (put 'tab 'ascii-character ?\t)
47 (put 'linefeed 'ascii-character ?\n)
48 (put 'clear 'ascii-character 12)
49 (put 'return 'ascii-character 13)
50 (put 'escape 'ascii-character ?\e)
52 ;; ----------------------------------------------------------------------
53 ;; DOS display setup
54 ;; =================
56 ;; DOS can only support a single font. On most systems (with the
57 ;; possible exception of Far Eastern DOS versions), this means that
58 ;; two character sets are available at any given time: the ASCII
59 ;; charset, and a single national charset, usually mapped to codes
60 ;; above 128 (i.e., with 8th bit set). Which national charset is
61 ;; supported depends on the codepage loaded by the system when it
62 ;; boots; usually, this codepage cannot be changed without
63 ;; rebooting.
65 ;; Since each codepage can usually display character of a single
66 ;; MULE charset, Emacs can display a single MULE charset with the
67 ;; glyphs of the current codepage. The mapping from DOS codepages
68 ;; to MULE charsets is established by the charset property of the
69 ;; cpNNN-decode-table variables in codepage.el, which also
70 ;; defines translation tables for each such pair, and a bunch of
71 ;; functions to generate coding systems that use those translation
72 ;; tables to convert codepage-encoded text to the appropriate MULE
73 ;; charset and back. When Emacs starts on DOS, it automatically
74 ;; sets its default coding systems for file I/O and terminal output
75 ;; according to the currend DOS codepage, given by the
76 ;; `dos-codepage' variable.
78 ;; This leaves us with the problem of displaying character sets
79 ;; other than the one which maps directly into the current codepage.
80 ;; The following functions and variables handle this nuisance by
81 ;; defining a display table where each character that doesn't have a
82 ;; glyph in some codepage is mapped to a string which represents it.
83 ;; For example, a small c with cedilla is mapped to the string
84 ;; "{,c}" (the braces serve as a sign that this is a single
85 ;; character). A nice feature of the display tables is that Emacs
86 ;; knows that the string represents a single character, and thus
87 ;; cursor motion works as you'd expect: a single `C-f' moves past
88 ;; the entire string which represents a single character.
89 ;; ----------------------------------------------------------------------
91 (defvar IT-character-translations
93 (latin-iso8859-1
94 . [255 "!I" "|c" "Pd" "$$" "Ye" "|" "SE" "\"" "(c)"
95 "_a" "<<" "~" "--" "(R)" "'-" "^o" "+-" "^2" "^3"
96 "'" "u" ".P" "^." "'," "^1" "_o" ">>" "1/4" "1/2"
97 "3/4" "?I" "`A" "A'" "A^" "~A" "\"A" "Ao" "AE" ",C"
98 "`E" "E'" "E^" "\"E" "`I" "I'" "I^" "\"I" "-D" "~N"
99 "`O" "O'" "O^" "~O" "\"O" "*x" "/O" "`U" "U'" "U^"
100 "\"U" "Y'" "-P" "ss" "`a" "a'" "a^" "~a" "\"a" "ao"
101 "ae" ",c" "`e" "e'" "e^" "\"e" "`i" "i'" "i^" "\"i"
102 "-d" "~n" "`o" "o'" "o^" "~o" "\"o" "-:" "/o" "`u"
103 "u'" "u^" "\"u" "y'" "-p" "\"y"]
105 (latin-iso8859-2
106 . [255 "A;" "'(" "/L" "$$" "L<" "S'" "SE" "\"" "S<"
107 ",S" "T<" "Z'" "--" "Z<" "Z^." "^o" "a;" "';" "/l"
108 "'" "l<" "s'" "'<" "'," "s<" ",s" "t<" "z'" "'"
109 "z<" "z^." "R'" "A'" "A^" "A(" "\"A" "L'" "C'" ",C"
110 "C<" "E'" "E;" "E:" "E<" "I'" "I^" "D<" "/D" "N'"
111 "N<" "O'" "O^" "O''" "\"O" "*x" "R<" "U^0" "U'" "U''"
112 "\"U" "Y'" ",T" "ss" "r'" "a'" "a^" "a(" "\"a" "l'"
113 "c'" ",c" "c<" "e'" "e;" "\"e" "e<" "i'" "i^" "d<"
114 "/d" "n'" "n<" "o'" "o^" "o''" "\"o" "-:" "r<" "u^0"
115 "u'" "u''" "\"u" "y'" ",t" "'."]
117 (latin-iso8859-3
118 . [255 "/H" "'(" "Pd" "$$" " " "H^" "SE" "\"" "I^."
119 ",S" "G(" "J^" "--" " " "Z^." "^o" "/h" "^2" "^3"
120 "'" "u" "h^" "." "'," "i^." ",s" "g(" "j^" "1/2"
121 " " "z^." "`A" "A'" "A^" " " "\"A" "C^." "C^" ",C"
122 "`E" "E'" "E^" "\"E" "`I" "I'" "I^" "\"I" " " "~N"
123 "`O" "O'" "O^" "G^." "\"O" "*x" "G^" "`U" "U'" "U^"
124 "\"U" "U(" "S^" "ss" "`a" "a'" "a^" " " "\"a" "c^."
125 "c^" ",c" "`e" "e'" "e^" "\"e" "`i" "i'" "i^" "\"i"
126 " " "~n" "`o" "o'" "o^" "g^." "\"o" "-:" "g^" "`u"
127 "u'" "u^" "\"u" "u(" "s^" "^."]
129 (latin-iso8859-4
130 . [255 "A;" "kk" ",R" "$$" "?I" ",L" "SE" "\"" "S<"
131 "E-" ",G" "/T" "--" "Z<" "'-" "^o" "a;" "';" ",r"
132 "'" "~i" ",l" "'<" "'," "s<" "e-" ",g" "/t" "NG"
133 "z<" "ng" "A-" "A'" "A^" "~A" "\"A" "Ao" "AE" "I;"
134 "C<" "E'" "E;" "\"E" "E^." "I'" "I^" "I-" "/D" ",N"
135 "O-" ",K" "O^" "~O" "\"O" "*x" "/O" "U;" "U'" "U^"
136 "\"U" "~U" "U-" "ss" "a-" "a'" "a^" "~a" "\"a" "ao"
137 "ae" "i;" "c<" "e'" "e;" "\"e" "e^." "i'" "i^" "i-"
138 "/d" ",n" "o-" ",k" "o^" "~o" "\"o" "-:" "/o" "u;"
139 "u'" "u^" "\"u" "~u" "u-" "^."]
141 (cyrillic-iso8859-5
142 . [255 "\"E" "Dj" "Gj" "IE" "Dz" "Ii" "Ji" "JE" "Lj"
143 "Nj" "Ts" "Kj" 240 "V%" "Dzh" 65 "B=" 66 226
144 68 69 "Z%" 51 85 "J=" 75 "L=" 77 72
145 79 "P=" 80 67 84 89 232 88 "C=" "C%"
146 "S%" "Sc" "=\"" "Y=" "%\"" "Ee" "Yu" "Ya" 97 98
147 "v=" "g=" 103 101 "z%" "z=" 117 "j=" 107 "l="
148 "m=" "n=" 111 110 112 99 "t=" 121 "f=" 120
149 "c=" "c%" "s%" "sc" "='" "y=" "%'" "ee" "yu" "ya"
150 "N0" "\"e" "dj" "gj" "ie" "dz" "ii" "ji" "je" "lj"
151 "nj" "ts" "kj" 21 "v%" "dzh"]
153 (arabic-iso8859-6
154 . [255 nil nil nil "$$" nil nil nil nil nil
155 nil nil ",+" "--" nil nil nil nil nil nil
156 nil nil nil nil nil nil nil ";+" nil nil
157 nil "?+" nil "H'" "aM" "aH" "wH" "ah" "yH"
158 "a+" "b+" "tm" "t+" "tk" "g+" "hk" "x+" "d+" "dk"
159 "r+" "z+" "s+" "sn" "c+" "dd" "tj" "zH" "e+" "i+"
160 nil nil nil nil nil "++" "f+" "q+" "k+" "l+"
161 "m+" "n+" "h+" "w+" "j+" "y+" ":+" "\"+" "=+" "/+"
162 "'+" "1+" "3+" "0+" nil nil nil nil nil nil
163 nil nil nil nil nil nil nil]
165 (greek-iso8859-7
166 . [255 "9'" "'9" "Pd" nil nil "|" "SE" "\"" "(c)"
167 nil "<<" "~" "--" nil "-M" "^o" "+-" "^2" "^3"
168 "'" "'%" "'A" "^." "'E" "'H" "'I" ">>" "'O" "1/2"
169 "'Y" "W%" "i3" 65 66 "G*" "D*" 69 90 72
170 "TH" 73 74 "L*" 77 78 "C*" 79 "P*" 80
171 nil "S*" 84 89 "F*" 88 "Q*" "W*" "\"I" "\"Y"
172 "a%" "e%" "y%" "i%" "u3" "a*" "b*" "g*" "d*" "e*"
173 "z*" "y*" "h*" "i*" 107 "l*" "m*" "n*" "c*" 111
174 "p*" "r*" "*s" "s*" "t*" 117 "f*" "x*" "q*" "w*"
175 "\"i" "\"u" "'o" "'u" "'w" nil]
177 ;; Note: some of the characters undefined according to ISO 8859-8
178 ;; in the ranges 190..220 and 250..255 are replaced with SI 1311-1
179 ;; points (Niqud) and bidi formatting characters
180 (hebrew-iso8859-8
181 . [255 nil "|c" "Pd" "$$" "Ye" "|" "SE" "\"" "(c)"
182 "*x" "<<" "~" "--" "(R)" "'-" "^o" "+-" "^2" "^3"
183 "'" "u" ".P" "^." "'," "^1" "-:" ">>" "1/4" "1/2"
184 "3/4" nil ":'" "v:" "-:" "-':" ".'" ".." "v'" "-'"
185 "-," "`." nil "\\." "(.)" "|'" "`-" "`=" "||" nil
186 nil "::" nil nil nil nil nil nil nil "LRO"
187 "RLO" "PDF" nil "=2" "A+" "B+" "G+" "D+" "H+" "W+"
188 "Z+" "X+" "Tj" "J+" "K%" "K+" "L+" "M%" "M+" "N%"
189 "N+" "S+" "E+" "P%" "P+" "Zj" "ZJ" "Q+" "R+" "Sh"
190 "T+" "LRE" "RLE" "LRM" "RLM" nil]
192 (latin-iso8859-9
193 . [255 "!I" "|c" "Pd" "$$" "Ye" "|" "SE" "\"" "(c)"
194 "_a" "<<" "~" "--" "(R)" "'-" "^o" "+-" "^2" "^3"
195 "'" "u" ".P" "^." "'," "^1" "_o" ">>" "1/4" "1/2"
196 "3/4" "?I" "`A" "A'" "A^" "~A" "\"A" "Ao" "AE" ",C"
197 "`E" "E'" "E^" "\"E" "`I" "I'" "I^" "\"I" "G(" "~N"
198 "`O" "O'" "O^" "~O" "\"O" "*x" "/O" "`U" "U'" "U^"
199 "\"U" "I^." ",S" "ss" "`a" "a'" "a^" "~a" "\"a" "ao"
200 "ae" ",c" "`e" "e'" "e<" "\"e" "e^." "i'" "i^" "i-"
201 "g(" "~n" "`o" "o'" "o^" "~o" "\"o" "-:" "/o" "`u"
202 "u'" "u^" "\"u" "i." ",s" "\"y"]
204 (latin-iso8859-14
205 . [255 "B`" "b`" "Pd" "C`" "c`" "D`" "SE" "`W" "(c)"
206 "W'" "d`" "`Y" "--" "(R)" "\"Y" "F`" "f`" "G`" "g`"
207 "M`" "m`" ".P" "P`" "`w" "p`" "w'" "S`" "`y" "\"W"
208 "\"w" "s`" "`A" "A'" "A^" "~A" "\"A" "Ao" "AE" ",C"
209 "`E" "E'" "E^" "\"E" "`I" "I'" "I^" "\"I" "W^" "~N"
210 "`O" "O'" "O^" "~O" "\"O" "T`" "/O" "`U" "U'" "U^"
211 "\"U" "Y'" "Y^" "ss" "`a" "a'" "a^" "~a" "\"a" "ao"
212 "ae" ",c" "`e" "e'" "e^" "\"e" "`i" "i'" "i^" "\"i"
213 "w^" "~n" "`o" "o'" "o^" "~o" "\"o" "t`" "/o" "`u"
214 "u'" "u^" "\"u" "y'" "y^" "\"y"]
216 (latin-iso8859-15
217 . [255 "!I" "|c" "Pd" "E=" "Ye" "S<" "SE" "s<" "(c)"
218 "_a" "<<" "~" "--" "(R)" "'-" "^o" "+-" "^2" "^3"
219 "Z<" "u" ".P" "^." "z<" "^1" "_o" ">>" "OE" "oe"
220 "\"Y" "?I" "`A" "A'" "A^" "~A" "\"A" "Ao" "AE" ",C"
221 "`E" "E'" "E^" "\"E" "`I" "I'" "I^" "\"I" "-D" "~N"
222 "`O" "O'" "O^" "~O" "\"O" "*x" "/O" "`U" "U'" "U^"
223 "\"U" "Y'" "|P" "ss" "`a" "a'" "a^" "~a" "\"a" "ao"
224 "ae" ",c" "`e" "e'" "e^" "\"e" "`i" "i'" "i^" "\"i"
225 "-d" "~n" "`o" "o'" "o^" "~o" "\"o" "-:" "/o" "`u"
226 "u'" "u^" "\"u" "y'" "|p" "\"y"]
229 "An alist of MULE ISO-8859 character sets and the strings that
230 should be used to represent the characters from each set on a DOS
231 terminal which does not have corresponding glyphs built into the
232 installed codepage.")
234 (defun IT-display-table-setup (codepage &optional table)
235 "Set up display table TABLE for a DOS terminal which supports
236 glyphs built into the codepage CODEPAGE.
238 If TABLE is nil or omitted, `standard-display-table' is used."
239 (let* ((surrogates IT-character-translations)
240 (disp-tab (or table standard-display-table))
241 (built-in-set (cp-charset-for-codepage codepage))
242 (offset (cp-offset-for-codepage codepage))
243 (cp-decoder
244 (symbol-value (intern-soft (format "%s-decode-table" codepage))))
245 (cp-decoder-len (length cp-decoder))
246 (c offset)
247 association chset)
248 ;; Undo the effects of previous call (where they may have used
249 ;; a different codepage) by reverting the display table for the
250 ;; built-in charset to its pristine shape.
251 (while (< c 256)
252 (aset disp-tab (make-char built-in-set c) nil)
253 (setq c (1+ c)))
254 (while surrogates
255 (setq association (car surrogates))
256 (setq chset (car association))
257 (let* ((vector (cdr association))
258 (veclen (length vector))
259 (i 0)
260 glyph)
261 (while (< i veclen)
262 (setq glyph (aref vector i))
263 (or glyph (setq glyph dos-unsupported-char-glyph))
264 (if (or (not (equal chset built-in-set))
265 (>= i cp-decoder-len)
266 (null (aref cp-decoder i)))
267 (aset disp-tab (make-char chset (+ i (logand offset 127)))
268 (vconcat
269 (if (numberp glyph)
270 (char-to-string glyph)
271 (if (> (length glyph) 1) (concat "{" glyph "}")
272 glyph)))))
273 (setq i (1+ i))))
274 (setq surrogates (cdr surrogates)))))
276 (defvar IT-unicode-translations
278 (mule-unicode-0100-24ff ; charset
279 256 ; base
280 256 563 ; first, last
281 [ "A-" "a-" "A(" "a(" "A;" "a;" "C'" "c'" "C>" "c>" ; Latin Extended-A
282 "C." "c." "C<" "c<" "D<" "d<" "D/" "d/" "E-" "e-"
283 "E(" "e(" "E." "e." "E;" "e;" "E<" "e<" "G>" "g>"
284 "G(" "g(" "G." "g." "G," "g," "H>" "h>" "H/" "h/"
285 "I~" "i~" "I-" "i-" "I(" "i(" "I;" "i;" "I." "i."
286 "IJ" "ij" "J>" "j>" "K," "k," "kk" "L'" "l'" "L,"
287 "l," "L<" "l<" "L." "l." "L/" "l/" "N'" "n'" "N,"
288 "n," "N<" "n<" "'n" "NG" "ng" "O-" "o-" "O(" "o("
289 "O\"" "o\"" "OE" "oe" "R'" "r'" "R," "r," "R<" "r<"
290 "S'" "s'" "S>" "s>" "S," "s," "S<" "s<" "T," "t,"
291 "T<" "t<" "T/" "t/" "U~" "u~" "U-" "u-" "U(" "u("
292 "U0" "u0" "U\"" "u\"" "U;" "u;" "W>" "w>" "Y>" "y>"
293 "Y:" "Z'" "z'" "Z." "z." "Z<" "z<" "s1" ; 017f
294 "b/" "B2" "=B" "=b" "B6" "b6" "!C" "C2" "c2" "-D" ;Lat. Extended-B
295 "D2" "=D" "=d" "!d" "!E" "-E" "Eps" "F2" "f2" "G2"
296 "V0" "hv" "io" "-I" "K2" "k2" "-l" "la-" "!M" "2N"
297 "n_" "-O" "O9" "o9" "OI" "oi" "P2" "p2" "'R" "!S"
298 "!s" "Esh" "!esh" "t~" "T2" "t2" "T~" "U9" "u9" "Ups"
299 "V2" "Y2" "y2" "Z/" "z/" "ED" "!ED" "!ed" "ed;" "2/"
300 "5-" "_5-" "ts" "wn" "|_" "||" "|=" "!_" "DZ<" "Dz<"
301 "dz<" "LJ3" "Lj3" "lj3" "NJ3" "Nj3" "nj3" "A<" "a<" "I<"
302 "i<" "O<" "o<" "U<" "u<" "U:-" "u:-" "U:'" "u:'" "U:<"
303 "u:<" "U:!" "u:!" "e1" "A:-" "a:-" "A.-" "a.-" "AE-" "ae-"
304 "G/" "g/" "G<" "g<" "K<" "k<" "O;" "o;" "O1" "o1"
305 "EZ" "ez" "j<" "DZ3" "Dz3" "dz3" "G'" "g'" "Hv" "Wn"
306 "N`" "n`" "AA'" "aa'" "AE'" "ae'" "O/'" "o/'" "A!!" "a!!"
307 "A)" "a)" "E!!" "e!!" "E)" "e)" "I!!" "i!!" "I)" "i)"
308 "O!!" "o!!" "O)" "o)" "R!!" "r!!" "R)" "r)" "U!!" "u!!"
309 "U)" "u)" ",S" ",s" ",T" ",t" "'3" "'3_" "H<" "h<"
310 nil nil "8" "8_" "Z2" "z2" "A." "a." "E," "e,"
311 "O:-" "o:-" "O~-" "o~-" "O." "o." "O.-" "o.-" "Y-" "y-"] ; 0x233
315 (mule-unicode-0100-24ff ; charset
316 256 ; base
317 884 1123 ; first, last
318 [ "'" "," nil nil nil nil "j3" nil nil nil ; Greek
319 "?;" nil nil nil nil nil "'*" "'%" "A%" ".*"
320 "E%" "Y%" "I%" nil "O%" nil "U%" "W%" "i3" "A*"
321 "B*" "G*" "D*" "E*" "Z*" "H*" "Th*" "I*" "K*" "L*"
322 "M*" "N*" "C*" "O*" "P*" "R*" nil "S*" "T*" "U*"
323 "F*" "X*" "Q*" "W*" "J*" "V*" "a%" "e%" "y%" "i%"
324 "u3" "a*" "b*" "g*" "d*" "e*" "z*" "h*" "th*" "i*"
325 "k*" "l*" "m*" "n*" "c*" "o*" "p*" "r*" "*s" "s*"
326 "t*" "u*" "f*" "x*" "q*" "w*" "j*" "v*" "o%" "u%"
327 "w%" nil "b3" "th%" "U2*" "'U2*" "U:2*" "ph*" "pi*" "ka*"
328 nil nil "Sti" "sti" "Dig" "dig" "Kop" "kop" "Sam" "sam"
329 "She" "she" "Fei" "fei" "Khe" "khe" "Hor" "hor" "Gan" "gan"
330 "Shi" "shi" "Dei" "dei" "ka*" "rh*" "ls*" "yo*" nil nil
331 nil nil nil nil nil nil nil nil nil nil
332 "IE'" "E:" "D%" "G%" "IE" "DS" "II" "YI" "J%" "LJ" ; Cyrillic
333 "NJ" "Ts" "KJ" "`I=" "V%" "DZ" 65 "B=" 66 "G="
334 68 69 "Z%" 51 85 "J=" 75 "L=" 77 72
335 79 "P=" 80 67 84 89 "F=" 88 "C=" "C%"
336 "S%" "Sc" "=\"" "Y=" "%\"" "Ee" "JU" "JA" 97 "b="
337 98 "g=" 103 101 "z%" "z=" 117 "j=" 107 "l="
338 109 "n=" 111 "p=" 112 99 "t=" 121 "f=" 120
339 "c=" "c%" "s%" "sc" "='" "y=" "%'" "ee" "ju" "ja"
340 "ie'" "e:" "d%" "g%" "ie" "ds" "ii" "yi" "j%" "lj"
341 "nj" "ts" "kj" "v%" "`i=" "dz" "OM=" "om=" "Y3" "y3"] ; 0x463
344 (mule-unicode-0100-24ff ; charset
345 256 ; base
346 1454 1645 ; first, last
347 [ nil nil ":'" "v:" "-:" "-':" ".'" ".." "v'" "-'"
348 "-," "`." nil "\\." "(.)" "|'" "`-" nil "||" nil
349 nil "::" nil nil nil nil nil nil nil nil
350 nil nil nil nil
351 "A+" "B+" "G+" "D+" "H+" "W+" "Z+" "X+" "Tj" "J+" ; Hebrew
352 "K%" "K+" "L+" "M%" "M+" "N%" "N+" "S+" "E+" "P%"
353 "P+" "Zj" "ZJ" "Q+" "R+" "Sh" "T+" nil nil nil
354 nil nil "WW+" "WJ+" "JJ+" "'+" "\"+" nil nil nil
355 nil nil nil nil nil nil nil nil nil nil
356 nil nil nil nil nil nil nil nil nil nil
357 ",+" nil nil nil nil nil nil nil nil nil ; Arabic
358 nil nil nil nil nil ";+" nil nil nil "?+"
359 nil "H'" "aM" "aH" "wH" "ah" "yH" "a+" "b+" "tm"
360 "t+" "tk" "g+" "hk" "x+" "d+" "dk" "r+" "z+" "s+"
361 "sn" "c+" "dd" "tj" "zH" "e+" "i+" nil nil nil
362 nil nil "++" "f+" "q+" "k+" "l+" "m+" "n+" "h+"
363 "w+" "j+" "y+" ":+" "\"+" "=+" "/+" "'+" "1+" "3+"
364 "0+" nil nil nil nil nil nil nil nil nil
365 nil nil nil nil "0a" "1a" "2a" "3a" "4a" "5a"
366 "6a" "7a" "8a" "9a" "a%" "a." "a," "a*" ]
369 (mule-unicode-0100-24ff ; charset
370 256 ; base
371 7680 9450 ; first, last
372 [ "A-0" "a-0" "B." "b." "B-." "b-." "B_" "b_" "C,'" "c,'" ; Lat Ext Add
373 "D." "d." "D-." "d-." "D_" "d_" "D," "d," "D->" "d->"
374 "E-!" "e-!" "E-'" "e-'" "E->" "e->" "E-?" "e-?" "E,(" "e,("
375 "F." "f." "G-" "g-" "H." "h." "H-." "h-." "H:" "h:"
376 "H," "h," "H-(" "h-(" "I-?" "i-?" "I:'" "i:'" "K'" "k'"
377 "K-." "k-." "K_" "k_" "L-." "l-." "_L-." "_l-." "L_" "l_"
378 "L->" "l->" "M'" "m'" "M." "m." "M-." "m-." "N." "n."
379 "N-." "n-." "N_" "n_" "N->" "n->" "O?'" "o?'" "O?:" "o?:"
380 "O-!" "o-!" "O-'" "o-'" "P'" "p'" "P." "p." "R." "r."
381 "R-." "r-." "_R-." "_r-." "R_" "r_" "S." "s." "S-." "s-."
382 "S'." "s'." "S<." "s<." ".S-." ".s-." "T." "t." "T-." "t-."
383 "T_" "t_" "T->" "t->" "U_:" "u_:" "U-?" "u-?" "U->" "u->"
384 "U?'" "u?'" "U-:" "u-:" "V?" "v?" "V-." "v-." "W!" "w!"
385 "W'" "w'" "W:" "w:" "W." "w." "W-." "w-." "X." "x."
386 "X:" "x:" "Y." "y." "Z>" "z>" "Z-." "z-." "Z_" "z_"
387 "h_" "t:" "w0" "y0" "a))" "s1." nil nil nil nil
388 "A-." "a-." "A2" "a2" "A>'" "a>'" "A>!" "a>!" "A>2" "a>2"
389 "A>~" "a>~" ".A>" ".a>" "A('" "a('" "A(!" "a(!" "A(2" "a(2"
390 "A(~" "a(~" ".A(" ".a(" "E-." "e-." "E2" "e2" "E~" "e~"
391 "E>'" "e>'" "E>!" "e>!" "E>2" "e>2" "E>~" "e>~" ".E>" ".e>"
392 "I2" "i2" "I-." "i-." "O-." "o-." "O2" "o2" "O>'" "o>'"
393 "O>!" "o>!" "O>2" "o>2" "O>~" "o>~" ".O>" ".o>" "O9'" "o9'"
394 "O9!" "o9!" "O92" "o92" "O9~" "o9~" ".O9" ".o9" "U-." "u-."
395 "U2" "u2" "U9'" "u9'" "U9!" "u9!" "U92" "u92" "U9~" "u9~"
396 ".U9" ".u9" "Y!" "y!" "Y-." "y-." "Y2" "y2" "Y~" "y~"
397 nil nil nil nil nil nil "a*," "a*;" nil nil ; Greek Ext (0x1f00)
398 nil nil nil nil "A*," "A*;" nil nil nil nil
399 nil nil "e*," "e*;" nil nil nil nil nil nil
400 "E*," "E*;" nil nil nil nil nil nil "y*," "y*;"
401 nil nil nil nil nil nil "Y*," "Y*;" nil nil
402 nil nil nil nil "i*," "i*;" nil nil nil nil
403 nil nil "I*," "I*;" nil nil nil nil nil nil
404 "o*," "o*;" nil nil nil nil nil nil "O*," "O*;"
405 nil nil nil nil nil nil "u*," "u*;" nil nil
406 nil nil nil nil nil "U*;" nil nil nil nil
407 nil nil "w*," "w*;" nil nil nil nil nil nil
408 "W*," "W*;" nil nil nil nil nil nil "a*!" "a*'"
409 "e*!" "e*'" "y*!" "y*'" "i*!" "i*'" "o*!" "o*'" "u*!" "u*'"
410 "w*!" "w*'" nil nil nil nil nil nil nil nil
411 nil nil nil nil nil nil nil nil nil nil
412 nil nil nil nil nil nil nil nil nil nil
413 nil nil nil nil nil nil nil nil nil nil
414 nil nil nil nil nil nil nil nil nil nil
415 nil nil "a*(" "a*-" nil "a*j" nil nil "a*~" nil
416 "A*(" "A*-" "A*!" "A*'" "A*J" ")*" "J3" ",," "?*" "?:"
417 nil "y*j" nil nil "y*?" nil "E*!" "E*'" "Y*!" "Y*'"
418 "Y*J" ",!" ",'" "?," "i*(" "i*-" nil nil nil nil
419 "i*?" nil "I*(" "I*-" "I*!" "I*'" nil ";!" ";'" "?;"
420 "u*(" "u*-" nil nil "r*," "r*;" "u*?" nil "U*(" "U*-"
421 "U*!" "U*'" "R*;" "!:" ":'" "!*" nil nil nil "w*j"
422 nil nil "w*?" nil "O*!" "O*'" "W*!" "W*'" "W*J" "/*"
423 ";;" nil nil nil "1N" "1M" "3M" "4M" "6M" nil ; Gen Punct
424 nil "1T" "1H" nil nil nil "LRM" "RLM" "-1" nil
425 nil "--" "---" "===" "!2" "=2" "6`" "'9" ".9" "9'"
426 "``" "''" ":9" "9``" "/-" "/=" "sb" "3b" nil ".."
427 "..." ".-" "LSep" "PSep" "LR[" "RL[" "PDF" "LRO" "RLO" 255
428 "%o" "%oo" "'" "''" "\"'" "`" "``" "```" ".^" "<,"
429 ",>" ":X" "!!" "?!" "'-" nil nil nil nil "-b"
430 "/f" nil nil nil nil nil nil nil nil nil
431 nil nil nil nil nil nil nil nil nil nil
432 nil nil nil nil nil nil nil nil nil nil
433 nil nil nil nil nil nil nil nil nil nil
434 nil nil nil nil "^0" nil nil nil "^4" "^5"
435 "^6" "^7" "^8" "^9" "^+" "^-" "^=" "^(" "^)" "^n"
436 "_0" "_1" "_2" "_3" "_4" "_5" "_6" "_7" "_8" "_9"
437 "_+" "_-" "_=" "_(" "_)" nil nil nil nil nil
438 nil nil nil nil nil nil nil nil nil nil
439 nil nil nil nil nil "Ff" "Li" nil nil "Pt"
440 nil "W=" "NIS" nil "E=" nil nil nil nil nil
441 nil nil nil nil nil nil nil nil nil nil
442 nil nil nil nil nil nil nil nil nil nil
443 nil nil nil nil nil nil nil nil nil nil
444 nil nil nil nil nil nil nil nil nil nil
445 nil nil nil nil nil nil nil nil nil nil
446 nil nil nil nil nil nil nil nil nil nil
447 nil nil nil nil nil nil nil nil nil nil
448 nil nil nil nil nil nil nil nil "a/c" "a/s"
449 nil "oC" nil "c/o" "c/u" "=e" nil "oF" nil nil
450 nil nil "-h" "=h" nil nil nil nil nil nil
451 "N0" "PO" nil nil nil nil "Re" nil "Rx" nil
452 "SM" "TEL" "TM" nil nil nil "Om" nil nil nil
453 "oK" "AO" nil nil "Est" nil nil nil nil nil
454 nil "Aleph" "Bet" "Gimel" "Dalet" "=i=" nil nil nil nil
455 nil nil nil nil nil nil nil nil nil nil
456 nil nil nil nil nil nil nil nil nil nil
457 nil "1/3" "2/3" "1/5" "2/5" "3/5" "4/5" "1/6" "5/6" "1/8"
458 "3/8" "5/8" "7/8" "1/" ".I" "II" "III" "IV" ".V" "VI"
459 "VII" "VIII" "IX" "X" "XI" "XII" ".L" ".C" ".D" ".M"
460 ".i" "ii" "iii" "iv" ".v" "vi" "vii" "viii" "ix" ".x"
461 "xi" ".l" ".c" ".d" ".m" "CD" "DD" "CoD" "CI" nil
462 nil nil nil nil nil nil nil nil nil nil
463 nil "<-" "|^" "->" "|v" "<->" "v|^" "^\\" "/^" "\\v"
464 "v/" "<-/" "/->" "<~" "~>" "<<-" "|^^" "->>" "|vv" "<-<"
465 ">->" "<-|" "_|^" "|->" "-|v" "_v|^" "<-?" "?->" "<-o" "o->"
466 "<~>" "<-/>" nil nil nil nil nil nil nil nil
467 nil nil nil nil nil nil nil nil nil nil
468 nil nil nil nil nil nil nil nil nil nil
469 nil nil nil "<=/" "<=/>" "/=>" "<=" "||^" "=>" "||v"
470 "<=>" "v||^" "^\\\\" "//^" "\\\\v" "v//" "<-=" "=->" nil nil
471 nil nil "<.." ":^" "..>" ":v" nil nil "<::" "::^"
472 "::>" "::v" nil nil nil nil nil nil nil nil
473 nil nil nil nil nil nil nil nil nil nil
474 nil nil nil nil "FA" "C." "dP" "TE" "~TE" "/0"
475 "DE" "NB" "(-" "~(-" "e-" "-)" "~-)" "-e" "QED" "*P"
476 nil "+Z" "--" "-+" ".+" "./" ".\\" "*-" "Ob" "Sb"
477 "SQR" "CBR" nil "0(" "00" "-L" "-V" nil nil ".|"
478 "~.|" "||" "/||" "AND" "OR" "(U" ")U" "In" "DI" nil
479 "Io" nil nil nil nil nil ".:" ":." ":R" "::"
480 ".-." "-:" ":-:" ":~:" "?~" "~?" "??" nil nil "/~"
481 "-~" "~-" "/~-" "~=" "~/=" "/~=" "~~" "/~~" nil nil
482 "=?" ")(" "v^" "^_" ".=" "=;" ".=." nil ":=" "=:"
483 nil "=o" "=)" "=^" "=v" "*=" "=<>" "=df" nil "?="
484 "!=" "-=" "!-=" "==" "=<" ">=" nil nil nil nil
485 "<<" ">>" "()" "/)(" "!<" "!>" nil nil nil nil
486 nil nil nil nil nil nil "<'" "`>" "=<'" "`>="
487 "~<'" "`>~" "/<'" "/`>" "(C" ")C" "/(C" "/)C" "(_" ")_"
488 "/(_" "/)_" nil nil nil nil nil nil nil nil
489 nil nil nil "0+" "0-" "0x" "0/" "0." "0o" "0*"
490 "0=" "0_" nil nil nil nil "|T" "T|" "-T" "_T"
491 nil nil nil nil nil nil nil nil nil nil
492 nil nil nil nil nil nil nil nil nil "-,-"
493 nil "XOR" "NAND" "NOR" nil nil nil nil nil nil
494 nil nil nil nil nil nil nil nil nil nil
495 nil nil nil nil nil nil nil nil "<." ".>"
496 "<<<" ">>>" nil nil nil nil nil nil nil nil
497 nil nil nil nil nil nil nil nil nil nil
498 nil nil ":3" "..." nil nil nil nil nil nil
499 nil nil nil nil nil nil nil nil nil nil
500 nil nil "Eh" nil nil nil nil nil "<7" ">7"
501 "7<" "7>" nil nil nil nil "~I" nil "(A" nil
502 nil "TR" nil "=||" "88" nil nil nil nil nil
503 nil nil "Iu" "Il" nil nil "-^-" "-`-" "D->" nil
504 nil "</" "/>" "<-D" nil nil nil nil nil nil
505 nil nil nil nil nil nil nil nil nil nil
506 nil nil nil nil nil nil nil nil nil nil
507 nil nil nil nil nil nil nil nil nil nil
508 nil nil nil nil nil nil nil nil nil nil
509 nil nil nil nil nil nil nil nil nil nil
510 nil nil nil nil nil nil nil nil nil nil
511 nil nil nil nil nil nil nil nil nil nil
512 nil nil nil nil nil nil nil nil nil nil
513 nil nil nil nil nil nil nil nil nil nil
514 nil nil nil nil nil nil nil nil nil nil
515 nil nil nil nil nil nil nil nil nil nil
516 nil nil nil nil nil nil nil nil nil nil
517 nil nil nil nil nil nil nil nil nil nil
518 nil nil nil nil nil nil nil nil nil nil
519 nil nil nil nil nil nil nil nil nil nil
520 nil nil nil nil nil nil nil nil nil nil
521 nil nil nil nil nil nil nil nil nil nil
522 nil nil nil nil nil nil nil nil nil nil
523 nil nil nil nil nil nil nil nil nil nil
524 nil nil nil nil nil nil nil nil nil nil
525 nil nil nil nil nil nil "NUL" "SOH" "STX" "ETX"
526 "EOT" "ENQ" "ACK" "BEL" "BS" "HT" "LF" "VT" "FF" "CR"
527 "SS" "SI" "DLE" "DC1" "DC2" "DC3" "DC4" "NAK" "SYN" "ETB"
528 "CAN" "EM" "SUB" "ESC" "FS" "GS" "RS" "US" "SP" "DEL"
529 "b/" ",_," "NL" nil "?^" nil nil nil nil nil
530 nil nil nil nil nil nil nil nil nil nil
531 nil nil nil nil nil nil nil nil nil nil
532 nil nil nil nil nil nil nil nil nil nil
533 nil nil nil nil nil nil nil nil nil nil
534 nil nil nil nil nil nil nil nil nil nil
535 nil nil "1-o" "2-o" "3-o" "4-o" "5-o" "6-o" "7-o" "8-o"
536 "9-o" "10-o" "11-o" "12-o" "13-o" "14-o" "15-o" "16-o" "17-o" "18-o"
537 "19-o" "20-o" "(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)"
538 "(9)" "(10)" "(11)" "(12)" "(13)" "(14)" "(15)" "(16)" "(17)" "(18)"
539 "(19)" "(20)" "1." "2." "3." "4." "5." "6." "7." "8."
540 "9." "10." "11." "12." "13." "14." "15." "16." "17." "18."
541 "19." "20." "(a)" "(b)" "(c)" "(d)" "(e)" "(f)" "(g)" "(h)"
542 "(i)" "(j)" "(k)" "(l)" "(m)" "(n)" "(o)" "(p)" "(q)" "(r)"
543 "(s)" "(t)" "(u)" "(v)" "(w)" "(x)" "(y)" "(z)" "A-o" "B-o"
544 "C-o" "D-o" "E-o" "F-o" "G-o" "H-o" "I-o" "J-o" "K-o" "L-o"
545 "M-o" "N-o" "O-o" "P-o" "Q-o" "R-o" "S-o" "T-o" "U-o" "V-o"
546 "W-o" "X-o" "Y-o" "Z-o" "a-o" "b-o" "c-o" "d-o" "e-o" "f-o"
547 "g-o" "h-o" "i-o" "j-o" "k-o" "l-o" "m-o" "n-o" "o-o" "p-o"
548 "q-o" "r-o" "s-o" "t-o" "u-o" "v-o" "w-o" "x-o" "y-o" "z-o"
549 "0-o" ]
553 "A list of mule-unicode-* character sets and the strings that
554 should be used to represent the characters from each set on a DOS
555 terminal which does not have corresponding glyphs built into the
556 installed codepage.")
558 (defun IT-setup-unicode-display (&optional table)
559 "Set up display table TABLE for displaying mule-unicode-* characters
560 on a DOS terminal. If TABLE is nil or omitted, `standard-display-table'
561 is used."
562 (interactive)
563 (let ((disp-tab (or table standard-display-table))
564 (tail IT-unicode-translations)
565 translation)
566 (while tail
567 (setq translation (car tail) tail (cdr tail))
568 (let* ((chset (car translation))
569 (base (nth 1 translation))
570 (first (nth 2 translation))
571 (last (nth 3 translation))
572 (table (nth 4 translation))
573 (i 0)
574 (this (- first base))
575 glyph)
576 (while (<= i (- last first))
577 (setq glyph (aref table i))
578 (or glyph (setq glyph dos-unsupported-char-glyph))
579 (aset disp-tab (make-char chset
580 (+ (/ this 96) 32)
581 (+ (% this 96) 32))
582 (vconcat
583 (if (numberp glyph)
584 (char-to-string glyph)
585 (if (> (length glyph) 1) (concat "{" glyph "}")
586 glyph))))
587 (setq i (1+ i) this (1+ this)))))))
589 (defun dos-cpNNN-setup (codepage)
590 "Set up the MULE environment using the DOS codepage CODEPAGE.
592 This function creates the coding system cpNNN (where NNN is the value
593 of the argument CODEPAGE), and then uses this coding system to set up
594 display tables, and the language environment options as appropriate."
595 (let* ((cp (format "cp%s" codepage))
596 (charset (cp-charset-for-codepage cp))
597 (offset (cp-offset-for-codepage cp)))
598 (cp-make-coding-systems-for-codepage cp charset offset)
599 ;; This is done by set-language-environment.
600 ;;(setq nonascii-translation-table
601 ;; (symbol-value (intern (concat cp "-nonascii-translation-table"))))
602 (set-language-environment (cp-language-for-codepage cp))
603 (set-default-coding-systems (intern (concat cp "-dos")))
604 (set-selection-coding-system (intern (concat cp "-dos")))
605 (set-terminal-coding-system
606 (setq default-terminal-coding-system (intern (concat cp
607 "-unix"))))
608 (IT-display-table-setup cp)
609 ;; It's time: too many input methods in leim/quail produce
610 ;; Unicode characters. Let the user see them.
611 (IT-setup-unicode-display)
612 (prefer-coding-system (intern (concat cp "-dos")))
613 (if default-enable-multibyte-characters
614 ;; We want this in multibyte version only, since unibyte version
615 ;; should not convert non-ASCII characters at all.
616 (setq unibyte-display-via-language-environment t)
617 ;; Let the unibyte version behave as Emacs 19 did. In particular,
618 ;; let it use and display native codepage-specific glyphs for
619 ;; non-ASCII characters. For this to work correctly, we need to
620 ;; establish the correspondence between lower-case letters and their
621 ;; upper-case brethren, as appropriate for the codepage in use. The
622 ;; code below makes this happen.
623 ;; (In the multibyte mode, the appropriate tables are prepared
624 ;; elsewhere, since multibyte Emacs uses normal MULE character sets,
625 ;; which are supported on all platforms.)
626 (let* ((i 128)
627 (modify (function
628 (lambda (ch sy)
629 (modify-syntax-entry ch sy text-mode-syntax-table)
630 (if (boundp 'tex-mode-syntax-table)
631 (modify-syntax-entry ch sy tex-mode-syntax-table))
632 (modify-syntax-entry ch sy (standard-syntax-table))
634 (table (standard-case-table))
635 ;; The following are strings of letters, first lower then
636 ;; upper case. This will look funny on terminals which
637 ;; display other code pages. In particular, what is
638 ;; displayed as blanks or triangles are not what they
639 ;; look like at all! (Use `C-x =' to see what they
640 ;; really are.)
641 (chars
642 (cond
643 ((= codepage 850)
644 "‡€�š‚�ƒ¶„Ž…·†�ÆÇ µˆÒ‰ÓŠÔ‹ØŒ×�Þ¡Ö‘’“â”™•ã¢à›�–ê£é—ë˜Yìí¡I£é¤¥ÐÑçè")
645 ((= codepage 865)
646 "‡€�š‚�ƒA„Ž…A†�ˆE‰EŠE‹IŒI�I‘’“O”™•O–U£U˜Y›� A¡I¢O£U¤¥")
647 ;; default is 437
648 (t "‡€�š‚�ƒA„Ž…A†�ˆE‰EŠE‹IŒI�I‘’“O”™•O–U£U˜Y A¡I¢O£U¤¥"))))
650 (while (< i 256)
651 (funcall modify i "_")
652 (setq i (1+ i)))
654 (setq i 0)
655 (while (< i (length chars))
656 (let ((ch1 (aref chars i))
657 (ch2 (aref chars (1+ i))))
658 (if (> ch2 127)
659 (set-case-syntax-pair ch2 ch1 table))
660 (setq i (+ i 2))))
661 (save-excursion
662 (mapcar (lambda (b) (set-buffer b) (set-case-table table))
663 (buffer-list)))
664 (set-standard-case-table table)))
665 ;; Some codepages have sporadic support for Latin-1, Greek, and
666 ;; symbol glyphs, which don't belong to their native character
667 ;; set. It's a nuisance to have all those glyphs here, for all
668 ;; the codepages (for starters, I don't even have references for
669 ;; all the codepages). So I provide a hook for those who want to
670 ;; squeeze every bit of support out of their terminal/font.
671 (run-hooks 'dos-codepage-setup-hook)
674 (defvar cjk-codepages-alist
675 '((932 "Japanese" japanese-shift-jis)
676 (950 "Chinese-BIG5" cn-big5)
677 (936 "Chinese-GB" cn-gb-2312)
678 (949 "Korean" euc-kr))
679 "An alist of Far-Eastern codepages and the names of the associated
680 language and supported coding system.")
682 (defun dos-codepage-setup ()
683 "Set up the MULE environment as appropriate for the installed DOS codepage.
685 This function sets coding systems, display tables, and the language
686 environment options as appropriate for the current value of `dos-codepage'.
688 This function is automatically run at startup via the `term-setup-hook'
689 list. You can (and should) also run it whenever the value of
690 `dos-codepage' changes."
691 (interactive)
692 (let* ((desc (cdr (assq dos-codepage cjk-codepages-alist)))
693 (lang (car desc))
694 (coding (car (cdr desc)))
695 coding-dos coding-unix)
696 (if (null desc)
697 (dos-cpNNN-setup dos-codepage)
698 ;; We've got one of the Far-Eastern codepages which support
699 ;; MULE native coding systems directly.
700 (setq coding-dos (intern (format "%s-dos" coding))
701 coding-unix (intern (format "%s-unix" coding)))
702 (set-language-environment lang)
703 (set-selection-coding-system coding-dos)
704 (setq file-name-coding-system coding-unix)
705 (set-terminal-coding-system
706 (setq default-terminal-coding-system coding-unix))
707 ;; Assume they support non-ASCII Latin characters like the IBM
708 ;; codepage 437 does.
709 (IT-display-table-setup "cp437")
710 ;; It's time: too many input methods in leim/quail produce
711 ;; Unicode characters. Let the user see them.
712 (IT-setup-unicode-display)
713 (prefer-coding-system coding-dos)
714 (if default-enable-multibyte-characters
715 (setq unibyte-display-via-language-environment t))
718 ;; We want to delay the terminal and other codepage-related setup
719 ;; until after the terminal is set and user's .emacs is processed,
720 ;; because people might define their `dos-codepage-setup-hook' there.
721 (add-hook 'term-setup-hook 'dos-codepage-setup)
723 ;; In multibyte mode, we want unibyte buffers to be displayed using
724 ;; the terminal coding system, so that they display correctly on the
725 ;; DOS terminal; in unibyte mode we want to see all 8-bit characters
726 ;; verbatim. In both cases, we want the entire range of 8-bit
727 ;; characters to arrive at our display code verbatim.
728 (standard-display-8bit 127 255)
730 ;; arch-tag: eea04c06-7311-4b5a-b531-3c1be1b070af
731 ;;; internal.el ends here