(help-xref-go-back): Don't try to set position.
[emacs.git] / lisp / international / iso-cvt.el
bloba862a89bdd117ca1027d12b372cb6945ebefb929
1 ;;; iso-cvt.-el -- translate ISO 8859-1 from/to various encodings
2 ;; This file was formerly called gm-lingo.el.
4 ;; Copyright (C) 1993, 1994, 1995, 1996, 1998 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:
27 ;; This lisp code is a general framework for translating various
28 ;; representations of the same data.
29 ;; among other things it can be used to translate TeX, HTML, and compressed
30 ;; files to ISO 8859-1. It can also be used to translate different charsets
31 ;; such as IBM PC, Macintosh or HP Roman8.
32 ;; Note that many translations use the GNU recode tool to do the actual
33 ;; conversion. So you might want to install that tool to get the full
34 ;; benefit of iso-cvt.el
37 ; TO DO:
38 ; Cover more cases for translation (There is an infinite number of ways to
39 ; represent accented characters in TeX)
41 ;; SEE ALSO:
42 ; If you are interested in questions related to using the ISO 8859-1
43 ; characters set (configuring emacs, Unix, etc. to use ISO), then you
44 ; can get the ISO 8859-1 FAQ via anonymous ftp from
45 ; ftp.vlsivie.tuwien.ac.at in /pub/bit/FAQ-ISO-8859-1
47 ;;; Code:
49 (provide 'iso-cvt)
50 (require 'format)
52 (defvar iso-spanish-trans-tab
54 ("~n" "ñ")
55 ("\([a-zA-Z]\)#" "\\1ñ")
56 ("~N" "Ñ")
57 ("\\([-a-zA-Z\"`]\\)\"u" "\\1ü")
58 ("\\([-a-zA-Z\"`]\\)\"U" "\\1Ü")
59 ("\\([-a-zA-Z]\\)'o" "\\1ó")
60 ("\\([-a-zA-Z]\\)'O" "\\Ó")
61 ("\\([-a-zA-Z]\\)'e" "\\1é")
62 ("\\([-a-zA-Z]\\)'E" "\\1É")
63 ("\\([-a-zA-Z]\\)'a" "\\1á")
64 ("\\([-a-zA-Z]\\)'A" "\\1A")
65 ("\\([-a-zA-Z]\\)'i" "\\1í")
66 ("\\([-a-zA-Z]\\)'I" "\\1Í")
68 "Spanish translation table.")
70 (defun iso-translate-conventions (from to trans-tab)
71 "Use the translation table TRANS-TAB to translate the current buffer."
72 (save-excursion
73 (save-restriction
74 (narrow-to-region from to)
75 (goto-char from)
76 (let ((work-tab trans-tab)
77 (buffer-read-only nil)
78 (case-fold-search nil))
79 (while work-tab
80 (save-excursion
81 (let ((trans-this (car work-tab)))
82 (while (re-search-forward (car trans-this) nil t)
83 (replace-match (car (cdr trans-this)) t nil)))
84 (setq work-tab (cdr work-tab)))))
85 (point-max))))
87 ;;;###autoload
88 (defun iso-spanish (from to &optional buffer)
89 "Translate net conventions for Spanish to ISO 8859-1.
90 The region between FROM and TO is translated using the table TRANS-TAB.
91 Optional arg BUFFER is ignored (so that the function can can be used in
92 `format-alist')."
93 (interactive "*r")
94 (iso-translate-conventions from to iso-spanish-trans-tab))
96 (defvar iso-aggressive-german-trans-tab
98 ("\"a" "ä")
99 ("\"A" "Ä")
100 ("\"o" "ö")
101 ("\"O" "Ö")
102 ("\"u" "ü")
103 ("\"U" "Ü")
104 ("\"s" "ß")
105 ("\\\\3" "ß")
107 "German translation table.
108 This table uses an aggressive translation approach and may erroneously
109 translate too much.")
111 (defvar iso-conservative-german-trans-tab
113 ("\\([-a-zA-Z\"`]\\)\"a" "\\1ä")
114 ("\\([-a-zA-Z\"`]\\)\"A" "\\1Ä")
115 ("\\([-a-zA-Z\"`]\\)\"o" "\\1ö")
116 ("\\([-a-zA-Z\"`]\\)\"O" "\\1Ö")
117 ("\\([-a-zA-Z\"`]\\)\"u" "\\1ü")
118 ("\\([-a-zA-Z\"`]\\)\"U" "\\1Ü")
119 ("\\([-a-zA-Z\"`]\\)\"s" "\\1ß")
120 ("\\([-a-zA-Z\"`]\\)\\\\3" "\\1ß")
122 "German translation table.
123 This table uses a conservative translation approach and may translate too
124 little.")
126 (defvar iso-german-trans-tab iso-aggressive-german-trans-tab
127 "Currently active translation table for German.")
129 ;;;###autoload
130 (defun iso-german (from to &optional buffer)
131 "Translate net conventions for German to ISO 8859-1.
132 The region between FROM and TO is translated using the table TRANS-TAB.
133 Optional arg BUFFER is ignored (so that the function can can be used in
134 `format-alist')."
135 (interactive "*r")
136 (iso-translate-conventions from to iso-german-trans-tab))
138 (defvar iso-iso2tex-trans-tab
140 ("ä" "{\\\\\"a}")
141 ("à" "{\\\\`a}")
142 ("á" "{\\\\'a}")
143 ("ã" "{\\\\~a}")
144 ("â" "{\\\\^a}")
145 ("ë" "{\\\\\"e}")
146 ("è" "{\\\\`e}")
147 ("é" "{\\\\'e}")
148 ("ê" "{\\\\^e}")
149 ("ï" "{\\\\\"\\\\i}")
150 ("ì" "{\\\\`\\\\i}")
151 ("í" "{\\\\'\\\\i}")
152 ("î" "{\\\\^\\\\i}")
153 ("ö" "{\\\\\"o}")
154 ("ò" "{\\\\`o}")
155 ("ó" "{\\\\'o}")
156 ("õ" "{\\\\~o}")
157 ("ô" "{\\\\^o}")
158 ("ü" "{\\\\\"u}")
159 ("ù" "{\\\\`u}")
160 ("ú" "{\\\\'u}")
161 ("û" "{\\\\^u}")
162 ("Ä" "{\\\\\"A}")
163 ("À" "{\\\\`A}")
164 ("Á" "{\\\\'A}")
165 ("Ã" "{\\\\~A}")
166 ("Â" "{\\\\^A}")
167 ("Ë" "{\\\\\"E}")
168 ("È" "{\\\\`E}")
169 ("É" "{\\\\'E}")
170 ("Ê" "{\\\\^E}")
171 ("Ï" "{\\\\\"I}")
172 ("Ì" "{\\\\`I}")
173 ("Í" "{\\\\'I}")
174 ("Î" "{\\\\^I}")
175 ("Ö" "{\\\\\"O}")
176 ("Ò" "{\\\\`O}")
177 ("Ó" "{\\\\'O}")
178 ("Õ" "{\\\\~O}")
179 ("Ô" "{\\\\^O}")
180 ("Ü" "{\\\\\"U}")
181 ("Ù" "{\\\\`U}")
182 ("Ú" "{\\\\'U}")
183 ("Û" "{\\\\^U}")
184 ("ñ" "{\\\\~n}")
185 ("Ñ" "{\\\\~N}")
186 ("ç" "{\\\\c c}")
187 ("Ç" "{\\\\c C}")
188 ("ß" "{\\\\ss}")
189 ("\306" "{\\\\AE}")
190 ("\346" "{\\\\ae}")
191 ("\305" "{\\\\AA}")
192 ("\345" "{\\\\aa}")
193 ("\251" "{\\\\copyright}")
194 ("£" "{\\\\pounds}")
195 ("¶" "{\\\\P}")
196 ("§" "{\\\\S}")
197 ("¿" "{?`}")
198 ("¡" "{!`}")
200 "Translation table for translating ISO 8859-1 characters to TeX sequences.")
202 ;;;###autoload
203 (defun iso-iso2tex (from to &optional buffer)
204 "Translate ISO 8859-1 characters to TeX sequences.
205 The region between FROM and TO is translated using the table TRANS-TAB.
206 Optional arg BUFFER is ignored (so that the function can can be used in
207 `format-alist')."
208 (interactive "*r")
209 (iso-translate-conventions from to iso-iso2tex-trans-tab))
211 (defvar iso-tex2iso-trans-tab
213 ("{\\\\\"a}" "ä")
214 ("{\\\\`a}" "à")
215 ("{\\\\'a}" "á")
216 ("{\\\\~a}" "ã")
217 ("{\\\\^a}" "â")
218 ("{\\\\\"e}" "ë")
219 ("{\\\\`e}" "è")
220 ("{\\\\'e}" "é")
221 ("{\\\\^e}" "ê")
222 ("{\\\\\"\\\\i}" "ï")
223 ("{\\\\`\\\\i}" "ì")
224 ("{\\\\'\\\\i}" "í")
225 ("{\\\\^\\\\i}" "î")
226 ("{\\\\\"i}" "ï")
227 ("{\\\\`i}" "ì")
228 ("{\\\\'i}" "í")
229 ("{\\\\^i}" "î")
230 ("{\\\\\"o}" "ö")
231 ("{\\\\`o}" "ò")
232 ("{\\\\'o}" "ó")
233 ("{\\\\~o}" "õ")
234 ("{\\\\^o}" "ô")
235 ("{\\\\\"u}" "ü")
236 ("{\\\\`u}" "ù")
237 ("{\\\\'u}" "ú")
238 ("{\\\\^u}" "û")
239 ("{\\\\\"A}" "Ä")
240 ("{\\\\`A}" "À")
241 ("{\\\\'A}" "Á")
242 ("{\\\\~A}" "Ã")
243 ("{\\\\^A}" "Â")
244 ("{\\\\\"E}" "Ë")
245 ("{\\\\`E}" "È")
246 ("{\\\\'E}" "É")
247 ("{\\\\^E}" "Ê")
248 ("{\\\\\"I}" "Ï")
249 ("{\\\\`I}" "Ì")
250 ("{\\\\'I}" "Í")
251 ("{\\\\^I}" "Î")
252 ("{\\\\\"O}" "Ö")
253 ("{\\\\`O}" "Ò")
254 ("{\\\\'O}" "Ó")
255 ("{\\\\~O}" "Õ")
256 ("{\\\\^O}" "Ô")
257 ("{\\\\\"U}" "Ü")
258 ("{\\\\`U}" "Ù")
259 ("{\\\\'U}" "Ú")
260 ("{\\\\^U}" "Û")
261 ("{\\\\~n}" "ñ")
262 ("{\\\\~N}" "Ñ")
263 ("{\\\\c c}" "ç")
264 ("{\\\\c C}" "Ç")
265 ("\\\\\"a" "ä")
266 ("\\\\`a" "à")
267 ("\\\\'a" "á")
268 ("\\\\~a" "ã")
269 ("\\\\^a" "â")
270 ("\\\\\"e" "ë")
271 ("\\\\`e" "è")
272 ("\\\\'e" "é")
273 ("\\\\^e" "ê")
274 ("\\\\\"\\\\i" "ï")
275 ("\\\\`\\\\i" "ì")
276 ("\\\\'\\\\i" "í")
277 ("\\\\^\\\\i" "î")
278 ("\\\\\"i" "ï")
279 ("\\\\`i" "ì")
280 ("\\\\'i" "í")
281 ("\\\\^i" "î")
282 ("\\\\\"o" "ö")
283 ("\\\\`o" "ò")
284 ("\\\\'o" "ó")
285 ("\\\\~o" "õ")
286 ("\\\\^o" "ô")
287 ("\\\\\"u" "ü")
288 ("\\\\`u" "ù")
289 ("\\\\'u" "ú")
290 ("\\\\^u" "û")
291 ("\\\\\"A" "Ä")
292 ("\\\\`A" "À")
293 ("\\\\'A" "Á")
294 ("\\\\~A" "Ã")
295 ("\\\\^A" "Â")
296 ("\\\\\"E" "Ë")
297 ("\\\\`E" "È")
298 ("\\\\'E" "É")
299 ("\\\\^E" "Ê")
300 ("\\\\\"I" "Ï")
301 ("\\\\`I" "Ì")
302 ("\\\\'I" "Í")
303 ("\\\\^I" "Î")
304 ("\\\\\"O" "Ö")
305 ("\\\\`O" "Ò")
306 ("\\\\'O" "Ó")
307 ("\\\\~O" "Õ")
308 ("\\\\^O" "Ô")
309 ("\\\\\"U" "Ü")
310 ("\\\\`U" "Ù")
311 ("\\\\'U" "Ú")
312 ("\\\\^U" "Û")
313 ("\\\\~n" "ñ")
314 ("\\\\~N" "Ñ")
315 ("\\\\\"{a}" "ä")
316 ("\\\\`{a}" "à")
317 ("\\\\'{a}" "á")
318 ("\\\\~{a}" "ã")
319 ("\\\\^{a}" "â")
320 ("\\\\\"{e}" "ë")
321 ("\\\\`{e}" "è")
322 ("\\\\'{e}" "é")
323 ("\\\\^{e}" "ê")
324 ("\\\\\"{\\\\i}" "ï")
325 ("\\\\`{\\\\i}" "ì")
326 ("\\\\'{\\\\i}" "í")
327 ("\\\\^{\\\\i}" "î")
328 ("\\\\\"{i}" "ï")
329 ("\\\\`{i}" "ì")
330 ("\\\\'{i}" "í")
331 ("\\\\^{i}" "î")
332 ("\\\\\"{o}" "ö")
333 ("\\\\`{o}" "ò")
334 ("\\\\'{o}" "ó")
335 ("\\\\~{o}" "õ")
336 ("\\\\^{o}" "ô")
337 ("\\\\\"{u}" "ü")
338 ("\\\\`{u}" "ù")
339 ("\\\\'{u}" "ú")
340 ("\\\\^{u}" "û")
341 ("\\\\\"{A}" "Ä")
342 ("\\\\`{A}" "À")
343 ("\\\\'{A}" "Á")
344 ("\\\\~{A}" "Ã")
345 ("\\\\^{A}" "Â")
346 ("\\\\\"{E}" "Ë")
347 ("\\\\`{E}" "È")
348 ("\\\\'{E}" "É")
349 ("\\\\^{E}" "Ê")
350 ("\\\\\"{I}" "Ï")
351 ("\\\\`{I}" "Ì")
352 ("\\\\'{I}" "Í")
353 ("\\\\^{I}" "Î")
354 ("\\\\\"{O}" "Ö")
355 ("\\\\`{O}" "Ò")
356 ("\\\\'{O}" "Ó")
357 ("\\\\~{O}" "Õ")
358 ("\\\\^{O}" "Ô")
359 ("\\\\\"{U}" "Ü")
360 ("\\\\`{U}" "Ù")
361 ("\\\\'{U}" "Ú")
362 ("\\\\^{U}" "Û")
363 ("\\\\~{n}" "ñ")
364 ("\\\\~{N}" "Ñ")
365 ("\\\\c{c}" "ç")
366 ("\\\\c{C}" "Ç")
367 ("{\\\\ss}" "ß")
368 ("{\\\\AE}" "\306")
369 ("{\\\\ae}" "\346")
370 ("{\\\\AA}" "\305")
371 ("{\\\\aa}" "\345")
372 ("{\\\\copyright}" "\251")
373 ("\\\\copyright{}" "\251")
374 ("{\\\\pounds}" "£" )
375 ("{\\\\P}" "¶" )
376 ("{\\\\S}" "§" )
377 ("\\\\pounds{}" "£" )
378 ("\\\\P{}" "¶" )
379 ("\\\\S{}" "§" )
380 ("{\\?`}" "¿")
381 ("{!`}" "¡")
382 ("\\?`" "¿")
383 ("!`" "¡")
385 "Translation table for translating TeX sequences to ISO 8859-1 characters.
386 This table is not exhaustive (and due to TeX's power can never be). It only
387 contains commonly used sequences.")
389 ;;;###autoload
390 (defun iso-tex2iso (from to &optional buffer)
391 "Translate TeX sequences to ISO 8859-1 characters.
392 The region between FROM and TO is translated using the table TRANS-TAB.
393 Optional arg BUFFER is ignored (so that the function can can be used in
394 `format-alist')."
395 (interactive "*r")
396 (iso-translate-conventions from to iso-tex2iso-trans-tab))
398 (defvar iso-gtex2iso-trans-tab
400 ("{\\\\\"a}" "ä")
401 ("{\\\\`a}" "à")
402 ("{\\\\'a}" "á")
403 ("{\\\\~a}" "ã")
404 ("{\\\\^a}" "â")
405 ("{\\\\\"e}" "ë")
406 ("{\\\\`e}" "è")
407 ("{\\\\'e}" "é")
408 ("{\\\\^e}" "ê")
409 ("{\\\\\"\\\\i}" "ï")
410 ("{\\\\`\\\\i}" "ì")
411 ("{\\\\'\\\\i}" "í")
412 ("{\\\\^\\\\i}" "î")
413 ("{\\\\\"i}" "ï")
414 ("{\\\\`i}" "ì")
415 ("{\\\\'i}" "í")
416 ("{\\\\^i}" "î")
417 ("{\\\\\"o}" "ö")
418 ("{\\\\`o}" "ò")
419 ("{\\\\'o}" "ó")
420 ("{\\\\~o}" "õ")
421 ("{\\\\^o}" "ô")
422 ("{\\\\\"u}" "ü")
423 ("{\\\\`u}" "ù")
424 ("{\\\\'u}" "ú")
425 ("{\\\\^u}" "û")
426 ("{\\\\\"A}" "Ä")
427 ("{\\\\`A}" "À")
428 ("{\\\\'A}" "Á")
429 ("{\\\\~A}" "Ã")
430 ("{\\\\^A}" "Â")
431 ("{\\\\\"E}" "Ë")
432 ("{\\\\`E}" "È")
433 ("{\\\\'E}" "É")
434 ("{\\\\^E}" "Ê")
435 ("{\\\\\"I}" "Ï")
436 ("{\\\\`I}" "Ì")
437 ("{\\\\'I}" "Í")
438 ("{\\\\^I}" "Î")
439 ("{\\\\\"O}" "Ö")
440 ("{\\\\`O}" "Ò")
441 ("{\\\\'O}" "Ó")
442 ("{\\\\~O}" "Õ")
443 ("{\\\\^O}" "Ô")
444 ("{\\\\\"U}" "Ü")
445 ("{\\\\`U}" "Ù")
446 ("{\\\\'U}" "Ú")
447 ("{\\\\^U}" "Û")
448 ("{\\\\~n}" "ñ")
449 ("{\\\\~N}" "Ñ")
450 ("{\\\\c c}" "ç")
451 ("{\\\\c C}" "Ç")
452 ("\\\\\"a" "ä")
453 ("\\\\`a" "à")
454 ("\\\\'a" "á")
455 ("\\\\~a" "ã")
456 ("\\\\^a" "â")
457 ("\\\\\"e" "ë")
458 ("\\\\`e" "è")
459 ("\\\\'e" "é")
460 ("\\\\^e" "ê")
461 ("\\\\\"\\\\i" "ï")
462 ("\\\\`\\\\i" "ì")
463 ("\\\\'\\\\i" "í")
464 ("\\\\^\\\\i" "î")
465 ("\\\\\"i" "ï")
466 ("\\\\`i" "ì")
467 ("\\\\'i" "í")
468 ("\\\\^i" "î")
469 ("\\\\\"o" "ö")
470 ("\\\\`o" "ò")
471 ("\\\\'o" "ó")
472 ("\\\\~o" "õ")
473 ("\\\\^o" "ô")
474 ("\\\\\"u" "ü")
475 ("\\\\`u" "ù")
476 ("\\\\'u" "ú")
477 ("\\\\^u" "û")
478 ("\\\\\"A" "Ä")
479 ("\\\\`A" "À")
480 ("\\\\'A" "Á")
481 ("\\\\~A" "Ã")
482 ("\\\\^A" "Â")
483 ("\\\\\"E" "Ë")
484 ("\\\\`E" "È")
485 ("\\\\'E" "É")
486 ("\\\\^E" "Ê")
487 ("\\\\\"I" "Ï")
488 ("\\\\`I" "Ì")
489 ("\\\\'I" "Í")
490 ("\\\\^I" "Î")
491 ("\\\\\"O" "Ö")
492 ("\\\\`O" "Ò")
493 ("\\\\'O" "Ó")
494 ("\\\\~O" "Õ")
495 ("\\\\^O" "Ô")
496 ("\\\\\"U" "Ü")
497 ("\\\\`U" "Ù")
498 ("\\\\'U" "Ú")
499 ("\\\\^U" "Û")
500 ("\\\\~n" "ñ")
501 ("\\\\~N" "Ñ")
502 ("\\\\\"{a}" "ä")
503 ("\\\\`{a}" "à")
504 ("\\\\'{a}" "á")
505 ("\\\\~{a}" "ã")
506 ("\\\\^{a}" "â")
507 ("\\\\\"{e}" "ë")
508 ("\\\\`{e}" "è")
509 ("\\\\'{e}" "é")
510 ("\\\\^{e}" "ê")
511 ("\\\\\"{\\\\i}" "ï")
512 ("\\\\`{\\\\i}" "ì")
513 ("\\\\'{\\\\i}" "í")
514 ("\\\\^{\\\\i}" "î")
515 ("\\\\\"{i}" "ï")
516 ("\\\\`{i}" "ì")
517 ("\\\\'{i}" "í")
518 ("\\\\^{i}" "î")
519 ("\\\\\"{o}" "ö")
520 ("\\\\`{o}" "ò")
521 ("\\\\'{o}" "ó")
522 ("\\\\~{o}" "õ")
523 ("\\\\^{o}" "ô")
524 ("\\\\\"{u}" "ü")
525 ("\\\\`{u}" "ù")
526 ("\\\\'{u}" "ú")
527 ("\\\\^{u}" "û")
528 ("\\\\\"{A}" "Ä")
529 ("\\\\`{A}" "À")
530 ("\\\\'{A}" "Á")
531 ("\\\\~{A}" "Ã")
532 ("\\\\^{A}" "Â")
533 ("\\\\\"{E}" "Ë")
534 ("\\\\`{E}" "È")
535 ("\\\\'{E}" "É")
536 ("\\\\^{E}" "Ê")
537 ("\\\\\"{I}" "Ï")
538 ("\\\\`{I}" "Ì")
539 ("\\\\'{I}" "Í")
540 ("\\\\^{I}" "Î")
541 ("\\\\\"{O}" "Ö")
542 ("\\\\`{O}" "Ò")
543 ("\\\\'{O}" "Ó")
544 ("\\\\~{O}" "Õ")
545 ("\\\\^{O}" "Ô")
546 ("\\\\\"{U}" "Ü")
547 ("\\\\`{U}" "Ù")
548 ("\\\\'{U}" "Ú")
549 ("\\\\^{U}" "Û")
550 ("\\\\~{n}" "ñ")
551 ("\\\\~{N}" "Ñ")
552 ("\\\\c{c}" "ç")
553 ("\\\\c{C}" "Ç")
554 ("{\\\\ss}" "ß")
555 ("{\\\\AE}" "\306")
556 ("{\\\\ae}" "\346")
557 ("{\\\\AA}" "\305")
558 ("{\\\\aa}" "\345")
559 ("{\\\\copyright}" "\251")
560 ("\\\\copyright{}" "\251")
561 ("{\\\\pounds}" "£" )
562 ("{\\\\P}" "¶" )
563 ("{\\\\S}" "§" )
564 ("\\\\pounds{}" "£" )
565 ("\\\\P{}" "¶" )
566 ("\\\\S{}" "§" )
567 ("?`" "¿")
568 ("!`" "¡")
569 ("{?`}" "¿")
570 ("{!`}" "¡")
571 ("\"a" "ä")
572 ("\"A" "Ä")
573 ("\"o" "ö")
574 ("\"O" "Ö")
575 ("\"u" "ü")
576 ("\"U" "Ü")
577 ("\"s" "ß")
578 ("\\\\3" "ß")
580 "Translation table for translating German TeX sequences to ISO 8859-1.
581 This table is not exhaustive (and due to TeX's power can never be). It only
582 contains commonly used sequences.")
584 (defvar iso-iso2gtex-trans-tab
586 ("ä" "\"a")
587 ("à" "{\\\\`a}")
588 ("á" "{\\\\'a}")
589 ("ã" "{\\\\~a}")
590 ("â" "{\\\\^a}")
591 ("ë" "{\\\\\"e}")
592 ("è" "{\\\\`e}")
593 ("é" "{\\\\'e}")
594 ("ê" "{\\\\^e}")
595 ("ï" "{\\\\\"\\\\i}")
596 ("ì" "{\\\\`\\\\i}")
597 ("í" "{\\\\'\\\\i}")
598 ("î" "{\\\\^\\\\i}")
599 ("ö" "\"o")
600 ("ò" "{\\\\`o}")
601 ("ó" "{\\\\'o}")
602 ("õ" "{\\\\~o}")
603 ("ô" "{\\\\^o}")
604 ("ü" "\"u")
605 ("ù" "{\\\\`u}")
606 ("ú" "{\\\\'u}")
607 ("û" "{\\\\^u}")
608 ("Ä" "\"A")
609 ("À" "{\\\\`A}")
610 ("Á" "{\\\\'A}")
611 ("Ã" "{\\\\~A}")
612 ("Â" "{\\\\^A}")
613 ("Ë" "{\\\\\"E}")
614 ("È" "{\\\\`E}")
615 ("É" "{\\\\'E}")
616 ("Ê" "{\\\\^E}")
617 ("Ï" "{\\\\\"I}")
618 ("Ì" "{\\\\`I}")
619 ("Í" "{\\\\'I}")
620 ("Î" "{\\\\^I}")
621 ("Ö" "\"O")
622 ("Ò" "{\\\\`O}")
623 ("Ó" "{\\\\'O}")
624 ("Õ" "{\\\\~O}")
625 ("Ô" "{\\\\^O}")
626 ("Ü" "\"U")
627 ("Ù" "{\\\\`U}")
628 ("Ú" "{\\\\'U}")
629 ("Û" "{\\\\^U}")
630 ("ñ" "{\\\\~n}")
631 ("Ñ" "{\\\\~N}")
632 ("ç" "{\\\\c c}")
633 ("Ç" "{\\\\c C}")
634 ("ß" "\"s")
635 ("\306" "{\\\\AE}")
636 ("\346" "{\\\\ae}")
637 ("\305" "{\\\\AA}")
638 ("\345" "{\\\\aa}")
639 ("\251" "{\\\\copyright}")
640 ("£" "{\\\\pounds}")
641 ("¶" "{\\\\P}")
642 ("§" "{\\\\S}")
643 ("¿" "{?`}")
644 ("¡" "{!`}")
646 "Translation table for translating ISO 8859-1 characters to German TeX.")
648 ;;;###autoload
649 (defun iso-gtex2iso (from to &optional buffer)
650 "Translate German TeX sequences to ISO 8859-1 characters.
651 The region between FROM and TO is translated using the table TRANS-TAB.
652 Optional arg BUFFER is ignored (so that the function can can be used in
653 `format-alist')."
654 (interactive "*r")
655 (iso-translate-conventions from to iso-gtex2iso-trans-tab))
657 ;;;###autoload
658 (defun iso-iso2gtex (from to &optional buffer)
659 "Translate ISO 8859-1 characters to German TeX sequences.
660 The region between FROM and TO is translated using the table TRANS-TAB.
661 Optional arg BUFFER is ignored (so that the function can can be used in
662 `format-alist')."
663 (interactive "*r")
664 (iso-translate-conventions from to iso-iso2gtex-trans-tab))
666 (defvar iso-iso2duden-trans-tab
667 '(("ä" "ae")
668 ("Ä" "Ae")
669 ("ö" "oe")
670 ("Ö" "Oe")
671 ("ü" "ue")
672 ("Ü" "Ue")
673 ("ß" "ss")))
675 ;;;###autoload
676 (defun iso-iso2duden (from to &optional buffer)
677 "Translate ISO 8859-1 characters to German TeX sequences.
678 The region between FROM and TO is translated using the table TRANS-TAB.
679 Optional arg BUFFER is ignored (so that the function can can be used in
680 `format-alist')."
681 (interactive "*r")
682 (iso-translate-conventions from to iso-iso2duden-trans-tab))
684 ;;;###autoload
685 (defun iso-cvt-read-only ()
686 "Warn that format is read-only."
687 (interactive)
688 (error "This format is read-only; specify another format for writing"))
690 ;;;###autoload
691 (defun iso-cvt-write-only ()
692 "Warn that format is write-only."
693 (interactive)
694 (error "This format is write-only"))
696 ;;;###autoload
697 (defun iso-cvt-define-menu ()
698 "Add submenus to the Files menu, to convert to and from various formats."
699 (interactive)
701 (define-key menu-bar-files-menu [load-as-separator] '("--"))
703 (define-key menu-bar-files-menu [load-as] '("Load As..." . load-as))
704 (defvar load-as-menu-map (make-sparse-keymap "Load As..."))
705 (fset 'load-as load-as-menu-map)
707 ;;(define-key menu-bar-files-menu [insert-as] '("Insert As..." . insert-as))
708 (defvar insert-as-menu-map (make-sparse-keymap "Insert As..."))
709 (fset 'insert-as insert-as-menu-map)
711 (define-key menu-bar-files-menu [write-as] '("Write As..." . write-as))
712 (defvar write-as-menu-map (make-sparse-keymap "Write As..."))
713 (fset 'write-as write-as-menu-map)
715 (define-key menu-bar-files-menu [translate-separator] '("--"))
717 (define-key menu-bar-files-menu [translate-to] '("Translate to..." . translate-to))
718 (defvar translate-to-menu-map (make-sparse-keymap "Translate to..."))
719 (fset 'translate-to translate-to-menu-map)
721 (define-key menu-bar-files-menu [translate-from] '("Translate from..." . translate-from))
722 (defvar translate-from-menu-map (make-sparse-keymap "Translate from..."))
723 (fset 'translate-from translate-from-menu-map)
725 (let ((file-types (reverse format-alist))
726 name
727 str-name)
728 (while file-types
729 (setq name (car (car file-types))
730 str-name (car (cdr (car file-types)))
731 file-types (cdr file-types))
732 (if (stringp str-name)
733 (progn
734 (define-key load-as-menu-map (vector name)
735 (cons str-name
736 (list 'lambda '(file) (list 'interactive (format "FFind file (as %s): " name))
737 (list 'format-find-file 'file (list 'quote name)))))
738 (define-key insert-as-menu-map (vector name)
739 (cons str-name
740 (list 'lambda '(file) (list 'interactive (format "FInsert file (as %s): " name))
741 (list 'format-insert-file 'file (list 'quote name)))))
742 (define-key write-as-menu-map (vector name)
743 (cons str-name
744 (list 'lambda '(file) (list 'interactive (format "FWrite file (as %s): " name))
745 (list 'format-write-file 'file (list 'quote (list name))))))
746 (define-key translate-to-menu-map (vector name)
747 (cons str-name
748 (list 'lambda '() '(interactive)
749 (list 'format-encode-buffer (list 'quote name)))))
750 (define-key translate-from-menu-map (vector name)
751 (cons str-name
752 (list 'lambda '() '(interactive)
753 (list 'format-decode-buffer (list 'quote (list name))))))
754 )))))
756 ;;; iso-cvt.el ends here