2
|
1 ;;; hm--html-mode --- Major mode for editing HTML documents for the WWW
|
177
|
2
|
|
3 ;; Copyright (C) 1996, 1997 Heiko Muenkel
|
|
4
|
|
5 ;; Author: Heiko Muenkel <muenkel@tnt.uni-hannover.de>
|
|
6 ;; Keywords: hypermedia languages help docs wp
|
|
7
|
|
8 ;; $Id: hm--html-mode.el,v 1.7 1997/07/26 22:09:45 steve Exp $
|
|
9
|
|
10 ;; This file is part of XEmacs.
|
|
11
|
|
12 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
13 ;; under the terms of the GNU General Public License as published by
|
|
14 ;; the Free Software Foundation; either version 2, or (at your
|
|
15 ;; option) any later version.
|
|
16
|
|
17 ;; This program is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with XEmacs; See the file COPYING. if not, write to the Free
|
|
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
25 ;; 02111-1307, USA
|
|
26
|
|
27 ;;; Synched up with: Not part of Emacs.
|
|
28
|
2
|
29 ;;; Commentary:
|
177
|
30
|
|
31 ;; Description:
|
|
32
|
|
33 ;; This file defines the hm--html-mode, a mode for editing html
|
|
34 ;; files. It is the main file of the package hm--html-menus.
|
|
35 ;; Previous releases had used the file html-mode.el from Marc
|
|
36 ;; Andreessen. In that times the mode was called html-mode. I've
|
|
37 ;; changed the name of the mode to distinquish it from other
|
|
38 ;; html modes. But feel free to set a
|
|
39 ;; (defalias 'hm--html-mode 'html-mode)
|
|
40 ;; to get back the old name of the mode.
|
|
41
|
|
42 ;; In the earlier releases of the package the main file was
|
|
43 ;; hm--html-menu.el. This has been changed to hm--html-mode.el.
|
|
44
|
|
45
|
|
46 ;; Installation:
|
|
47
|
|
48 ;; Put this file and all the other files of the package
|
|
49 ;; in one of your load path directories and the
|
|
50 ;; following lines in your .emacs:
|
2
|
51
|
177
|
52 ;; (autoload 'hm--html-mode "hm--html-mode" "HTML major mode." t)
|
|
53
|
|
54 ;; (or (assoc "\\.html$" auto-mode-alist)
|
|
55 ;; (setq auto-mode-alist (cons '("\\.html$" . hm--html-mode)
|
|
56 ;; auto-mode-alist)))
|
|
57 ;; If there is already another html-mode (like psgml in the XEmacs
|
|
58 ;; 19.14, then you must put the following instead of the last form
|
|
59 ;; in your .emacs:
|
|
60 ;; (setq auto-mode-alist (cons '("\\.html$" . hm--html-mode)
|
|
61 ;; auto-mode-alist))
|
|
62
|
|
63 ;; But you can also use the hm--html-minor-mode as an addition to
|
|
64 ;; the psgml html modes. For that you've to put the following line in
|
|
65 ;; your .emacs:
|
|
66 ;; (add-hook 'html-mode-hook 'hm--html-minor-mode)
|
|
67
|
|
68 ;; Note: This works only in an XEmacs version greater than 19.14 and
|
|
69 ;; also not in the XEmacs 20.0.
|
|
70
|
|
71 ;; Look at the file hm--html-configuration for further installation
|
|
72 ;; points.
|
|
73
|
|
74 ;;; Code:
|
2
|
75
|
|
76 (require 'font-lock)
|
116
|
77 (require 'cl)
|
2
|
78 (require 'adapt)
|
|
79 (require 'hm--date)
|
|
80 (require 'hm--html)
|
116
|
81 ;(require 'hm--html-not-standard)
|
102
|
82
|
100
|
83 (eval-when-compile
|
|
84 (require 'hm--html-configuration))
|
102
|
85
|
2
|
86 (hm--html-load-config-files)
|
98
|
87 (require 'hm--html-indentation)
|
102
|
88
|
|
89 (defvar hm--html-minor-mode nil
|
|
90 "Non-nil, if the `hm--html-minor-mode' is active.")
|
|
91
|
2
|
92 (require 'hm--html-menu)
|
116
|
93
|
|
94 (require 'hm--html-keys)
|
|
95
|
|
96 ;(defvar hm--html-minor-mode nil
|
|
97 ; "Non-nil, if the `hm--html-minor-mode' is active.")
|
|
98 ;
|
|
99 ;(require 'hm--html-menu)
|
70
|
100 (require 'hm--html-drag-and-drop)
|
46
|
101
|
2
|
102
|
|
103 ;;; The package version
|
|
104 (defconst hm--html-menus-package-maintainer "muenkel@tnt.uni-hannover.de")
|
|
105
|
|
106 (defconst hm--html-menus-package-name "hm--html-menus")
|
|
107
|
177
|
108 (defconst hm--html-menus-package-version "5.8")
|
2
|
109
|
|
110
|
|
111 ;;; Generate the help buffer faces
|
|
112 (hm--html-generate-help-buffer-faces)
|
|
113
|
|
114 ;;; syntax table
|
|
115
|
|
116 (defvar hm--html-mode-syntax-table nil
|
|
117 "Syntax table used while in html mode.")
|
|
118
|
|
119 (if hm--html-mode-syntax-table
|
|
120 ()
|
|
121 (setq hm--html-mode-syntax-table (make-syntax-table))
|
98
|
122 ; (modify-syntax-entry ?\" ". " hm--html-mode-syntax-table)
|
|
123 ; (modify-syntax-entry ?\\ ". " hm--html-mode-syntax-table)
|
|
124 ; (modify-syntax-entry ?' "w " hm--html-mode-syntax-table)
|
|
125 (modify-syntax-entry ?\\ "." hm--html-mode-syntax-table)
|
|
126 (modify-syntax-entry ?' "w" hm--html-mode-syntax-table)
|
|
127 (modify-syntax-entry ?< "(>" hm--html-mode-syntax-table)
|
|
128 (modify-syntax-entry ?> ")<" hm--html-mode-syntax-table)
|
|
129 (modify-syntax-entry ?\" "\"" hm--html-mode-syntax-table)
|
|
130 (modify-syntax-entry ?= "." hm--html-mode-syntax-table))
|
2
|
131
|
|
132
|
|
133 ;;; abbreviation table
|
|
134
|
|
135 (defvar hm--html-mode-abbrev-table nil
|
|
136 "Abbrev table used while in html mode.")
|
|
137
|
|
138 (define-abbrev-table 'hm--html-mode-abbrev-table ())
|
|
139
|
|
140 ;;; the hm--html-mode
|
|
141
|
|
142 (defvar hm--html-mode-name-string "HTML"
|
|
143 "The hm--html-mode name string.")
|
|
144
|
|
145 ;;;###autoload
|
|
146 (defun hm--html-mode ()
|
|
147 "Major mode for editing HTML hypertext documents.
|
|
148 Special commands:\\{hm--html-mode-map}
|
|
149 Turning on hm--html-mode calls the value of the variable hm--html-mode-hook,
|
|
150 if that value is non-nil."
|
|
151 (interactive)
|
|
152 (kill-all-local-variables)
|
|
153 (use-local-map hm--html-mode-map)
|
|
154 (setq mode-name hm--html-mode-name-string)
|
|
155 (setq major-mode 'hm--html-mode)
|
|
156 (setq local-abbrev-table hm--html-mode-abbrev-table)
|
|
157 (set-syntax-table hm--html-mode-syntax-table)
|
98
|
158 (make-local-variable 'comment-start)
|
|
159 (make-local-variable 'comment-end)
|
|
160 (setq comment-start "<!--" comment-end "-->")
|
|
161 (make-local-variable 'sentence-end)
|
|
162 (setq sentence-end "[<>.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*")
|
102
|
163 (make-local-variable 'indent-line-function)
|
98
|
164 (setq indent-line-function 'hm--html-indent-line)
|
2
|
165 (setq idd-actions hm--html-idd-actions)
|
|
166 (hm--install-html-menu hm--html-mode-pulldown-menu-name)
|
|
167 (make-variable-buffer-local 'write-file-hooks)
|
|
168 (add-hook 'write-file-hooks 'hm--html-maybe-new-date-and-changed-comment)
|
177
|
169 (if (adapt-xemacsp)
|
|
170 (put major-mode 'font-lock-defaults '((hm--html-font-lock-keywords
|
|
171 hm--html-font-lock-keywords-1
|
|
172 hm--html-font-lock-keywords-2)
|
|
173 t
|
|
174 t
|
|
175 nil
|
|
176 nil))
|
|
177 (make-local-variable 'font-lock-defaults)
|
|
178 (setq font-lock-defaults '((hm--html-font-lock-keywords
|
|
179 hm--html-font-lock-keywords-1
|
|
180 hm--html-font-lock-keywords-2)
|
|
181 t
|
|
182 t
|
|
183 nil
|
|
184 nil)))
|
2
|
185 (run-hooks 'hm--html-mode-hook))
|
|
186
|
|
187 ;;;; Minor Modes
|
|
188
|
|
189 ;;; hm--html-region-mode
|
|
190
|
|
191 (defvar hm--html-region-mode nil
|
|
192 "T, if the region is active in the `hm--html-mode'.")
|
|
193
|
|
194 (make-variable-buffer-local 'hm--html-region-mode)
|
|
195
|
|
196 (add-minor-mode 'hm--html-region-mode " Region" hm--html-region-mode-map)
|
|
197
|
|
198 (if (adapt-xemacsp)
|
|
199
|
|
200 (defun hm--html-region-mode (&optional arg)
|
|
201 "Toggle 'hm--html-region-mode'.
|
|
202 With ARG, turn hm--html-region-mode on iff ARG is positive.
|
|
203
|
|
204 If the `major-mode' isn't the `hm--html-mode' then the minor
|
|
205 mode is switched off, regardless of the ARG and the state
|
|
206 of `hm--html-region-mode'."
|
|
207 (interactive "P")
|
|
208 (setq zmacs-regions-stays t)
|
|
209 (setq hm--html-region-mode
|
|
210 (and (eq major-mode 'hm--html-mode)
|
|
211 (if (null arg) (not hm--html-region-mode)
|
|
212 (> (prefix-numeric-value arg) 0))))
|
|
213 )
|
|
214
|
|
215 (defun hm--html-region-mode (&optional arg)
|
|
216 "Toggle 'hm--html-region-mode'.
|
|
217 With ARG, turn hm--html-region-mode on iff ARG is positive.
|
|
218
|
|
219 If the `major-mode' isn't the `hm--html-mode' then the minor
|
|
220 mode is switched off, regardless of the ARG and the state
|
|
221 of `hm--html-region-mode'."
|
|
222 (interactive "P")
|
|
223 (setq hm--html-region-mode
|
|
224 (and (eq major-mode 'hm--html-mode)
|
|
225 (if (null arg) (not hm--html-region-mode)
|
|
226 (> (prefix-numeric-value arg) 0))))
|
|
227 (if hm--html-region-mode
|
|
228 (define-key hm--html-mode-map
|
|
229 hm--html-emacs19-popup-noregion-menu-button
|
|
230 nil)
|
|
231 (if hm--html-expert
|
|
232 (define-key hm--html-mode-map
|
|
233 hm--html-emacs19-popup-noregion-menu-button
|
|
234 hm--html-menu-noregion-expert-map)
|
|
235 (define-key hm--html-mode-map
|
|
236 hm--html-emacs19-popup-noregion-menu-button
|
|
237 hm--html-menu-noregion-novice-map)))
|
|
238 )
|
|
239
|
|
240 )
|
|
241
|
|
242
|
|
243 ;;; hm--html-minor-mode
|
|
244 (make-variable-buffer-local 'hm--html-minor-mode)
|
|
245
|
|
246 (add-minor-mode 'hm--html-minor-mode " HM-HTML" hm--html-minor-mode-map)
|
|
247
|
|
248 ;;;###autoload
|
|
249 (defun hm--html-minor-mode (&optional arg)
|
|
250 "Toggle hm--html-minor-mode.
|
|
251 With arg, turn hm--html-minor-mode on iff arg is positive."
|
|
252 (interactive "P")
|
|
253 (setq hm--html-minor-mode
|
|
254 (if (null arg) (not hm--html-minor-mode)
|
|
255 (> (prefix-numeric-value arg) 0)))
|
|
256 (if hm--html-minor-mode
|
177
|
257 (progn
|
|
258 (hm--install-html-menu hm--html-minor-mode-pulldown-menu-name)
|
|
259 (when (adapt-emacs19p)
|
|
260 (hm--html-add-major-menu-to-minor-menus)))
|
|
261 (when (and current-menubar (assoc hm--html-minor-mode-pulldown-menu-name
|
|
262 current-menubar))
|
|
263 (delete-menu-item (list hm--html-minor-mode-pulldown-menu-name)))
|
|
264 (when (adapt-emacs19p)
|
|
265 (hm--html-remove-major-menu-from-minor-menus)))
|
2
|
266 )
|
|
267
|
|
268
|
|
269 ;;; hm--html-minor-region-mode
|
|
270
|
|
271 (defvar hm--html-minor-region-mode nil
|
|
272 "Non-nil, if the `hm--html-minor-region-mode' is active.")
|
|
273
|
|
274 (make-variable-buffer-local 'hm--html-minor-region-mode)
|
|
275
|
|
276 (add-minor-mode 'hm--html-minor-region-mode
|
|
277 " Region"
|
|
278 hm--html-minor-region-mode-map)
|
|
279
|
|
280
|
|
281 (if (adapt-xemacsp)
|
|
282
|
|
283 (defun hm--html-minor-region-mode (&optional arg)
|
|
284 "Toggle `hm--html-minor-region-mode'.
|
|
285 With arg, turn `hm--html-minor-region-mode' on iff arg is positive.
|
|
286
|
|
287 But however, if the `hm--html-minor-mode' isn't active, then it
|
|
288 turns `hm--html-minor-region-mode' off."
|
|
289 (interactive "P")
|
|
290 (setq zmacs-regions-stays t)
|
|
291 (setq hm--html-minor-region-mode
|
|
292 (and hm--html-minor-mode
|
|
293 (if (null arg) (not hm--html-minor-region-mode)
|
|
294 (> (prefix-numeric-value arg) 0))))
|
|
295 )
|
|
296
|
|
297 (defun hm--html-minor-region-mode (&optional arg)
|
|
298 "Toggle `hm--html-minor-region-mode'.
|
|
299 With arg, turn `hm--html-minor-region-mode' on iff arg is positive.
|
|
300
|
|
301 But however, if the `hm--html-minor-mode' isn't active, then it
|
|
302 turns `hm--html-minor-region-mode' off."
|
|
303 (interactive "P")
|
|
304 (setq hm--html-minor-region-mode
|
|
305 (and hm--html-minor-mode
|
|
306 (if (null arg) (not hm--html-minor-region-mode)
|
|
307 (> (prefix-numeric-value arg) 0))))
|
|
308 (if hm--html-minor-region-mode
|
|
309 (define-key hm--html-minor-mode-map
|
|
310 hm--html-emacs19-popup-noregion-menu-button
|
|
311 nil)
|
|
312 (if hm--html-expert
|
|
313 (define-key hm--html-minor-mode-map
|
|
314 hm--html-emacs19-popup-noregion-menu-button
|
|
315 hm--html-menu-noregion-expert-map)
|
|
316 (define-key hm--html-minor-mode-map
|
|
317 hm--html-emacs19-popup-noregion-menu-button
|
|
318 hm--html-menu-noregion-novice-map)))
|
|
319 )
|
|
320 )
|
|
321
|
|
322
|
|
323
|
|
324 ;;; Hook function for toggling the region minor modes
|
|
325 (defun hm--html-switch-region-modes-on ()
|
|
326 "Switches the region minor modes of the hm--html-menus package on.
|
|
327 This function should be only be used for the `zmacs-activate-region-hook'
|
|
328 or for the `activate-mark-hook'."
|
|
329 (hm--html-region-mode 1)
|
|
330 (hm--html-minor-region-mode 1))
|
|
331
|
|
332 (defun hm--html-switch-region-modes-off ()
|
|
333 "Switches the region minor modes of the hm--html-menus package on.
|
|
334 This function should be only be used for the `zmacs-deactivate-region-hook'
|
|
335 or for the `deactivate-mark-hook'."
|
|
336 (hm--html-region-mode -1)
|
|
337 (hm--html-minor-region-mode -1))
|
|
338
|
|
339
|
|
340 ;;; Run the load hook
|
|
341 (run-hooks 'hm--html-load-hook)
|
|
342
|
|
343
|
|
344 ;;; Announce the feature hm--html-configuration
|
|
345 (provide 'hm--html-mode)
|
177
|
346
|
|
347
|
|
348 ;;; hm--html-mode.el ends here
|