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