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