annotate lisp/psgml/psgml-other.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-other.el --- Part of SGML-editing mode with parsing support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; $Id: psgml-other.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
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
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 ;;; Part of psgml.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Menus for use with FSF Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (require 'psgml)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (require 'easymenu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (defvar sgml-max-menu-size (/ (* (frame-height) 2) 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 "*Max number of entries in Tags and Entities menus before they are split
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 into several panes.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;;; Menu bar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (easy-menu-define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 sgml-dtd-menu sgml-mode-map "DTD menu"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 '("DTD"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defconst sgml-dtd-root-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 '("DTD"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ["Parse DTD" sgml-parse-prolog t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ("Info"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ["General DTD info" sgml-general-dtd-info t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ["Describe element type" sgml-describe-element-type t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ["Describe entity" sgml-describe-entity t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ["List elements" sgml-list-elements t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ["List attributes" sgml-list-attributes t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ["List terminals" sgml-list-terminals t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ["List content elements" sgml-list-content-elements t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ["List occur in elements" sgml-list-occur-in-elements t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 "--"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ["Load Parsed DTD" sgml-load-dtd t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ["Save Parsed DTD" sgml-save-dtd t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (easy-menu-define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 sgml-view-menu sgml-mode-map "View menu"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 '("View"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ["Fold Element" sgml-fold-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ["Fold Subelement" sgml-fold-subelement t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ["Unfold Line" sgml-unfold-line t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ["Unfold Element" sgml-unfold-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ["Expand" sgml-expand-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ["Fold Region" sgml-fold-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ["Unfold All" sgml-unfold-all t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ["Hide Tags" sgml-hide-tags t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ["Hide Attributes" sgml-hide-attributes t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ["Show All Tags" sgml-show-tags t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (easy-menu-define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 sgml-markup-menu sgml-mode-map "Markup menu"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 '("Markup")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defconst sgml-markup-root-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 '("Markup"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ["Insert Element" sgml-element-menu t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ["Insert Start-Tag" sgml-start-tag-menu t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ["Insert End-Tag" sgml-end-tag-menu t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ["Tag Region" sgml-tag-region-menu t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ["Insert Attribute" sgml-attrib-menu t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ["Insert Entity" sgml-entities-menu t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (easy-menu-define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 sgml-move-menu sgml-mode-map "Menu of move commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 '("Move"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ["Next trouble spot" sgml-next-trouble-spot t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ["Next data field" sgml-next-data-field t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ["Forward element" sgml-forward-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ["Backward element" sgml-backward-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ["Up element" sgml-up-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ["Down element" sgml-down-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ["Backward up element" sgml-backward-up-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ["Beginning of element" sgml-beginning-of-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ["End of element" sgml-end-of-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (easy-menu-define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 sgml-modify-menu sgml-mode-map "Menu of modification commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 '("Modify"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ["Normalize" sgml-normalize t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ["Expand All Short References" sgml-expand-all-shortrefs t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ["Expand Entity Reference" sgml-expand-entity-reference t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ["Normalize Element" sgml-normalize-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ["Make Character Reference" sgml-make-character-reference t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ["Unmake Character Reference" (sgml-make-character-reference t) t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ["Fill Element" sgml-fill-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ["Change Element Name..." sgml-change-element-name t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ["Edit Attributes..." sgml-edit-attributes t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ["Kill Markup" sgml-kill-markup t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ["Kill Element" sgml-kill-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ["Untag Element" sgml-untag-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ["Trim and leave element" sgml-trim-and-leave-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ["Decode Character Entities" sgml-charent-to-display-char t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ["Encode Characters" sgml-display-char-to-charent 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (easy-menu-define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 sgml-main-menu sgml-mode-map "Main menu"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 '("SGML"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ["Reset Buffer" normal-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ["End Element" sgml-insert-end-tag t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ["Show Context" sgml-show-context t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ["What Element" sgml-what-element t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ["List Valid Tags" sgml-list-valid-tags t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ["Show/Hide Warning Log" sgml-show-or-clear-log t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ["Validate" sgml-validate t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ["File Options >" sgml-file-options-menu t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ["User Options >" sgml-user-options-menu t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ["Save File Options" sgml-save-options t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ["Submit Bug Report" sgml-submit-bug-report t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;;; Key Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; Doesn't this work in Lucid? ***
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (define-key sgml-mode-map [?\M-\C-\ ] 'sgml-mark-element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (define-key sgml-mode-map [S-mouse-1] 'sgml-tags-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;;; Pop Up Menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defun sgml-popup-menu (event title entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 "Display a popup menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ENTRIES is a list where every element has the form (STRING . VALUE) or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 STRING."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (x-popup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (let ((menus (list (cons title entries))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (cond ((> (length entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 sgml-max-menu-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (setq menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (loop for i from 1 while entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 collect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (let ((submenu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (subseq entries 0 (min (length entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 sgml-max-menu-size))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (setq entries (nthcdr sgml-max-menu-size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 entries))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (format "%s '%s'-'%s'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 title
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (sgml-range-indicator (caar submenu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (sgml-range-indicator (caar (last submenu))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 submenu))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (cons title menus))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (defun sgml-range-indicator (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (substring string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (min (length string) sgml-range-indicator-max-length)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (defun sgml-popup-multi-menu (event title menus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 "Display a popup menu.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 MENUS is a list of menus on the form (TITLE ITEM1 ITEM2 ...).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ITEM should have to form (STRING EXPR) or STRING. The EXPR gets evaluated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 if the item is selected."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (nconc menus '(("---" "---"))) ; Force x-popup-menu to use two level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ; menu even if there is only one entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ; on the first level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (eval (car (x-popup-menu event (cons title menus)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;;;; Build Custom Menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (defun sgml-build-custom-menus ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;; Build custom menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; (sgml-add-custom-entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; sgml-markup-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; (mapcar (function (lambda (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; (sgml-markup (car e) (cadr e))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; sgml-custom-markup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (easy-menu-define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 sgml-markup-menu sgml-mode-map "Markup menu"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (append sgml-markup-root-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (list "----")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (loop for e in sgml-custom-markup collect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (vector (first e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (` (sgml-insert-markup (, (cadr e))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (easy-menu-define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 sgml-dtd-menu sgml-mode-map "DTD menu"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (append sgml-dtd-root-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (list "----")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (loop for e in sgml-custom-dtd collect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (vector (first e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (` (sgml-doctype-insert (, (cadr e))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 '(, (cddr e))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;(defun sgml-add-custom-entries (keymap entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ; "Add to KEYMAP the ENTRIES, a list of (name . command) pairs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;The entries are added last in keymap and a blank line precede it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ; (let ((l keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ; (last (last keymap))) ; cons with keymap name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ; ;; Find the cons before 'blank-c' event, or last cons.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ; (while (and (cdr l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ; (consp (cadr l))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ; (not (eq 'blank-c (caadr l))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ; (setq l (cdr l)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ; ;; Delete entries after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ; (setcdr l nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ; (when entries ; now add the entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ; (setcdr l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ; (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ; '(blank-c "") ; a blank line before custom entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ; (loop for i from 0 as e in entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ; collect (cons (intern (concat "custom" i)) e)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ; ;; add keymap name to keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ; (setcdr (last keymap) last)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;;;; Insert with properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defvar sgml-write-protect-intagible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (not (boundp 'emacs-minor-version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (defun sgml-insert (props format &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (insert (apply (function format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (when (and sgml-write-protect-intagible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (getf props 'intangible))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (setf (getf props 'read-only) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (add-text-properties start (point) props)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;;;; Set face of markup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (defun sgml-set-face-for (start end type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (let ((current (overlays-at start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (face (cdr (assq type sgml-markup-faces)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (pos start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 o)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (while current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (cond ((and (null o)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (eq type (overlay-get (car current) 'sgml-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (setq o (car current)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ((overlay-get (car current) 'sgml-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (delete-overlay (car current))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (setq current (cdr current)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (while (< (setq pos (next-overlay-change pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (setq current (overlays-at pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (while current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (when (overlay-get (car current) 'sgml-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (delete-overlay (car current)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (setq current (cdr current))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (cond (o
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (move-overlay o start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (if (null (overlay-get o 'face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (overlay-put o 'face face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq o (make-overlay start end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (overlay-put o 'sgml-type type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (overlay-put o 'face face)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (defun sgml-set-face-after-change (start end &optional pre-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (when sgml-set-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (loop for o in (overlays-at start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 do (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ((not (overlay-get o 'sgml-type)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ((= start (overlay-start o))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (move-overlay o end (overlay-end o)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (defalias 'next-overlay-at 'next-overlay-change) ; fix bug in cl.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (defun sgml-clear-faces ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (loop for o being the overlays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 if (overlay-get o 'sgml-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 do (delete-overlay o)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;;;; Provide
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (provide 'psgml-other)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;;; psgml-other.el ends here