comparison lisp/psgml/README.psgml @ 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 This is the READ ME file for psgml.el version 1a9. -*- text -*-
2
3 PSGML is a major mode for editing SGML documents. It works with
4 GNU Emacs 19.19 and later or with Lucid Emacs 19.9.
5
6 This distribution should contain the following source files:
7 psgml.el
8 psgml.texi
9 psgml-other.el
10 psgml-lucid.el
11 psgml-edit.el
12 psgml-parse.el
13 psgml-dtd.el
14 psgml-info.el
15 psgml-charent.el
16 psgml-debug.el -- some functions used in development
17 psgml-api.texi -- internals documentation
18 psgml-api.el -- Extra functions for the API
19 fs.el -- Example use of psgml to format a SGML file
20 style.el -- example style file for fs.el
21 catalog.sgml -- example SGML-file for fs.el and style.el
22 iso88591.map
23
24 In addition the distribution contains the formatted versions of the
25 documentation files (psgml.info, ...). But the compiled elisp code is
26 no longer supplied. You will have to byte compile the files before
27 PSGML will achive usable speed.
28
29 If you are not using Lucid Emacs or XEmacs you should compile:
30 psgml.el
31 psgml-other.el
32 psgml-edit.el
33 psgml-parse.el
34 psgml-dtd.el
35 psgml-info.el
36 psgml-charent.el
37
38 If you on the other hand are using Lucid Emacs or XEmacs you should
39 compile
40 psgml.el
41 psgml-lucid.el
42 psgml-edit.el
43 psgml-parse.el
44 psgml-dtd.el
45 psgml-info.el
46 psgml-charent.el
47
48 Additionally the following can be compiled, they are not normaly used
49 by PSGML:
50 psgml-api.el -- Extra functions for the API
51 fs.el -- Example use of psgml to format a SGML file
52 psgml-debug.el -- some functions used in development
53
54 Send bug reports, comments and suggestions to lenst@lysator.liu.se.
55
56 New in version 1.0a9
57
58 * XEmacs may have problem if sgml-set-face is t
59
60 I tried with the latest version on a sun4 Solaris 2 machine and PSGML
61 would always parse to the end of the buffer even if I typed something.
62 There seem to be a problem with the input-pending-p function. I don't
63 know if this is specific fo Solaris. Emacs on Solaris has problems
64 with signal handling.
65
66
67 * New options for insert-element
68 ** sgml-insert-missing-element-comment
69 ** sgml-insert-end-tag-on-new-line
70
71 * psgml-api:
72 ** sgml-map-content: new optional argument. If the argument ENTITY-FUN
73 is specified it should be a function with one argument. The function
74 will be called for data entity references instead of the entity text
75 beeing passed to the DATA-FUN. The argument is the entity referenced.
76 Use `sgml-entity-name', `sgml-entity-type' etc.
77
78
79 Version 1.0a8 has only bugfixes.
80
81
82 New in version 1.0a7
83
84 * Better CATALOG parsing
85
86 ** Will handle SGMLDECL, etc..
87
88 ** New option: sgml-system-identifiers-are-preferred
89 If nil PSGML will look up external entities by searching the catalogs
90 in `sgml-local-catalogs' and `sgml-catalog-files' and only if the entity
91 is not found in will a given system identifer be used. If the variable
92 is non-nil and a system identifer is given, the system identifier will
93 be used for the entity. If no system identifier is given the catalogs
94 will searched.
95
96 * File names for external entities (e.g system identifiers) are
97 relative to the directory containing the file declaring of the entity.
98
99 * Changes to how the DTD is found
100
101 ** If the variable sgml-doctype is set, it should be the name of a file
102 containing the DOCTYPE declaration to use.
103
104 ** The variable sgml-parent-document is used when the current file
105 is part of a bigger document, and the variable describes how the
106 current files content fits into the element hierarchy. The variable
107 should have the form
108
109 (parent-file context-element* top-element (has-seen-element*)?)
110
111 *** parent-file (string) is the name of the file contatining the
112 document entity.
113
114 *** context-element (string) is used to set up exceptions and short
115 reference map. Good candidates for these elements are the elements
116 open when the entity pointing to the current file is used.
117
118 *** top-element (string) is the top level element in the current file.
119 The file should contain one instance of this element, unless the last
120 (lisp) element of sgml-parent-document is a list. If it is a list, the
121 top level of the file should follow the content model of top-element.
122
123 *** has-seen-element (string) element satisfied in the content model
124 of top-element.
125
126
127 * sgml-validate
128 The variable sgml-validate-command can now be a list of strings. The
129 strings can contain %-sequences that will be expanded:
130 %b to buffer file name,
131 %s to SGML Declaration file, either the value of sgml-declaration
132 variable or SGML Declaration file for parent document or DOCTYPE file or
133 SGMLDECL from catalog.
134 %d value of sgml-doctype.
135
136
137 * Hooks
138
139 ** sgml-new-attribute-list-function
140 This hook is run when a new element is inserted to construct the
141 attribute specification list. The default function prompts for the
142 required attributes.
143
144
145 * API
146
147 ** New file psgml-api.el
148
149 This file contain API-functions that are not used by other parts of
150 psgml. Use (require 'psgml-api) to use the API functions (psgml-api
151 includes the rest of the psgml files).
152
153 The new functions in psgml-api is two functions to travers the element
154 structure.
155
156 *** (sgml-map-content element element-function data-function pi-function)
157
158 Call element-function with every child of element.
159 Call data-function with all the data in element.
160 Don't modify the buffer in these functions.
161
162 *** (sgml-map-element-modify function element)
163
164 Call function on every sub element of element, allows the function to
165 modify the buffer (e.g. add/modify attributes of the elements).
166
167 ** Example of API use: fs.el -- a simple style sheet driven formatter.
168
169 Try fs.el with the catalog.sgml file. The style.el is the style sheet
170 for catalog.sgml. The command to format current buffer is
171 `M-x style-format'.
172
173
174 New in version 1.0 a6
175
176 * Entity manager
177
178 ** Use system id as file name, if there is no %S in sgml-public-map.
179
180 ** Finds PUBLIC entries before DOCTYPE and ENTITY in catalog files.
181
182 * Better error recovery for out of context data and tags
183
184 * New command: sgml-general-dtd-info
185
186 * Disables auto-fill in the prolog
187
188 * Insert element leaves point at the end of the element,
189 it used to leave point at the beginning of the element.
190
191 * sgml-hide-tags/attributes is better at handling minimized tags
192
193 * New options
194 ** sgml-validate-files and slight change of sgml-validate-command.
195 ** sgml-recompile-out-of-date-cdtd
196
197 * Now saving attribute specification list in parse tree
198 Faster sgml-element-attval, but more memory used.
199
200 * Long menus that are split into submenus now show the range of
201 choices in the different submenus.
202
203 The option `sgml-range-indicator-max-length' determines how many
204 characters from the first and the last choice to show.
205
206 * Private abbrev table
207
208
209 New in version 1.0 a5
210
211 * New menu structure
212 Perhaps there is to many top-level menus now. Any suggestions how to
213 organize the menus?
214
215 * Some new functions
216
217 ** Information from the DTD (used to be nefarious.el)
218
219 *** sgml-describe-element-type
220
221 *** sgml-describe-entity
222
223 *** sgml-list-elements
224 Will list all elements and the attributes declared for the element.
225
226 *** sgml-list-attributes
227 Will list all attributes declared and the elements that use them.
228
229 *** sgml-list-terminals
230 Will list all elements that can contain data.
231
232 *** sgml-list-occur-in-elements
233 Will list all element types and where it can occur.
234
235 *** sgml-list-content-elements
236 Will list all element types and the element types that can occur
237 in its content.
238
239
240 ** Translating between characters and entity references
241
242 Set the variable `sgml-display-char-list-filename' to a file file that
243 contains mappings between all characters present in the presentation
244 character set, and their "standard replacement text" names, e.g. "å"
245 -> "[aring ]", e.t.c.
246
247 The default value for this variable is `iso88591.map'.
248
249 The use the functions (also in the Modify menu)
250
251 sgml-charent-to-display-char
252 sgml-display-char-to-charent
253
254 to translate between entities and characters.
255
256
257
258 * Two major bugs fixed
259 ** DTD using undeclared elements was improperly saved
260 ** Bug in using a precompiled DTD and local element, attlist or usemap
261 declaration.
262
263
264
265 New in version 1.0 a4
266
267 * If the document prolog does not contain a document type declaration,
268 PSGML will try to supply one on the form `<!DOCTYPE DocTypeName
269 SYSTEM>' If the variable `sgml-default-doctype-name' is defined this
270 will be used for the document type name, otherwise the GI of the first
271 start tag will be used. I.e., if the document starts with `<book>', a
272 document type declaration `<!DOCTYPE book SYSTEM>' will be assumed.
273
274
275 * Compiled DTDs are now associated with external `Document Type
276 Declaration Subset' entitys. You will have to create a catalog with
277 entries for all the DTDs that should be compiled. This should make
278 it, in most cases, unnecessary to make saved dtds or to set the
279 `sgml-default-dtd-file', at the expense of having to maintain the
280 catalog file.
281
282 ** Options
283
284 `sgml-ecat-files' List of compiled dtd catalog files.
285 Default: ("ECAT" "~/sgml/ECAT" "/usr/local/lib/sgml/ECAT")
286
287 `sgml-local-ecat-files' This can be set as a buffer local variable to
288 a list of catalogs to be searched before `sgml-ecat-files'.
289
290 ** Catalog format
291
292 The catalog is similar to the catalog used to resolve public
293 identifiers. There are two types of entries:
294
295 PUBLIC pubid pents? cfile
296 and
297 FILE file pents? cfile
298
299 where pubid is a public identifier (as a minimum literal), pents is a
300 optional list of parameter entities and values, file is the file name
301 of a DTD file and cfile is the name of the complied DTD. The syntax
302 for pents is
303
304 `[' (name literal)* `]'
305
306 Example:
307
308 PUBLIC "-//lenst//dtd My DTD//en" cdtd/bar
309 FILE "bar.dtd" cdtd/bar
310
311 To better handle DTDs with options, like TEI and HTML 2.0/+ it is
312 possible to have several entries for the same DTD with different
313 parameter entity settings. The parameters are listed between `[' and
314 `]' before the file name of the compiled dtd.
315
316 FILE "~/sgml/htmlplus.dtd"
317 [ HTML.emph "INCLUDE" ] "~/sgml/htmlplus.ced"
318
319 PUBLIC "-//Text Encoding Initiative//DTD
320 P3 3.6.1: Main TEI document type declaration//EN"
321 [ TEI.prose 'INCLUDE' TEI.analysis 'INCLUDE' ] "tei2an.cdtd"
322
323 PUBLIC "-//Text Encoding Initiative//DTD
324 P3 3.6.1: Main TEI document type declaration//EN"
325 [ TEI.prose 'INCLUDE' TEI.verse 'INCLUDE' ] "tei2verse.cdtd"
326
327 The entries will be searched in order and the first matching will be
328 used. Put more specific entries before less specific. Matching is
329 done by matching pubid or file and checking that all the listed
330 parameters are defined with the listed values.
331
332
333
334 ** Example: setting up for editing HTML
335
336 If you have the files for the html.dtd in ~/sgml.
337 Put in ~/sgml/CATALOG:
338 PUBLIC "-//IETF//DTD HTML//EN" html.dtd
339 PUBLIC "-//IETF//DTD HTML//EN//2.0" html.dtd
340 PUBLIC "-//IETF//DTD HTML Level 1//EN//2.0" html-1.dtd
341 PUBLIC "-//IETF//ENTITIES Added Latin 1 for HTML//EN" ISOlat1.sgml
342 DOCTYPE HTML html.dtd
343
344 Put in ~/sgml/ECAT:
345 FILE html.dtd [ HTML.Recommended "INCLUDE" ] cdtd/html-r
346 FILE html.dtd cdtd/html
347
348 Put ~/sgml/CATALOG in sgml-catalog-files and ~/sgml/ECAT in
349 sgml-ecat-files.
350
351 Now it should be possible to edit html files if you put them in
352 sgml-mode. The file must either start with a proper DOCTYPE or with a
353 <html> tag. To be abel to start with empty files and to edit files
354 not starting with <html> you can create a html-mode that sets the
355 default document type name:
356
357 (defun html-mode ()
358 (interactive)
359 (sgml-mode)
360 (make-local-variable 'sgml-declaration)
361 (make-local-variable 'sgml-default-doctype-name)
362 (setq sgml-declaration "~/sgml/html.decl"
363 sgml-default-doctype-name "html"
364 sgml-always-quote-attributes t
365 sgml-indent-step 2
366 sgml-indent-data t
367 sgml-minimize-attributes nil
368 sgml-omittag t
369 sgml-shortag t ))
370
371
372 * Handling of tags for undefined elements
373
374 ** Start-tags for undefined elements will either be ignored, if
375 `sgml-ignore-undefined-elements' is t, or assumed to be acceptabled in
376 the current element and defined with `O O ANY'.
377
378 ** An end-tag for an element that is not currently open will be ignored.
379
380
381 * I have (as an experiment) turned off all warnings. Warnings are only
382 given if the sgml-next-trouble-spot is used or while parsing the DTD.
383
384
385 * Entity manager
386
387 ** sgml-system-path is no longer used for entity lookup
388
389 ** PSGML will recognize that a catalog file has been changed
390
391
392 News in version 1.0 a3
393
394 * Change in user options
395
396 ** sgml-live-element-indicator no longer buffer local
397
398 ** sgml-save-options only saves:
399 (sgml-parent-document sgml-omittag sgml-shorttag
400 sgml-minimize-attributes sgml-always-quote-attributes sgml-indent-step
401 sgml-indent-data sgml-default-dtd-file sgml-exposed-tags)
402 and saves all of them, even if they have no buffer local value
403
404 ** Options menu split in to two menus
405
406 * Cleaned up Markup menu
407 The removed entries can be added with sgml-custom-markup:
408
409 (setq sgml-custom-markup
410 '(
411 ("<!entity ... >" "<!entity \r>\n")
412 ("<!attlist ... >" "<!attlist \r>\n")
413 ("<!element ... >" "<!element \r>\n")
414 ("<!doctype ...>" "<!doctype \r -- public or system --\n[\n]>\n")
415 ("Local variables comment" "<!--\nLocal variables:\n\rEnd:\n-->\n")
416 ("Comment" "<!-- \r -->\n")
417 ))
418
419
420 * Some bug fixes
421 Including new default for sgml-catalog-files is
422 "CATALOG" and "/usr/local/lib/sgml/CATALOG".
423
424 * Some tuning
425
426
427 News in version 1.0 a2
428
429 * Support for short references
430
431 ** Command: sgml-expand-all-shortrefs
432 Expand all short references in the buffer. Short references to text
433 entities are expanded to the replacement text of the entity, other
434 short references are expanded into general entity references. If
435 argument, TO-ENTITY, is non-nil, or if called interactive with numeric
436 prefix argument, all short references are replaced by generaly entity
437 references.
438
439 ** sgml-normalize: expand short references also
440 Normalize buffer by filling in omitted tags and expanding empty tags.
441 Argument TO-ENTITY controls how short references are expanded as with
442 `sgml-expand-all-shortrefs'.
443
444
445 * Variable: sgml-auto-activate-dtd
446
447 PSGML was behaving inconsistent when a new file was loaded. If the
448 variable `sgml-set-face' was true the DTD would automatically be
449 activated (loaded or parsed), but only if psgml-parse already loaded.
450
451 Rather than let `sgml-set-face' decide if the DTD is activated, there
452 is now a distinct option for this. This option works even the first
453 time.
454
455 If non-nil, loading a sgml-file will automatically try to activate its DTD.
456 Activation means either to parse the document type declaration or to
457 load a previously saved parsed DTD. The name of the activated DTD
458 will be shown in the mode line.
459
460
461 * face setting
462 If `sgml-set-face' is true and the DTD has been activated, PSGML will
463 automatically set the face of markup in the buffer. This is done by
464 parsing, with error messages turned off, as much as possible after
465 every command. The parsing is interrupted by input and is almost
466 transparent.
467
468 * Local catalog files
469 Variabel `sgml-local-catalogs'
470 A list of SGML entity catalogs to be searched first when parsing the buffer.
471 This is used in addtion to `sgml-catalog-files', and `sgml-public-map'.
472 This variable is automatically local to the buffer.
473
474 * New commands
475 Thanks to David Megginson the custom menus are now reacable from the
476 keyboard:
477 ** C-c C-u C-d (sgml-custom-dtd)
478 ** C-c C-u C-m (sgml-custom-markup)
479
480 * New command: sgml-expand-entity-reference
481 Insert the text of the entity referenced at point.
482
483 * sgml-validate-command is now a format string
484
485
486 News in version 1.0 a1
487
488 * A lot of internal changes
489
490 * Support for general entities
491
492 * New entity manager
493
494 The new entity manager will handle an entity thus:
495
496 1. If the entity has a system identifier, the entity manager will
497 first try and call the functions on sgml-sysid-resolve-functions
498 with the system identifier as argument, and if any function returns
499 non-nil assume that the function has handled the entity.
500 2. Next the entity manager will try the catalogue, and
501 3. if not found there use the sgml-public-map.
502
503 The catalogue files searched is given by the variable
504 sgml-catalog-files (I suppose it would be confusing to call it
505 sgml-catalogue-files.) This variable is initialised from the
506 environment variable SGML_CATALOG_FILES (should be a colon separated
507 list of files).
508
509 The sgml-public-map is initialised from the environment variable
510 SGML_PATH.
511
512 sgml-system-path defaults to nil.
513
514 Supports most of sgmls substitutions for sgml-public-map.
515 Supported: %%, %N, %P, %S, %Y, %C, %L, %O, %T, %V
516 Unsupported: %D, %X, %A, %E, %I, %R, %U
517 Note: that %D is and alias for %C in PSGML (historical accident).
518
519
520 * Hooks
521
522 ** sgml-close-element-hook
523 The hook run by `sgml-close-element'.
524 These functions are invoked with `sgml-current-tree' bound to the
525 element just parsed.
526
527 ** sgml-doctype-parsed-hook
528 This hook is called after the doctype has been parsed.
529 It can be used to load any additional information into the DTD structure.
530
531 Example: add description to element types
532 (defun set-help-info ()
533 (let ((help '(("para" "A Paragraph")
534 ("q" "A Quotation")
535 ("date" "A Date")))
536 (dtd (sgml-pstate-dtd sgml-buffer-parse-state)))
537 (loop for h in help do
538 (setf (sgml-eltype-appdata (sgml-lookup-eltype (first h) dtd)
539 'help-string)
540 (second h)))))
541 (add-hook 'sgml-doctype-parsed-hook 'set-help-info)
542
543 (defun sgml-help-for-element ()
544 (interactive)
545 (let* ((el (sgml-find-element-of (point)))
546 (help (sgml-element-appdata el 'help-string)))
547 (and help
548 (message "%s" help))))
549
550
551 ** sgml-sysid-resolve-functions
552 This variable should contain a list of functions.
553 Each function should take one argument, the system identifier of an entity.
554 If the function can handle that identifier, it should insert the text
555 of the entity into the current buffer at point and return t. If the
556 system identifier is not handled the function should return nil.
557
558 Example use: Support URLs as system identifiers
559 (defun sgml-url-sysid (sysid)
560 (cond ((string-match "^\\([a-z]+\\):" sysid) ; looks like url
561 (require 'url)
562 (set-buffer (prog1 (current-buffer)
563 (url-retrieve sysid)))
564 (insert-buffer url-working-buffer)
565 t)))
566 (add-hook 'sgml-sysid-resolve-functions 'sgml-url-sysid)
567
568
569 * sgml-set-face Now automatically sets faces for all visible text,
570 with a delay of 1s.
571
572 * sgml-exposed-tags
573 The list of tag names that remain visible, despite M-x sgml-hide-tags.
574 Each name is a lowercase string, and start-tags and end-tags must be
575 listed individually.
576
577 `sgml-exposed-tags' is local to each buffer in which it has been set;
578 use `setq-default' to set it to a value that is shared among buffers.