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