comparison lisp/international/latin1-disp.el @ 31673:6d39ec089c7b

*** empty log message ***
author Dave Love <fx@gnu.org>
date Sun, 17 Sep 2000 17:44:47 +0000
parents
children fc837c2f746a
comparison
equal deleted inserted replaced
31672:a442bf280b14 31673:6d39ec089c7b
1 ;;; latin1-disp.el --- display tables for other ISO 8859 on Latin-1 terminals -*- coding: emacs-mule -*-
2
3 ;; Copyright (C) 2000 Free Software Foundation, Inc.
4
5 ;; Author: Dave Love <fx@gnu.org>
6 ;; Keywords: i18n
7
8 ;; This file is part of GNU Emacs.
9
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 2, or (at your option)
13 ;; any later version.
14
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.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;; This package sets up display of ISO 8859-n for n>1 by substituting
28 ;; Latin-1 characters and sequences of them for characters which can't
29 ;; be displayed, either beacuse we're on a tty or beacuse we don't
30 ;; have the relevant window system fonts available. For instance,
31 ;; Latin-9 is very similar to Latin-1, so we can display most Latin-9
32 ;; characters using the Latin-1 characters at the same code point and
33 ;; fall back on more-or-less mnemonic ASCII sequences for the rest.
34
35 ;; For the Latin charsets the ASCII sequences are mostly consistent
36 ;; with the Quail prefix input sequences. Latin-4 uses the Quail
37 ;; postfix sequences as a prefix method isn't defined for Latin-4.
38
39 ;; A different approach is taken in the DOS display tables in
40 ;; term/internal.el, and the relevant ASCII sequences from there are
41 ;; available as an alternative; see `latin1-display-mnemonic'. Only
42 ;; these sequences are used for Cyrillic, Greek and Hebrew.
43
44 ;; If you don't even have Latin-1, see iso-ascii.el and use the
45 ;; complete tables from internal.el. The ASCII sequences used here
46 ;; are mostly in the same style as iso-ascii.
47
48 ;;; Code:
49
50 (defconst latin1-display-sets '(latin-2 latin-3 latin-4 latin-5 latin-8
51 latin-9 cyrillic greek hebrew)
52 "The ISO8859 character sets with defined Latin-1 display sequences.
53 These are the nicknames for the sets and correspond to Emacs language
54 environments.")
55
56 (defgroup latin1-display ()
57 "Set up display tables for ISO8859 characters using Latin-1."
58 :version "21.1"
59 :group 'i18n)
60
61 (defcustom latin1-display-format "{%s}"
62 "A format string used to display the ASCII sequences.
63 The default encloses the sequence in braces, but you could just use
64 \"%s\" to avoid the braces."
65 :group 'latin1-display
66 :type 'string)
67
68 ;;;###autoload
69 (defcustom latin1-display nil
70 "Set up Latin-1/ASCII display for ISO8859 character sets.
71 This is done for each character set in the list `latin1-display-sets',
72 if no font is available to display it. Characters are displayed using
73 the corresponding Latin-1 characters where they match. Otherwise
74 ASCII sequences are used, mostly following the Latin prefix input
75 methods. Some different ASCII sequences are used if
76 `latin1-display-mnemonic' is non-nil.
77
78 Setting this variable directly does not take effect;
79 use either M-x customize of the function `latin1-display'."
80 :group 'latin1-display
81 :type 'boolean
82 :require 'latin1-disp
83 :initialize 'custom-initialize-default
84 :set (lambda (symbol value)
85 (if value
86 (mapc (if value
87 #'latin1-display-setup
88 #'latin1-display-reset)
89 latin1-display-sets))))
90
91 ;;;###autoload
92 (defun latin1-display (&rest sets)
93 "Set up Latin-1/ASCII display for the arguments character SETS.
94 See option `latin1-display' for the method. The members of the list
95 must be in `latin1-display-sets'. With no arguments, reset the
96 display for all of `latin1-display-sets'. See also `latin1-display-setup'."
97 (if sets
98 (mapc #'latin1-display-setup sets)
99 (mapc #'latin1-display-reset latin1-display-sets)))
100
101 (defcustom latin1-display-mnemonic nil
102 "Non-nil means to display potentially more mnemonic sequences.
103 These are taken from the tables in `internal.el' rather than the Quail
104 input sequences."
105 :type 'boolean
106 :group 'latin1-display)
107
108 (defun latin1-display-char (char display &optional alt-display)
109 "Make an entry in `standard-display-table' for CHAR using string DISPLAY.
110 If ALT-DISPLAY is provided, use that instead if
111 `latin1-display-mnemonic' is non-nil. The actual string displayed is
112 formatted using `latin1-display-format'."
113 (if (and (stringp alt-display)
114 latin1-display-mnemonic)
115 (setq display alt-display))
116 (if (stringp display)
117 (standard-display-ascii char (format latin1-display-format display))
118 (aset standard-display-table char display)))
119
120 (defun latin1-display-identities (charset)
121 "Display each character in CHARSET as the corresponding Latin-1 character.
122 CHARSET is a symbol naming a language environment using an ISO8859
123 character set."
124 (if (eq charset 'cyrillic)
125 (setq charset 'cyrillic-iso))
126 (let ((i 32)
127 (set (car (remq 'ascii (get-language-info charset 'charset)))))
128 (while (<= i 127)
129 (aset standard-display-table
130 (make-char set i)
131 (vector (make-char 'latin-iso8859-1 i)))
132 (setq i (1+ i)))))
133
134 (defun latin1-display-reset (language)
135 "Set up the default display for each character of LANGUAGE's charset.
136 CHARSET is a symbol naming a language environment using an ISO8859
137 character set."
138 (if (eq language 'cyrillic)
139 (setq language 'cyrillic-iso))
140 (let ((charset (car (remq 'ascii (get-language-info language
141 'charset)))))
142 (standard-display-default (make-char charset 32)
143 (make-char charset 127)))
144 (sit-for 0))
145
146 ;; Is there a better way than this?
147 (defun latin1-display-check-font (language)
148 "Return non-nil if we have a font with an encoding for LANGUAGE.
149 LANGUAGE is a symbol naming a language environment using an ISO8859
150 character set: `latin-2', `hebrew' etc."
151 (if (eq language 'cyrillic)
152 (setq language 'cyrillic-iso))
153 (if window-system
154 (let* ((info (get-language-info language 'charset))
155 (str (symbol-name (car (remq 'ascii info)))))
156 (string-match "-iso8859-[0-9]+\\'" str)
157 (x-list-fonts (concat "*" (match-string 0 str))))))
158
159 (defun latin1-display-setup (set &optional force)
160 "Set up Latin-1 display for characters in the given SET.
161 SET must be a member of `latin1-display-sets'. Normally, check
162 whether a font for SET is available and don't set the display if it
163 is. If FORCE is non-nil, set up the display regardless."
164 (cond
165 ((eq set 'latin-2)
166 (when (or force
167 (not (latin1-display-check-font set)))
168 (latin1-display-identities set)
169 (mapc
170 (lambda (l)
171 (apply 'latin1-display-char l))
172 '((?と "'C" "C'")
173 (?ひ "'D" "/D")
174 (?え "'S" "S'")
175 (?よ "'c" "c'")
176 (?を "'d" "/d")
177 (?で "'L" "L'")
178 (?ん "'n" "n'")
179 (?び "'N" "N'")
180 (?も "'r" "r'")
181 (?ぢ "'R" "R'")
182 (?じ "'s" "s'")
183 (?ぞ "'z" "z'")
184 (?ぎ "'Z" "Z'")
185 (?ぃ "`A" "A;")
186 (?ぬ "`E" "E;")
187 (?ぅ "`L" "/L")
188 (?が "`S" ",S")
189 (?む "`T" ",T")
190 (?け "`Z" "Z^.")
191 (?こ "`a" "a;")
192 (?さ "`l" "/l")
193 (?れ "`e" "e;")
194 (?ぜ "`s" ",s")
195 (? "`t" ",t")
196 (?ち "`z" "z^.")
197 (? "`." "'.")
198 (?づ "~A" "A(")
199 (?な "~C" "C<")
200 (?ぱ "~D" "D<")
201 (?の "~E" "E<")
202 (?ゎ "~e" "e<")
203 (?ぇ "~L" "L<")
204 (?ぴ "~N" "N<")
205 (?ぷ "~O" "O''")
206 (?ぺ "~R" "R<")
207 (?か "~S" "S<")
208 (?き "~T" "T<")
209 (?ぽ "~U" "U''")
210 (?ぐ "~Z" "Z<")
211 (?ゅ "~a" "a(}")
212 (?り "~c" "c<")
213 (?ゑ "~d" "d<")
214 (?し "~l" "l<")
215 (? "~n" "n<")
216 (? "~o" "o''")
217 (? "~r" "r<")
218 (?せ "~s" "s<")
219 (?そ "~t" "t<")
220 (? "~u" "u''")
221 (?だ "~z" "z<")
222 (?す "~v" "'<") ; ?い in latin-pre
223 (?い "~~" "'(")
224 (? "uu" "u^0")
225 (?ほ "UU" "U^0")
226 (?て "\"A")
227 (?ゆ "\"a")
228 (?ね "\"E" "E:")
229 (?ろ "\"e")
230 (?た "''" "'")
231 (?す "'<") ; Lynx's rendering of caron
232 ))))
233
234 ((eq set 'latin-3)
235 (when (or force
236 (not (latin1-display-check-font set)))
237 (latin1-display-identities set)
238 (mapc
239 (lambda (l)
240 (apply 'latin1-display-char l))
241 '((?Γ "/H")
242 (?Δ "~`" "'(")
243 (?Θ "^H" "H^")
244 (?Ω "^h" "h^") (?Λ ".I" "I^.")
245 (?Μ ",S")
246 (?Ν "~G" "G(")
247 (?Ξ "^J" "J^")
248 (?Ρ ".Z" "Z^.")
249 (?Τ "/h")
250 (?ケ ".i" "i^.")
251 (?コ ",s")
252 (?サ "~g" "g(")
253 (?シ "^j" "j^")
254 (?α ".Z" "z^.")
255 (?η ".c" "C^.")
256 (?θ "^C" "C^")
257 (?ψ ".G" "G^.")
258 (?リ "^G" "G^")
259 (?ン "~U" "U(")
260 (?゙ "^S" "S^")
261 (? ".C" "c^.")
262 (? "^c" "c^")
263 (? ".g" "g^.")
264 (? "^g" "g^")
265 (? "~u" "u(")
266 (? "^s" "s^")
267 (? "/." "^.")))))
268
269 ((eq set 'latin-4)
270 (when (or force
271 (not (latin1-display-check-font set)))
272 (latin1-display-identities set)
273 (mapc
274 (lambda (l)
275 (apply 'latin1-display-char l))
276 '((?┌ "A," "A;")
277 (?┐ "k/" "kk")
278 (?┘ "R," ",R")
279 (?├ "I~" "?I")
280 (?┬ "L," ",L")
281 (?┼ "S~" "S<")
282 (?━ "E-")
283 (?┃ "G," ",G")
284 (?┏ "T/" "/T")
285 (?┛ "Z~" "Z<")
286 (?┳ "a," "a;")
287 (?┫ "';")
288 (?┻ "r," ",r")
289 (?┠ "i~" "~i")
290 (?┯ "l," ",l")
291 (?┨ "'<")
292 (?┿ "s~" "s<")
293 (?┝ "e-")
294 (?┰ "g," ",g")
295 (?┥ "t/" "/t")
296 (?┸ "N/" "NG")
297 (?╂ "z~" "z<")
298 (?ソ "n/" "ng")
299 (?タ "A-")
300 (?ヌ "I," "I;")
301 (?ネ "C~" "C<")
302 (?ハ "E," "E;")
303 (?フ "E." "E^.")
304 (?マ "I-")
305 (?ム "N," ",N")
306 (?メ "O-")
307 (?モ "K," ",K")
308 (?ル "U," "U;")
309 (?ン "U~" "~U")
310 (?゙ "U-")
311 (? "a-")
312 (? "i," "i;")
313 (? "c~" "c<")
314 (? "e," "e;")
315 (? "e." "e^.")
316 (? "i-")
317 (? "d/" "/d")
318 (? "n," ",n")
319 (? "o-")
320 (? "k," ",k")
321 (? "u," "u;")
322 (? "u~" "~u")
323 (? "u-")
324 (? "^.")))))
325
326 ((eq set 'latin-5)
327 (when (or force
328 (not (latin1-display-check-font set)))
329 (latin1-display-identities set)
330 (mapc
331 (lambda (l)
332 (apply 'latin1-display-char l))
333 '((?昨 "~g" "g(")
334 (?災 "~G" "G(")
335 (?在 ".I" "I^.")
336 (? ",s")
337 (?材 ",S")
338 (?碕 "^e" "e<") ; from latin-post
339 (?作 ".e" "e^.")
340 (?搾 "\"i" "i-") ; from latin-post
341 (? ".i" "i.")))))
342
343 ((eq set 'latin-8)
344 (when (or force
345 (not (latin1-display-check-font set)))
346 (latin1-display-identities set)
347 (mapc
348 (lambda (l)
349 (apply 'latin1-display-char l))
350 '((?升 ".B" "B`")
351 (?召 ".b" "b`")
352 (?唱 ".c" "c`")
353 (?商 ".C" "C`")
354 (?嘗 ".D" "D`")
355 (?将 ".d" "d`")
356 (?昇 "`w")
357 (?妾 "`W")
358 (?昭 "'w" "w'")
359 (?宵 "'W" "W'")
360 (?松 "`y")
361 (?小 "`Y")
362 (?廠 ".f" "f`")
363 (?床 ".F" "F`")
364 (?承 ".g" "g`")
365 (?彰 ".G" "G`")
366 (?招 ".m" "m`")
367 (?抄 ".M" "M`")
368 (?昌 ".p" "p`")
369 (?捷 ".P" "P`")
370 (?樵 ".s" "s`")
371 (?晶 ".S" "S`")
372 (?樟 "\"w")
373 (?梢 "\"W")
374 (?条 "^w" "w^")
375 (?紹 "^W" "W^")
376 (?譲 ".t" "t`")
377 (?訟 ".T" "T`")
378 (? "^y" "y^")
379 (?鉦 "^Y" "Y^")
380 (?庄 "\"Y")))))
381
382 ((eq set 'latin-9)
383 (when (or force
384 (not (latin1-display-check-font set)))
385 (latin1-display-identities set)
386 (mapc
387 (lambda (l)
388 (apply 'latin1-display-char l))
389 '((?耳 "~s" "s<")
390 (?示 "~S" "S<")
391 (?痔 "Euro" "E=")
392 (?失 "~z" "z<")
393 (?雫 "~Z" "Z<")
394 (?疾 "\"Y")
395 (?漆 "oe")
396 (?湿 "OE")))))
397
398 ((eq set 'greek)
399 (when (or force
400 (not (latin1-display-check-font set)))
401 (mapc
402 (lambda (l)
403 (apply 'latin1-display-char l))
404 '((?。 "9'")
405 (?「 "'9")
406 (?ッ "-M")
407 (?オ "'%")
408 (?カ "'A")
409 (?ク "'E")
410 (?ケ "'H")
411 (?コ "'I")
412 (?シ "'O")
413 (?セ "'Y")
414 (?ソ "W%")
415 (?タ "i3")
416 (?テ "G*")
417 (?ト "D*")
418 (?ネ "TH")
419 (?ヒ "L*")
420 (?ホ "C*")
421 (?ミ "P*")
422 (?モ "S*")
423 (?ヨ "F*")
424 (?リ "Q*")
425 (?ル "W*")
426 (?レ "\"I")
427 (?ロ "\"Y")
428 (?ワ "a%")
429 (?ン "e%")
430 (?゙ "y%")
431 (?゚ "i%")
432 (? "u3")
433 (? "a*")
434 (? "b*")
435 (? "g*")
436 (? "d*")
437 (? "e*")
438 (? "z*")
439 (? "y*")
440 (? "h*")
441 (? "i*")
442 (? "k")
443 (? "l*")
444 (? "m*")
445 (? "n*")
446 (? "c*")
447 (? "p*")
448 (? "r*")
449 (? "*s")
450 (? "s*")
451 (? "t*")
452 (? "u")
453 (? "f*")
454 (? "x*")
455 (? "q*")
456 (? "w*")
457 (? "\"i")
458 (? "\"u")
459 (? "'o")
460 (? "'u")
461 (? "'w")))
462 (mapc
463 (lambda (l)
464 (aset standard-display-table (car l) (string-to-vector (cadr l))))
465 '((?チ "A")
466 (?ツ "B")
467 (?ナ "E")
468 (?ニ "Z")
469 (?ヌ "H")
470 (?ノ "I")
471 (?ハ "J")
472 (?フ "M")
473 (?ヘ "N")
474 (?マ "O")
475 (?ム "P")
476 (?ヤ "T")
477 (?ユ "Y")
478 (?ラ "X")
479 (? "o")))))
480
481 ((eq set 'hebrew)
482 (when (or force
483 (not (latin1-display-check-font set)))
484 ;; Don't start with identities, since we don't have definitions
485 ;; for a lot of Hebrew in internal.el. (Intlfonts is also
486 ;; missing some glyphs.)
487 (let ((i 34))
488 (while (<= i 62)
489 (aset standard-display-table
490 (make-char 'hebrew-iso8859-8 i)
491 (vector (make-char 'latin-iso8859-1 i)))
492 (setq i (1+ i))))
493 (mapc
494 (lambda (l)
495 (aset standard-display-table (car l) (string-to-vector (cadr l))))
496 '((?衣 "=2")
497 (?謂 "A+")
498 (?違 "B+")
499 (?遺 "G+")
500 (?医 "D+")
501 (?井 "H+")
502 (?亥 "W+")
503 (?域 "Z+")
504 (?育 "X+")
505 (?郁 "Tj")
506 (?磯 "J+")
507 (?一 "K%")
508 (?壱 "K+")
509 (?溢 "L+")
510 (?逸 "M%")
511 (?稲 "M+")
512 (?茨 "N%")
513 (?芋 "N+")
514 (?鰯 "S+")
515 (?允 "E+")
516 (?印 "P%")
517 (?咽 "P+")
518 (?員 "Zj")
519 (?因 "ZJ")
520 (?姻 "Q+")
521 (?引 "R+")
522 (?飲 "Sh")
523 (?淫 "T+")))))
524
525 ((eq set 'cyrillic)
526 (setq set 'cyrillic-iso)
527 (when (or force
528 (not (latin1-display-check-font set)))
529 (mapc
530 (lambda (l)
531 (apply 'latin1-display-char l))
532 '((?犬 "Dj")
533 (?献 "Gj")
534 (?研 "IE")
535 (?見 "Lj")
536 (?謙 "Nj")
537 (?賢 "Ts")
538 (?軒 "Kj")
539 (?鍵 "V%")
540 (?険 "Dzh")
541 (?験 "B=")
542 (?元 "")
543 (?原 "D")
544 (?幻 "Z%")
545 (?弦 "3")
546 (?減 "U")
547 (?源 "J=")
548 (?現 "L=")
549 (?諺 "P=")
550 (?古 "Y")
551 (?呼 "")
552 (?姑 "C=")
553 (?孤 "C%")
554 (?己 "S%")
555 (?庫 "Sc")
556 (?弧 "=\"")
557 (?戸 "Y=")
558 (?故 "%\"")
559 (?枯 "Ee")
560 (?湖 "Yu")
561 (?狐 "Ya")
562 (?袴 "b")
563 (?股 "v=")
564 (?胡 "g=")
565 (?菰 "g")
566 (?誇 "z%")
567 (?跨 "z=")
568 (?鈷 "u")
569 (?雇 "j=")
570 (?顧 "k")
571 (?鼓 "l=")
572 (?五 "m=")
573 (?互 "n=")
574 (?午 "n")
575 (?呉 "p")
576 (?娯 "t=")
577 (?御 "f=")
578 (?梧 "c=")
579 (?檎 "c%")
580 (?瑚 "s%")
581 (?碁 "sc")
582 (?語 "='")
583 (?誤 "y=")
584 (?護 "%'")
585 (?醐 "ee")
586 (?乞 "yu")
587 (?鯉 "ya")
588 (?交 "N0")
589 (?侯 "dj")
590 (?候 "gj")
591 (?倖 "ie")
592 (?勾 "lj")
593 (?厚 "nj")
594 (?口 "ts")
595 (?向 "kj")
596 (? "v%")
597 (? "dzh")))
598 (mapc
599 (lambda (l)
600 (aset standard-display-table (car l) (string-to-vector (cadr l))))
601 '((?牽 "⇒")
602 (?硯 "S")
603 (?絹 "I")
604 (?県 "マ")
605 (?肩 "J")
606 (?佼 "")
607 (? "〒")
608 (?遣 "-")
609 (?顕 "A")
610 (?鹸 "B")
611 (?厳 "E")
612 (?玄 "K")
613 (?絃 "M")
614 (?舷 "H")
615 (?言 "O")
616 (?限 "P")
617 (?乎 "C")
618 (?個 "T")
619 (?固 "X")
620 (?糊 "a")
621 (?虎 "e")
622 (?伍 "o")
623 (?吾 "c")
624 (?後 "y")
625 (?悟 "x")
626 (?光 "s")
627 (?公 "i")
628 (?功 "")
629 (?効 "j")))))
630
631 (t (error "Unsupported character set: %S" set)))
632
633 (sit-for 0))
634
635 (provide 'latin1-disp)
636
637 ;;; latin1-disp.el ends here