annotate lisp/psgml/psgml-xemacs.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-xemacs.el --- Part of SGML-editing mode with parsing support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; $Id: psgml-xemacs.el,v 1.1.1.1 1996/12/18 03:35:23 steve Exp $
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1994 Lennart Staflin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Author: Lennart Staflin <lenst@lysator.liu.se>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; William M. Perry <wmperry@indiana.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; This program is free software; you can redistribute it and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; modify it under the terms of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; as published by the Free Software Foundation; either version 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; of the License, or (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Part of psgml.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Menus for use with XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (require 'psgml)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;(require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (autoload 'sgml-do-set-option "psgml-edit"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (defvar sgml-max-menu-size (/ (* (frame-height) 2) 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 "*Max number of entries in Tags and Entities menus before they are split
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 into several panes.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;;; Pop Up Menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defun sgml-popup-menu (event title entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 "Display a popup menu."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (setq entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (loop for ent in entries collect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (vector (car ent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (list 'setq 'value (list 'quote (cdr ent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (cond ((> (length entries) sgml-max-menu-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (setq entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (loop for i from 1 while entries collect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (let ((submenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (subseq entries 0 (min (length entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 sgml-max-menu-size))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (setq entries (nthcdr sgml-max-menu-size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 entries))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (format "%s '%s'-'%s'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 title
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (sgml-range-indicator (aref (car submenu) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (sgml-range-indicator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (aref (car (last submenu)) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 submenu))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (sgml-xemacs-get-popup-value (cons title entries)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defun sgml-range-indicator (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (substring string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (min (length string) sgml-range-indicator-max-length)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (defun sgml-xemacs-get-popup-value (menudesc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (let ((value nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (event nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (popup-menu menudesc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (while (popup-menu-up-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (setq event (next-command-event event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (cond ((menu-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ((eq (event-object event) 'abort)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (signal 'quit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ((eq (event-object event) 'menu-no-selection-hook)
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 (eval (event-object event)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ((button-release-event-p event) ; don't beep twice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ((and (fboundp 'event-matches-key-specifier-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (event-matches-key-specifier-p event (quit-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (signal 'quit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (message "please make a choice from the menu."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (defun sgml-popup-multi-menu (pos title menudesc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 "Display a popup menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 MENUS is a list of menus on the form (TITLE ITEM1 ITEM2 ...).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ITEM should have to form (STRING EXPR) or STRING. The EXPR gets evaluated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 if the item is selected."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (cons title
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (loop for menu in menudesc collect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (cons (car menu) ; title
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (loop for item in (cdr menu) collect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (if (stringp item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (vector (car item) (cadr item) t))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;;; XEmacs menu bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (defvar sgml-dtd-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 '("DTD"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ["Parse DTD" sgml-parse-prolog t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ("Info"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ["Describe element type" sgml-describe-element-type t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ["Describe entity" sgml-describe-entity t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ["List elements" sgml-list-elements t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ["List attributes" sgml-list-attributes t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ["List terminals" sgml-list-terminals t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ["List content elements" sgml-list-content-elements t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ["List occur in elements" sgml-list-occur-in-elements t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 "---"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ["Load Parsed DTD" sgml-load-dtd t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ["Save Parsed DTD" sgml-save-dtd t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (defvar sgml-fold-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 '("Fold"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ["Fold Element" sgml-fold-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ["Fold Subelement" sgml-fold-subelement t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ["Fold Region" sgml-fold-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ["Unfold Line" sgml-unfold-line t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ["Unfold Element" sgml-unfold-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ["Unfold All" sgml-unfold-all t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ["Expand" sgml-expand-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (defvar sgml-markup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 '("Markup"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ["Insert Element" (sgml-element-menu last-command-event) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ["Insert Start-Tag" (sgml-start-tag-menu last-command-event) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ["Insert End-Tag" (sgml-end-tag-menu last-command-event) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ["Tag Region" (sgml-tag-region-menu last-command-event) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ["Insert Attribute" (sgml-attrib-menu last-command-event) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ["Insert Entity" (sgml-entities-menu last-command-event) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 sgml-move-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 '("Move"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ["Next trouble spot" sgml-next-trouble-spot t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ["Next data field" sgml-next-data-field t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ["Forward element" sgml-forward-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ["Backward element" sgml-backward-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ["Up element" sgml-up-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ["Down element" sgml-down-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ["Backward up element" sgml-backward-up-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ["Beginning of element" sgml-beginning-of-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ["End of element" sgml-end-of-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 "Menu of move commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (defvar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 sgml-modify-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 '("Modify"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ["Normalize" sgml-normalize t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ["Expand All Short References" sgml-expand-all-shortrefs t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ["Expand Entity Reference" sgml-expand-entity-reference t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ["Normalize Element" sgml-normalize-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ["Make Character Reference" sgml-make-character-reference t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ["Unmake Character Reference" (sgml-make-character-reference t) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ["Fill Element" sgml-fill-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ["Change Element Name..." sgml-change-element-name t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ["Edit Attributes..." sgml-edit-attributes t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ["Kill Markup" sgml-kill-markup t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ["Kill Element" sgml-kill-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ["Untag Element" sgml-untag-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ["Decode Character Entities" sgml-charent-to-display-char t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ["Encode Characters" sgml-display-char-to-charent t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 "Menu of modification commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (defun sgml-make-options-menu (vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (loop for var in vars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 for type = (sgml-variable-type var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 for desc = (sgml-variable-description var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 collect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ((eq type 'toggle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (vector desc (list 'setq var (list 'not var))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ':style 'toggle ':selected var))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ((consp type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (cons desc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (loop for c in type collect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (if (atom c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (vector (prin1-to-string c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (`(setq (, var) (, c)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 :style 'toggle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 :selected (`(eq (, var) '(, c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (vector (car c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (`(setq (, var) '(,(cdr c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 :style 'toggle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 :selected (`(eq (, var) '(,(cdr c)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (vector desc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (`(sgml-do-set-option '(, var)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (defvar sgml-sgml-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 '("SGML"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ["Reset Buffer" normal-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ["Show Context" sgml-show-context t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ["What Element" sgml-what-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ["Show Valid Tags" sgml-list-valid-tags t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ["Show/Hide Warning Log" sgml-show-or-clear-log t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ["Validate" sgml-validate t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (if (or (not (boundp 'emacs-major-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (and (boundp 'emacs-minor-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (< emacs-minor-version 10)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ["File Options" sgml-file-options-menu t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ["User Options" sgml-user-options-menu t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (cons "File Options" (sgml-make-options-menu sgml-file-options))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (cons "User Options" (sgml-make-options-menu sgml-user-options))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 '(["Save File Options" sgml-save-options t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ["Submit Bug Report" sgml-submit-bug-report t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (defun sgml-install-xemacs-menus ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 "Install xemacs menus for psgml mode"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (set-buffer-menubar (copy-sequence current-menubar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (add-menu nil (car sgml-sgml-menu) (cdr sgml-sgml-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (add-menu nil (car sgml-markup-menu) (copy-sequence (cdr sgml-markup-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (add-menu nil (car sgml-modify-menu) (cdr sgml-modify-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (add-menu nil (car sgml-move-menu) (cdr sgml-move-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (add-menu nil (car sgml-fold-menu) (cdr sgml-fold-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (add-menu nil (car sgml-dtd-menu) (cdr sgml-dtd-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;;;; Custom menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (defun sgml-build-custom-menus ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (and sgml-custom-markup (add-menu-item '("Markup") "------------" nil t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 "Insert Element"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (add-menu-item '("Markup") (nth 0 x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (list 'sgml-insert-markup (nth 1 x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 "------------")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 sgml-custom-markup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (and sgml-custom-dtd (add-menu-item '("DTD") "-------------" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (add-menu-item '("DTD") (nth 0 x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (list 'apply ''sgml-doctype-insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (cadr x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (list 'quote (cddr x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 sgml-custom-dtd))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;;;; Key definitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (define-key sgml-mode-map [button3] 'sgml-tags-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;;;; Insert with properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (defun sgml-insert (props format &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (let ((start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 tem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (insert (apply (function format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (remf props 'rear-nonsticky) ; not useful in XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; Copy face prop from category
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (when (setq tem (getf props 'category))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (when (setq tem (get tem 'face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (set-face-underline-p (make-face 'underline) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (setf (getf props 'face) tem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (add-text-properties start (point) props)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; A read-only value of 1 is used for the text after values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;; and this should in XEmacs be open at the front.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (if (eq 1 (getf props 'read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (set-extent-property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (extent-at start nil 'read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 'start-open t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;;;; Set face of markup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (defun sgml-set-face-for (start end type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (let ((face (cdr (assq type sgml-markup-faces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 o)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (loop for e being the extents from start to end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 do (when (extent-property e 'type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (cond ((and (null o)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (eq type (extent-property e 'type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (setq o e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (t (delete-extent e)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (cond (o
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (set-extent-endpoints o start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (setq o (make-extent start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (set-extent-property o 'type type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (set-extent-property o 'face face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (set-extent-face o face)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (defun sgml-set-face-after-change (start end &optional pre-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (when sgml-set-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (let ((o (extent-at start nil 'type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ((null o))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ((= start (extent-start-position o))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (set-extent-endpoints o end (extent-end-position o)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (t (delete-extent o))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;(defalias 'next-overlay-at 'next-overlay-change) ; fix bug in cl.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (defun sgml-clear-faces ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (loop for o being the overlays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 if (extent-property o 'type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 do (delete-extent o)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;;;; Functions not in XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (unless (fboundp 'frame-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (defalias 'frame-width 'screen-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (unless (fboundp 'frame-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defalias 'frame-height 'screen-height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (unless (fboundp 'buffer-substring-no-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (defalias 'buffer-substring-no-properties 'buffer-substring))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 ;;;; Provide
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (provide 'psgml-xemacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ;;; psgml-xemacs.el ends here