0
|
1 ;; iso-sgml.el --- display SGML entity references as ISO 8859-1 characters
|
|
2
|
|
3 ;; Copyright (C) 1994 Frederic Lepied
|
|
4
|
|
5 ;; Author: Frederic Lepied <lepied@cenaath.cena.dgac.fr>
|
|
6 ;; Maintainer: lepied@cenaath.cena.dgac.fr
|
|
7 ;; Keywords: SGML, HTML, ISO, Latin, i18n
|
|
8 ;; Status: Works with emacs 19.24
|
|
9 ;; Created: 1994-06-21
|
|
10 ;; Last Modified By: Frederic Lepied [STERIA SIT] 69577103
|
|
11 ;; Last Modified On: Wed Dec 7 10:14:41 1994
|
|
12 ;; Update Count: 5
|
|
13
|
|
14 ;; LCD Archive Entry:
|
|
15 ;; iso-sgml|Frederic Lepied|lepied@cenaath.cena.dgac.fr|
|
|
16 ;; Edit SGML or HTML buffers with ISO 8859-1 (Latin-1) display|
|
|
17 ;; 10-May-1995|1.4|~/misc/iso-sgml.el.Z|
|
|
18
|
70
|
19 ;; $Id: iso-sgml.el,v 1.1.1.1 1996/12/18 22:43:36 steve Exp $
|
0
|
20
|
|
21 ;; This program is free software; you can redistribute it and/or modify
|
|
22 ;; it under the terms of the GNU General Public License as published by
|
|
23 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
24 ;; any later version.
|
|
25 ;;
|
|
26 ;; This program is distributed in the hope that it will be useful,
|
|
27 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
28 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
29 ;; GNU General Public License for more details.
|
|
30 ;;
|
|
31 ;; You should have received a copy of the GNU General Public License
|
|
32 ;; along with this program; if not, you can either send email to this
|
|
33 ;; program's maintainer or write to: The Free Software Foundation,
|
|
34 ;; Inc.; 675 Massachusetts Avenue; Cambridge, MA 02139, USA.
|
|
35
|
|
36 ;; Commentary:
|
|
37 ;; Based on iso-cvt.el from Michael Gschwind <mike@vlsivie.tuwien.ac.at>,
|
|
38 ;; iso-sgml.el transparently displays entity references in SGML or HTML
|
|
39 ;; buffers as ISO 8859-1 (aka Latin-1) characters.
|
2
|
40 ;; Modified for XEmacs 19.15 to include the proposed extensions to Latin-1
|
|
41 ;; by Steve Baur <steve@miranova.com>
|
0
|
42
|
|
43 ;; SEE ALSO:
|
|
44 ;; iso-cvt.el
|
|
45 ;; If you are interested in questions related to using the ISO 8859-1
|
|
46 ;; characters set (configuring emacs, Unix, etc. to use ISO), then you
|
|
47 ;; can get the ISO 8859-1 FAQ via anonymous ftp from
|
|
48 ;; ftp.vlsivie.tuwien.ac.at in /pub/bit/FAQ-ISO-8859-1
|
|
49
|
|
50 ;; INSTALLATION:
|
|
51 ;; add the following line to your .emacs :
|
|
52 ;; (load "iso-sgml")
|
|
53 ;; If you want it to work with other modes change the value of the
|
|
54 ;; the variable isosgml-modes-list like this :
|
|
55 ;; (setq isosgml-modes-list '(my-mode))
|
|
56
|
|
57 ;; Code:
|
|
58
|
70
|
59 (defconst isosgml-version "$Id: iso-sgml.el,v 1.1.1.1 1996/12/18 22:43:36 steve Exp $"
|
0
|
60 "iso-sgml RCS version number")
|
|
61
|
|
62 (defvar isosgml-modes-list '(html-mode html-helper-mode sgml-mode)
|
|
63 "*List of modes to translate between SGML or HTML entity references
|
|
64 and the ISO 8859-1 character set.")
|
|
65
|
|
66
|
|
67 (defun isosgml-translate-conventions (trans-tab)
|
|
68 "Use the translation table argument to translate the current buffer."
|
|
69 (save-excursion
|
|
70 (let ((beg (point-min-marker)) ; see the `(elisp)Narrowing' Info node
|
|
71 (end (point-max-marker)))
|
|
72 (unwind-protect
|
|
73 (progn
|
|
74 (widen)
|
|
75 (goto-char (point-min))
|
|
76 (let ((buffer-read-only nil) ; (inhibit-read-only t)?
|
|
77 (case-fold-search nil))
|
|
78 (while trans-tab
|
|
79 (save-excursion
|
|
80 (let ((trans-this (car trans-tab)))
|
|
81 (while (search-forward (car trans-this) nil t)
|
|
82 (replace-match (car (cdr trans-this)) t t)))
|
|
83 (setq trans-tab (cdr trans-tab))))))
|
|
84 (narrow-to-region beg end)))))
|
|
85
|
|
86 (defvar sgml2iso-trans-tab
|
|
87 '(
|
|
88 ("Æ\;" "Æ")
|
|
89 ("Á\;" "Á")
|
|
90 ("Â\;" "Â")
|
|
91 ("À\;" "À")
|
|
92 ("Ã\;" "Ã")
|
|
93 ("Ç\;" "Ç")
|
|
94 ("É\;" "É")
|
|
95 ("È\;" "È")
|
|
96 ("Ë\;" "Ë")
|
|
97 ("Í\;" "Í")
|
|
98 ("Î\;" "Î")
|
|
99 ("Ì\;" "Ì")
|
|
100 ("Ï\;" "Ï")
|
|
101 ("Ñ\;" "Ñ")
|
|
102 ("Ó\;" "Ó")
|
|
103 ("Ô\;" "Ô")
|
|
104 ("Ò\;" "Ò")
|
|
105 ("Ø\;" "Ø")
|
|
106 ("Ú\;" "Ú")
|
|
107 ("Ù\;" "Ù")
|
|
108 ("Ý\;" "Ý")
|
|
109 ("á\;" "á")
|
|
110 ("â\;" "â")
|
2
|
111 ("´\;" "´")
|
0
|
112 ("æ\;" "æ")
|
|
113 ("à\;" "à")
|
|
114 ("å\;" "å")
|
|
115 ("ã\;" "ã")
|
2
|
116 ("¦\;" "¦")
|
0
|
117 ("ç\;" "ç")
|
2
|
118 ("¸\;" "¸")
|
|
119 ("¢\;" "¢")
|
|
120 ("©\;" "©")
|
|
121 ("¤\;" "¤")
|
|
122 ("°\;" "°")
|
0
|
123 ("é\;" "é")
|
|
124 ("ê\;" "ê")
|
|
125 ("è\;" "è")
|
|
126 ("ë\;" "ë")
|
2
|
127 ("½\;" "½")
|
|
128 ("¼\;" "¼")
|
|
129 ("¾\;" "¾")
|
0
|
130 ("í\;" "í")
|
|
131 ("î\;" "î")
|
|
132 ("ì\;" "ì")
|
2
|
133 ("¡\;" "¡")
|
|
134 ("¿\;" "¿")
|
0
|
135 ("ï\;" "ï")
|
2
|
136 ("«\;" "«")
|
|
137 ("¯\;" "¯")
|
|
138 ("µ\;" "µ")
|
|
139 ("·\;" "·")
|
|
140 (" \;" " ")
|
|
141 ("¬\;" "¬")
|
0
|
142 ("ñ\;" "ñ")
|
|
143 ("ó\;" "ó")
|
|
144 ("ô\;" "ô")
|
|
145 ("ò\;" "ò")
|
2
|
146 ("ª\;" "ª")
|
|
147 ("º\;" "º")
|
0
|
148 ("ø\;" "ø")
|
|
149 ("õ\;" "õ")
|
2
|
150 ("¶\;" "¶")
|
|
151 ("£\;" "£")
|
|
152 ("±\;" "±")
|
|
153 ("«\;" "»")
|
|
154 ("®\;" "®")
|
|
155 ("§\;" "§")
|
|
156 ("­\;" "")
|
|
157 ("¹\;" "¹")
|
|
158 ("²\;" "²")
|
|
159 ("²\;" "³")
|
0
|
160 ("ú\;" "ú")
|
|
161 ("û\;" "û")
|
|
162 ("ù\;" "ù")
|
2
|
163 ("¨\;" "¨")
|
0
|
164 ("ý\;" "ý")
|
2
|
165 ("¥\;" "¥")
|
0
|
166 ("Ä\;" "Ä")
|
|
167 ("ä\;" "ä")
|
|
168 ("Ö\;" "Ö")
|
|
169 ("ö\;" "ö")
|
|
170 ("Ü\;" "Ü")
|
|
171 ("ü\;" "ü")
|
|
172 ("ß\;" "ß")
|
|
173 ("§\;" "§")
|
|
174 ("¶\;" "¶")
|
|
175 ("©\;" "©")
|
|
176 ("¡\;" "¡")
|
|
177 ("¿\;" "¿")
|
|
178 ("¢\;" "¢")
|
|
179 ("£\;" "£")
|
|
180 ("×\;" "×")
|
|
181 ("±\;" "±")
|
|
182 ("÷\;" "÷")
|
|
183 ("¬\;" "¬")
|
|
184 ("&mu\;" "µ")
|
|
185 ("&Ae\;" "Ä")
|
|
186 ("&ae\;" "ä")
|
|
187 ("&Oe\;" "Ö")
|
|
188 ("&oe\;" "ö")
|
|
189 ("&Ue\;" "Ü")
|
|
190 ("&ue\;" "ü")
|
|
191 ("&sz\;" "ß")
|
|
192 )
|
|
193 "Translation table from SGML entity references to ISO 8859-1 characters.")
|
|
194
|
|
195 (defun fix-sgml2iso ()
|
|
196 "Replace SGML entity references with ISO 8859-1 (aka Latin-1) characters."
|
|
197 (interactive)
|
|
198 (if (member major-mode isosgml-modes-list)
|
|
199 (let ((buffer-modified-p (buffer-modified-p)))
|
|
200 (unwind-protect
|
|
201 (isosgml-translate-conventions sgml2iso-trans-tab)
|
|
202 (set-buffer-modified-p buffer-modified-p)))))
|
|
203
|
|
204 (defvar iso2sgml-trans-tab
|
|
205 (mapcar (function (lambda (entity-char) ; (ENTITY CHAR)
|
|
206 ;; Return (CHAR ENTITY)
|
|
207 (list (car (cdr entity-char))
|
|
208 (car entity-char))))
|
|
209 sgml2iso-trans-tab)
|
|
210 "Translation table from ISO 8859-1 characters to SGML entity references.")
|
|
211
|
|
212 (defun fix-iso2sgml ()
|
|
213 "Replace ISO 8859-1 (aka Latin-1) characters with SGML entity references."
|
|
214 (interactive)
|
|
215 (if (member major-mode isosgml-modes-list)
|
|
216 (let ((buffer-modified-p (buffer-modified-p)))
|
|
217 (unwind-protect
|
|
218 (isosgml-translate-conventions iso2sgml-trans-tab)
|
|
219 (set-buffer-modified-p buffer-modified-p)))))
|
|
220
|
|
221
|
|
222 (add-hook 'find-file-hooks 'fix-sgml2iso)
|
|
223 (add-hook 'write-file-hooks 'fix-iso2sgml)
|
|
224 (add-hook 'after-save-hook 'fix-sgml2iso)
|
|
225
|
|
226 (provide 'iso-sgml)
|
|
227
|
|
228 ;; iso-sgml.el ends here
|
|
229
|
|
230 ; $Log: iso-sgml.el,v $
|
70
|
231 ; Revision 1.1.1.1 1996/12/18 22:43:36 steve
|
|
232 ; XEmacs 20.0 -- Beta 30
|
0
|
233 ;
|
|
234 ; Revision 1.4 1995/05/10 06:19:41 lepied
|
|
235 ; * protect code with unwind-protect to prevent errors
|
|
236 ;
|
|
237 ; Revision 1.3 1994/12/07 09:08:07 lepied
|
|
238 ; Thanks to kevinr@ihs.com (Kevin Rodgers)
|
|
239 ; * replace regular expression search with normal one
|
|
240 ; * cleanup interactive use
|
|
241 ;
|
|
242 ; Revision 1.2 1994/11/24 06:49:08 lepied
|
|
243 ; Integrated patch from kevinr@ihs.com (Kevin Rodgers) :
|
|
244 ;
|
|
245 ; * iso-sgml.el (sgml2iso-trans-tab): Delete backslash (`\') from
|
|
246 ; "±" entity reference.
|
|
247 ;
|
|
248 ; * iso-sgml.el (file header, library header (Keywords), LCD
|
|
249 ; Archive Entry (description) [comment blocks]): Properly refer to
|
|
250 ; SGML entity references; uppercase acronyms (ISO, SGML, HTML);
|
|
251 ; capitalize Latin.
|
|
252 ; (Commentary [comment block]): Rewrite as a complete sentence.
|
|
253 ; (sgml2iso-trans-tab, fix-sgml2iso [doc strings]): Properly refer
|
|
254 ; to SGML entity references.
|
|
255 ; (iso2sgml-trans-tab, fix-iso2sgml [doc strings]): Properly refer
|
|
256 ; to SGML entity references.
|
|
257 ;
|
|
258 ; * iso-sgml.el (iso2sgml-trans-tab): Initialize by
|
|
259 ; programmatically reversing elements of sgml2iso-trans-tab,
|
|
260 ; instead of hand-coding each element.
|
|
261 ;
|
|
262 ; Revision 1.1 1994/06/22 15:15:13 lepied
|
|
263 ; Initial revision
|
|
264 ;
|