Debian Codegraph @

psgml.el

raw ◀ ▶
1 Debian patch touch this file
1 ;;; psgml.el --- SGML-editing mode with parsing support
2 ;; $Id: psgml.el,v 2.70 2005/03/02 19:44:04 lenst Exp $
3
4 ;; Copyright (C) 1993-2002 Lennart Staflin
5 ;; Copyright (C) 1992 Free Software Foundation, Inc.
6
7 ;; Author: Lennart Staflin <[email protected]>
8 ;; James Clark <[email protected]>
9 ;; Maintainer: Lennart Staflin <[email protected]>
10 ;; Keywords: languages
11
12 ;;
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License
15 ;; as published by the Free Software Foundation; either version 2
16 ;; of the License, or (at your option) any later version.
17 ;;
18 ;; This program is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
22 ;;
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with this program; if not, write to the Free Software
25 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27
28 ;;; Commentary:
29
30 ;; Major mode for editing the SGML document-markup language.
31
32 ;; Send bugs to [email protected]
33
34 ;; WHAT IT CAN DO
35
36 ;; - Identify structural errors (but it is not a validator)
37 ;; - Menus for inserting tags with only the contextually valid tags
38 ;; - Edit attribute values in separate window with information about types
39 ;; and defaults
40 ;; - Hide attributes
41 ;; - Fold elements
42 ;; - Indent according to element nesting depth
43 ;; - Show context
44 ;; - Structure editing: move and kill by element
45 ;; - Find next data context
46
47 ;; LIMITATIONS
48
49 ;; - only accepts the reference concrete syntax, though it does allow
50 ;; unlimited lengths on names
51
52
53 ;;; Code:
54
55 (defconst psgml-version "1.4.0"
56 "Version of psgml package.")
57
58 (defconst psgml-maintainer-address "[email protected]")
59
60 (eval-when-compile (require 'cl))
61 (require 'easymenu)
62
63 (defvar sgml-debug nil)
64
65 (defmacro sgml-debug (&rest x)
66 (list 'if 'sgml-debug (cons 'message x)))
67
68
69 ;;;; Variables
70
71 (defvar sgml-mode-abbrev-table nil
72 "Abbrev table in use in SGML mode.")
73 (define-abbrev-table 'sgml-mode-abbrev-table ())
74
75 (eval-and-compile
76 (defconst sgml-running-lucid (string-match "Lucid" emacs-version))
77 (defconst sgml-have-re-char-clases (string-match "[[:alpha:]]" "x")
78 "Non-nil if this Emacs supports regexp character classes.
79 E.g. `[-.[:alnum:]]'."))
80
81 (defconst sgml-default-nonsticky (boundp 'text-property-default-nonsticky)
82 "Non-nil means use `text-property-default-nonsticky'. locally.
83 Otherwise put explicit properties.")
84
85
86 (defvar sgml-xml-p nil
87 "Is this an XML document?")
88 (make-variable-buffer-local 'sgml-xml-p)
89
90 ;;; User settable options:
91
92 (defvar sgml-insert-defaulted-attributes nil
93 "*Controls whether defaulted attributes (not #FIXED) are inserted explicitly
94 or not. nil means don't insert, t means insert.")
95
96 (defvar sgml-insert-missing-element-comment t
97 "*If true, and sgml-auto-insert-required-elements also true,
98 `sgml-insert-element' will insert a comment if there is an element required
99 but there is more than one to choose from." )
100
101 (defvar sgml-insert-end-tag-on-new-line nil
102 "*If true, `sgml-insert-element' will put the end-tag on a new line
103 after the start-tag. Useful on slow terminals if you find the end-tag after
104 the cursor irritating." )
105
106 (defvar sgml-doctype nil
107 "*If non-nil the name of a file that contains the doctype declaration to use.
108 declaration to use.
109 Setting this variable automatically makes it local to the current buffer.")
110 (put 'sgml-doctype 'sgml-type 'string)
111 (make-variable-buffer-local 'sgml-doctype)
112
113 (defvar sgml-system-identifiers-are-preferred nil
114 "*Controls lookup of external entities.
115 nil means look up external entities by searching the catalogs
116 in `sgml-local-catalogs' and `sgml-catalog-files' and only if the
117 entity is not found in the catalogs use a given system identifier.
118 Non-nil means use a system identifier for the entity if one is given.
119 If no system identifier is given the catalogs will searched.")
120
121 (defvar sgml-range-indicator-max-length 9
122 "*Control of menu indicators.
123 Maximum number of characters used from the first and last entry
124 of a submenu to indicate the range of that menu.")
125
126 (defvar sgml-default-doctype-name nil
127 "*If non-nil, document type name to use if no DTD is present.")
128 (put 'sgml-default-doctype-name 'sgml-type 'string-or-nil)
129
130 (defvar sgml-markup-faces
131 ;; Fixme: are the font-lock correspondences here the most appopriate
132 ;; ones? I don't recall whence this set came. -- fx
133 `((start-tag . ,(if (facep 'font-lock-function-name-face)
134 'font-lock-function-name-face
135 'bold))
136 (end-tag . ,(if (facep 'font-lock-function-name-face)
137 'font-lock-function-name-face
138 'bold))
139 (comment . ,(if (facep 'font-lock-comment-face)
140 'font-lock-comment-face
141 'bold))
142 (pi . ,(if (facep 'font-lock-type-face)
143 'font-lock-type-face
144 'bold))
145 (sgml . ,(if (facep 'font-lock-type-face)
146 'font-lock-type-face
147 'bold))
148 (doctype . ,(if (facep 'font-lock-keyword-face)
149 'font-lock-keyword-face
150 'bold))
151 (entity . ,(if (facep 'font-lock-string-face)
152 'font-lock-string-face
153 'bold))
154 (shortref . ,(if (facep 'font-lock-string-face)
155 'font-lock-string-face
156 'bold))
157 (ignored . ,(if (facep 'font-lock-constant-face)
158 'font-lock-constant-face
159 'default))
160 (ms-start . ,(if (facep 'font-lock-constant-face)
161 'font-lock-constant-face
162 'default))
163 (ms-end . ,(if (facep 'font-lock-constant-face)
164 'font-lock-constant-face
165 'default)))
166 "*Alist of markup to face mappings.
167 Element are of the form (MARKUP-TYPE . FACE).
168 Possible values for MARKUP-TYPE are:
169 comment - comment declaration
170 doctype - doctype declaration
171 end-tag
172 ignored - ignored marked section
173 ms-end - marked section start, if not ignored
174 ms-start- marked section end, if not ignored
175 pi - processing instruction
176 sgml - SGML declaration
177 start-tag
178 entity - general entity reference
179 shortref- short reference")
180
181 (defvar sgml-buggy-subst-char-in-region
182 (or (not (boundp 'emacs-minor-version))
183 (not (natnump emacs-minor-version))
184 (and (eq emacs-major-version 19)
185 (< emacs-minor-version 23)))
186 "*If non-nil, work around a bug in subst-char-in-region.
187 The bug sets the buffer modified. If this is set, folding commands
188 will be slower.")
189
190 (defvar sgml-set-face nil
191 "*If non-nil, psgml will set the face of parsed markup.")
192 (put 'sgml-set-face 'sgml-desc "Set face of parsed markup")
193
194 (defvar sgml-live-element-indicator nil
195 "*If non-nil, indicate current element in mode line.
196 This may be slow.")
197
198 (defvar sgml-auto-activate-dtd nil
199 "*If non-nil, loading a sgml-file will automatically try to activate its DTD.
200 Activation means either to parse the document type declaration or to
201 load a previously saved parsed DTD. The name of the activated DTD
202 will be shown in the mode line.")
203 (put 'sgml-auto-activate-dtd 'sgml-desc "Auto Activate DTD")
204
205 (defvar sgml-offer-save t
206 "*If non-nil, ask about saving modified buffers before \\[sgml-validate] is run.")
207
208 (defvar sgml-parent-document nil
209 "*How to handle the current file as part of a bigger document.
210
211 The variable describes how the current file's content fit into the element
212 hierarchy. The value should have the form
213
214 (PARENT-FILE CONTEXT-ELEMENT* TOP-ELEMENT (HAS-SEEN-ELEMENT*)?)
215
216 PARENT-FILE is a string, the name of the file containing the
217 document entity.
218 CONTEXT-ELEMENT is a string, that is the name of an element type.
219 It can occur 0 or more times and is used to set up
220 exceptions and short reference map. Good candidates
221 for these elements are the elements open when the
222 entity pointing to the current file is used.
223 TOP-ELEMENT is a string that is the name of the element type
224 of the top level element in the current file. The file
225 should contain one instance of this element, unless
226 the last \(Lisp) element of `sgml-parent-document' is a
227 list. If it is a list, the top level of the file
228 should follow the content model of top-element.
229 HAS-SEEN-ELEMENT is a string that is the name of an element type. This
230 element is satisfied in the content model of top-element.
231
232 Setting this variable automatically makes it local to the current buffer.")
233 (make-variable-buffer-local 'sgml-parent-document)
234 (put 'sgml-parent-document 'sgml-type 'list)
235
236 (defvar sgml-tag-region-if-active nil
237 "*If non-nil, the Tags menu will tag a region if the region is
238 considered active by emacs. If nil, region must be active and
239 transient-mark-mode must be on for the region to be tagged.")
240
241 (defvar sgml-normalize-trims t
242 "*If non-nil, sgml-normalize will trim off white space from end of element
243 when adding end tag.")
244
245 (defvar sgml-omittag t
246 "*Non-nil means use OMITTAG YES.
247
248 Setting this variable automatically makes it local to the current buffer.")
249
250 (make-variable-buffer-local 'sgml-omittag)
251 (put 'sgml-omittag 'sgml-desc "OMITTAG")
252
253 (defvar sgml-shorttag t
254 "*Non-nil means use SHORTTAG YES.
255
256 Setting this variable automatically makes it local to the current buffer.")
257
258 (make-variable-buffer-local 'sgml-shorttag)
259 (put 'sgml-shorttag 'sgml-desc "SHORTTAG")
260
261 (defvar sgml-namecase-general t
262 "*Non-nil means use NAMECASE GENERAL YES.
263
264 Setting this variable automatically makes it local to the current buffer.")
265
266 (make-variable-buffer-local 'sgml-namecase-general)
267 (put 'sgml-namecase-general 'sgml-desc "NAMECASE GENERAL")
268
269
270
271 ;;[lenst/1998-03-09 19:51:55]
272 (defconst sgml-namecase-entity nil)
273
274 (defvar sgml-general-insert-case 'lower
275 "*The case that will be used for general names in inserted markup.
276 This can be the symbol `lower' or `upper'. Only effective if
277 `sgml-namecase-general' is true.")
278 (put 'sgml-general-insert-case 'sgml-type '(lower upper))
279
280 (defvar sgml-entity-insert-case nil)
281
282
283 (defvar sgml-minimize-attributes nil
284 "*Determines minimization of attributes inserted by edit-attributes.
285 Actually two things are done
286 1. If non-nil, omit attribute name, if attribute value is from a token group.
287 2. If `max', omit attributes with default value.
288
289 Setting this variable automatically makes it local to the current buffer.")
290
291 (make-variable-buffer-local 'sgml-minimize-attributes)
292 (put 'sgml-minimize-attributes 'sgml-type
293 '(("No" . nil) ("Yes" . t) ("Max" . max)))
294
295 (defvar sgml-always-quote-attributes t
296 "*Non-nil means quote all attribute values inserted after editing attributes.
297 Setting this variable automatically makes it local to the current buffer.")
298
299 (make-variable-buffer-local 'sgml-always-quote-attributes)
300
301 (defvar sgml-auto-insert-required-elements t
302 "*If non-nil, automatically insert required elements in the content
303 of an inserted element.")
304
305 (defvar sgml-balanced-tag-edit t
306 "*If non-nil, context menu inserts start-end tag pairs.")
307
308 (defvar sgml-omittag-transparent (not sgml-balanced-tag-edit)
309 "*If non-nil, will show legal tags inside elements with omitable start tags
310 and legal tags beyond omitable end tags.")
311
312 (defvar sgml-leave-point-after-insert nil
313 "*If non-nil, the point will remain after inserted tag(s).
314 If nil, the point will be placed before the inserted tag(s).")
315
316 (defvar sgml-warn-about-undefined-elements t
317 "*If non-nil, print a warning when a tag for an undefined element is found.")
318
319 (defvar sgml-warn-about-undefined-entities t
320 "*If non-nil, print a warning when an undefined entity is found.")
321
322 (defvar sgml-ignore-undefined-elements nil
323 "*If non-nil, recover from an undefined element by ignoring the tag.
324 If nil, recover from an undefined element by assuming it can occur any
325 where and has content model ANY.")
326
327 (defvar sgml-recompile-out-of-date-cdtd 'ask
328 "*If non-nil, out of date compiled DTDs will be automatically recompiled.
329 If the value is `ask', PSGML will ask before recompiling. A `nil'
330 value will cause PSGML to silently load an out of date compiled DTD.
331 A DTD that refers to undefined external entities is always out of
332 date, thus in such case it can be useful to set this variable to
333 `nil'.")
334 (put 'sgml-recompile-out-of-date-cdtd 'sgml-type '(("No" . nil)
335 ("Yes" . t)
336 ("Ask" . ask)))
337
338 (defvar sgml-trace-entity-lookup nil
339 "*If non-nil, log messages about catalog files used to look for
340 external entities.")
341
342 (defvar sgml-indent-step 2
343 "*How much to increment indent for every element level.
344 If nil, no indentation.
345 Setting this variable automatically makes it local to the current buffer.")
346 (make-variable-buffer-local 'sgml-indent-step)
347 (put 'sgml-indent-step 'sgml-type '(("None" . nil) 0 1 2 3 4 5 6 7 8))
348
349 (defvar sgml-indent-data nil
350 "*If non-nil, indent in data/mixed context also.
351 Setting this variable automatically makes it local to the current buffer.")
352 (make-variable-buffer-local 'sgml-indent-data)
353
354 (defvar sgml-content-indent-function 'sgml-indent-according-to-level)
355 (defvar sgml-attribute-indent-function 'sgml-indent-according-to-stag)
356
357
358 (defun sgml-parse-colon-path (cd-path)
359 "Explode a colon-separated list of paths into a string list."
360 (if (null cd-path)
361 nil
362 (let ((cd-sep ":")
363 cd-list (cd-start 0) cd-colon)
364 (if (boundp 'path-separator)
365 (setq cd-sep path-separator))
366 (setq cd-path (concat cd-path cd-sep))
367 (while (setq cd-colon (string-match cd-sep cd-path cd-start))
368 (setq cd-list
369 (nconc cd-list
370 (list (if (= cd-start cd-colon)
371 nil
372 (substitute-in-file-name
373 (substring cd-path cd-start cd-colon))))))
374 (setq cd-start (+ cd-colon 1)))
375 cd-list)))
376
377 (defvar sgml-system-path (sgml-parse-colon-path
378 (or (getenv "SGML_SEARCH_PATH")
379 "."))
380 "*List of directories used to look for system identifiers.")
381 (put 'sgml-system-path 'sgml-type 'file-list)
382
383 (defvar sgml-public-map (or (sgml-parse-colon-path (getenv "SGML_PATH"))
384 '("%S" "/usr/local/lib/sgml/%o/%c/%d" ))
385 "*Mapping from public identifiers to file names.
386 This is a list of possible file names. To find the file for a public
387 identifier the elements of the list are used one at the time from the
388 beginning. If the element is a string a file name is constructed from
389 the string by substitution of the whole public identifier for %P,
390 owner for %O, public text class for %C, and public text description
391 for %D. The text class will be converted to lower case and the owner
392 and description will be transliterated according to the variable
393 `sgml-public-transliterations'. If the file exists it will be the file
394 used for the public identifier. An element can also be a dotted pair
395 \(regexp . filename), the filename is a string treated as above, but
396 only if the regular expression, regexp, matches the public
397 identifier.")
398 (put 'sgml-public-map 'sgml-type 'list)
399
400 (defvar sgml-local-catalogs nil
401 "*A list of SGML entity catalogs to be searched first when parsing the buffer.
402 This is used in addition to `sgml-catalog-files', and `sgml-public-map'.
403 This variable is automatically local to the buffer.")
404 (make-variable-buffer-local 'sgml-local-catalogs)
405 (put 'sgml-local-catalogs 'sgml-type 'file-list)
406
407 (defvar sgml-catalog-files (or (delete nil
408 (sgml-parse-colon-path
409 (getenv "SGML_CATALOG_FILES")))
•410 '("catalog" "/etc/sgml/catalog"
411 "/usr/lib/sgml/catalog"
412 "/usr/local/share/sgml/catalog"
413 "/usr/local/lib/sgml/catalog"))
414 "*List of catalog entry files.
415 The files are in the format defined in the SGML Open Draft Technical
416 Resolution on Entity Management.")
417 (put 'sgml-catalog-files 'sgml-type 'file-list)
418
•419 (defvar sgml-ecat-files '("ECAT" "~/sgml/ECAT" "/usr/lib/sgml/ECAT"
420 "/usr/local/share/sgml/ECAT" "/usr/local/lib/sgml/ECAT" )
421 "*List of catalog files for PSGML.")
422 (put 'sgml-ecat-files 'sgml-type 'file-list)
423
424 (defvar sgml-local-ecat-files nil
425 "*List of local catalog files for PSGML.
426 Automatically becomes buffer local if set.")
427
428 (make-variable-buffer-local 'sgml-local-ecat-files)
429 (put 'sgml-local-ecat-files 'sgml-type 'file-list)
430
431 (defvar sgml-public-transliterations '((? . ?_) (?/ . ?%))
432 "*Transliteration for characters that should be avoided in file names.
433 This is a list of dotted pairs (FROM . TO); where FROM is the the
434 character to be translated to TO. This is used when parts of a public
435 identifier are used to construct a file name.")
436
437 (defvar sgml-default-dtd-file nil
438 "*This is the default file name for saved DTD.
439 This is set by sgml-mode from the buffer file name.
440 Can be changed in the Local variables section of the file.")
441 (put 'sgml-default-dtd-file 'sgml-type 'string)
442 (put 'sgml-default-dtd-file 'sgml-desc "Default (saved) DTD File")
443
444 (defvar sgml-exposed-tags '()
445 "*The list of tag names that remain visible, despite \\[sgml-hide-tags].
446 Each name is a lowercase string, and start-tags and end-tags must be
447 listed individually.
448
449 `sgml-exposed-tags' is local to each buffer in which it has been set;
450 use `setq-default' to set it to a value that is shared among buffers.")
451 (make-variable-buffer-local 'sgml-exposed-tags)
452 (put 'sgml-exposed-tags 'sgml-type 'list)
453
454
455 (defvar sgml-custom-markup nil
456 "*Menu entries to be added to the Markup menu.
457 The value should be a list of lists of two strings. The first
458 string is the menu line and the second string is the text inserted
459 when the menu item is chosen. The second string can contain a \\r
460 where the cursor should be left. Also if a selection is made
461 according the same rules as for the Tags menu, the selection is
462 replaced with the second string and \\r is replaced with the
463 selection.
464
465 Example:
466
467 ((\"Version1\" \"<![%Version1[\\r]]>\")
468 (\"New page\" \"<?NewPage>\"))
469 ")
470
471 (defvar sgml-custom-dtd nil
472 "Menu entries to be added to the DTD menu.
473 The value should be a list of entries to be added to the DTD menu.
474 Every entry should be a list. The first element of the entry is a string
475 used as the menu entry. The second element is a string containing a
476 doctype declaration (this can be nil if no doctype). The rest of the
477 list should be a list of variables and values. For backward
478 compatibility a single string instead of a variable is assigned to
479 `sgml-default-dtd-file'. All variables are made buffer local and are also
480 added to the buffers local variables list.
481
482 Example:
483 ((\"HTML\" nil
484 sgml-default-dtd-file \"~/sgml/html.ced\"
485 sgml-omittag nil sgml-shorttag nil)
486 (\"HTML+\" \"<!doctype htmlplus system 'htmlplus.dtd'>\"
487 \"~/sgml/htmlplus.ced\"
488 sgml-omittag t sgml-shorttag nil)
489 (\"DOCBOOK\" \"<!doctype docbook system 'docbook.dtd'>\"
490 \"~/sgml/docbook.ced\"
491 sgml-omittag nil sgml-shorttag t)))
492 ")
493
494
495 ;;; Faces used in edit attribute buffer:
496 (put 'sgml-default 'face 'underline) ; Face for #DEFAULT
497 (put 'sgml-fixed 'face 'underline) ; Face of #FIXED "..."
498
499
•500 ;;; onsgmls is a free SGML parser
501 ;;; Its error messages can be parsed by next-error.
502 ;;; The -s option suppresses output.
503
•504 (defvar sgml-validate-command "onsgmls -s %s %s"
505 "*The shell command to validate an SGML document.
506
507 This is a `format' control string that by default should contain two
508 `%s' conversion specifications: the first will be replaced by the
509 value of `sgml-declaration' \(or the empty string, if nil\); the
510 second will be replaced by the current buffer's file name \(or the
511 empty string, if nil\).
512
513 If `sgml-validate-files' is non-nil, the format string should contain
514 one `%s' conversion specification for each element of its result.
515
516 If sgml-validate-command is a list, then every element should be a
517 string. The strings will be tried in order and %-sequences in the
518 string will be replaced according to the list below, if the string contains
519 %-sequences with no replacement value the next string will be tried.
520
521 %b means the visited file of the current buffer
522 %s means the SGML declaration specified in the sgml-declaration variable
523 %d means the file containing the DOCTYPE declaration, if not in the buffer
524 ")
525 (make-variable-buffer-local 'sgml-validate-command)
526
•527 (defvar sgml-xml-validate-command
528 (concat "/bin/sh -c \"SP_CHARSET_FIXED=YES SP_ENCODING=XML "
529 "onsgmls -wxml -mdeclaration/xml.soc -gues %s %s\"")
530 "*The default for `sgml-validate-command' in XML mode.")
531
532 (defvar sgml-validate-files nil
533 "If non-nil, a function of no arguments that returns a list of file names.
534 These file names will serve as the arguments to the `sgml-validate-command'
535 format control string instead of the defaults.")
536
537 (defvar sgml-validate-error-regexps
538 '((".*:\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[EXW]: " 1 2 3)
539 ("\\(error\\|warning\\) at \\([^,]+\\), line \\([0-9]+\\)" 2 3)
540 ("\n[a-zA-Z]?:?[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\
541 \\([0-9]+\\):\\(\\([0-9]+\\)[: \t]\\)?" 1 2 4))
542 "Alist of regexps to recognize error messages from `sgml-validate'.
543 See `compilation-error-regexp-alist'.")
544
545 (defvar sgml-declaration nil
546 "*If non-nil, the name of the SGML declaration file.")
547 (put 'sgml-declaration 'sgml-type 'file-or-nil)
548
549 (defvar sgml-xml-declaration nil
550 "*If non-nil, the name of the SGML declaration for XML files.")
551 (put 'sgml-xml-declaration 'sgml-type 'file-or-nil)
552
553 (defvar sgml-mode-hook nil
554 "A hook or list of hooks to be run when entering sgml-mode")
555
556 (defvar sgml-mode-map nil
557 "Keymap for SGML mode")
558
559 (defvar sgml-show-context-function
560 'sgml-show-context-standard
561 "*Function to called to show context of and element.
562 Should return a string suitable form printing in the echo area.")
563
564 (defconst sgml-file-options
565 '(
566 sgml-omittag
567 sgml-shorttag
568 sgml-namecase-general
569 sgml-general-insert-case
570 sgml-minimize-attributes
571 sgml-always-quote-attributes
572 sgml-indent-step
573 sgml-indent-data
574 sgml-doctype
575 sgml-parent-document
576 sgml-default-dtd-file
577 sgml-exposed-tags
578 sgml-local-catalogs
579 sgml-local-ecat-files
580 )
581 "Options for the current file, can be saved or set from menu."
582 )
583
584 (defconst sgml-user-options
585 '(
586 sgml-set-face
587 sgml-live-element-indicator
588 sgml-auto-activate-dtd
589 sgml-offer-save
590 sgml-tag-region-if-active
591 sgml-normalize-trims
592 sgml-auto-insert-required-elements
593 sgml-balanced-tag-edit
594 sgml-omittag-transparent
595 sgml-leave-point-after-insert
596 sgml-insert-missing-element-comment
597 sgml-insert-end-tag-on-new-line
598 sgml-warn-about-undefined-elements
599 sgml-warn-about-undefined-entities
600 sgml-ignore-undefined-elements
601 sgml-recompile-out-of-date-cdtd
602 sgml-default-doctype-name
603 sgml-declaration
604 sgml-validate-command
605 sgml-markup-faces
606 sgml-system-identifiers-are-preferred
607 sgml-trace-entity-lookup
608 sgml-public-map
609 sgml-catalog-files
610 sgml-ecat-files
611 sgml-general-insert-case
612 )
613 "User options that can be saved or set from menu."
614 )
615
616 ;;; Internal variables
617
618 (defvar sgml-validate-command-history nil
619 "The minibuffer history list for `sgml-validate''s COMMAND argument.")
620
621 (defvar sgml-active-dtd-indicator nil
622 "Displayed in the mode line")
623
624
625 ;;;; User options handling
626
627 (defun sgml-variable-description (var)
628 (or (get var 'sgml-desc)
629 (let ((desc (symbol-name var)))
630 (if (string= "sgml-" (substring desc 0 5))
631 (setq desc (substring desc 5)))
632 (loop for c across-ref desc
633 do (if (eq c ?-) (setf c ? )))
634 (capitalize desc))))
635
636 (defun sgml-variable-type (var)
637 (or (get var 'sgml-type)
638 (if (memq (symbol-value var) '(t nil))
639 'toggle)))
640
641 (defun sgml-set-local-variable (var val)
642 "Set the value of variable VAR to VAL in buffer and local variables list."
643 (set (make-local-variable var) val)
644 (save-excursion
645 (let ((prefix "")
646 (suffix "")
647 (case-fold-search t))
648 (goto-char (max (point-min) (- (point-max) 3000)))
649 (cond ((search-forward "Local Variables:" nil t)
650 (setq suffix (buffer-substring (point)
651 (save-excursion (end-of-line 1)
652 (point))))
653 (setq prefix
654 (buffer-substring (save-excursion (beginning-of-line 1)
655 (point))
656 (match-beginning 0))))
657 (t
658 (goto-char (point-max))
659 (unless (bolp)
660 (insert ?\n))
661 (insert
662 "<!-- Keep this comment at the end of the file\n"
663 "Local variables:\n"
664 (if sgml-xml-p
665 "mode: xml\n"
666 "mode: sgml\n")
667 "End:\n"
668 "-->\n")
669 (forward-line -3)))
670 (let* ((endpos (save-excursion
671 (search-forward (format "\n%send:" prefix))))
672 (varpos (search-forward (format "\n%s%s:" prefix var) endpos t)))
673 (cond (varpos
674 (delete-region (point)
675 (save-excursion (end-of-line 1)
676 (point)))
677 (insert (format "%S" val) suffix))
678 (t
679 (goto-char endpos)
680 (beginning-of-line 1)
681 (insert prefix (format "%s:%S" var val) suffix ?\n)))))))
682
683 (defun sgml-valid-option (var)
684 (let ((type (sgml-variable-type var))
685 (val (symbol-value var)))
686 (cond ((eq 'string type)
687 (stringp val))
688 ((eq 'list-or-string type)
689 (or (stringp val)
690 (consp val)))
691 (t
692 t))))
693
694 (defun sgml-save-options ()
695 "Save user options for SGML mode that have buffer local values."
696 (interactive)
697 (loop for var in sgml-file-options do
698 (when (sgml-valid-option var)
699 (sgml-set-local-variable var (symbol-value var)))))
700
701
702 ;;;; Run hook with args
703
704 (unless (fboundp 'run-hook-with-args)
705 (defun run-hook-with-args (hook &rest args)
706 "Run HOOK with the specified arguments ARGS.
707 HOOK should be a symbol, a hook variable. If HOOK has a non-nil
708 value, that value may be a function or a list of functions to be
709 called to run the hook. If the value is a function, it is called with
710 the given arguments and its return value is returned. If it is a list
711 of functions, those functions are called, in order,
712 with the given arguments ARGS.
713 It is best not to depend on the value return by `run-hook-with-args',
714 as that may change."
715 (and (boundp hook)
716 (symbol-value hook)
717 (let ((value (symbol-value hook)))
718 (if (and (listp value) (not (eq (car value) 'lambda)))
719 (mapcar '(lambda (foo) (apply foo args))
720 value)
721 (apply value args))))))
722
723
724
725
726 ;;;; SGML mode: template functions
727
728 (defun sgml-markup (entry text)
729 (cons entry
730 `(lambda ()
731 (interactive)
732 (sgml-insert-markup ,text))))
733
734 (defun sgml-insert-markup (text)
735 (let ((end (sgml-mouse-region))
736 before after
737 old-text)
738 (when end
739 (setq old-text (buffer-substring (point) end))
740 (delete-region (point) end))
741 (setq before (point))
742 (if (stringp text)
743 (insert text)
744 (eval text))
745 (setq after (point))
746 (goto-char before)
747 (when (search-forward "\r" after t)
748 (delete-char -1))
749 (when old-text (insert old-text))))
750
751 (defun sgml-mouse-region ()
752 (let (start end)
753 (cond
754 (sgml-running-lucid
755 (cond
756 ((null (mark-marker)) nil)
757 (t (setq start (region-beginning)
758 end (region-end)))))
759 ((and transient-mark-mode
760 mark-active)
761 (setq start (region-beginning)
762 end (region-end)))
763 ((and mouse-secondary-overlay
764 (eq (current-buffer)
765 (overlay-buffer mouse-secondary-overlay)))
766 (setq start (overlay-start mouse-secondary-overlay)
767 end (overlay-end mouse-secondary-overlay))
768 (delete-overlay mouse-secondary-overlay)))
769 (when start
770 (goto-char start))
771 end))
772
773
774 ;;;; SGML mode: indentation
775
776 (defun sgml-indent-or-tab ()
777 "Indent line in proper way for current major mode."
778 (interactive)
779 (if (null sgml-indent-step)
780 (insert-tab)
781 (funcall indent-line-function)))
782
783 ;;;; Bug reporting
784
785 (eval-and-compile
786 (autoload 'reporter-submit-bug-report "reporter"))
787
788 (defun sgml-submit-bug-report ()
789 "Submit via mail a bug report on PSGML."
790 (interactive)
791 (and (y-or-n-p "Do you really want to submit a report on PSGML? ")
792 (reporter-submit-bug-report
793 psgml-maintainer-address
794 (concat "psgml.el " psgml-version)
795 (list
796 'major-mode
797 'sgml-always-quote-attributes
798 'sgml-auto-activate-dtd
799 'sgml-auto-insert-required-elements
800 'sgml-balanced-tag-edit
801 'sgml-catalog-files
802 'sgml-declaration
803 'sgml-doctype
804 'sgml-ecat-files
805 'sgml-indent-data
806 'sgml-indent-step
807 'sgml-leave-point-after-insert
808 'sgml-live-element-indicator
809 'sgml-local-catalogs
810 'sgml-local-ecat-files
811 'sgml-markup-faces
812 'sgml-minimize-attributes
813 'sgml-normalize-trims
814 'sgml-omittag
815 'sgml-omittag-transparent
816 'sgml-parent-document
817 'sgml-public-map
818 'sgml-set-face
819 'sgml-shorttag
820 'sgml-namecase-general
821 'sgml-tag-region-if-active
822 'sgml-use-text-properties
823 ))))
824
825 ;;;; SGML mode: syntax table
826
827 (defvar sgml-mode-syntax-table
828 (let ((s (copy-syntax-table text-mode-syntax-table)))
829 (modify-syntax-entry ?< "." s)
830 (modify-syntax-entry ?> "." s)
831 s))
832
833
834 ;;;; SGML mode: keys and menus
835
836 (if sgml-mode-map
837 ()
838 (setq sgml-mode-map (make-sparse-keymap)))
839
840 (defvar sgml-prefix-f-map (make-sparse-keymap))
841 (defvar sgml-prefix-u-map (make-sparse-keymap))
842
843 (define-key sgml-mode-map "\C-c\C-f" sgml-prefix-f-map)
844 (define-key sgml-mode-map "\C-c\C-u" sgml-prefix-u-map)
845
846 ;;; Key commands
847
848 (define-key sgml-mode-map "\t" 'sgml-indent-or-tab)
849 ;(define-key sgml-mode-map "<" 'sgml-insert-tag)
850 (define-key sgml-mode-map ">" 'sgml-close-angle)
851 (define-key sgml-mode-map "/" 'sgml-slash)
852 (define-key sgml-mode-map "\C-c#" 'sgml-make-character-reference)
853 (define-key sgml-mode-map "\C-c-" 'sgml-untag-element)
854 (define-key sgml-mode-map "\C-c+" 'sgml-insert-attribute)
855 (define-key sgml-mode-map "\C-c/" 'sgml-insert-end-tag)
856 (define-key sgml-mode-map "\C-c<" 'sgml-insert-tag)
857 (define-key sgml-mode-map "\C-c=" 'sgml-change-element-name)
858 (define-key sgml-mode-map "\C-c\C-a" 'sgml-edit-attributes)
859 (define-key sgml-mode-map "\C-c\C-c" 'sgml-show-context)
860 (define-key sgml-mode-map "\C-c\C-d" 'sgml-next-data-field)
861 (define-key sgml-mode-map "\C-c\C-e" 'sgml-insert-element)
862 (define-key sgml-mode-map "\C-c\C-f\C-e" 'sgml-fold-element)
863 (define-key sgml-mode-map "\C-c\C-f\C-r" 'sgml-fold-region)
864 (define-key sgml-mode-map "\C-c\C-f\C-s" 'sgml-fold-subelement)
865 (define-key sgml-mode-map "\C-c\C-f\C-x" 'sgml-expand-element)
866 (define-key sgml-mode-map "\C-c\C-i" 'sgml-add-element-to-element)
867 (define-key sgml-mode-map "\C-c\C-k" 'sgml-kill-markup)
868 (define-key sgml-mode-map "\C-c\r" 'sgml-split-element)
869 (define-key sgml-mode-map "\C-c\C-n" 'sgml-up-element)
870 (define-key sgml-mode-map "\C-c\C-o" 'sgml-next-trouble-spot)
871 (define-key sgml-mode-map "\C-c\C-p" 'sgml-load-doctype)
872 (define-key sgml-mode-map "\C-c\C-q" 'sgml-fill-element)
873 (define-key sgml-mode-map "\C-c\C-r" 'sgml-tag-region)
874 (define-key sgml-mode-map "\C-c\C-s" 'sgml-show-structure)
875 ;(define-key sgml-mode-map "\C-c\C-t" 'sgml-list-valid-tags)
876 (define-key sgml-mode-map "\C-c\C-t" 'sgml-show-current-element-type)
877 (define-key sgml-mode-map "\C-c\C-u\C-a" 'sgml-unfold-all)
878 (define-key sgml-mode-map "\C-c\C-u\C-d" 'sgml-custom-dtd)
879 (define-key sgml-mode-map "\C-c\C-u\C-e" 'sgml-unfold-element)
880 (define-key sgml-mode-map "\C-c\C-u\C-l" 'sgml-unfold-line)
881 (define-key sgml-mode-map "\C-c\C-u\C-m" 'sgml-custom-markup)
882 (define-key sgml-mode-map "\C-c\C-v" 'sgml-validate)
883 (define-key sgml-mode-map "\C-c\C-w" 'sgml-what-element)
884 (define-key sgml-mode-map "\C-c\C-z" 'sgml-trim-and-leave-element)
885
886 (define-key sgml-mode-map "\e\C-a" 'sgml-beginning-of-element)
887 (define-key sgml-mode-map "\e\C-e" 'sgml-end-of-element)
888 (define-key sgml-mode-map "\e\C-f" 'sgml-forward-element)
889 (define-key sgml-mode-map "\e\C-b" 'sgml-backward-element)
890 (define-key sgml-mode-map "\e\C-d" 'sgml-down-element)
891 (define-key sgml-mode-map "\e\C-u" 'sgml-backward-up-element)
892 (define-key sgml-mode-map "\e\C-k" 'sgml-kill-element)
893 (define-key sgml-mode-map "\e\C-@" 'sgml-mark-element)
894 ;;(define-key sgml-mode-map [?\M-\C-\ ] 'sgml-mark-element)
895 (define-key sgml-mode-map [(meta control h)] 'sgml-mark-current-element)
896 (define-key sgml-mode-map "\e\C-t" 'sgml-transpose-element)
897 (define-key sgml-mode-map "\M-\t" 'sgml-complete)
898
899 ;;;; Menu bar
900
901 (easy-menu-define
902 sgml-main-menu sgml-mode-map "Main menu"
903 '("SGML"
904 ["Parse DTD" sgml-parse-prolog t]
905 ("DTD Info"
906 ["General DTD info" sgml-general-dtd-info t]
907 ["Describe element type" sgml-describe-element-type t]
908 ["Describe entity" sgml-describe-entity t]
909 ["List elements" sgml-list-elements t]
910 ["List attributes" sgml-list-attributes t]
911 ["List terminals" sgml-list-terminals t]
912 ["List content elements" sgml-list-content-elements t]
913 ["List occur in elements" sgml-list-occur-in-elements t])
914 ("Insert Markup"
915 ["Insert Element" sgml-element-menu t]
916 ["Insert Start-Tag" sgml-start-tag-menu t]
917 ["Insert End-Tag" sgml-end-tag-menu t]
918 ["End Current Element" sgml-insert-end-tag t]
919 ["Tag Region" sgml-tag-region-menu t]
920 ["Insert Attribute" sgml-attrib-menu t]
921 ["Insert Entity" sgml-entities-menu t]
922 ["Add Element to Element" sgml-add-element-menu t]
923 ("Insert DTD")
924 ("Custom markup" "---"))
925 "--"
926 ["Show Context" sgml-show-context t]
927 ["What Element" sgml-what-element t]
928 ["List Valid Tags" sgml-list-valid-tags t]
929 ["Validate" sgml-validate t]
930 "--"
931 ("Move"
932 ["Next trouble spot" sgml-next-trouble-spot t]
933 ["Next data field" sgml-next-data-field t]
934 ["Forward element" sgml-forward-element t]
935 ["Backward element" sgml-backward-element t]
936 ["Up element" sgml-up-element t]
937 ["Down element" sgml-down-element t]
938 ["Backward up element" sgml-backward-up-element t]
939 ["Beginning of element" sgml-beginning-of-element t]
940 ["End of element" sgml-end-of-element t])
941 ("View"
942 ["Fold Element" sgml-fold-element t]
943 ["Fold Subelement" sgml-fold-subelement t]
944 ["Unfold Line" sgml-unfold-line t]
945 ["Unfold Element" sgml-unfold-element t]
946 ["Expand" sgml-expand-element t]
947 ["Fold Region" sgml-fold-region t]
948 ["Unfold All" sgml-unfold-all t]
949 ["Hide Tags" sgml-hide-tags t]
950 ["Hide Attributes" sgml-hide-attributes t]
951 ["Show All Tags" sgml-show-tags t])
952 "--"
953 ["Normalize Document" sgml-normalize t]
954 ["Normalize Element" sgml-normalize-element t]
955 ["Expand All Short References" sgml-expand-all-shortrefs (not sgml-xml-p)]
956 ["Expand Entity Reference" sgml-expand-entity-reference t]
957 ["Make Character Reference" sgml-make-character-reference t]
958 ["Unmake Character Reference" (sgml-make-character-reference t) t]
959 ["Fill Element" sgml-fill-element t]
960 ["Change Element Name..." sgml-change-element-name t]
961 ["Edit Attributes..." sgml-edit-attributes t]
962 ["Kill Markup" sgml-kill-markup t]
963 ["Kill Element" sgml-kill-element t]
964 ["Untag Element" sgml-untag-element t]
965 ["Trim and leave element" sgml-trim-and-leave-element t]
966 ["Decode Character Entities" sgml-charent-to-display-char t]
967 ["Encode Characters" sgml-display-char-to-charent t]
968 "--"
969 ("File Options" "---")
970 ("User Options" "---")
971 ["Reset Buffer" normal-mode t]
972 ["Submit Bug Report" sgml-submit-bug-report t]
973 ))
974
975
976 (defun sgml-options-menu-items (vars)
977 (mapcar (lambda (var)
978 (let ((desc (format "%s [%s]"
979 (sgml-variable-description var)
980 (sgml-option-value-indicator var)))
981 (type (sgml-variable-type var)))
982 (cond ((consp type)
983 (cons desc
984 (mapcar (lambda (c)
985 (vector
986 (if (consp c) (car c) (format "%s" c))
987 `(setq ,var ',(if (consp c) (cdr c) c))
988 t))
989 type)))
990 (t
991 (vector desc `(sgml-do-set-option ',var) t)))))
992 vars))
993
994 (defun sgml-option-value-indicator (var)
995 (let ((type (sgml-variable-type var))
996 (val (symbol-value var)))
997 (cond
998 ((eq type 'toggle)
999 (if val "Yes" "No"))
1000 ((eq type 'string)
1001 (if (stringp val)
1002 (substring val 0 (min (length val) 4))
1003 "-"))
1004 ((and (atom type) val)
1005 "...")
1006 ((consp type)
1007 (or (car (rassq val type))
1008 val))
1009 (t
1010 "-"))))
1011
1012 (defvar sgml-last-options-menu-values ())
1013
1014 (defun sgml-any-option-changed (oldvalues vars)
1015 (not (loop for val in oldvalues
1016 for var in vars
1017 always (eq val (symbol-value var)))))
1018
1019 (defun sgml-update-options-menu (menuname option-vars &optional save-func)
1020 (let ((last-values (assoc menuname sgml-last-options-menu-values)))
1021 (when (or (null last-values)
1022 (sgml-any-option-changed (cdr last-values)
1023 option-vars))
1024 (condition-case err
1025 (easy-menu-change '("SGML") menuname
1026 (nconc (sgml-options-menu-items option-vars)
1027 (if save-func
1028 (list "---"
1029 (vector (format "Save %s" menuname)
1030 save-func t)))))
1031 (error
1032 (message "Error in update menu: %s" err)))
1033 (unless last-values
1034 (setq last-values (cons menuname nil))
1035 (push last-values sgml-last-options-menu-values))
1036 (setf (cdr last-values) (mapcar (function symbol-value) option-vars)))))
1037
1038
1039 (defun sgml-update-all-options-menus ()
1040 (sgml-update-options-menu "File Options" sgml-file-options
1041 'sgml-save-options)
1042 (sgml-update-options-menu "User Options" sgml-user-options)
1043 nil)
1044
1045 (defun sgml-compute-insert-dtd-items ()
1046 (loop for e in sgml-custom-dtd collect
1047 (vector (first e)
1048 `(sgml-doctype-insert ,(cadr e) ',(cddr e))
1049 t)))
1050
1051 (defun sgml-compute-custom-markup-items ()
1052 (loop for e in sgml-custom-markup collect
1053 (vector (first e)
1054 `(sgml-insert-markup ,(cadr e))
1055 t)))
1056
1057 (defun sgml-build-custom-menus ()
1058 "Build custom parts of Markup and DTD menus."
1059 (let ((button3 (lookup-key (current-local-map) [button3])))
1060 (unless (or (null button3)
1061 (numberp button3))
1062 (local-set-key [button3] button3))
1063 (when sgml-custom-dtd
1064 (easy-menu-change '("SGML" "Insert Markup") "Insert DTD"
1065 (sgml-compute-insert-dtd-items)))
1066 (when sgml-custom-markup
1067 (easy-menu-change '("SGML" "Insert Markup") "Custom markup"
1068 (sgml-compute-custom-markup-items))))
1069 nil)
1070
1071
1072 ;;;; Post command hook
1073
1074 (defvar sgml-auto-activate-dtd-tried nil)
1075 (make-variable-buffer-local 'sgml-auto-activate-dtd-tried)
1076
1077 (defvar sgml-buffer-parse-state nil
1078 "If the buffers DTD has been activated this contains the parser state.
1079 The parser state has been created with `sgml-make-pstate' and contains
1080 the information about the DTD and the parse tree. This parse state is
1081 actually only the state that persists between commands.")
1082 (make-variable-buffer-local 'sgml-buffer-parse-state)
1083
1084 (eval-and-compile ; Interface to psgml-parse
1085 (loop for fun in '(sgml-need-dtd sgml-update-display
1086 sgml-fontify-buffer
1087 sgml-subst-expand
1088 sgml-declaration)
1089 do (autoload fun "psgml-parse")))
1090
1091
1092 (defun sgml-command-post ()
1093 (when (and (null sgml-buffer-parse-state)
1094 sgml-auto-activate-dtd
1095 (null sgml-auto-activate-dtd-tried)
1096 (not (zerop (buffer-size)))
1097 (looking-at ".*<"))
1098 (setq sgml-auto-activate-dtd-tried t)
1099 (ignore-errors
1100 (sgml-need-dtd)
1101 (sgml-fontify-buffer 0)))
1102 (when sgml-buffer-parse-state
1103 (sgml-update-display)))
1104
1105
1106 ;;;; SGML mode: major mode definition
1107
1108 ;;; This section is mostly from sgml-mode by James Clark.
1109
1110 ;;;###autoload
1111 (defun sgml-mode ()
1112 "Major mode for editing SGML.
1113 \\<sgml-mode-map>Makes > display the matching <. Makes / display matching /.
1114 Use \\[sgml-validate] to validate your document with an SGML parser.
1115
1116 You can find information with:
1117 \\[sgml-show-context] Show the nesting of elements at cursor position.
1118 \\[sgml-list-valid-tags] Show the tags valid at cursor position.
1119
1120 Insert tags with completion of contextually valid tags with \\[sgml-insert-tag].
1121 End the current element with \\[sgml-insert-end-tag]. Insert an element (i.e.
1122 both start and end tag) with \\[sgml-insert-element]. Or tag a region with
1123 \\[sgml-tag-region].
1124
1125 To tag a region with the mouse, use transient mark mode or secondary selection.
1126
1127 Structure editing:
1128 \\[sgml-backward-element] Moves backwards over the previous element.
1129 \\[sgml-forward-element] Moves forward over the next element.
1130 \\[sgml-down-element] Move forward and down one level in the element structure.
1131 \\[sgml-backward-up-element] Move backward out of this element level.
1132 \\[sgml-beginning-of-element] Move to after the start tag of the current element.
1133 \\[sgml-end-of-element] Move to before the end tag of the current element.
1134 \\[sgml-kill-element] Kill the element following the cursor.
1135
1136 Finding interesting positions
1137 \\[sgml-next-data-field] Move forward to next point where data is allowed.
1138 \\[sgml-next-trouble-spot] Move forward to next point where something is
1139 amiss with the structure.
1140
1141 Folding and unfolding
1142 \\[sgml-fold-element] Fold the lines comprising the current element, leaving
1143 the first line visible.
1144 \\[sgml-fold-subelement] Fold the elements in the content of the current element.
1145 Leaving the first line of every element visible.
1146 \\[sgml-unfold-line] Show hidden lines in current line.
1147
1148 User options:
1149
1150 sgml-omittag Set this to reflect OMITTAG in the SGML declaration.
1151 sgml-shorttag Set this to reflect SHORTTAG in the SGML declaration.
1152 sgml-namecase-general Set this to reflect NAMECASE GENERAL in the SGML declaration.
1153 sgml-auto-insert-required-elements If non-nil, automatically insert required
1154 elements in the content of an inserted element.
1155 sgml-omittag-transparent If non-nil, will show legal tags inside elements
1156 with omitable start tags and legal tags beyond omitable end tags.
1157 sgml-leave-point-after-insert If non-nil, the point will remain after
1158 inserted tag(s).
1159 sgml-warn-about-undefined-elements If non-nil, print a warning when a tag
1160 for a undefined element is found.
1161 sgml-max-menu-size Max number of entries in Tags and Entities menus before
1162 they are split into several panes.
1163 sgml-always-quote-attributes If non-nil, quote all attribute values
1164 inserted after finishing edit attributes.
1165 sgml-minimize-attributes Determines minimization of attributes inserted by
1166 edit-attributes.
1167 sgml-normalize-trims If non-nil, sgml-normalize will trim off white space
1168 from end of element when adding end tag.
1169 sgml-indent-step How much to increment indent for every element level.
1170 sgml-indent-data If non-nil, indent in data/mixed context also.
1171 sgml-set-face If non-nil, psgml will set the face of parsed markup.
1172 sgml-markup-faces The faces used when the above variable is non-nil.
1173 sgml-public-map Mapping from public identifiers to file names.
1174 sgml-offer-save If non-nil, ask about saving modified buffers before
1175 \\[sgml-validate] is run.
1176
1177 All bindings:
1178 \\{sgml-mode-map}"
1179 (interactive)
1180 (kill-all-local-variables)
1181 (setq sgml-xml-p nil)
1182 (setq local-abbrev-table sgml-mode-abbrev-table)
1183 (use-local-map sgml-mode-map)
1184 (setq mode-name "SGML")
1185 (setq major-mode 'sgml-mode)
1186
1187 ;; A start or end tag by itself on a line separates a paragraph.
1188 ;; This is desirable because SGML discards a newline that appears
1189 ;; immediately after a start tag or immediately before an end tag.
1190
1191 (set (make-local-variable 'paragraph-separate)
1192 (if sgml-have-re-char-clases
1193 "^[ \t\n]*$\\|\
1194 ^[ \t]*</?\\([_[:alpha:]]\\([-:._[:alnum:]= \t\n]\\|\
1195 \"[^\"]*\"\\|'[^']*'\\)*\\)?>$"
1196 "^[ \t\n]*$\\|\
1197 ^[ \t]*</?\\([_A-Za-z]\\([-:._A-Za-z0-9= \t\n]\\|\
1198 \"[^\"]*\"\\|'[^']*'\\)*\\)?>$"))
1199 (set (make-local-variable 'paragraph-start)
1200 paragraph-separate)
1201
1202 (set-syntax-table sgml-mode-syntax-table)
1203 (make-local-variable 'comment-start)
1204 (setq comment-start "<!-- ")
1205 (make-local-variable 'comment-end)
1206 (setq comment-end " -->")
1207 (make-local-variable 'comment-indent-function)
1208 (setq comment-indent-function 'sgml-comment-indent)
1209 (make-local-variable 'comment-start-skip)
1210 ;; This will allow existing comments within declarations to be
1211 ;; recognized. [Does not work well with auto-fill, Lst/940205]
1212 ;;(setq comment-start-skip "--[ \t]*")
1213 (setq comment-start-skip "<!--[ \t]*")
1214 ;; Added for psgml:
1215 (make-local-variable 'indent-line-function)
1216 (setq indent-line-function 'sgml-indent-line)
1217 (make-local-variable 'mode-line-format)
1218 (if (featurep 'xemacs)
1219 ;; Modify mode-line-format with susbt (sugested by wing)
1220 ;; Apart from requiring CL at runtime, this doesn't work in Emacs
1221 ;; 21. It's the sort of thing which-func is supposed to do...
1222 (setq mode-line-format
1223 (subst '("" mode-name sgml-active-dtd-indicator) 'mode-name
1224 mode-line-format))
1225 (set (make-local-variable 'which-func-format) 'sgml-active-dtd-indicator))
1226 (make-local-variable 'sgml-default-dtd-file)
1227 (when (setq sgml-default-dtd-file (sgml-default-dtd-file))
1228 (unless (file-exists-p sgml-default-dtd-file)
1229 (setq sgml-default-dtd-file nil)))
1230 ;;; This doesn't DTRT with Emacs 21.1 newcomment -- intermediate lines
1231 ;;; are prefixed by `!--'. -- fx
1232 ;;; (set (make-local-variable 'comment-style) 'multi-line)
1233 (when sgml-default-nonsticky
1234 (make-local-variable 'text-property-default-nonsticky)
1235 ;; see `sgml-set-face-for':
1236 (add-to-list 'text-property-default-nonsticky '(face . t)))
1237 (add-hook 'post-command-hook 'sgml-command-post 'append 'local)
1238 (add-hook 'activate-menubar-hook 'sgml-update-all-options-menus
1239 nil 'local)
1240 (run-hooks 'text-mode-hook 'sgml-mode-hook)
1241 (easy-menu-add sgml-main-menu)
1242 (sgml-build-custom-menus))
1243
1244 ;; It would be nice to generalize the `auto-mode-interpreter-regexp'
1245 ;; machinery so that we could select xml-mode on the basis of the
1246 ;; leading xml PI. -- fx
1247
1248 ;;;###autoload
1249 (define-derived-mode xml-mode sgml-mode "XML"
1250 "Major mode for editing XML, specialized from SGML mode.
1251 Sets various variables appropriately for XML.
1252
1253 Can be used without a DTD. In that case, warnings about undefined
1254 elements and entities are suppressed and various commands' behaviour
1255 is modified to account for the lack of information. For instance, the
1256 element names offered for selection or completion are those in the
1257 parse of the document, but other names may be entered.
1258
1259 Note that without a DTD, indenting lines will only work if
1260 `sgml-indent-data' is non-nil."
1261 (setq sgml-xml-p t)
1262 ;; XML-friendly settings
1263 (setq sgml-omittag nil)
1264 (setq sgml-shorttag nil)
1265 (setq sgml-namecase-general nil)
1266 (setq sgml-minimize-attributes nil)
1267 (setq sgml-always-quote-attributes t)
1268 (make-local-variable 'sgml-declaration)
•1269 (setq sgml-declaration sgml-xml-declaration)
1270 (setq sgml-validate-command sgml-xml-validate-command)
1271 )
1272
1273 (defun sgml-default-dtd-file ()
1274 (and (buffer-file-name)
1275 (let ((base (file-name-nondirectory (buffer-file-name))))
1276 (concat
1277 (cond ((string-match "\\.[^.]+$" base)
1278 (substring base 0 (match-beginning 0)))
1279 (t
1280 base))
1281 ".ced"))))
1282
1283 (defun sgml-comment-indent ()
1284 (if (and (looking-at "--")
1285 (not (and (eq (char-after (1- (point))) ?!)
1286 (eq (char-after (- (point) 2)) ?<))))
1287 (progn
1288 (skip-chars-backward " \t")
1289 (max comment-column (1+ (current-column))))
1290 0))
1291
1292 (defconst sgml-start-tag-regex
1293 (if sgml-have-re-char-clases
1294 "<[_[:alpha:]]\\([-:.[:alnum:]= \n\t]\\|\"[^\"]*\"\\|'[^']*'\\)*"
1295 "<[_A-Za-z]\\([-:.A-Za-z0-9= \n\t]\\|\"[^\"]*\"\\|'[^']*'\\)*")
1296 "Regular expression that matches a non-empty start tag.
1297 Any terminating > or / is not matched.")
1298
1299 (defvar sgml-mode-markup-syntax-table nil
1300 "Syntax table used for scanning SGML markup.")
1301
1302 (if sgml-mode-markup-syntax-table
1303 ()
1304 (setq sgml-mode-markup-syntax-table (make-syntax-table))
1305 (modify-syntax-entry ?< "(>" sgml-mode-markup-syntax-table)
1306 (modify-syntax-entry ?> ")<" sgml-mode-markup-syntax-table)
1307 (modify-syntax-entry ?- "_ 1234" sgml-mode-markup-syntax-table)
1308 (modify-syntax-entry ?\' "\"" sgml-mode-markup-syntax-table))
1309
1310 (defvar sgml-angle-distance 4000
1311 "*If non-nil, is the maximum distance to search for matching <.")
1312
1313 (defun sgml-close-angle (arg)
1314 "Insert > and display matching <."
1315 (interactive "p")
1316 (insert-char ?> arg)
1317 (if (> arg 0)
1318 (let ((oldpos (point))
1319 (blinkpos))
1320 (save-excursion
1321 (save-restriction
1322 (if sgml-angle-distance
1323 (narrow-to-region (max (point-min)
1324 (- (point) sgml-angle-distance))
1325 oldpos))
1326 ;; See if it's the end of a marked section.
1327 (and (> (- (point) (point-min)) 3)
1328 (eq (char-after (- (point) 2)) ?\])
1329 (eq (char-after (- (point) 3)) ?\])
1330 (re-search-backward (if sgml-have-re-char-clases
1331 "<!\\[\\(-?[[:alnum:]. \t\n&;]\\|\
1332 --\\([^-]\\|-[^-]\\)*--\\)*\\["
1333 "<!\\[\\(-?[A-Za-z0-9. \t\n&;]\\|\
1334 --\\([^-]\\|-[^-]\\)*--\\)*\\[")
1335 (point-min)
1336 t)
1337 (let ((msspos (point)))
1338 (if (and (search-forward "]]>" oldpos t)
1339 (eq (point) oldpos))
1340 (setq blinkpos msspos))))
1341 ;; This handles cases where the > ends one of the following:
1342 ;; markup declaration starting with <! (possibly including a
1343 ;; declaration subset); start tag; end tag; SGML declaration.
1344 (if blinkpos
1345 ()
1346 (goto-char oldpos)
1347 (condition-case ()
1348 (let ((oldtable (syntax-table))
1349 (parse-sexp-ignore-comments t))
1350 (unwind-protect
1351 (progn
1352 (set-syntax-table sgml-mode-markup-syntax-table)
1353 (setq blinkpos (scan-sexps oldpos -1)))
1354 (set-syntax-table oldtable)))
1355 (error nil))
1356 (and blinkpos
1357 (goto-char blinkpos)
1358 (or
1359 ;; Check that it's a valid delimiter in context.
1360 (not (looking-at
1361 (if sgml-have-re-char-clases
1362 "<\\(\\?\\|/?[[:alpha:]>]\\|!\\([[[:alpha:]]\\|--\\)\\)"
1363 "<\\(\\?\\|/?[A-Za-z>]\\|!\\([[A-Za-z]\\|--\\)\\)")))
1364 ;; Check that it's not a net-enabling start tag
1365 ;; nor an unclosed start-tag.
1366 (looking-at (concat sgml-start-tag-regex "[/<]"))
1367 ;; Nor an unclosed end-tag.
1368 (looking-at (if sgml-have-re-char-clases
1369 "</[[:alpha:]][-:.[:alnum:]]*[ \t]*<"
1370 "</[A-Za-z][-:.A-Za-z0-9]*[ \t]*<")))
1371 (setq blinkpos nil)))
1372 (if blinkpos
1373 ()
1374 ;; See if it's the end of a processing instruction.
1375 (goto-char oldpos)
1376 (if (search-backward "<?" (point-min) t)
1377 (let ((pipos (point)))
1378 (if (and (search-forward ">" oldpos t)
1379 (eq (point) oldpos))
1380 (setq blinkpos pipos))))))
1381 (if blinkpos
1382 (progn
1383 (goto-char blinkpos)
1384 (if (pos-visible-in-window-p)
1385 (sit-for 1)
1386 (message "Matches %s"
1387 (buffer-substring blinkpos
1388 (progn (end-of-line)
1389 (point)))))))))))
1390
1391 ;;; I doubt that null end tags are used much for large elements,
1392 ;;; so use a small distance here.
1393 (defvar sgml-slash-distance 1000
1394 "*If non-nil, is the maximum distance to search for matching /.")
1395
1396 (defun sgml-slash (arg)
1397 "Insert / and display any previous matching /.
1398 Two /s are treated as matching if the first / ends a net-enabling
1399 start tag, and the second / is the corresponding null end tag."
1400 (interactive "p")
1401 (insert-char ?/ arg)
1402 (if (> arg 0)
1403 (let ((oldpos (point))
1404 (blinkpos)
1405 (level 0))
1406 (save-excursion
1407 (save-restriction
1408 (if sgml-slash-distance
1409 (narrow-to-region (max (point-min)
1410 (- (point) sgml-slash-distance))
1411 oldpos))
1412 (if (and (re-search-backward sgml-start-tag-regex (point-min) t)
1413 (eq (match-end 0) (1- oldpos)))
1414 ()
1415 (goto-char (1- oldpos))
1416 (while (and (not blinkpos)
1417 (search-backward "/" (point-min) t))
1418 (let ((tagend (save-excursion
1419 (if (re-search-backward sgml-start-tag-regex
1420 (point-min) t)
1421 (match-end 0)
1422 nil))))
1423 (if (eq tagend (point))
1424 (if (eq level 0)
1425 (setq blinkpos (point))
1426 (setq level (1- level)))
1427 (setq level (1+ level)))))))
1428 (if blinkpos
1429 (progn
1430 (goto-char blinkpos)
1431 (if (pos-visible-in-window-p)
1432 (sit-for 1)
1433 (message "Matches %s"
1434 (buffer-substring (progn
1435 (beginning-of-line)
1436 (point))
1437 (1+ blinkpos))))))))))
1438
1439 (eval-and-compile
•1440 (autoload 'compilation-start "compile" ""))
1441
1442 (defun sgml-default-validate-command ()
1443 (cond
1444 ((consp sgml-validate-command)
1445 (let ((validate-subst
1446 (list
1447 (cons ?b (and (buffer-file-name)
1448 (file-name-nondirectory (buffer-file-name))))
1449 (cons ?s (sgml-declaration))
1450 (cons ?v sgml-declaration)
1451 (cons ?d sgml-doctype))))
1452 (loop for template in sgml-validate-command
1453 thereis
1454 (sgml-subst-expand template validate-subst))))
1455 (t
1456 (apply 'format sgml-validate-command
1457 (if sgml-validate-files
1458 (funcall sgml-validate-files)
1459 (list (or sgml-declaration "")
1460 (let ((name (buffer-file-name)))
1461 (if name
1462 (file-name-nondirectory name)
1463 ""))))))))
1464
1465 (defun sgml-validate (command)
1466 "Validate an SGML document.
1467 Runs COMMAND, a shell command, in a separate process asynchronously
1468 with output going to the buffer *compilation*.
1469 You can then use the command \\[next-error] to find the next error message
1470 and move to the line in the SGML document that caused it."
1471 (interactive
1472 (list (read-from-minibuffer "Validate command: "
1473 (sgml-default-validate-command)
1474 nil nil 'sgml-validate-command-history)))
1475 (if sgml-offer-save
1476 (save-some-buffers nil nil))
•1477 (compilation-start command 'compilation-minor-mode nil sgml-validate-error-regexps))
1478
1479 (defalias 'sgml-restore-buffer-modified-p
1480 (if (fboundp 'restore-buffer-modified-p)
1481 'restore-buffer-modified-p ; doesn't update mode line
1482 'set-buffer-modified-p))
1483
1484 ;;;; Autoloads and hooks
1485
1486 (autoload 'sgml-doctype-insert "psgml-edit"
1487 nil
1488 nil nil)
1489 (autoload 'sgml-indent-line "psgml-edit" nil)
1490 (autoload 'sgml-element-endable-p "psgml-edit" nil)
1491 (autoload 'sgml-do-set-option "psgml-edit" nil)
1492
1493 ;;; Generated by sgml-build-autoloads
1494
1495 (autoload 'sgml-load-dtd "psgml-parse" "Load a saved DTD from FILE." t)
1496 (autoload 'sgml-show-or-clear-log "psgml-parse" "Show the *SGML LOG* buffer if it is not showing, or clear and
1497 remove it if it is showing." t)
1498 (autoload 'sgml-load-doctype "psgml-parse" "Load the documents DTD.
1499 Either from parent document or by parsing the document prolog." t)
1500 (autoload 'sgml-parse-prolog "psgml-parse" "Parse the document prolog to learn the DTD." t)
1501 (autoload 'sgml-beginning-of-element "psgml-edit" "Move to after the start-tag of the current element.
1502 If the start-tag is implied, move to the start of the element." t)
1503 (autoload 'sgml-end-of-element "psgml-edit" "Move to before the end-tag of the current element." t)
1504 (autoload 'sgml-backward-up-element "psgml-edit" "Move backward out of this element level.
1505 That is move to before the start-tag or where a start-tag is implied." t)
1506 (autoload 'sgml-up-element "psgml-edit" "Move forward out of this element level.
1507 That is move to after the end-tag or where an end-tag is implied." t)
1508 (autoload 'sgml-forward-element "psgml-edit" "Move forward over next element." t)
1509 (autoload 'sgml-backward-element "psgml-edit" "Move backward over previous element at this level.
1510 With implied tags this is ambiguous." t)
1511 (autoload 'sgml-down-element "psgml-edit" "Move forward and down one level in the element structure." t)
1512 (autoload 'sgml-kill-element "psgml-edit" "Kill the element following the cursor." t)
1513 (autoload 'sgml-transpose-element "psgml-edit" "Interchange element before point with element after point, leave point after." t)
1514 (autoload 'sgml-mark-element "psgml-edit" "Set mark after next element." t)
1515 (autoload 'sgml-mark-current-element "psgml-edit" "Set mark at end of current element, and leave point before current element." t)
1516 (autoload 'sgml-change-element-name "psgml-edit" "Replace the name of the current element with a new name.
1517 Eventual attributes of the current element will be translated if
1518 possible." t)
1519 (autoload 'sgml-untag-element "psgml-edit" "Remove tags from current element." t)
1520 (autoload 'sgml-kill-markup "psgml-edit" "Kill next tag, markup declaration or process instruction." t)
1521 (autoload 'sgml-fold-region "psgml-edit" "Hide (or if prefixarg unhide) region.
1522 If called from a program first two arguments are start and end of
1523 region. And optional third argument true unhides." t)
1524 (autoload 'sgml-fold-element "psgml-edit" "Fold the lines comprising the current element, leaving the first line visible.
1525 This uses the selective display feature." t)
1526 (autoload 'sgml-fold-subelement "psgml-edit" "Fold all elements current elements content, leaving the first lines visible.
1527 This uses the selective display feature." t)
1528 (autoload 'sgml-unfold-line "psgml-edit" "Show hidden lines in current line." t)
1529 (autoload 'sgml-unfold-element "psgml-edit" "Show all hidden lines in current element." t)
1530 (autoload 'sgml-expand-element "psgml-edit" "As sgml-fold-subelement, but unfold first." t)
1531 (autoload 'sgml-unfold-all "psgml-edit" "Show all hidden lines in buffer." t)
1532 (autoload 'sgml-next-data-field "psgml-edit" "Move forward to next point where data is allowed." t)
1533 (autoload 'sgml-next-trouble-spot "psgml-edit" "Move forward to next point where something is amiss with the structure." t)
1534 (autoload 'sgml-list-valid-tags "psgml-edit" "Display a list of the contextually valid tags." t)
1535 (autoload 'sgml-show-context "psgml-edit" "Display where the cursor is in the element hierarchy." t)
1536 (autoload 'sgml-what-element "psgml-edit" "Display what element is under the cursor." t)
1537 (autoload 'sgml-insert-tag "psgml-edit" "Insert a tag, reading tag name in minibuffer with completion.
1538 If sgml-leave-point-after-insert is t, the point is left after the
1539 inserted tag(s), unless the element has some required content. If
1540 sgml-leave-point-after-insert is nil the point is left after the first
1541 tag inserted." t)
1542 (autoload 'sgml-insert-element "psgml-edit" "Reads element name from minibuffer and inserts start and end tags." t)
1543 (autoload 'sgml-tag-region "psgml-edit" "Reads element name from minibuffer and inserts start and end tags." t)
1544 (autoload 'sgml-insert-end-tag "psgml-edit" "Insert end-tag for the current open element." t)
1545 (autoload 'sgml-insert-attribute "psgml-edit" "Read attribute name and value from minibuffer and insert attribute spec." t)
1546 (autoload 'sgml-split-element "psgml-edit" "Split the current element at point.
1547 If repeated, the containing element will be split before the beginning
1548 of then current element." t)
1549 (autoload 'sgml-custom-dtd "psgml-edit" "Insert a DTD declaration from the sgml-custom-dtd alist." t)
1550 (autoload 'sgml-custom-markup "psgml-edit" "Insert markup from the sgml-custom-markup alist." t)
1551 (autoload 'sgml-tags-menu "psgml-edit" "Pop up a menu with valid tags and insert the chosen tag.
1552 If the variable sgml-balanced-tag-edit is t, also inserts the
1553 corresponding end tag. If sgml-leave-point-after-insert is t, the point
1554 is left after the inserted tag(s), unless the element has some required
1555 content. If sgml-leave-point-after-insert is nil the point is left
1556 after the first tag inserted." t)
1557 (autoload 'sgml-element-menu "psgml-edit" "Pop up a menu with valid elements and insert choice.
1558 If sgml-leave-point-after-insert is nil the point is left after the first
1559 tag inserted." t)
1560 (autoload 'sgml-add-element-menu "psgml-edit" nil t)
1561 (autoload 'sgml-start-tag-menu "psgml-edit" "Pop up a menu with valid start-tags and insert choice." t)
1562 (autoload 'sgml-end-tag-menu "psgml-edit" "Pop up a menu with valid end-tags and insert choice." t)
1563 (autoload 'sgml-tag-region-menu "psgml-edit" "Pop up a menu with valid elements and tag current region with the choice." t)
1564 (autoload 'sgml-entities-menu "psgml-edit" nil t)
1565 (autoload 'sgml-attrib-menu "psgml-edit" "Pop up a menu of the attributes of the current element
1566 \(or the element with start-tag before point)." t)
1567 (autoload 'sgml-right-menu "psgml-edit" "Pop up a menu with valid tags and insert the choosen tag.
1568 If the variable sgml-balanced-tag-edit is t, also inserts the
1569 corresponding end tag. If sgml-leave-point-after-insert is t, the point
1570 is left after the inserted tag(s), unless the element has som required
1571 content. If sgml-leave-point-after-insert is nil the point is left
1572 after the first tag inserted." t)
1573 (autoload 'sgml-fill-element "psgml-edit" "Fill biggest enclosing element with mixed content.
1574 If current element has pure element content, recursively fill the
1575 subelements." t)
1576 (autoload 'sgml-edit-attributes "psgml-edit" "Edit attributes of current element.
1577 Editing is done in a separate window." t)
1578 (autoload 'sgml-edit-attrib-finish "psgml-edit" "Finish editing and insert attribute values in original buffer." t)
1579 (autoload 'sgml-edit-attrib-default "psgml-edit" "Set current attribute value to default." t)
1580 (autoload 'sgml-edit-attrib-clear "psgml-edit" "Kill the value of current attribute." t)
1581 (autoload 'sgml-edit-attrib-field-start "psgml-edit" "Go to the start of the attribute value field." t)
1582 (autoload 'sgml-edit-attrib-field-end "psgml-edit" "Go to the end of the attribute value field." t)
1583 (autoload 'sgml-edit-attrib-next "psgml-edit" "Move to next attribute value." t)
1584 (autoload 'sgml-hide-tags "psgml-edit" "Hide all tags in buffer." t)
1585 (autoload 'sgml-show-tags "psgml-edit" "Show hidden tags in buffer." t)
1586 (autoload 'sgml-hide-attributes "psgml-edit" "Hide all attribute specifications in the buffer." t)
1587 (autoload 'sgml-show-attributes "psgml-edit" "Show all attribute specifications in the buffer." t)
1588 (autoload 'sgml-expand-all-shortrefs "psgml-edit" "Expand all short references in the buffer.
1589 Short references to text entities are expanded to the replacement text
1590 of the entity; other short references are expanded into general entity
1591 references. If argument TO-ENTITY is non-nil, or if called
1592 interactively with a numeric prefix argument, all short references are
1593 replaced by general entity references." t)
1594 (autoload 'sgml-normalize "psgml-edit" "Normalize buffer by filling in omitted tags and expanding empty tags.
1595 Argument TO-ENTITY controls how short references are expanded as with
1596 `sgml-expand-all-shortrefs'. An optional argument ELEMENT can be the
1597 element to normalize instead of the whole buffer, if used no short
1598 references will be expanded." t)
1599 (autoload 'sgml-normalize-element "psgml-edit" nil t)
1600 (autoload 'sgml-make-character-reference "psgml-edit" "Convert character after point into a character reference.
1601 If called with a numeric argument, convert a character reference back
1602 to a normal character. If called from a program, set optional
1603 argument INVERT to non-nil." t)
1604 (autoload 'sgml-expand-entity-reference "psgml-edit" "Insert the text of the entity referenced at point." t)
1605 (autoload 'sgml-trim-and-leave-element "psgml-edit" "Remove blanks at end of current element and move point to after element." t)
1606 (autoload 'sgml-edit-external-entity "psgml-edit" "Open a new window and display the external entity at the point." t)
1607 (autoload 'sgml-complete "psgml-edit" "Complete the word/tag/entity before point.
1608 If it is a tag (starts with < or </) complete with valid tags.
1609 If it is an entity (starts with &) complete with declared entities.
1610 If it is a markup declaration (starts with <!) complete with markup
1611 declaration names.
1612 If it is something else complete with ispell-complete-word." t)
1613 (autoload 'sgml-file-options-menu "psgml-edit" nil t)
1614 (autoload 'sgml-user-options-menu "psgml-edit" nil t)
1615 (autoload 'sgml-add-element-to-element "psgml-edit" "Add an element of type GI to the current element.
1616 The element will be added at the last legal position if FIRST is `nil',
1617 otherwise it will be added at the first legal position." t)
1618 (autoload 'sgml-show-current-element-type "psgml-edit" "Show information about the current element and its type." t)
1619 (autoload 'sgml-show-structure "psgml-edit" "Show the document structure in a separate buffer." t)
1620 (autoload 'sgml-save-dtd "psgml-dtd" "Save the parsed dtd on FILE." t)
1621 (autoload 'sgml-list-elements "psgml-info" "List the elements and their attributes in the current DTD." t)
1622 (autoload 'sgml-list-attributes "psgml-info" "List the attributes and in which elements they occur." t)
1623 (autoload 'sgml-list-terminals "psgml-info" "List the elements that can have data in their content." t)
1624 (autoload 'sgml-list-content-elements "psgml-info" "List all element types and the element types that can occur in its content." t)
1625 (autoload 'sgml-list-occur-in-elements "psgml-info" "List all element types and where it can occur." t)
1626 (autoload 'sgml-describe-entity "psgml-info" "Describe the properties of an entity as declared in the current DTD." t)
1627 (autoload 'sgml-describe-element-type "psgml-info" "Describe the properties of an element type as declared in the current DTD." t)
1628 (autoload 'sgml-describe-dtd "psgml-info" "Display information about the current DTD." t)
1629 (autoload 'sgml-charent-to-display-char "psgml-charent" "Replace character entities with their display character equivalents" t)
1630 (autoload 'sgml-display-char-to-charent "psgml-charent" "Replace displayable characters with their character entity equivalents" t)
1631
1632
1633 ;;;; Last provisions
1634
1635 (provide 'psgml)
1636 (provide 'sgml-mode)
1637
1638
1639 ;;; psgml.el ends here