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