comparison man/psgml.texi @ 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 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename ../info/psgml.info
4 @settitle psgml
5 @c @setchapternewpage odd
6 @syncodeindex fn cp
7 @syncodeindex vr cp
8 @synindex ky cp
9 @c %**end of header
10 @c $Id: psgml.texi,v 1.1.1.1 1996/12/18 03:36:10 steve Exp $
11
12 @ifinfo
13 Documentation for PSGML, a major mode for SGML.
14
15 Copyright 1994 Lennart Staflin
16
17 Permission is granted to make and distribute verbatim
18 copies of this manual provided the copyright notice and
19 this permission notice are preserved on all copies.
20
21 @ignore
22 Permission is granted to process this file through TeX
23 and print the results, provided the printed document
24 carries a copying permission notice identical to this
25 one except for the removal of this paragraph (this
26 paragraph not being relevant to the printed manual).
27
28 @end ignore
29 Permission is granted to copy and distribute modified
30 versions of this manual under the conditions for
31 verbatim copying, and provided that the entire
32 resulting derived work is distributed under the terms
33 of a permission notice identical to this one.
34
35 Permission is granted to copy and distribute
36 translations of this manual into another language,
37 under the above conditions for modified versions,
38 except that this permission notice may be stated in a
39 translation approved by the Free Software Foundation.
40
41 @end ifinfo
42
43 @titlepage
44
45 @title Editing SGML with Emacs and PSGML
46 @author Lennart Staflin
47
48 @c The following two commands
49 @c start the copyright page.
50 @page
51 @vskip 0pt plus 1filll
52 Copyright @copyright{} 1994 Lennart Staflin
53
54 @c Published by ...
55
56 Permission is granted to make and distribute verbatim
57 copies of this manual provided the copyright notice and
58 this permission notice are preserved on all copies.
59
60 @ignore
61 Permission is granted to process this file through TeX
62 and print the results, provided the printed document
63 carries a copying permission notice identical to this
64 one except for the removal of this paragraph (this
65 paragraph not being relevant to the printed manual).
66
67 @end ignore
68 Permission is granted to copy and distribute modified
69 versions of this manual under the conditions for
70 verbatim copying, and provided that the entire
71 resulting derived work is distributed under the terms
72 of a permission notice identical to this one.
73
74 Permission is granted to copy and distribute
75 translations of this manual into another language,
76 under the above conditions for modified versions,
77 except that this permission notice may be stated in a
78 translation approved by the Free Software Foundation.
79 @end titlepage
80
81 @node Top, Introduction, (dir), (dir)
82 @comment node-name, next, previous, up
83 @ifinfo
84 @top PSGML
85
86 PSGML is a major mode for editing SGML documents, with special
87 additions for HTML. This is the DRAFT documentation for PSGML
88 version 1.0.
89 @end ifinfo
90
91 @menu
92 * Introduction:: Introduction
93 * Install:: How to install PSGML
94 * Invoke:: How to invoke PSGML
95 * Entity manager:: The Entity Manager
96 * Validate:: Running an external SGML parser
97 * SGML declaration:: Using an SGML declaration
98 * Managing the DTD:: Specifying what DTD to use
99 * Edit:: Commands for editing
100 * Display:: Appearance of text in the buffer
101 * Bugs:: Reporting bugs
102 * Index::
103 @end menu
104
105 @c ------------------------------------------------------------------
106
107 @node Introduction, Install, Top, Top
108 @comment node-name, next, previous, up
109 @chapter Introduction
110 @cindex CONCUR
111 @cindex DATATAG
112 @cindex LINK
113 @cindex RANK
114 @cindex SGML Declaration
115
116 PSGML is a major mode for editing SGML documents, and includes a number
117 of features for working specifically with HTML. It works with GNU Emacs
118 19.19 and later or with Lucid Emacs 19.9 and later. PSGML contains a
119 simple SGML parser and can work with any DTD. Functions provided
120 includes menus and commands for inserting tags with only the
121 contextually valid tags, identification of structural errors, editing of
122 attribute values in a separate window with information about types and
123 defaults, and structure based editing.
124
125 SGML, a language for encoding the structure of a document, is an ISO
126 standard: ISO 8879:1986 ``Information processing -- Text and office
127 systems -- Standard Generalized Markup Language (SGML)''.
128
129 A good introduction to SGML is @cite{A Gentle Introduction to SGML}
130 produced by Text Encoding Initiative (this is really chapter 2 of TEI
131 P3). This can be found on
132 @file{ftp://ftp.ifi.uio.no/pub/SGML/TEI/P3SG.DOC}.
133
134 A SGML document has three major parts, in order:
135
136 @enumerate
137 @item
138 SGML Declaration (@samp{<!SGML "ISO 8879:1986" @dots{} >})
139 @item
140 Document Type Declaration (@samp{<!DOCTYPE @var{name} @dots{} >})
141 @item
142 Document Element (@samp{<@var{name}> @dots{} </@var{name}>})
143 @end enumerate
144
145 The SGML declaration contains general information about character sets,
146 concrete syntax, and SGML features used. PSGML does not use the SGML
147 Declaration, it can be left out, and if included is ignored. Many SGML
148 systems allow the SGML declaration to be defaulted. PSGML always use
149 the Concrete Reference Syntax but without limitations on
150 lengths. Features used has to be indicated with variables (@pxref{SGML
151 declaration}).
152
153 The document type declaration specifies the valid elements and entities
154 and how they can be nested. A document type is usually needed, but can
155 reside in another file (@pxref{Managing the DTD}).
156
157 The system declaration for PSGML:
158 @format
159 SYSTEM "ISO 8879:1986"
160 CHARSET
161 BASESET "ISO 646-1983//CHARSET
162 International Reference Version (IRV)//ESC 2/5 4/0"
163 DESCSET 0 128 0
164 CAPACITY PUBLIC "ISO 8879:1986//CAPACITY Reference//EN"
165 FEATURES
166 MINIMIZE DATATAG NO OMITTAG YES RANK NO SHORTTAG YES
167 LINK SIMPLE NO IMPLICIT NO EXPLICIT NO
168 OTHER CONCUR NO SUBDOC YES 1 FORMAL YES
169 SCOPE DOCUMENT
170 SYNTAX PUBLIC "ISO 8879:1986//SYNTAX Reference//EN"
171 @c SYNTAX PUBLIC "ISO 8879:1986//SYNTAX Core//EN"
172 VALIDATE
173 GENERAL NO MODEL NO EXCLUDE NO CAPACITY NO
174 NONSGML NO SGML NO FORMAL NO
175 SDIF PACK NO UNPACK NO
176 @end format
177
178
179 @c -------------------------------------------------------------------------
180 @node Install, Invoke, Introduction, Top
181 @comment node-name, next, previous, up
182 @chapter Installing PSGML
183
184 Place the @file{*.el} and the @file{*.elc} files in a directory where
185 Emacs can find it (i.e. one of the directories in the @code{load-path}
186 variable, you can add a directory to this variable in your
187 @file{.emacs}.) If you obtained PSGML without @file{*.elc} files, you
188 can create them by letting Emacs byte compile the @file{*.el} files (use
189 @kbd{M-x byte-compile-file}). Parsing SGML in Emacs Lisp is slow and
190 needs all the speed it can get.
191
192 Put the following line in your .emacs:
193
194 @lisp
195 (autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t )
196 @end lisp
197
198 You may also want to set up search paths for external entities,
199 @xref{Entity manager}.
200
201 The @file{psgml.info} is the documentation for PSGML in the info format.
202 You can read this with the Emacs command @kbd{C-u C-h i}. You can also
203 install the file in your systems info directory and edit the
204 @file{dir} file to include @file{psgml.info} in the menu.
205
206 The info file @file{psgml.info} is created from the texinfo file
207 @file{psgml.texi}. The texinfo file can also be used to create a hard
208 copy of the documentation. To do this you need the @TeX{} program and a
209 copy of @file{texinfo.tex}.
210
211
212
213
214 @c --------------------------------------------------------------------------
215 @node Invoke, Entity manager, Install, Top
216 @comment node-name, next, previous, up
217 @chapter How to invoke PSGML
218 @cindex invoke
219 @cindex start up
220 @cindex major mode
221
222 @findex sgml-mode
223 PSGML defines a major mode called @code{sgml-mode}. Files with
224 extensions @file{.sgml}, @file{.sgm} or @file{.dtd} will
225 automatically be edited in SGML mode. To edit some other file in
226 sgml mode, type @kbd{M-x sgml-mode @key{RET}} after finding the
227 file.
228
229 If you can modify the file you can add a @dfn{Local Variables} list
230 (@pxref{file variables, , Local Variables in Files, emacs, The Emacs
231 Editor}) to the end of the file. This can make Emacs
232 automatically set sgml mode and user options when the file is loaded.
233 The simplest Local Variables list would look like:
234
235 @example
236 <!--
237 Local Variables:
238 mode: sgml
239 End:
240 -->
241 @end example
242
243 You can also put a line at the top of the file to tell emacs to use sgml
244 mode:
245
246 @example
247 <!-- -*- sgml -*- -->
248 @end example
249
250 But remember that you can't have a comment before the @emph{SGML
251 declaration}.
252
253
254 @c -------------------------------------------------------------------------
255 @node Entity manager, Validate, Invoke, Top
256 @comment node-name, next, previous, up
257 @chapter The Entity Manager
258 @cindex public identifier
259 @cindex system identifier
260 @cindex external identifier
261
262 SGML can refer to an external file (really entity) with an
263 @emph{external identifier}, this is a @emph{public identifier} or a
264 @emph{system identifier}.
265
266 A typical public identifier looks like
267
268 @example
269 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN"
270 @end example
271
272 @noindent
273 where ``ISO 8879:1986'' is the owner, ``ENTITIES'' is the text class and
274 ``Added Latin 1'' is the text description (and ``EN'' is language).
275
276 A system identifier looks like
277
278 @example
279 SYSTEM "htmlplus.dtd"
280 @end example
281
282 @noindent where ``htmlplus.dtd'' is a system-specific identifier.
283
284 To map external identifiers to file names, PSGML first searches entity
285 catalog files and then search the list of file name templates in the
286 variable @code{sgml-public-map}.
287
288 *** Describe the catalog format
289
290 The catalog format is according to SGML/Opens resoution on entity
291 management. The catalog consists of a series of entries and comment. A
292 comment is delimited by @samp{--} like in a markup declaration.
293 The entry types recognized are described in the following table.
294
295 @table @samp
296
297 @item PUBLIC @var{pubid} @var{file}
298 The @var{file} will be used for the entity text of an entity
299 with the public identifier @var{pubid}.
300
301 @item ENTITY @var{name} @var{file}
302 The @var{file} will be used for the entity text of an entity
303 with the name @var{name}. If the @var{name} starts with a @samp{%} the
304 rest of the name will be matched against parameter entities.
305
306 @item DOCTYPE @var{name} @var{file}
307 The DOCTYPE keyword indicates that an entity manager should use the
308 associated |storage object identifier| to locate the entity text
309 (to be used as the external subset) for a doctype declaration whose
310 document type name is specified by the |entity name spec|.
311
312 @item SGMLDECL @var{file}
313 The SGMLDECL keyword indicates that an entity manager should use
314 the associated |storage object identifier| to locate the entity
315 text to be used as the SGML declaration.
316
317 @end table
318
319 The @code{sgml-public-map} variable can contain a list of file name
320 templates where @samp{%P} will be substituted with the whole public
321 identifier, owner is substituted for @samp{%O}, public text class for
322 @samp{%C}, and public text description for @samp{%D}. The text class
323 will be converted to lower case and the owner and description will be
324 transliterated according to the variable
325 @code{sgml-public-transliterations}. The templates in the list is tried
326 in order until an existing file is found.
327
328 Given the public identifier above and the file name template
329 @samp{/usr/local/lib/sgml/%o/%c/%d}, the resulting file name is
330
331 @example
332 /usr/local/lib/sgml/ISO_8879:1986/entities/Added_Latin_1
333 @end example
334
335 Note: blanks are transliterated to @samp{_} (and also @samp{/} to
336 @samp{%}) and the text class is down cased.
337
338
339
340 @defopt sgml-catalog-files
341 This is a list of catalog entry files.
342 The files are in the format defined in the SGML Open Draft Technical
343 Resolution on Entity Management. The Emacs variable is initialized from
344 the environment variable @code{SGML_CATALOG_FILES} or if this variable
345 is undefined the default is
346
347 @lisp
348 ("CATALOG" "/usr/local/lib/sgml/CATALOG")
349 @end lisp
350 @end defopt
351
352 @defopt sgml-local-catalogs
353 A list of SGML entity catalogs to be searched first when parsing the
354 buffer. This is used in addition to @code{sgml-catalog-files}, and
355 @code{sgml-public-map}. This variable is automatically local to the
356 buffer.
357 @end defopt
358
359 @defopt sgml-public-map
360 This should be a list of file name templates. This variable is
361 initialized from the environment variable @code{SGML_PATH}. This is
362 the same environment variable that @file{sgmls} uses. If the
363 environment variable is undefined the default is
364
365 @lisp
366 ("%S" "/usr/local/lib/sgml/%o/%c/%d")
367 @end lisp
368 @c Mapping from public identifiers to file names.
369 @end defopt
370
371 @c the colon separated list in @code{SGML_PATH} is converted to a lisp list
372
373 @c -------------------------------------------------------------------------
374 @node Validate, SGML declaration, Entity manager, Top
375 @comment node-name, next, previous, up
376 @chapter Running an external SGML parser
377
378 @kindex C-c C-v
379 @findex sgml-validate
380 PSGML can not validate an SGML document (see below what it can and can't
381 do). If you have a validating SGML parser, like @file{sgmls}, you can
382 run the parser on your file with the command @kbd{C-c C-v}
383 (@code{sgml-validate}).
384
385 Some variables control this function:
386
387 @defopt sgml-validate-command
388 The shell command to validate an SGML document.
389
390 This is a @code{format} control string that by default should contain
391 two `%s' conversion specifications: the first will be replaced by the
392 value of @code{sgml-declaration} (or the empty string, if nil); the
393 second will be replaced by the current buffer's file name (or the empty
394 string, if nil).
395
396 If @code{sgml-validate-files} is non-nil, the format string should
397 contain one `%s' conversion specification for each element of its
398 result.
399
400 The default value is @code{sgml -s %s %s}.
401 @end defopt
402
403 @defopt sgml-validate-files
404 If non-nil, a function of no arguments that returns a list of file
405 names. These file names will serve as the arguments to the
406 @code{sgml-validate-command} format control string instead of the
407 defaults.
408 @end defopt
409
410 @defopt sgml-declaration
411 The name of the SGML declaration file.
412 @end defopt
413
414 @defopt sgml-offer-save
415 If non-nil, @kbd{C-c C-v} (@code{sgml-validate}) will ask about saving
416 modified buffers before running the validate command. The default value
417 is @code{t}.
418 @end defopt
419
420
421 @kindex C-c C-o
422 @findex sgml-next-trouble-spot
423 The built-in parser can find some markup errors. The command @kbd{C-c
424 C-o} (@code{sgml-next-trouble-spot}) is the best way to use the built-in
425 parser for this. To check the whole file go to the beginning of the
426 buffer and use @kbd{C-c C-o}.
427
428 Some of the markup errors not found are:
429
430 @itemize @bullet
431 @item
432 Errors in the SGML declaration.
433 @item
434 Errors in attribute specifications.
435 @item
436 Markup errors in entity replacement text.
437 @item
438 Omitted start-tags for empty elements.
439 @end itemize
440
441
442 @node SGML declaration, Managing the DTD, Validate, Top
443 @comment node-name, next, previous, up
444 @chapter SGML Declaration
445 @cindex SHORTTAG
446 @cindex OMITTAG
447
448 PSGML does not understand the SGML declaration, it accepts one in the
449 file but it is ignored. If you have the SGML declaration in another
450 file you can make @file{sgmls} use it when you use the @kbd{C-c C-v}
451 (@code{sgml-validate}) command (@pxref{Validate}).
452
453 PSGML has some options in what features it uses and what markup it
454 creates. You have to set these options to make PSGML's behavior
455 consistent with your SGML declaration and personal preferences.
456
457 @defopt sgml-omittag
458 Set this to @code{t} if the SGML declaration has @samp{OMITTAG YES} and
459 to @code{nil} otherwise.
460 @end defopt
461
462 @defopt sgml-shorttag
463 Set this to @code{t} if the SGML declaration has @samp{SHORTTAG YES} and
464 to @code{nil} otherwise.
465 @end defopt
466
467 @defopt sgml-always-quote-attributes
468 If non-nil, quote all attribute values inserted after finishing edit
469 attributes. If this variable is @code{nil} and @code{sgml-shorttag} is
470 non-@code{nil}, attribute values that consists of only name characters
471 will not be quoted.
472 @end defopt
473
474 @defopt sgml-minimize-attributes
475 Determines minimization of attributes inserted by edit-attributes. If
476 non-nil, omit attribute name if the attribute value is from a token
477 group. If @code{max}, omit attributes with default value. Minimization
478 will only be done if they produce legal SGML (assuming
479 @code{sgml-omittag} and @code{sgml-shorttag} are set correctly).
480 @end defopt
481
482
483 @c --------------------------------------------------------------------------
484 @node Managing the DTD, Edit, SGML declaration, Top
485 @comment node-name, next, previous, up
486 @chapter Document Type Declaration
487 @cindex DOCTYPE
488
489 @findex sgml-parse-prolog
490 PSGML needs to know about the DTD you are using for many of its commands.
491 You can use PSGML without specifying a DTD, it will then accept any tags
492 and assume a content model of @code{ANY} with no omissible tags.
493
494 If you have a @samp{DOCTYPE} declaration in your file, PSGML will try to
495 parse this. Either the first time you do something that needs to parse
496 the document or with the command @code{sgml-parse-prolog}. Big DTDs
497 take some time to parse.
498
499 @vindex sgml-system-path
500 @vindex sgml-default-dtd-file
501 @vindex sgml-parent-document
502 You can have the @samp{DOCTYPE} declaration in another file either by
503 setting @code{sgml-parent-document} to the other file or by creating a
504 saved DTD and setting @code{sgml-default-dtd-file} to that file. If
505 @code{sgml-default-dtd-file} contains a relative file name, the
506 directories in @code{sgml-system-path} will be searched for the file.
507
508
509 @findex sgml-save-dtd
510 @findex sgml-load-dtd
511 If parsing the DTD takes too long time you can save the parsed DTD in a
512 file using the command @kbd{M-x sgml-save-dtd}. Next time PSGML can
513 load that file instead of parsing the DTD. For PSGML to find the saved
514 DTD you must either save the DTD using the default name or do a @kbd{M-x
515 sgml-save-options} after saving the DTD. To directly use an already
516 parsed and saved DTD, load the file containing the saved DTD with the
517 command @kbd{M-x sgml-load-dtd}.
518
519 When the DTD has been parsed or loaded the name of the document element
520 will be displayed in the mode line inside brackets. If there was an
521 error parsing the DTD or there is no DTD, the mode line will display
522 @samp{[ANY]}.
523
524 @defopt sgml-default-dtd-file
525 This is the default file name for saved DTD. This is set by
526 @code{sgml-mode} to the buffer file name less extension plus the
527 extension @code{.ced}, if that file exists. Can be changed in the Local
528 variables section of the file.
529 @end defopt
530
531 @defopt sgml-parent-document
532 This can be set to the name (a string) of a file containing the
533 @samp{DOCTYPE} declaration to use, or a list @code{(@var{filename}
534 @var{doctypename})}, where @var{filename} is the name of a file
535 containing the @samp{DOCTYPE} declaration to use, with the modification
536 that the document type name is @var{doctypename}.
537 @end defopt
538
539 If you change the doctype you must execute @code{sgml-parse-prolog},
540 changes in the doctype are not automatically recognized.
541
542 @defopt sgml-custom-dtd
543 Menu entries to be added to the DTD menu. The value should be a list of
544 entries to be added to the DTD menu.
545
546 Every entry should be a list. The first element of the entry is a string
547 used as the menu entry. The second element is a string containing a
548 doctype declaration (this can be nil if no doctype). The rest of the
549 list should be a list of variables and values. For backward
550 compatibility a single string instead of a variable is assigned to
551 @code{sgml-default-dtd-file}. All variables are made buffer local and
552 are also added to the buffers local variables list.
553
554 When an entry is selected from the DTD menu, the doctype declaration will
555 be inserted, the variables will be set to the values in the entry and a
556 local variables list will be created in the buffer.
557
558 Example:
559
560 @example
561 (("HTML" nil
562 sgml-default-dtd-file "~/sgml/html.ced"
563 sgml-omittag nil sgml-shorttag nil)
564 ("HTML+" "<!doctype htmlplus system 'htmlplus.dtd'>"
565 "~/sgml/htmlplus.ced"
566 sgml-omittag t sgml-shorttag nil)
567 ("DOCBOOK" "<!doctype docbook system 'docbook.dtd'>"
568 "~/sgml/docbook.ced"
569 sgml-omittag nil sgml-shorttag t)))
570 @end example
571 @end defopt
572
573 @c ---------------------------------------------------------------------------
574 @node Edit, Display, Managing the DTD, Top
575 @comment node-name, next, previous, up
576 @chapter Commands for editing
577
578 @menu
579 * Insert:: Inserting Markup
580 * Complete:: Markup completion
581 * Information:: Showing information
582 * Indent:: Indentation according to structure
583 * Move:: Move in the element structure
584 * Attributes:: Editing attributes
585 * Change and delete:: Changing and deleting markup
586 @end menu
587
588 @c ------------------------------------------------------------------
589 @node Insert, Complete, Edit, Edit
590 @comment node-name, next, previous, up
591 @section Inserting Markup
592
593 @c erik says "inserts" ??
594 The commands that insert start-tags works only if the document has an
595 associated DTD.
596
597 Keyboard commands for inserting:
598
599 @table @kbd
600 @kindex C-c <
601 @findex sgml-insert-tag
602 @item C-c <
603 Will ask, for the tag to insert, in the mini-buffer with completion on the
604 tags that are valid at point (@code{sgml-insert-tag}).
605
606 If the option @code{sgml-balanced-tag-edit} is non-nil, inserting a
607 start-tag will also insert the corresponding end-tag. If, in addition,
608 @code{sgml-auto-insert-required-elements} is non-nil, tags for elements
609 required between the inserted tags will also be inserted.
610
611 The list of valid tags, computed for a position in the buffer, will
612 contain:
613
614 @enumerate
615 @item
616 The end-tag for the current element, if it can be ended at the position
617 and @code{sgml-balanced-tag-edit} is nil. Furthermore it will contain
618 end-tags for enclosing elements if the necessary omissible end-tag
619 declarations have been made in the DTD.
620
621 @item
622 The start-tags of all elements that could occur after point. If
623 @code{sgml-omittag-transparent} is nil, the above will be limited to the
624 elements that can occur within the current element.
625 @end enumerate
626
627
628 @kindex C-c C-e
629 @findex sgml-insert-element
630 @item C-c C-e
631 Insert start and end-tags for an element (@code{sgml-insert-element}).
632 The name of the element is read from the mini-buffer with completion on
633 valid elements.
634
635 If @code{sgml-omittag-transparent} is nil, the list of valid elements
636 will only contain the elements that can be in the content of the current
637 element.
638
639 Required elements in the content will be automatically inserted if the
640 option @code{sgml-auto-insert-required-elements} is non-nil.
641
642 @kindex C-c C-r
643 @findex sgml-tag-region
644 @item C-c C-r
645 Makes the region into a new element (@code{sgml-tag-region}). Reads
646 element name from mini-buffer with completion as for @kbd{C-c C-e}.
647
648 @kindex C-c /
649 @findex sgml-insert-end-tag
650 @item C-c /
651 Inserts an end-tag for the current element (@code{sgml-insert-end-tag}).
652
653 @kindex C-c RET
654 @findex sgml-split-element
655 @item C-c RET
656 Split the current element at point. If repeated, the containing element
657 will be split before the beginning of then current element.
658
659 Typical use is to start a new paragraph element when inside a paragraph.
660
661 @kindex C-c +
662 @findex sgml-insert-attribute
663 @item C-c +
664 Read attribute name and value from mini-buffer and insert attribute
665 specification (@code{sgml-insert-attribute}). If point is immediately
666 after a start-tag, this command operates on that start-tag. Otherwise
667 the command will operate on the element after point.
668
669 The attribute name will be read with completion. If the attribute has a
670 token list as declared value the attribute value will also be read with
671 completion. The prompt for attribute value will typically look like:
672
673 @example
674 Value for @var{attribute} (@var{type} Default: @var{current value}):
675 @end example
676
677 @end table
678
679 Menu bar:
680
681 @table @samp
682 @item Markup
683 Selecting from this menu will insert markup. The menu contains
684 sub menus with tags and with entities, some other markup and a user
685 defined section.
686
687 Sub menus:
688
689 @item Insert element
690 Pops up a menu of valid elements and insert start and end-tags for
691 the selected element. Selections from the menu works like the @kbd{C-c
692 C-e} command.
693
694 @item Insert start-tag
695 Pops up a menu of valid start-tags and insert the selected tag. The
696 menu has the same start-tags as the completion list for @kbd{C-c <}.
697
698 @item Insert end-tag
699 Pops up a menu of valid end-tags and insert the selected tag.
700
701 @item Tag region
702 Pops up a menu of valid elements and tag the region with the
703 selection. Selections from the menu works like the @kbd{C-c C-r}
704 command.
705
706 @item Insert entity
707 Menu of all general entities defined in the DTD.
708
709 @item Insert attribute
710 Pops up a menu with all the attributes of an element. The element is
711 either the one which start-tag is immediately before point or the
712 element after point. Selecting from this menu edits the attribute
713 specification list for the element.
714
715 The menu has a sub menu for every attribute which declared value is a
716 token list. The rest of the attributes are collected in one sub menu.
717 For the token list attributes, selecting a value will insert that
718 attribute-value pair. Selecting some other attribute reads the
719 attribute-value from the mini-buffer and inserts the attribute value
720 pair.
721 @end table
722
723 @kindex S-@key{mouse-1}
724 A menu is also available directly with a mouse button click in the
725 buffer. In GNU Emacs it is the first mouse button combined with shift
726 (@kbd{S-@key{mouse-1}}). In Lucid Emacs it is bound to the third mouse
727 button. The mouse button click will pop-up a menu of valid tags or a
728 menu of attributes if the point is in a start-tag. The attributes menu
729 works as the ``Insert attribute'' menu from the menu-bar. The tags list
730 is the list of valid tags described above for command @kbd{C-c <}.
731 Selection from the tags menu works like the @kbd{C-c <} command, with
732 the following exception:
733
734 You can tag a region, with start and end-tag. There are two ways to
735 indicate the region to mark:
736
737 @enumerate
738 @item
739 Use the normal mouse commands to mark region.
740
741 For this to work you must either use @dfn{transient mark mode}
742 (@pxref{Transient Mark, , Transient Mark Mode, emacs, The Emacs
743 Editor}) or set the option @code{sgml-tag-region-if-active} to non-nil
744 (don't set this unless you are sure that you want it).
745
746 @item
747 Alternatively make a secondary selection, this is done by holding down
748 the meta key and using the mouse buttons.
749 @xref{Secondary selection, , , emacs, The Emacs Editor}.
750 Some window managers intercept these events, which makes it hard use the
751 secondary selection in Emacs.
752 @end enumerate
753
754 @defopt sgml-balanced-tag-edit
755 If non-nil, inserting a start-tag will also insert the corresponding
756 end-tag.
757 @end defopt
758
759 @defopt sgml-auto-insert-required-elements
760 If non-nil, automatically inserts required elements in the content
761 of an inserted element.
762 @end defopt
763
764 @defopt sgml-omittag-transparent
765 If non-nil, will show legal tags inside elements with omissible start-tags
766 and legal tags beyond omissible end-tags.
767 @end defopt
768
769 @defopt sgml-tag-region-if-active
770 If non-nil, the @samp{Insert tags} menu will tag a region if the region
771 is considered active by emacs. If nil, region must be active and
772 @code{transient-mark-mode} must be on for the region to be tagged.
773 @end defopt
774
775 @defopt sgml-custom-markup
776 Menu entries to be added to the Markup menu. The value should be a list
777 of lists of two strings. The first string is the menu line and the
778 second string is the text inserted when the menu item is selected. The
779 second string can contain a @samp{\r} where the cursor should be left.
780 Also, if a selection is made according to the same rules as for the
781 @kbd{S-mouse-1} menu, the selection is replaced with the second string
782 and @samp{\r} is replaced with the selection.
783
784 Example:
785
786 @example
787 (("Version1" "<![%Version1[\r]]>")
788 ("New page" "<?NewPage>"))
789 @end example
790 @end defopt
791
792
793 @c -------------------------------------------------------------------------
794 @node Complete, Information, Insert, Edit
795 @comment node-name, next, previous, up
796 @section Markup completion
797
798 @kindex M-TAB
799 @findex sgml-complete
800 If you are typing in markup directly, @kbd{M-TAB} will help you by
801 completing a tag name, an entity name or a markup declaration name. If
802 you type @kbd{M-TAB} after a plain word, @code{ispell-complete-word}
803 will be invoked instead.
804
805 If you have typed (@point{} marks the position of point)
806
807 @example
808 &At@point{}
809 @end example
810
811 @noindent and type @kbd{M-TAB} (assuming you use the @file{ISOLat1}
812 entity set) you get:
813
814 @example
815 &Atilde@point{}
816 @end example
817
818
819 @c ---------------------------------------------------------------------------
820 @node Information, Indent, Complete, Edit
821 @comment node-name, next, previous, up
822 @section Showing information
823
824 Commands for showing information obtained by parsing the buffer.
825
826 @table @kbd
827 @kindex C-c C-c
828 @findex sgml-show-context
829 @item C-c C-c
830 Shows in the message area: context at point, if in a tag or in mixed
831 content and the open elements (@code{sgml-show-context}).
832
833 @kindex C-c C-w
834 @findex sgml-what-element
835 @item C-c C-w
836 Shows what element the character after point (under the cursor) belongs
837 to; also shows context of element (@code{sgml-what-element}).
838
839 @kindex C-c C-t
840 @findex sgml-list-valid-tags
841 @item C-c C-t
842 List contextually valid tags (@code{sgml-list-valid-tags}). Displays
843 information about current element, all valid end-tags, valid start-tags
844 in current element, and start-tags valid at this point but in other
845 elements together with the tags omitted.
846 @end table
847
848 You can make the mode-line display the name of the current open element
849 by setting the @code{sgml-live-element-indicator} variable. Setting
850 this will make all commands slower due to the work needed to keep the
851 mode-line up to date.
852
853 @defopt sgml-live-element-indicator
854 If non-nil, indicate current element in mode line.
855
856 NOTE: Setting this implies that every command can cause a parse.
857 @end defopt
858
859
860
861 @c --------------------------------------------------------------------------
862 @node Indent, Move, Information, Edit
863 @comment node-name, next, previous, up
864 @section Indentation according to structure
865
866 @kindex @key{TAB}
867 @kindex @key{LFD}
868 @findex sgml-indent-or-tab
869 @findex newline-and-indent
870 You can indent a line according to the depth of element nesting at the
871 beginning of the line. To indent the current line use @kbd{@key{TAB}}.
872 You can also use @kbd{@key{LFD}} (@code{newline-and-indent}) to start a
873 new line with correct indentation.
874
875 @defopt sgml-indent-step
876 How much to increment indent for every element level. If nil, no
877 indentation.
878
879 If this is nil, @kbd{@key{TAB}} will insert a tab instead of indenting.
880 @end defopt
881
882 @defopt sgml-indent-data
883 If non-nil, indent in data/mixed context also.
884 @end defopt
885
886
887
888 @c ---------------------------------------------------------------------------
889 @node Move, Attributes, Indent, Edit
890 @comment node-name, next, previous, up
891 @section Move in the element structure
892
893 These commands move in the element structure. The commands uses
894 knowledge of SGML syntax, and if available the specific DTD.
895
896 @table @kbd
897 @kindex C-M-a
898 @findex sgml-beginning-of-element
899 @item C-M-a
900 Move to the (content) beginning of the current element
901 (@code{sgml-beginning-of-element}).
902
903 @kindex C-M-e
904 @findex sgml-end-of-element
905 @item C-M-e
906 Move to the (content) end of the current element (@code{sgml-end-of-element}).
907
908 @kindex C-M-f
909 @findex sgml-forward-element
910 @item C-M-f
911 Move forward by element (@code{sgml-forward-element}).
912
913 @kindex C-M-b
914 @findex sgml-backward-element
915 @item C-M-b
916 Move backward by element (@code{sgml-backward-element}).
917
918 @kindex C-M-u
919 @findex sgml-backward-up-element
920 @item C-M-u
921 Move up to before current element (@code{sgml-backward-up-element}).
922
923 @kindex C-c C-n
924 @findex sgml-up-element
925 @item C-c C-n
926 Move up to after current element (@code{sgml-up-element}).
927
928 @kindex C-M-d
929 @findex sgml-down-element
930 @item C-M-d
931 Move down to the (content) beginning of the next element
932 (@code{sgml-down-element}).
933
934 @kindex C-c C-d
935 @findex sgml-next-data-field
936 @item C-c C-d
937 Move to the next place where data is allowed (@code{sgml-next-data-field}).
938 @end table
939
940 You can also move to the next place where there is some structural error
941 with @kbd{C-c C-o} (@pxref{Validate}).
942
943
944 @c ---------------------------------------------------------------------------
945 @node Attributes, Change and delete, Move, Edit
946 @comment node-name, next, previous, up
947 @section Editing attributes
948
949 @findex sgml-edit-attributes
950 @kindex C-c C-a
951 If you want to change the attributes of a start-tag you can simply edit
952 them directly in the buffer. Or you can place the cursor at or after
953 the start-tag and use the @code{sgml-edit-attributes} command, available
954 from the @samp{SGML}-menu or on @kbd{C-c C-a}. This will create a new
955 Emacs window with all possible attributes listed in the form
956
957 @example
958 @var{attribute name} = @var{current value}.
959 @end example
960
961 The @var{current value} may be shown as @samp{#DEFAULT} if the attribute
962 has not been given a value in the start-tag. The list also contains the
963 attributes declaration as a comment. Note also that the @var{current
964 value} is show without eventual quotes.
965
966 @kindex C-c C-d
967 @kindex @key{TAB}
968 It is now possible to edit the attribute values. You can move to the
969 next attribute with @kbd{@key{TAB}}. If you want to let an attribute
970 have its default value use @kbd{C-c C-d}, this will insert a
971 @samp{#DEFAULT} in the value field.
972
973 If Emacs is running in an X window, the @samp{#DEFAULT} will be
974 underlined to distinguish it from normal values.
975
976 @kindex C-c C-c
977 Finish the editing with @kbd{C-c C-c}; this will replace the attribute
978 values in the main buffer with those edited. Note that values will be
979 quoted as needed.
980
981 If you want to abort the editing, you can remove the window with
982 @kbd{C-x 0} or if you want it neat, kill the buffer and remove the
983 window.
984
985 Some other keys are:
986 @table @kbd
987 @kindex C-a
988 @findex sgml-edit-attrib-field-start
989 @item C-a
990 Go to the beginning of the value field
991 (@code{sgml-edit-attrib-field-start}).
992
993 @kindex C-e
994 @findex sgml-edit-attrib-field-end
995 @item C-e
996 Go to the end of the value field
997 (@code{sgml-edit-attrib-field-end}).
998
999 @kindex C-c C-k
1000 @findex sgml-edit-attrib-clear
1001 @item C-c C-k
1002 Clear the value field
1003 (@code{sgml-edit-attrib-clear}).
1004
1005 @kindex C-c C-d
1006 @findex sgml-edit-attrib-default
1007 @item C-c C-d
1008 Set the value field to @samp{#DEFAULT}
1009 (@code{sgml-edit-attrib-default}). This is a special value that will
1010 make the attribute be implied.
1011 @end table
1012
1013
1014 @c --------------------------------------------------------------------------
1015 @node Change and delete, , Attributes, Edit
1016 @comment node-name, next, previous, up
1017 @section Changing and deleting markup
1018
1019 @table @kbd
1020 @kindex C-c =
1021 @findex sgml-change-element-name
1022 @item C-c =
1023 Change the name of the current element (@code{sgml-change-element-name}).
1024 Tries to translate attribute specifications. An attribute will be
1025 translated to an attribute with the same name. If the new element has
1026 no attribute with the same name, the attribute will be ignored. If
1027 there is an attribute with the same name but different declared content,
1028 a warning is given.
1029
1030 ID attributes are handled specially, an attribute with declared value ID
1031 will always be translated to the attribute with declared value ID.
1032
1033 @kindex C-c C-k
1034 @findex sgml-kill-markup
1035 @item C-c C-k
1036 Kill next tag, markup declaration or process instruction
1037 (@code{sgml-kill-markup}).
1038
1039 @kindex C-M-k
1040 @findex sgml-kill-element
1041 @item C-M-k
1042 Kill the element following the cursor (@code{sgml-kill-element}).
1043
1044 @kindex C-c -
1045 @findex sgml-untag-element
1046 @item C-c -
1047 Remove tags from current element (@code{sgml-untag-element}).
1048
1049 @kindex C-c #
1050 @findex sgml-make-character-reference
1051 @item C-c #
1052 Convert character after point to a character reference
1053 (@code{sgml-make-character-reference}). If called with a numeric
1054 argument, convert a character reference back to a normal character.
1055
1056 @kindex C-c C-q
1057 @findex sgml-fill-element
1058 @item C-c C-q
1059 Fills an element as a paragraph (@code{sgml-fill-element}). This is a
1060 substitute for the normal @code{fill-paragraph}. The command uses
1061 heuristics to decide what should be a paragraph.
1062
1063 @enumerate
1064 @item
1065 If point is in an element content, recursively fill the sub-elements.
1066 @item
1067 Find the biggest element with mixed content containing point.
1068 @item
1069 If the above element is mixed but contains elements with pure element
1070 content then fill what is between the pure elements as paragraphs and
1071 fill the pure elements recursively.
1072 @end enumerate
1073
1074
1075 @findex sgml-normalize
1076 @item M-x sgml-normalize
1077 Normalize the document in the buffer. This will
1078
1079 @enumerate
1080 @item
1081 insert missing tags,
1082 @item
1083 replace minimized tags with full tags,
1084 @item
1085 fix attribute specification lists according to options set.
1086 @end enumerate
1087
1088 There is one option for the normalize command. With its default value,
1089 normalize may actually change the data content of some elements. But
1090 only by removing some white-space from the end of elements with omitted
1091 end-tags.
1092 @end table
1093
1094 @defopt sgml-normalize-trims
1095 If non-nil, @code{sgml-normalize} will trim off white space from end of
1096 element when adding end-tag.
1097
1098 Default: @code{t}.
1099 @end defopt
1100
1101
1102 @c ---------------------------------------------------------------------------
1103 @node Display, Bugs, Edit, Top
1104 @comment node-name, next, previous, up
1105 @chapter Appearance of text in the buffer
1106
1107 @menu
1108 * Fold:: Folding editing
1109 * Highlight:: Highlighting markup
1110 @end menu
1111
1112 @c ---------------------------------------------------------------------------
1113 @node Fold, Highlight, Display, Display
1114 @comment node-name, next, previous, up
1115 @section Folding editing
1116
1117 With these commands you can make parts of the text temporarily invisible
1118 to make it easier to see the overall structure of your text.
1119
1120 When folding a region all the lines but the first will be invisible.
1121 The first line of the region will still be visible with an ellipsis at
1122 the end.
1123
1124 @xref{Outline Mode, , , emacs, The Emacs Editor}.
1125
1126 @table @kbd
1127 @kindex C-c C-f C-r
1128 @findex sgml-fold-region
1129 @item C-c C-f C-r
1130 The region between point and mark will be folded (@code{sgml-fold-region}).
1131
1132 @kindex C-c C-f C-e
1133 @findex sgml-fold-element
1134 @item C-c C-f C-e
1135 The region between the start and end of the current element will be
1136 folded (@code{sgml-fold-element}).
1137
1138 This command can also fold the SGML declaration or the DOCTYPE
1139 declaration.
1140
1141 @kindex C-c C-f C-s
1142 @findex sgml-fold-subelement
1143 @item C-c C-f C-s
1144 Fold all the sub elements of the current element
1145 (@code{sgml-fold-subelement}).
1146
1147 @kindex C-c C-s
1148 @kindex C-c C-u C-l
1149 @findex sgml-unfold-line
1150 @item C-c C-s
1151 @itemx C-c C-u C-l
1152 Unfold the current line, assuming it is the first line of a folded
1153 region (@code{sgml-unfold-line}).
1154
1155 @kindex C-c C-u C-e
1156 @findex sgml-unfold-element
1157 @item C-c C-u C-e
1158 Make all lines in current element visible (@code{sgml-unfold-element}).
1159
1160 @kindex C-c C-u C-a
1161 @findex sgml-unfold-all
1162 @item C-c C-u C-a
1163 Make all lines in current buffer visible (@code{sgml-unfold-all}).
1164
1165 @kindex C-c C-f C-x
1166 @findex sgml-expand-element
1167 @item C-c C-f C-x
1168 Unfold current element and then fold the subelements
1169 (@code{sgml-expand-element}). If the current element is folded this
1170 expands what is visible.
1171 @end table
1172
1173
1174
1175
1176 @c ---------------------------------------------------------------------------
1177 @node Highlight, , Fold, Display
1178 @comment node-name, next, previous, up
1179 @section Highlighting markup
1180
1181
1182 PSGML can highlight the markup as it parses it by giving the markup a
1183 different @dfn{face} (@pxref{Faces, , Using Multiple Typefaces, emacs,
1184 The Emacs Editor}). The highlighting will only be done if the variable
1185 @code{sgml-set-face} is non-nil. The default settings make tags bold
1186 and comments italic, but this can be modified with the variable
1187 @code{sgml-markup-faces}.
1188
1189 @findex sgml-clear-faces
1190 To remove the highlighting type @kbd{M-x sgml-clear-faces}.
1191
1192 @defopt sgml-set-face
1193 If non-nil, psgml will set the face of parsed markup.
1194 @end defopt
1195
1196 @defopt sgml-markup-faces
1197 A list of markup to face mappings.
1198 Each element looks like @code{(@var{markup-type} . @var{face})}.
1199 Possible values for @var{markup-type} is:
1200
1201 @table @code
1202 @item comment
1203 comment declaration
1204 @item doctype
1205 doctype declaration
1206 @item end-tag
1207 end-tag
1208 @item ignored
1209 ignored marked section
1210 @item ms-start
1211 marked section end, if not ignored
1212 @item ms-end
1213 marked section start, if not ignored
1214 @item pi
1215 processing instruction
1216 @item sgml
1217 SGML declaration
1218 @item start-tag
1219 start-tag
1220 @item entity
1221 entity reference
1222 @item shortref
1223 short reference
1224 @end table
1225 @end defopt
1226
1227 @c ------------------------------------------------------------------
1228 @node Bugs, Index, Display, Top
1229 @comment node-name, next, previous, up
1230 @chapter Bugs
1231
1232
1233 If you encounter something that you think is a bug, please report
1234 it. Try to include a clear description of the undesired behaviour.
1235 A test case that exhibits the bug, would also be useful.
1236
1237 You can report a bug with the command @kbd{M-x sgml-submit-bug-report}.
1238
1239 When PSGML needs contextual information it parses the document up to
1240 the point. During the parsing, it builds a parse tree. The parse
1241 tree is used to initialize the next parse, to avoid having to parse
1242 things already parsed. Changes to the buffer is supposed to prune
1243 the tree of all outdated information. But if you get strange
1244 complaints from the parser, try and back up a bit and use @kbd{C-c
1245 C-o} (@code{sgml-next-trouble-spot}).
1246
1247
1248
1249 @c ------------------------------------------------------------------
1250 @node Index, , Bugs, Top
1251 @comment node-name, next, previous, up
1252 @chapter Index
1253
1254 @printindex cp
1255
1256 @bye