Mercurial > emacs
annotate lisp/international/iso-cvt.el @ 7853:77fc514da1b7
(xterm.o): Depend on dispextern.h.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 11 Jun 1994 20:09:33 +0000 |
parents | b6f3dd2511bc |
children | 8996abee8718 |
rev | line source |
---|---|
7260 | 1 ;; iso-cvt.el -- translate to ISO 8859-1 from/to net/TeX conventions |
2 ;; Copyright © 1993 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: | |
7425
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
25 ;; This lisp code server two purposes, both of which involve |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
26 ;; the translation of various conventions for representing European |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
27 ;; character sets to ISO 8859-1. |
7260 | 28 |
7425
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
29 ; Net support: |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
30 ; Various conventions exist in Newsgroups on how to represent national |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
31 ; characters. The functions provided here translate these net conventions |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
32 ; to ISO. |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
33 ; |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
34 ; Calling `iso-german' will turn the net convention for umlauts ("a etc.) |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
35 ; into ISO latin1 umlaute for easy reading. |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
36 ; 'iso-spanish' will turn net conventions for representing spanish |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
37 ; to ISO latin1. (Note that accents are omitted in news posts most |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
38 ; of the time, only enye is escaped.) |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
39 |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
40 ; TeX support |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
41 ; This mode installs hooks which change TeX files to ISO Latin-1 for |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
42 ; simplified editing. When the TeX file is saved, ISO latin1 characters are |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
43 ; translated back to escape sequences. |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
44 ; |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
45 ; An alternative is a TeX style that handles 8 bit ISO files |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
46 ; (available on ftp.vlsivie.tuwien.ac.at in /pub/8bit) |
7260 | 47 ; - but these files are difficult to transmit ... so while the net is |
48 ; still @ 7 bit this may be useful | |
49 | |
7425
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
50 ;; TO DO: |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
51 ; The net support should install hooks (like TeX support does) |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
52 ; which recognizes certains news groups and translates all articles from |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
53 ; those groups. |
7260 | 54 ; |
7425
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
55 ; Cover more cases for translation (There is an infinite number of ways to |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
56 ; represent accented characters in TeX) |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
57 |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
58 ;; SEE ALSO: |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
59 ; If you are interested in questions related to using the ISO 8859-1 |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
60 ; characters set (configuring emacs, Unix, etc. to use ISO), then you |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
61 ; can get the ISO 8859-1 FAQ via anonymous ftp from |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
62 ; ftp.vlsivie.tuwien.ac.at in /pub/bit/FAQ-ISO-8859-1 |
7260 | 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) | |
7850
b6f3dd2511bc
(iso-translate-conventions): Get rid of interactive spec.
Richard M. Stallman <rms@gnu.org>
parents:
7831
diff
changeset
|
87 "Use the translation table TRANS-TAB to translate the current buffer." |
7260 | 88 (save-excursion |
89 (widen) | |
90 (goto-char (point-min)) | |
91 (let ((work-tab trans-tab) | |
7831
343a21c51172
(iso-translate-conventions): Use case-dependent search and don't alter case.
Richard M. Stallman <rms@gnu.org>
parents:
7425
diff
changeset
|
92 (buffer-read-only nil) |
343a21c51172
(iso-translate-conventions): Use case-dependent search and don't alter case.
Richard M. Stallman <rms@gnu.org>
parents:
7425
diff
changeset
|
93 (case-fold-search nil)) |
7260 | 94 (while work-tab |
95 (save-excursion | |
96 (let ((trans-this (car work-tab))) | |
97 (while (re-search-forward (car trans-this) nil t) | |
7831
343a21c51172
(iso-translate-conventions): Use case-dependent search and don't alter case.
Richard M. Stallman <rms@gnu.org>
parents:
7425
diff
changeset
|
98 (replace-match (car (cdr trans-this)) t nil))) |
7260 | 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 translate | |
119 erroneously 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 ("¿" "{?`}") | |
197 ("¡" "{!`}") | |
198 ) | |
199 "Translation table for translating ISO 8859-1 characters to TeX sequences.") | |
200 | |
201 | |
202 | |
203 | |
204 (defun iso-iso2tex () | |
205 "Translate ISO 8859-1 characters to TeX sequences." | |
206 (interactive) | |
207 (iso-translate-conventions iso-iso2tex-trans-tab)) | |
208 | |
209 | |
210 (defvar iso-tex2iso-trans-tab | |
211 '( | |
212 ("{\\\\\"a}" "ä") | |
213 ("{\\\\`a}" "à") | |
214 ("{\\\\'a}" "á") | |
215 ("{\\\\~a}" "ã") | |
216 ("{\\\\^a}" "â") | |
217 ("{\\\\\"e}" "ë") | |
218 ("{\\\\`e}" "è") | |
219 ("{\\\\'e}" "é") | |
220 ("{\\\\^e}" "ê") | |
221 ("{\\\\\"\\\\i}" "ï") | |
222 ("{\\\\`\\\\i}" "ì") | |
223 ("{\\\\'\\\\i}" "í") | |
224 ("{\\\\^\\\\i}" "î") | |
225 ("{\\\\\"i}" "ï") | |
226 ("{\\\\`i}" "ì") | |
227 ("{\\\\'i}" "í") | |
228 ("{\\\\^i}" "î") | |
229 ("{\\\\\"o}" "ö") | |
230 ("{\\\\`o}" "ò") | |
231 ("{\\\\'o}" "ó") | |
232 ("{\\\\~o}" "õ") | |
233 ("{\\\\^o}" "ô") | |
234 ("{\\\\\"u}" "ü") | |
235 ("{\\\\`u}" "ù") | |
236 ("{\\\\'u}" "ú") | |
237 ("{\\\\^u}" "û") | |
238 ("{\\\\\"A}" "Ä") | |
239 ("{\\\\`A}" "À") | |
240 ("{\\\\'A}" "Á") | |
241 ("{\\\\~A}" "Ã") | |
242 ("{\\\\^A}" "Â") | |
243 ("{\\\\\"E}" "Ë") | |
244 ("{\\\\`E}" "È") | |
245 ("{\\\\'E}" "É") | |
246 ("{\\\\^E}" "Ê") | |
247 ("{\\\\\"I}" "Ï") | |
248 ("{\\\\`I}" "Ì") | |
249 ("{\\\\'I}" "Í") | |
250 ("{\\\\^I}" "Î") | |
251 ("{\\\\\"O}" "Ö") | |
252 ("{\\\\`O}" "Ò") | |
253 ("{\\\\'O}" "Ó") | |
254 ("{\\\\~O}" "Õ") | |
255 ("{\\\\^O}" "Ô") | |
256 ("{\\\\\"U}" "Ü") | |
257 ("{\\\\`U}" "Ù") | |
258 ("{\\\\'U}" "Ú") | |
259 ("{\\\\^U}" "Û") | |
260 ("{\\\\~n}" "ñ") | |
261 ("{\\\\~N}" "Ñ") | |
262 ("{\\\\c c}" "ç") | |
263 ("{\\\\c C}" "Ç") | |
264 ("\\\\\"{a}" "ä") | |
265 ("\\\\`{a}" "à") | |
266 ("\\\\'{a}" "á") | |
267 ("\\\\~{a}" "ã") | |
268 ("\\\\^{a}" "â") | |
269 ("\\\\\"{e}" "ë") | |
270 ("\\\\`{e}" "è") | |
271 ("\\\\'{e}" "é") | |
272 ("\\\\^{e}" "ê") | |
273 ("\\\\\"{\\\\i}" "ï") | |
274 ("\\\\`{\\\\i}" "ì") | |
275 ("\\\\'{\\\\i}" "í") | |
276 ("\\\\^{\\\\i}" "î") | |
277 ("\\\\\"{i}" "ï") | |
278 ("\\\\`{i}" "ì") | |
279 ("\\\\'{i}" "í") | |
280 ("\\\\^{i}" "î") | |
281 ("\\\\\"{o}" "ö") | |
282 ("\\\\`{o}" "ò") | |
283 ("\\\\'{o}" "ó") | |
284 ("\\\\~{o}" "õ") | |
285 ("\\\\^{o}" "ô") | |
286 ("\\\\\"{u}" "ü") | |
287 ("\\\\`{u}" "ù") | |
288 ("\\\\'{u}" "ú") | |
289 ("\\\\^{u}" "û") | |
290 ("\\\\\"{A}" "Ä") | |
291 ("\\\\`{A}" "À") | |
292 ("\\\\'{A}" "Á") | |
293 ("\\\\~{A}" "Ã") | |
294 ("\\\\^{A}" "Â") | |
295 ("\\\\\"{E}" "Ë") | |
296 ("\\\\`{E}" "È") | |
297 ("\\\\'{E}" "É") | |
298 ("\\\\^{E}" "Ê") | |
299 ("\\\\\"{I}" "Ï") | |
300 ("\\\\`{I}" "Ì") | |
301 ("\\\\'{I}" "Í") | |
302 ("\\\\^{I}" "Î") | |
303 ("\\\\\"{O}" "Ö") | |
304 ("\\\\`{O}" "Ò") | |
305 ("\\\\'{O}" "Ó") | |
306 ("\\\\~{O}" "Õ") | |
307 ("\\\\^{O}" "Ô") | |
308 ("\\\\\"{U}" "Ü") | |
309 ("\\\\`{U}" "Ù") | |
310 ("\\\\'{U}" "Ú") | |
311 ("\\\\^{U}" "Û") | |
312 ("\\\\~{n}" "ñ") | |
313 ("\\\\~{N}" "Ñ") | |
314 ("\\\\c{c}" "ç") | |
315 ("\\\\c{C}" "Ç") | |
316 ("{\\\\ss}" "ß") | |
317 ("?`" "¿") | |
318 ("!`" "¡") | |
319 ("{?`}" "¿") | |
320 ("{!`}" "¡") | |
321 ) | |
322 "Translation table for translating TeX sequences to ISO 8859-1 characters. | |
323 This table is not exhaustive (and due to TeX's power can never be). It only | |
324 contains commonly used sequences.") | |
325 | |
326 (defun iso-tex2iso () | |
327 "Translate TeX sequences to ISO 8859-1 characters." | |
328 (interactive) | |
329 (iso-translate-conventions iso-tex2iso-trans-tab)) | |
330 | |
331 (defvar iso-gtex2iso-trans-tab | |
332 '( | |
333 ("{\\\\\"a}" "ä") | |
334 ("{\\\\`a}" "à") | |
335 ("{\\\\'a}" "á") | |
336 ("{\\\\~a}" "ã") | |
337 ("{\\\\^a}" "â") | |
338 ("{\\\\\"e}" "ë") | |
339 ("{\\\\`e}" "è") | |
340 ("{\\\\'e}" "é") | |
341 ("{\\\\^e}" "ê") | |
342 ("{\\\\\"\\\\i}" "ï") | |
343 ("{\\\\`\\\\i}" "ì") | |
344 ("{\\\\'\\\\i}" "í") | |
345 ("{\\\\^\\\\i}" "î") | |
346 ("{\\\\\"i}" "ï") | |
347 ("{\\\\`i}" "ì") | |
348 ("{\\\\'i}" "í") | |
349 ("{\\\\^i}" "î") | |
350 ("{\\\\\"o}" "ö") | |
351 ("{\\\\`o}" "ò") | |
352 ("{\\\\'o}" "ó") | |
353 ("{\\\\~o}" "õ") | |
354 ("{\\\\^o}" "ô") | |
355 ("{\\\\\"u}" "ü") | |
356 ("{\\\\`u}" "ù") | |
357 ("{\\\\'u}" "ú") | |
358 ("{\\\\^u}" "û") | |
359 ("{\\\\\"A}" "Ä") | |
360 ("{\\\\`A}" "À") | |
361 ("{\\\\'A}" "Á") | |
362 ("{\\\\~A}" "Ã") | |
363 ("{\\\\^A}" "Â") | |
364 ("{\\\\\"E}" "Ë") | |
365 ("{\\\\`E}" "È") | |
366 ("{\\\\'E}" "É") | |
367 ("{\\\\^E}" "Ê") | |
368 ("{\\\\\"I}" "Ï") | |
369 ("{\\\\`I}" "Ì") | |
370 ("{\\\\'I}" "Í") | |
371 ("{\\\\^I}" "Î") | |
372 ("{\\\\\"O}" "Ö") | |
373 ("{\\\\`O}" "Ò") | |
374 ("{\\\\'O}" "Ó") | |
375 ("{\\\\~O}" "Õ") | |
376 ("{\\\\^O}" "Ô") | |
377 ("{\\\\\"U}" "Ü") | |
378 ("{\\\\`U}" "Ù") | |
379 ("{\\\\'U}" "Ú") | |
380 ("{\\\\^U}" "Û") | |
381 ("{\\\\~n}" "ñ") | |
382 ("{\\\\~N}" "Ñ") | |
383 ("{\\\\c c}" "ç") | |
384 ("{\\\\c C}" "Ç") | |
385 ("\\\\\"{a}" "ä") | |
386 ("\\\\`{a}" "à") | |
387 ("\\\\'{a}" "á") | |
388 ("\\\\~{a}" "ã") | |
389 ("\\\\^{a}" "â") | |
390 ("\\\\\"{e}" "ë") | |
391 ("\\\\`{e}" "è") | |
392 ("\\\\'{e}" "é") | |
393 ("\\\\^{e}" "ê") | |
394 ("\\\\\"{\\\\i}" "ï") | |
395 ("\\\\`{\\\\i}" "ì") | |
396 ("\\\\'{\\\\i}" "í") | |
397 ("\\\\^{\\\\i}" "î") | |
398 ("\\\\\"{i}" "ï") | |
399 ("\\\\`{i}" "ì") | |
400 ("\\\\'{i}" "í") | |
401 ("\\\\^{i}" "î") | |
402 ("\\\\\"{o}" "ö") | |
403 ("\\\\`{o}" "ò") | |
404 ("\\\\'{o}" "ó") | |
405 ("\\\\~{o}" "õ") | |
406 ("\\\\^{o}" "ô") | |
407 ("\\\\\"{u}" "ü") | |
408 ("\\\\`{u}" "ù") | |
409 ("\\\\'{u}" "ú") | |
410 ("\\\\^{u}" "û") | |
411 ("\\\\\"{A}" "Ä") | |
412 ("\\\\`{A}" "À") | |
413 ("\\\\'{A}" "Á") | |
414 ("\\\\~{A}" "Ã") | |
415 ("\\\\^{A}" "Â") | |
416 ("\\\\\"{E}" "Ë") | |
417 ("\\\\`{E}" "È") | |
418 ("\\\\'{E}" "É") | |
419 ("\\\\^{E}" "Ê") | |
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 ("\\\\~{n}" "ñ") | |
434 ("\\\\~{N}" "Ñ") | |
435 ("\\\\c{c}" "ç") | |
436 ("\\\\c{C}" "Ç") | |
437 ("{\\\\ss}" "ß") | |
438 ("?`" "¿") | |
439 ("!`" "¡") | |
440 ("{?`}" "¿") | |
441 ("{!`}" "¡") | |
7425
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
442 ("\"a" "ä") |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
443 ("\"A" "Ä") |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
444 ("\"o" "ö") |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
445 ("\"O" "Ö") |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
446 ("\"u" "ü") |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
447 ("\"U" "Ü") |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
448 ("\"s" "ß") |
eb4b69bf2d4e
(iso-gtex2iso-trans-tab): Redorder this list.
Richard M. Stallman <rms@gnu.org>
parents:
7260
diff
changeset
|
449 ("\\\\3" "ß") |
7260 | 450 ) |
451 "Translation table for translating German TeX sequences to ISO 8859-1. | |
452 This table is not exhaustive (and due to TeX's power can never be). It only | |
453 contains commonly used sequences.") | |
454 | |
455 (defvar iso-iso2gtex-trans-tab | |
456 '( | |
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 ("ö" "\"o") | |
471 ("ò" "{\\\\`o}") | |
472 ("ó" "{\\\\'o}") | |
473 ("õ" "{\\\\~o}") | |
474 ("ô" "{\\\\^o}") | |
475 ("ü" "\"u") | |
476 ("ù" "{\\\\`u}") | |
477 ("ú" "{\\\\'u}") | |
478 ("û" "{\\\\^u}") | |
479 ("Ä" "\"A") | |
480 ("À" "{\\\\`A}") | |
481 ("Á" "{\\\\'A}") | |
482 ("Ã" "{\\\\~A}") | |
483 ("Â" "{\\\\^A}") | |
484 ("Ë" "{\\\\\"E}") | |
485 ("È" "{\\\\`E}") | |
486 ("É" "{\\\\'E}") | |
487 ("Ê" "{\\\\^E}") | |
488 ("Ï" "{\\\\\"I}") | |
489 ("Ì" "{\\\\`I}") | |
490 ("Í" "{\\\\'I}") | |
491 ("Î" "{\\\\^I}") | |
492 ("Ö" "\"O") | |
493 ("Ò" "{\\\\`O}") | |
494 ("Ó" "{\\\\'O}") | |
495 ("Õ" "{\\\\~O}") | |
496 ("Ô" "{\\\\^O}") | |
497 ("Ü" "\"U") | |
498 ("Ù" "{\\\\`U}") | |
499 ("Ú" "{\\\\'U}") | |
500 ("Û" "{\\\\^U}") | |
501 ("ñ" "{\\\\~n}") | |
502 ("Ñ" "{\\\\~N}") | |
503 ("ç" "{\\\\c c}") | |
504 ("Ç" "{\\\\c C}") | |
505 ("ß" "\"s") | |
506 ("¿" "{?`}") | |
507 ("¡" "{!`}") | |
508 ) | |
509 "Translation table for translating ISO 8859-1 characters to German TeX.") | |
510 | |
511 (defun iso-gtex2iso () | |
512 "Translate German TeX sequences to ISO 8859-1 characters." | |
513 (interactive) | |
514 (iso-translate-conventions iso-gtex2iso-trans-tab)) | |
515 | |
516 | |
517 (defun iso-iso2gtex () | |
518 "Translate ISO 8859-1 characters to German TeX sequences." | |
519 (interactive) | |
520 (iso-translate-conventions iso-iso2gtex-trans-tab)) | |
521 | |
522 | |
523 (defun iso-german-tex-p () | |
524 "Check if tex buffer is German LaTeX." | |
525 (save-excursion | |
526 (widen) | |
527 (goto-char (point-min)) | |
528 (re-search-forward "\\\\documentstyle\\[.*german.*\\]" nil t))) | |
529 | |
530 (defun iso-fix-iso2tex () | |
531 "Turn ISO 8859-1 (aka. ISO Latin-1) buffer into TeX sequences. | |
532 If German TeX is used, German TeX sequences are generated." | |
533 (if (or (equal major-mode 'latex-mode) | |
534 (equal major-mode 'LaTeX-mode)) ; AucTeX wants this | |
535 (if (iso-german-tex-p) | |
536 (iso-iso2gtex) | |
537 (iso-iso2tex))) | |
538 (if (or (equal major-mode 'tex-mode) | |
539 (equal major-mode 'TeX-mode)) ; AucTeX wants this | |
540 (iso-iso2tex))) | |
541 | |
542 (defun iso-fix-tex2iso () | |
543 "Turn TeX sequences into ISO 8859-1 (aka. ISO Latin-1) characters. | |
544 This function recognices German TeX buffers." | |
545 (if (or (equal major-mode 'latex-mode) | |
546 (equal major-mode 'Latex-mode)) ; AucTeX wants this | |
547 (if (iso-german-tex-p) | |
548 (iso-gtex2iso) | |
549 (iso-tex2iso))) | |
550 (if (or (equal major-mode 'tex-mode) | |
551 (equal major-mode 'TeX-mode)) ;; AucTeX wants this | |
552 (iso-tex2iso))) | |
553 | |
554 (defun iso-cvt-ffh () | |
555 "find-file-hook for iso-cvt-cvt.el." | |
556 (iso-fix-tex2iso) | |
557 (set-buffer-modified-p nil)) | |
558 | |
559 (defun iso-cvt-wfh () | |
560 "write file hook for iso-cvt-cvt.el." | |
561 (iso-fix-iso2tex)) | |
562 | |
563 (defun iso-cvt-ash () | |
564 "after save hook for iso-cvt-cvt.el." | |
565 (iso-fix-tex2iso) | |
566 (set-buffer-modified-p nil)) | |
567 | |
568 (add-hook 'find-file-hooks 'iso-cvt-ffh) | |
569 (add-hook 'write-file-hooks 'iso-cvt-wfh) | |
570 (add-hook 'after-save-hook 'iso-cvt-ash) | |
571 | |
572 ;;; iso-cvt.el ends here |