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