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