annotate lisp/psgml/psgml-info.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;;; psgml-info.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; Last edited: Mon Aug 7 23:00:54 1995 by lenst@katja.lysator.liu.se (Lennart Staflin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; $Id: psgml-info.el,v 1.1.1.1 1996/12/18 03:35:21 steve Exp $
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Copyright (C) 1994, 1995 Lennart Staflin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Author: Lennart Staflin <lenst@lysator.liu.se>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This program is free software; you can redistribute it and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; modify it under the terms of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; as published by the Free Software Foundation; either version 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; of the License, or (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; This file is an addon to the PSGML package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; This file contains some commands to print out information about the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; current DTD.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; sgml-list-elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Will list all elements and the attributes declared for the element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; sgml-list-attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; Will list all attributes declared and the elements that use them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; sgml-list-terminals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; Will list all elements that can contain data.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; sgml-list-occur-in-elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; Will list all element types and where it can occur.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; sgml-list-content-elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; Will list all element types and the element types that can occur
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; in its content.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (require 'psgml)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (require 'psgml-parse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defconst sgml-attr-col 18)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;;; Utility functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defsubst sgml-add-to-table (row-index elem table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (let ((p (assoc row-index table)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (cond ((null p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (cons (list row-index elem) table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (nconc p (list elem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 table))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defsubst sgml-add-last-unique (x l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (unless (memq x l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (nconc l (list x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defun sgml-map-element-types (func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (sgml-need-dtd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (sgml-map-eltypes func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (sgml-pstate-dtd sgml-buffer-parse-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defun sgml-eltype-refrenced-elements (eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 "List of element types referenced in the model of ELTYPE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; Now with cache. Uses appdata prop re-cache.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (sgml-eltype-appdata eltype 're-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (let* ((res ; result list (eltypes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (states ; list of states
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (list (sgml-eltype-model eltype)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (agenda ; point into states
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 states))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ((not (sgml-model-group-p (car states)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (while agenda
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ((sgml-normal-state-p (car agenda))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (loop for m in (append (sgml-state-opts (car agenda))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (sgml-state-reqs (car agenda)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (pushnew (sgml-move-token m) res)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (sgml-add-last-unique (sgml-move-dest m) states)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (t ; &-node
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (sgml-add-last-unique (sgml-&node-next (car agenda)) states)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (loop for dfa in (sgml-&node-dfas (car agenda)) do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (sgml-add-last-unique dfa states))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (setq agenda (cdr agenda)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (setf (sgml-eltype-appdata eltype 're-cache) res)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 res)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;;; List elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defun sgml-list-elements ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 "List the elements and their attributes in the current DTD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (message "Creating table...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (sgml-display-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (sgml-map-element-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (lambda (eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (cons (sgml-eltype-name eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (mapcar (function sgml-attdecl-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (sgml-eltype-attlist eltype))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 "Elements" "Element" "Attribute"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;;; List attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (defun sgml-list-attributes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 "List the attributes and in which elements they occur."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (let ((attributes nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (message "Creating table...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (sgml-map-element-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (lambda (eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (loop for a in (sgml-eltype-attlist eltype) do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (setq attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (sgml-add-to-table (sgml-attdecl-name a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (sgml-eltype-name eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 attributes))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (sgml-display-table attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 "Attributes" "Attribute" "Element")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;;; List terminals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (defun sgml-list-terminals ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 "List the elements that can have data in their content."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (message "Creating table...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (let ((data-models (list sgml-cdata sgml-rcdata sgml-any)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (sgml-display-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (delq nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (sgml-map-element-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (lambda (eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (if (or (sgml-eltype-mixed eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (memq (sgml-eltype-model eltype) data-models))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (list (sgml-eltype-name eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (symbol-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (if (sgml-model-group-p (sgml-eltype-model eltype))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 'mixed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (sgml-eltype-model eltype)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 "Terminals" "Element" "Content")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;;; Element cross reference list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (defun sgml-list-content-elements ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 "List all element types and the element types that can occur in its content."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (message "Creating table...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (sgml-display-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (sgml-map-element-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (lambda (eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (cons (sgml-eltype-name eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (mapcar (function sgml-eltype-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (sgml-eltype-refrenced-elements eltype))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 "Elements refrenced by elements"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 "Element" "Content"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (defun sgml-list-occur-in-elements ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 "List all element types and where it can occur."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (message "Creating table...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (let ((cross nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (sgml-map-element-types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (lambda (eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (loop for ref in (sgml-eltype-refrenced-elements eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 do (setq cross (sgml-add-to-table ref
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (sgml-eltype-name eltype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 cross))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (sgml-display-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 cross
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 "Cross referenced element types" "Element" "Can occur in")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;;; Display table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (defun sgml-display-table (table title col-title1 col-title2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 &optional width nosort)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (or width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (setq width sgml-attr-col))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (let ((buf (get-buffer-create (format "*%s*" title))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (message "Preparing display...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (insert col-title1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (indent-to width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (insert col-title2 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (insert-char ?= (length col-title1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (indent-to width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (insert-char ?= (length col-title2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (unless nosort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (setq table (sort table (function (lambda (a b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (string< (car a) (car b)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (loop for e in table do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (insert (format "%s" (car e)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (loop for name in (if nosort
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (cdr e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (sort (cdr e) (function string-lessp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (when (> (+ (length name) (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 fill-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (when (< (current-column) sgml-attr-col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (indent-to width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (insert name " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (display-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (message nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;;;; Describe entity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defun sgml-describe-entity (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 "Describe the properties of an entity as declared in the current DTD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (let (default input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (sgml-need-dtd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (sgml-with-parser-syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (unless (sgml-parse-delim "ERO")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (skip-chars-backward "^&\"'= \t\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (setq default (or (sgml-parse-name t) ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (setq input (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (format "Entity name (%s): " default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (sgml-entity-completion-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (sgml-dtd-entities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (sgml-pstate-dtd sgml-buffer-parse-state)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (if (equal "" input) default input))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (with-output-to-temp-buffer "*Help*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (let ((entity (sgml-lookup-entity name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (sgml-dtd-entities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (sgml-pstate-dtd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 sgml-buffer-parse-state)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (or entity (error "Undefined entity"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (princ (format "Entity %s is %s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (cond ((null entity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 "undefined")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (format "a %s entity"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (sgml-entity-type entity))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (when entity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (let ((text (sgml-entity-text entity)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (cond ((stringp text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (princ "Defined to be:\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (princ text))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (princ "With external identifier ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (princ (if (car text) "PUBLIC" "SYSTEM"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (when (car text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (princ (format " '%s'" (car text))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (when (cdr text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (princ (format " '%s'" (cdr text)))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;;;; Describe element type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (defun sgml-describe-element-type (et-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 "Describe the properties of an element type as declared in the current DTD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (let (default input)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (sgml-need-dtd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (sgml-with-parser-syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (unless (sgml-parse-delim "STAGO")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (skip-syntax-backward "w_"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (setq default (sgml-parse-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (unless (and default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (sgml-eltype-defined (sgml-lookup-eltype default)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (setq default nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (setq input (sgml-read-element-type (if default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (format "Element type (%s): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 "Element type: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 sgml-dtd-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (sgml-eltype-name input))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (sgml-need-dtd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (let ((et (sgml-lookup-eltype et-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (with-output-to-temp-buffer "*Help*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (princ (format "ELEMENT: %s\n\n" (sgml-eltype-name et)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (princ (format " Start-tag is %s.\n End-tag is %s.\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (if (sgml-eltype-stag-optional et)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 "optional" "required")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (if (sgml-eltype-etag-optional et)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 "optional" "required")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (princ "\nATTRIBUTES:\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (loop for attdecl in (sgml-eltype-attlist et) do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (let ((name (sgml-attdecl-name attdecl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (dval (sgml-attdecl-declared-value attdecl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (defl (sgml-attdecl-default-value attdecl)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (when (listp dval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (setq dval (concat (if (eq (first dval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 'notation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 "#NOTATION (" "(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (mapconcat (function identity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (second dval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 "|")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ")")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (cond ((sgml-default-value-type-p 'fixed defl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (setq defl (format "#FIXED '%s'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (sgml-default-value-attval defl))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ((symbolp defl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (setq defl (upcase (format "#%s" defl))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (setq defl (format "'%s'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (sgml-default-value-attval defl)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (princ (format " %-9s %-30s %s\n" name dval defl))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;; ----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (let ((s (sgml-eltype-shortmap et)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (when s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (princ (format "\nUSEMAP: %s\n" s))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;; ----
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (princ "\nOCCURS IN:\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (sgml-map-eltypes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (function (lambda (cand)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (when (memq et (sgml-eltype-refrenced-elements cand))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (princ (format " %s" (sgml-eltype-name cand))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (sgml-pstate-dtd sgml-buffer-parse-state)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;;;; Print general info about the DTD.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (defun sgml-general-dtd-info ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 "Display information about the current DTD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (sgml-need-dtd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (let ((elements 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (entities 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (parameters 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (fmt "%20s %s\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (hdr "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (sgml-map-eltypes (function (lambda (e) (incf elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 sgml-dtd-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (sgml-map-entities (function (lambda (e) (incf entities)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (sgml-dtd-entities sgml-dtd-info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (sgml-map-entities (function (lambda (e) (incf parameters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (sgml-dtd-parameters sgml-dtd-info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (with-output-to-temp-buffer "*Help*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (princ (format fmt "Doctype:" (sgml-dtd-doctype sgml-dtd-info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (when (sgml-dtd-merged sgml-dtd-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (princ (format fmt "Compiled DTD:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (car (sgml-dtd-merged sgml-dtd-info)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (princ (format fmt "Element types:" (format "%d" elements)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (princ (format fmt "Entities:" (format "%d" entities)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (princ (format fmt "Parameter entities:" (format "%d" parameters)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (setq hdr "Files used:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (loop for x in (sgml-dtd-dependencies sgml-dtd-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 if (stringp x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 do (princ (format fmt hdr x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (setq hdr ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (setq hdr "Undef parameters:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (sgml-map-entities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (function (lambda (entity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (when (sgml-entity-marked-undefined-p entity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (princ (format fmt hdr (sgml-entity-name entity)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (setq hdr ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (sgml-dtd-parameters sgml-dtd-info)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;;; psgml-info.el ends here