(ffap-list-env): Doc fix.
[bpt/emacs.git] / lisp / international / iso-cvt.el
1 ;;; iso-cvt.-el -- translate to ISO 8859-1 from/to net/TeX conventions
2 ;; This file was formerly called gm-lingo.el.
3
4 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
5
6 ;; Author: Michael Gschwind <mike@vlsivie.tuwien.ac.at>
7 ;; Keywords: tex, iso, latin, i18n
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24
25 ;;; Commentary:
26 ;; This lisp code serves two purposes, both of which involve
27 ;; the translation of various conventions for representing European
28 ;; character sets to ISO 8859-1.
29
30 ; Net support:
31 ; Various conventions exist in Newsgroups on how to represent national
32 ; characters. The functions provided here translate these net conventions
33 ; to ISO.
34 ;
35 ; Calling `iso-german' will turn the net convention for umlauts ("a etc.)
36 ; into ISO latin1 umlaute for easy reading.
37 ; 'iso-spanish' will turn net conventions for representing spanish
38 ; to ISO latin1. (Note that accents are omitted in news posts most
39 ; of the time, only enye is escaped.)
40
41 ; TeX support
42 ; This mode installs hooks which change TeX files to ISO Latin-1 for
43 ; simplified editing. When the TeX file is saved, ISO latin1 characters are
44 ; translated back to escape sequences.
45 ;
46 ; An alternative is a TeX style that handles 8 bit ISO files
47 ; (available on ftp.vlsivie.tuwien.ac.at in /pub/8bit)
48 ; - but these files are difficult to transmit ... so while the net is
49 ; still @ 7 bit this may be useful
50
51 ;; TO DO:
52 ; The net support should install hooks (like TeX support does)
53 ; which recognizes certains news groups and translates all articles from
54 ; those groups.
55 ;
56 ; Cover more cases for translation (There is an infinite number of ways to
57 ; represent accented characters in TeX)
58
59 ;; SEE ALSO:
60 ; If you are interested in questions related to using the ISO 8859-1
61 ; characters set (configuring emacs, Unix, etc. to use ISO), then you
62 ; can get the ISO 8859-1 FAQ via anonymous ftp from
63 ; ftp.vlsivie.tuwien.ac.at in /pub/bit/FAQ-ISO-8859-1
64
65 ;;; Code:
66
67 (provide 'iso-cvt)
68
69 (defvar iso-spanish-trans-tab
70 '(
71 ("~n" "ñ")
72 ("\([a-zA-Z]\)#" "\\1ñ")
73 ("~N" "Ñ")
74 ("\\([-a-zA-Z\"`]\\)\"u" "\\1ü")
75 ("\\([-a-zA-Z\"`]\\)\"U" "\\1Ü")
76 ("\\([-a-zA-Z]\\)'o" "\\1ó")
77 ("\\([-a-zA-Z]\\)'O" "\\Ó")
78 ("\\([-a-zA-Z]\\)'e" "\\1é")
79 ("\\([-a-zA-Z]\\)'E" "\\1É")
80 ("\\([-a-zA-Z]\\)'a" "\\1á")
81 ("\\([-a-zA-Z]\\)'A" "\\1A")
82 ("\\([-a-zA-Z]\\)'i" "\\1í")
83 ("\\([-a-zA-Z]\\)'I" "\\1Í")
84 )
85 "Spanish translation table.")
86
87 (defun iso-translate-conventions (trans-tab)
88 "Use the translation table TRANS-TAB to translate the current buffer."
89 (save-excursion
90 (goto-char (point-min))
91 (let ((work-tab trans-tab)
92 (buffer-read-only nil)
93 (case-fold-search nil))
94 (while work-tab
95 (save-excursion
96 (let ((trans-this (car work-tab)))
97 (while (re-search-forward (car trans-this) nil t)
98 (replace-match (car (cdr trans-this)) t nil)))
99 (setq work-tab (cdr work-tab)))))))
100
101 (defun iso-spanish ()
102 "Translate net conventions for Spanish to ISO 8859-1."
103 (interactive)
104 (iso-translate-conventions iso-spanish-trans-tab))
105
106 (defvar iso-aggressive-german-trans-tab
107 '(
108 ("\"a" "ä")
109 ("\"A" "Ä")
110 ("\"o" "ö")
111 ("\"O" "Ö")
112 ("\"u" "ü")
113 ("\"U" "Ü")
114 ("\"s" "ß")
115 ("\\\\3" "ß")
116 )
117 "German translation table.
118 This table uses an aggressive translation approach and may erroneously
119 translate too much.")
120
121 (defvar iso-conservative-german-trans-tab
122 '(
123 ("\\([-a-zA-Z\"`]\\)\"a" "\\1ä")
124 ("\\([-a-zA-Z\"`]\\)\"A" "\\1Ä")
125 ("\\([-a-zA-Z\"`]\\)\"o" "\\1ö")
126 ("\\([-a-zA-Z\"`]\\)\"O" "\\1Ö")
127 ("\\([-a-zA-Z\"`]\\)\"u" "\\1ü")
128 ("\\([-a-zA-Z\"`]\\)\"U" "\\1Ü")
129 ("\\([-a-zA-Z\"`]\\)\"s" "\\1ß")
130 ("\\([-a-zA-Z\"`]\\)\\\\3" "\\1ß")
131 )
132 "German translation table.
133 This table uses a conservative translation approach and may translate too
134 little.")
135
136
137 (defvar iso-german-trans-tab iso-aggressive-german-trans-tab
138 "Currently active translation table for German.")
139
140 (defun iso-german ()
141 "Translate net conventions for German to ISO 8859-1."
142 (interactive)
143 (iso-translate-conventions iso-german-trans-tab))
144
145 (defvar iso-iso2tex-trans-tab
146 '(
147 ("ä" "{\\\\\"a}")
148 ("à" "{\\\\`a}")
149 ("á" "{\\\\'a}")
150 ("ã" "{\\\\~a}")
151 ("â" "{\\\\^a}")
152 ("ë" "{\\\\\"e}")
153 ("è" "{\\\\`e}")
154 ("é" "{\\\\'e}")
155 ("ê" "{\\\\^e}")
156 ("ï" "{\\\\\"\\\\i}")
157 ("ì" "{\\\\`\\\\i}")
158 ("í" "{\\\\'\\\\i}")
159 ("î" "{\\\\^\\\\i}")
160 ("ö" "{\\\\\"o}")
161 ("ò" "{\\\\`o}")
162 ("ó" "{\\\\'o}")
163 ("õ" "{\\\\~o}")
164 ("ô" "{\\\\^o}")
165 ("ü" "{\\\\\"u}")
166 ("ù" "{\\\\`u}")
167 ("ú" "{\\\\'u}")
168 ("û" "{\\\\^u}")
169 ("Ä" "{\\\\\"A}")
170 ("À" "{\\\\`A}")
171 ("Á" "{\\\\'A}")
172 ("Ã" "{\\\\~A}")
173 ("Â" "{\\\\^A}")
174 ("Ë" "{\\\\\"E}")
175 ("È" "{\\\\`E}")
176 ("É" "{\\\\'E}")
177 ("Ê" "{\\\\^E}")
178 ("Ï" "{\\\\\"I}")
179 ("Ì" "{\\\\`I}")
180 ("Í" "{\\\\'I}")
181 ("Î" "{\\\\^I}")
182 ("Ö" "{\\\\\"O}")
183 ("Ò" "{\\\\`O}")
184 ("Ó" "{\\\\'O}")
185 ("Õ" "{\\\\~O}")
186 ("Ô" "{\\\\^O}")
187 ("Ü" "{\\\\\"U}")
188 ("Ù" "{\\\\`U}")
189 ("Ú" "{\\\\'U}")
190 ("Û" "{\\\\^U}")
191 ("ñ" "{\\\\~n}")
192 ("Ñ" "{\\\\~N}")
193 ("ç" "{\\\\c c}")
194 ("Ç" "{\\\\c C}")
195 ("ß" "{\\\\ss}")
196 ("\306" "{\\\\AE}")
197 ("\346" "{\\\\ae}")
198 ("\305" "{\\\\AA}")
199 ("\345" "{\\\\aa}")
200 ("\251" "{\\\\copyright}")
201 ("£" "{\\\\pounds}")
202 ("¶" "{\\\\P}")
203 ("§" "{\\\\S}")
204 ("¿" "{?`}")
205 ("¡" "{!`}")
206 )
207 "Translation table for translating ISO 8859-1 characters to TeX sequences.")
208
209
210
211
212 (defun iso-iso2tex ()
213 "Translate ISO 8859-1 characters to TeX sequences."
214 (interactive)
215 (iso-translate-conventions iso-iso2tex-trans-tab))
216
217
218 (defvar iso-tex2iso-trans-tab
219 '(
220 ("{\\\\\"a}" "ä")
221 ("{\\\\`a}" "à")
222 ("{\\\\'a}" "á")
223 ("{\\\\~a}" "ã")
224 ("{\\\\^a}" "â")
225 ("{\\\\\"e}" "ë")
226 ("{\\\\`e}" "è")
227 ("{\\\\'e}" "é")
228 ("{\\\\^e}" "ê")
229 ("{\\\\\"\\\\i}" "ï")
230 ("{\\\\`\\\\i}" "ì")
231 ("{\\\\'\\\\i}" "í")
232 ("{\\\\^\\\\i}" "î")
233 ("{\\\\\"i}" "ï")
234 ("{\\\\`i}" "ì")
235 ("{\\\\'i}" "í")
236 ("{\\\\^i}" "î")
237 ("{\\\\\"o}" "ö")
238 ("{\\\\`o}" "ò")
239 ("{\\\\'o}" "ó")
240 ("{\\\\~o}" "õ")
241 ("{\\\\^o}" "ô")
242 ("{\\\\\"u}" "ü")
243 ("{\\\\`u}" "ù")
244 ("{\\\\'u}" "ú")
245 ("{\\\\^u}" "û")
246 ("{\\\\\"A}" "Ä")
247 ("{\\\\`A}" "À")
248 ("{\\\\'A}" "Á")
249 ("{\\\\~A}" "Ã")
250 ("{\\\\^A}" "Â")
251 ("{\\\\\"E}" "Ë")
252 ("{\\\\`E}" "È")
253 ("{\\\\'E}" "É")
254 ("{\\\\^E}" "Ê")
255 ("{\\\\\"I}" "Ï")
256 ("{\\\\`I}" "Ì")
257 ("{\\\\'I}" "Í")
258 ("{\\\\^I}" "Î")
259 ("{\\\\\"O}" "Ö")
260 ("{\\\\`O}" "Ò")
261 ("{\\\\'O}" "Ó")
262 ("{\\\\~O}" "Õ")
263 ("{\\\\^O}" "Ô")
264 ("{\\\\\"U}" "Ü")
265 ("{\\\\`U}" "Ù")
266 ("{\\\\'U}" "Ú")
267 ("{\\\\^U}" "Û")
268 ("{\\\\~n}" "ñ")
269 ("{\\\\~N}" "Ñ")
270 ("{\\\\c c}" "ç")
271 ("{\\\\c C}" "Ç")
272 ("\\\\\"a" "ä")
273 ("\\\\`a" "à")
274 ("\\\\'a" "á")
275 ("\\\\~a" "ã")
276 ("\\\\^a" "â")
277 ("\\\\\"e" "ë")
278 ("\\\\`e" "è")
279 ("\\\\'e" "é")
280 ("\\\\^e" "ê")
281 ("\\\\\"\\\\i" "ï")
282 ("\\\\`\\\\i" "ì")
283 ("\\\\'\\\\i" "í")
284 ("\\\\^\\\\i" "î")
285 ("\\\\\"i" "ï")
286 ("\\\\`i" "ì")
287 ("\\\\'i" "í")
288 ("\\\\^i" "î")
289 ("\\\\\"o" "ö")
290 ("\\\\`o" "ò")
291 ("\\\\'o" "ó")
292 ("\\\\~o" "õ")
293 ("\\\\^o" "ô")
294 ("\\\\\"u" "ü")
295 ("\\\\`u" "ù")
296 ("\\\\'u" "ú")
297 ("\\\\^u" "û")
298 ("\\\\\"A" "Ä")
299 ("\\\\`A" "À")
300 ("\\\\'A" "Á")
301 ("\\\\~A" "Ã")
302 ("\\\\^A" "Â")
303 ("\\\\\"E" "Ë")
304 ("\\\\`E" "È")
305 ("\\\\'E" "É")
306 ("\\\\^E" "Ê")
307 ("\\\\\"I" "Ï")
308 ("\\\\`I" "Ì")
309 ("\\\\'I" "Í")
310 ("\\\\^I" "Î")
311 ("\\\\\"O" "Ö")
312 ("\\\\`O" "Ò")
313 ("\\\\'O" "Ó")
314 ("\\\\~O" "Õ")
315 ("\\\\^O" "Ô")
316 ("\\\\\"U" "Ü")
317 ("\\\\`U" "Ù")
318 ("\\\\'U" "Ú")
319 ("\\\\^U" "Û")
320 ("\\\\~n" "ñ")
321 ("\\\\~N" "Ñ")
322 ("\\\\\"{a}" "ä")
323 ("\\\\`{a}" "à")
324 ("\\\\'{a}" "á")
325 ("\\\\~{a}" "ã")
326 ("\\\\^{a}" "â")
327 ("\\\\\"{e}" "ë")
328 ("\\\\`{e}" "è")
329 ("\\\\'{e}" "é")
330 ("\\\\^{e}" "ê")
331 ("\\\\\"{\\\\i}" "ï")
332 ("\\\\`{\\\\i}" "ì")
333 ("\\\\'{\\\\i}" "í")
334 ("\\\\^{\\\\i}" "î")
335 ("\\\\\"{i}" "ï")
336 ("\\\\`{i}" "ì")
337 ("\\\\'{i}" "í")
338 ("\\\\^{i}" "î")
339 ("\\\\\"{o}" "ö")
340 ("\\\\`{o}" "ò")
341 ("\\\\'{o}" "ó")
342 ("\\\\~{o}" "õ")
343 ("\\\\^{o}" "ô")
344 ("\\\\\"{u}" "ü")
345 ("\\\\`{u}" "ù")
346 ("\\\\'{u}" "ú")
347 ("\\\\^{u}" "û")
348 ("\\\\\"{A}" "Ä")
349 ("\\\\`{A}" "À")
350 ("\\\\'{A}" "Á")
351 ("\\\\~{A}" "Ã")
352 ("\\\\^{A}" "Â")
353 ("\\\\\"{E}" "Ë")
354 ("\\\\`{E}" "È")
355 ("\\\\'{E}" "É")
356 ("\\\\^{E}" "Ê")
357 ("\\\\\"{I}" "Ï")
358 ("\\\\`{I}" "Ì")
359 ("\\\\'{I}" "Í")
360 ("\\\\^{I}" "Î")
361 ("\\\\\"{O}" "Ö")
362 ("\\\\`{O}" "Ò")
363 ("\\\\'{O}" "Ó")
364 ("\\\\~{O}" "Õ")
365 ("\\\\^{O}" "Ô")
366 ("\\\\\"{U}" "Ü")
367 ("\\\\`{U}" "Ù")
368 ("\\\\'{U}" "Ú")
369 ("\\\\^{U}" "Û")
370 ("\\\\~{n}" "ñ")
371 ("\\\\~{N}" "Ñ")
372 ("\\\\c{c}" "ç")
373 ("\\\\c{C}" "Ç")
374 ("{\\\\ss}" "ß")
375 ("{\\\\AE}" "\306")
376 ("{\\\\ae}" "\346")
377 ("{\\\\AA}" "\305")
378 ("{\\\\aa}" "\345")
379 ("{\\\\copyright}" "\251")
380 ("\\\\copyright{}" "\251")
381 ("{\\\\pounds}" "£" )
382 ("{\\\\P}" "¶" )
383 ("{\\\\S}" "§" )
384 ("\\\\pounds{}" "£" )
385 ("\\\\P{}" "¶" )
386 ("\\\\S{}" "§" )
387 ("{\\?`}" "¿")
388 ("{!`}" "¡")
389 ("\\?`" "¿")
390 ("!`" "¡")
391 )
392 "Translation table for translating TeX sequences to ISO 8859-1 characters.
393 This table is not exhaustive (and due to TeX's power can never be). It only
394 contains commonly used sequences.")
395
396 (defun iso-tex2iso ()
397 "Translate TeX sequences to ISO 8859-1 characters."
398 (interactive)
399 (iso-translate-conventions iso-tex2iso-trans-tab))
400
401 (defvar iso-gtex2iso-trans-tab
402 '(
403 ("{\\\\\"a}" "ä")
404 ("{\\\\`a}" "à")
405 ("{\\\\'a}" "á")
406 ("{\\\\~a}" "ã")
407 ("{\\\\^a}" "â")
408 ("{\\\\\"e}" "ë")
409 ("{\\\\`e}" "è")
410 ("{\\\\'e}" "é")
411 ("{\\\\^e}" "ê")
412 ("{\\\\\"\\\\i}" "ï")
413 ("{\\\\`\\\\i}" "ì")
414 ("{\\\\'\\\\i}" "í")
415 ("{\\\\^\\\\i}" "î")
416 ("{\\\\\"i}" "ï")
417 ("{\\\\`i}" "ì")
418 ("{\\\\'i}" "í")
419 ("{\\\\^i}" "î")
420 ("{\\\\\"o}" "ö")
421 ("{\\\\`o}" "ò")
422 ("{\\\\'o}" "ó")
423 ("{\\\\~o}" "õ")
424 ("{\\\\^o}" "ô")
425 ("{\\\\\"u}" "ü")
426 ("{\\\\`u}" "ù")
427 ("{\\\\'u}" "ú")
428 ("{\\\\^u}" "û")
429 ("{\\\\\"A}" "Ä")
430 ("{\\\\`A}" "À")
431 ("{\\\\'A}" "Á")
432 ("{\\\\~A}" "Ã")
433 ("{\\\\^A}" "Â")
434 ("{\\\\\"E}" "Ë")
435 ("{\\\\`E}" "È")
436 ("{\\\\'E}" "É")
437 ("{\\\\^E}" "Ê")
438 ("{\\\\\"I}" "Ï")
439 ("{\\\\`I}" "Ì")
440 ("{\\\\'I}" "Í")
441 ("{\\\\^I}" "Î")
442 ("{\\\\\"O}" "Ö")
443 ("{\\\\`O}" "Ò")
444 ("{\\\\'O}" "Ó")
445 ("{\\\\~O}" "Õ")
446 ("{\\\\^O}" "Ô")
447 ("{\\\\\"U}" "Ü")
448 ("{\\\\`U}" "Ù")
449 ("{\\\\'U}" "Ú")
450 ("{\\\\^U}" "Û")
451 ("{\\\\~n}" "ñ")
452 ("{\\\\~N}" "Ñ")
453 ("{\\\\c c}" "ç")
454 ("{\\\\c C}" "Ç")
455 ("\\\\\"a" "ä")
456 ("\\\\`a" "à")
457 ("\\\\'a" "á")
458 ("\\\\~a" "ã")
459 ("\\\\^a" "â")
460 ("\\\\\"e" "ë")
461 ("\\\\`e" "è")
462 ("\\\\'e" "é")
463 ("\\\\^e" "ê")
464 ("\\\\\"\\\\i" "ï")
465 ("\\\\`\\\\i" "ì")
466 ("\\\\'\\\\i" "í")
467 ("\\\\^\\\\i" "î")
468 ("\\\\\"i" "ï")
469 ("\\\\`i" "ì")
470 ("\\\\'i" "í")
471 ("\\\\^i" "î")
472 ("\\\\\"o" "ö")
473 ("\\\\`o" "ò")
474 ("\\\\'o" "ó")
475 ("\\\\~o" "õ")
476 ("\\\\^o" "ô")
477 ("\\\\\"u" "ü")
478 ("\\\\`u" "ù")
479 ("\\\\'u" "ú")
480 ("\\\\^u" "û")
481 ("\\\\\"A" "Ä")
482 ("\\\\`A" "À")
483 ("\\\\'A" "Á")
484 ("\\\\~A" "Ã")
485 ("\\\\^A" "Â")
486 ("\\\\\"E" "Ë")
487 ("\\\\`E" "È")
488 ("\\\\'E" "É")
489 ("\\\\^E" "Ê")
490 ("\\\\\"I" "Ï")
491 ("\\\\`I" "Ì")
492 ("\\\\'I" "Í")
493 ("\\\\^I" "Î")
494 ("\\\\\"O" "Ö")
495 ("\\\\`O" "Ò")
496 ("\\\\'O" "Ó")
497 ("\\\\~O" "Õ")
498 ("\\\\^O" "Ô")
499 ("\\\\\"U" "Ü")
500 ("\\\\`U" "Ù")
501 ("\\\\'U" "Ú")
502 ("\\\\^U" "Û")
503 ("\\\\~n" "ñ")
504 ("\\\\~N" "Ñ")
505 ("\\\\\"{a}" "ä")
506 ("\\\\`{a}" "à")
507 ("\\\\'{a}" "á")
508 ("\\\\~{a}" "ã")
509 ("\\\\^{a}" "â")
510 ("\\\\\"{e}" "ë")
511 ("\\\\`{e}" "è")
512 ("\\\\'{e}" "é")
513 ("\\\\^{e}" "ê")
514 ("\\\\\"{\\\\i}" "ï")
515 ("\\\\`{\\\\i}" "ì")
516 ("\\\\'{\\\\i}" "í")
517 ("\\\\^{\\\\i}" "î")
518 ("\\\\\"{i}" "ï")
519 ("\\\\`{i}" "ì")
520 ("\\\\'{i}" "í")
521 ("\\\\^{i}" "î")
522 ("\\\\\"{o}" "ö")
523 ("\\\\`{o}" "ò")
524 ("\\\\'{o}" "ó")
525 ("\\\\~{o}" "õ")
526 ("\\\\^{o}" "ô")
527 ("\\\\\"{u}" "ü")
528 ("\\\\`{u}" "ù")
529 ("\\\\'{u}" "ú")
530 ("\\\\^{u}" "û")
531 ("\\\\\"{A}" "Ä")
532 ("\\\\`{A}" "À")
533 ("\\\\'{A}" "Á")
534 ("\\\\~{A}" "Ã")
535 ("\\\\^{A}" "Â")
536 ("\\\\\"{E}" "Ë")
537 ("\\\\`{E}" "È")
538 ("\\\\'{E}" "É")
539 ("\\\\^{E}" "Ê")
540 ("\\\\\"{I}" "Ï")
541 ("\\\\`{I}" "Ì")
542 ("\\\\'{I}" "Í")
543 ("\\\\^{I}" "Î")
544 ("\\\\\"{O}" "Ö")
545 ("\\\\`{O}" "Ò")
546 ("\\\\'{O}" "Ó")
547 ("\\\\~{O}" "Õ")
548 ("\\\\^{O}" "Ô")
549 ("\\\\\"{U}" "Ü")
550 ("\\\\`{U}" "Ù")
551 ("\\\\'{U}" "Ú")
552 ("\\\\^{U}" "Û")
553 ("\\\\~{n}" "ñ")
554 ("\\\\~{N}" "Ñ")
555 ("\\\\c{c}" "ç")
556 ("\\\\c{C}" "Ç")
557 ("{\\\\ss}" "ß")
558 ("{\\\\AE}" "\306")
559 ("{\\\\ae}" "\346")
560 ("{\\\\AA}" "\305")
561 ("{\\\\aa}" "\345")
562 ("{\\\\copyright}" "\251")
563 ("\\\\copyright{}" "\251")
564 ("{\\\\pounds}" "£" )
565 ("{\\\\P}" "¶" )
566 ("{\\\\S}" "§" )
567 ("\\\\pounds{}" "£" )
568 ("\\\\P{}" "¶" )
569 ("\\\\S{}" "§" )
570 ("?`" "¿")
571 ("!`" "¡")
572 ("{?`}" "¿")
573 ("{!`}" "¡")
574 ("\"a" "ä")
575 ("\"A" "Ä")
576 ("\"o" "ö")
577 ("\"O" "Ö")
578 ("\"u" "ü")
579 ("\"U" "Ü")
580 ("\"s" "ß")
581 ("\\\\3" "ß")
582 )
583 "Translation table for translating German TeX sequences to ISO 8859-1.
584 This table is not exhaustive (and due to TeX's power can never be). It only
585 contains commonly used sequences.")
586
587 (defvar iso-iso2gtex-trans-tab
588 '(
589 ("ä" "\"a")
590 ("à" "{\\\\`a}")
591 ("á" "{\\\\'a}")
592 ("ã" "{\\\\~a}")
593 ("â" "{\\\\^a}")
594 ("ë" "{\\\\\"e}")
595 ("è" "{\\\\`e}")
596 ("é" "{\\\\'e}")
597 ("ê" "{\\\\^e}")
598 ("ï" "{\\\\\"\\\\i}")
599 ("ì" "{\\\\`\\\\i}")
600 ("í" "{\\\\'\\\\i}")
601 ("î" "{\\\\^\\\\i}")
602 ("ö" "\"o")
603 ("ò" "{\\\\`o}")
604 ("ó" "{\\\\'o}")
605 ("õ" "{\\\\~o}")
606 ("ô" "{\\\\^o}")
607 ("ü" "\"u")
608 ("ù" "{\\\\`u}")
609 ("ú" "{\\\\'u}")
610 ("û" "{\\\\^u}")
611 ("Ä" "\"A")
612 ("À" "{\\\\`A}")
613 ("Á" "{\\\\'A}")
614 ("Ã" "{\\\\~A}")
615 ("Â" "{\\\\^A}")
616 ("Ë" "{\\\\\"E}")
617 ("È" "{\\\\`E}")
618 ("É" "{\\\\'E}")
619 ("Ê" "{\\\\^E}")
620 ("Ï" "{\\\\\"I}")
621 ("Ì" "{\\\\`I}")
622 ("Í" "{\\\\'I}")
623 ("Î" "{\\\\^I}")
624 ("Ö" "\"O")
625 ("Ò" "{\\\\`O}")
626 ("Ó" "{\\\\'O}")
627 ("Õ" "{\\\\~O}")
628 ("Ô" "{\\\\^O}")
629 ("Ü" "\"U")
630 ("Ù" "{\\\\`U}")
631 ("Ú" "{\\\\'U}")
632 ("Û" "{\\\\^U}")
633 ("ñ" "{\\\\~n}")
634 ("Ñ" "{\\\\~N}")
635 ("ç" "{\\\\c c}")
636 ("Ç" "{\\\\c C}")
637 ("ß" "\"s")
638 ("\306" "{\\\\AE}")
639 ("\346" "{\\\\ae}")
640 ("\305" "{\\\\AA}")
641 ("\345" "{\\\\aa}")
642 ("\251" "{\\\\copyright}")
643 ("£" "{\\\\pounds}")
644 ("¶" "{\\\\P}")
645 ("§" "{\\\\S}")
646 ("¿" "{?`}")
647 ("¡" "{!`}")
648 )
649 "Translation table for translating ISO 8859-1 characters to German TeX.")
650
651 (defun iso-gtex2iso ()
652 "Translate German TeX sequences to ISO 8859-1 characters."
653 (interactive)
654 (iso-translate-conventions iso-gtex2iso-trans-tab))
655
656
657 (defun iso-iso2gtex ()
658 "Translate ISO 8859-1 characters to German TeX sequences."
659 (interactive)
660 (iso-translate-conventions iso-iso2gtex-trans-tab))
661
662
663 (defun iso-german-tex-p ()
664 "Check if tex buffer is German LaTeX."
665 (save-excursion
666 (save-restriction
667 (widen)
668 (goto-char (point-min))
669 (re-search-forward "\\\\documentstyle\\[.*german.*\\]" nil t))))
670
671 (defun iso-fix-iso2tex ()
672 "Turn ISO 8859-1 (aka. ISO Latin-1) buffer into TeX sequences.
673 If German TeX is used, German TeX sequences are generated."
674 (if (or (equal major-mode 'latex-mode)
675 (equal major-mode 'LaTeX-mode)) ; AucTeX wants this
676 (if (iso-german-tex-p)
677 (iso-iso2gtex)
678 (iso-iso2tex)))
679 (if (or (equal major-mode 'tex-mode)
680 (equal major-mode 'TeX-mode) ; AucTeX wants this
681 (equal major-mode 'plain-tex-mode))
682 (iso-iso2tex)))
683
684 (defun iso-fix-tex2iso ()
685 "Turn TeX sequences into ISO 8859-1 (aka. ISO Latin-1) characters.
686 This function recognices German TeX buffers."
687 (if (or (equal major-mode 'latex-mode)
688 (equal major-mode 'Latex-mode)) ; AucTeX wants this
689 (if (iso-german-tex-p)
690 (iso-gtex2iso)
691 (iso-tex2iso)))
692 (if (or (equal major-mode 'tex-mode)
693 (equal major-mode 'TeX-mode) ; AucTeX wants this
694 (equal major-mode 'plain-tex-mode))
695 (iso-tex2iso)))
696
697 (defun iso-cvt-ffh ()
698 "find-file-hook for iso-cvt.el."
699 (iso-fix-tex2iso)
700 (set-buffer-modified-p nil))
701
702 (defun iso-cvt-wfh ()
703 "write file hook for iso-cvt.el."
704 (iso-fix-iso2tex))
705
706 (defun iso-cvt-ash ()
707 "after save hook for iso-cvt.el."
708 (iso-fix-tex2iso)
709 (set-buffer-modified-p nil))
710
711 (add-hook 'find-file-hooks 'iso-cvt-ffh)
712 (add-hook 'write-file-hooks 'iso-cvt-wfh)
713 (add-hook 'after-save-hook 'iso-cvt-ash)
714
715 ;;; iso-cvt.el ends here