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