Mercurial > hg > xemacs-beta
comparison lisp/psgml/iso-sgml.el @ 0:376386a54a3c r19-14
Import from CVS: tag r19-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:45:50 +0200 |
parents | |
children | ac2d302a0011 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:376386a54a3c |
---|---|
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 | |
19 ;; $Id: iso-sgml.el,v 1.1.1.1 1996/12/18 03:35:17 steve Exp $ | |
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. | |
40 | |
41 ;; SEE ALSO: | |
42 ;; iso-cvt.el | |
43 ;; If you are interested in questions related to using the ISO 8859-1 | |
44 ;; characters set (configuring emacs, Unix, etc. to use ISO), then you | |
45 ;; can get the ISO 8859-1 FAQ via anonymous ftp from | |
46 ;; ftp.vlsivie.tuwien.ac.at in /pub/bit/FAQ-ISO-8859-1 | |
47 | |
48 ;; INSTALLATION: | |
49 ;; add the following line to your .emacs : | |
50 ;; (load "iso-sgml") | |
51 ;; If you want it to work with other modes change the value of the | |
52 ;; the variable isosgml-modes-list like this : | |
53 ;; (setq isosgml-modes-list '(my-mode)) | |
54 | |
55 ;; Code: | |
56 | |
57 (defconst isosgml-version "$Id: iso-sgml.el,v 1.1.1.1 1996/12/18 03:35:17 steve Exp $" | |
58 "iso-sgml RCS version number") | |
59 | |
60 (defvar isosgml-modes-list '(html-mode html-helper-mode sgml-mode) | |
61 "*List of modes to translate between SGML or HTML entity references | |
62 and the ISO 8859-1 character set.") | |
63 | |
64 | |
65 (defun isosgml-translate-conventions (trans-tab) | |
66 "Use the translation table argument to translate the current buffer." | |
67 (save-excursion | |
68 (let ((beg (point-min-marker)) ; see the `(elisp)Narrowing' Info node | |
69 (end (point-max-marker))) | |
70 (unwind-protect | |
71 (progn | |
72 (widen) | |
73 (goto-char (point-min)) | |
74 (let ((buffer-read-only nil) ; (inhibit-read-only t)? | |
75 (case-fold-search nil)) | |
76 (while trans-tab | |
77 (save-excursion | |
78 (let ((trans-this (car trans-tab))) | |
79 (while (search-forward (car trans-this) nil t) | |
80 (replace-match (car (cdr trans-this)) t t))) | |
81 (setq trans-tab (cdr trans-tab)))))) | |
82 (narrow-to-region beg end))))) | |
83 | |
84 (defvar sgml2iso-trans-tab | |
85 '( | |
86 ("Æ\;" "Æ") | |
87 ("Á\;" "Á") | |
88 ("Â\;" "Â") | |
89 ("À\;" "À") | |
90 ("Ã\;" "Ã") | |
91 ("Ç\;" "Ç") | |
92 ("É\;" "É") | |
93 ("È\;" "È") | |
94 ("Ë\;" "Ë") | |
95 ("Í\;" "Í") | |
96 ("Î\;" "Î") | |
97 ("Ì\;" "Ì") | |
98 ("Ï\;" "Ï") | |
99 ("Ñ\;" "Ñ") | |
100 ("Ó\;" "Ó") | |
101 ("Ô\;" "Ô") | |
102 ("Ò\;" "Ò") | |
103 ("Ø\;" "Ø") | |
104 ("Ú\;" "Ú") | |
105 ("Ù\;" "Ù") | |
106 ("Ý\;" "Ý") | |
107 ("á\;" "á") | |
108 ("â\;" "â") | |
109 ("æ\;" "æ") | |
110 ("à\;" "à") | |
111 ("å\;" "å") | |
112 ("ã\;" "ã") | |
113 ("ç\;" "ç") | |
114 ("é\;" "é") | |
115 ("ê\;" "ê") | |
116 ("è\;" "è") | |
117 ("ë\;" "ë") | |
118 ("í\;" "í") | |
119 ("î\;" "î") | |
120 ("ì\;" "ì") | |
121 ("ï\;" "ï") | |
122 ("ñ\;" "ñ") | |
123 ("ó\;" "ó") | |
124 ("ô\;" "ô") | |
125 ("ò\;" "ò") | |
126 ("ø\;" "ø") | |
127 ("õ\;" "õ") | |
128 ("ú\;" "ú") | |
129 ("û\;" "û") | |
130 ("ù\;" "ù") | |
131 ("ý\;" "ý") | |
132 ("Ä\;" "Ä") | |
133 ("ä\;" "ä") | |
134 ("Ö\;" "Ö") | |
135 ("ö\;" "ö") | |
136 ("Ü\;" "Ü") | |
137 ("ü\;" "ü") | |
138 ("ß\;" "ß") | |
139 ("§\;" "§") | |
140 ("¶\;" "¶") | |
141 ("©\;" "©") | |
142 ("¡\;" "¡") | |
143 ("¿\;" "¿") | |
144 ("¢\;" "¢") | |
145 ("£\;" "£") | |
146 ("×\;" "×") | |
147 ("±\;" "±") | |
148 ("÷\;" "÷") | |
149 ("¬\;" "¬") | |
150 ("&mu\;" "µ") | |
151 ("&Ae\;" "Ä") | |
152 ("&ae\;" "ä") | |
153 ("&Oe\;" "Ö") | |
154 ("&oe\;" "ö") | |
155 ("&Ue\;" "Ü") | |
156 ("&ue\;" "ü") | |
157 ("&sz\;" "ß") | |
158 ) | |
159 "Translation table from SGML entity references to ISO 8859-1 characters.") | |
160 | |
161 (defun fix-sgml2iso () | |
162 "Replace SGML entity references with ISO 8859-1 (aka Latin-1) characters." | |
163 (interactive) | |
164 (if (member major-mode isosgml-modes-list) | |
165 (let ((buffer-modified-p (buffer-modified-p))) | |
166 (unwind-protect | |
167 (isosgml-translate-conventions sgml2iso-trans-tab) | |
168 (set-buffer-modified-p buffer-modified-p))))) | |
169 | |
170 (defvar iso2sgml-trans-tab | |
171 (mapcar (function (lambda (entity-char) ; (ENTITY CHAR) | |
172 ;; Return (CHAR ENTITY) | |
173 (list (car (cdr entity-char)) | |
174 (car entity-char)))) | |
175 sgml2iso-trans-tab) | |
176 "Translation table from ISO 8859-1 characters to SGML entity references.") | |
177 | |
178 (defun fix-iso2sgml () | |
179 "Replace ISO 8859-1 (aka Latin-1) characters with SGML entity references." | |
180 (interactive) | |
181 (if (member major-mode isosgml-modes-list) | |
182 (let ((buffer-modified-p (buffer-modified-p))) | |
183 (unwind-protect | |
184 (isosgml-translate-conventions iso2sgml-trans-tab) | |
185 (set-buffer-modified-p buffer-modified-p))))) | |
186 | |
187 | |
188 (add-hook 'find-file-hooks 'fix-sgml2iso) | |
189 (add-hook 'write-file-hooks 'fix-iso2sgml) | |
190 (add-hook 'after-save-hook 'fix-sgml2iso) | |
191 | |
192 (provide 'iso-sgml) | |
193 | |
194 ;; iso-sgml.el ends here | |
195 | |
196 ; $Log: iso-sgml.el,v $ | |
197 ; Revision 1.1.1.1 1996/12/18 03:35:17 steve | |
198 ; XEmacs 19.14 -- Release | |
199 ; | |
200 ; Revision 1.4 1995/05/10 06:19:41 lepied | |
201 ; * protect code with unwind-protect to prevent errors | |
202 ; | |
203 ; Revision 1.3 1994/12/07 09:08:07 lepied | |
204 ; Thanks to kevinr@ihs.com (Kevin Rodgers) | |
205 ; * replace regular expression search with normal one | |
206 ; * cleanup interactive use | |
207 ; | |
208 ; Revision 1.2 1994/11/24 06:49:08 lepied | |
209 ; Integrated patch from kevinr@ihs.com (Kevin Rodgers) : | |
210 ; | |
211 ; * iso-sgml.el (sgml2iso-trans-tab): Delete backslash (`\') from | |
212 ; "±" entity reference. | |
213 ; | |
214 ; * iso-sgml.el (file header, library header (Keywords), LCD | |
215 ; Archive Entry (description) [comment blocks]): Properly refer to | |
216 ; SGML entity references; uppercase acronyms (ISO, SGML, HTML); | |
217 ; capitalize Latin. | |
218 ; (Commentary [comment block]): Rewrite as a complete sentence. | |
219 ; (sgml2iso-trans-tab, fix-sgml2iso [doc strings]): Properly refer | |
220 ; to SGML entity references. | |
221 ; (iso2sgml-trans-tab, fix-iso2sgml [doc strings]): Properly refer | |
222 ; to SGML entity references. | |
223 ; | |
224 ; * iso-sgml.el (iso2sgml-trans-tab): Initialize by | |
225 ; programmatically reversing elements of sgml2iso-trans-tab, | |
226 ; instead of hand-coding each element. | |
227 ; | |
228 ; Revision 1.1 1994/06/22 15:15:13 lepied | |
229 ; Initial revision | |
230 ; |