2
|
1 ;;; hm--html-mode --- Major mode for editing HTML documents for the WWW
|
|
2 ;;;
|
|
3 ;;; Keywords: hypermedia languages help docs wp
|
|
4 ;;;
|
46
|
5 ;;; $Id: hm--html-mode.el,v 1.6 1997/03/26 22:42:39 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)
|
46
|
71 (require 'cl)
|
2
|
72 (require 'adapt)
|
|
73 (require 'hm--date)
|
|
74 (require 'hm--html)
|
42
|
75 ;(require 'hm--html-not-standard)
|
26
|
76
|
24
|
77 (eval-when-compile
|
|
78 (require 'hm--html-configuration))
|
26
|
79
|
2
|
80 (hm--html-load-config-files)
|
22
|
81 (require 'hm--html-indentation)
|
26
|
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)
|
46
|
87
|
|
88 (require 'hm--html-keys)
|
|
89
|
|
90 ;(defvar hm--html-minor-mode nil
|
|
91 ; "Non-nil, if the `hm--html-minor-mode' is active.")
|
|
92 ;
|
|
93 ;(require 'hm--html-menu)
|
2
|
94 (require 'hm--html-drag-and-drop)
|
|
95
|
|
96
|
|
97 ;;; The package version
|
|
98 (defconst hm--html-menus-package-maintainer "muenkel@tnt.uni-hannover.de")
|
|
99
|
|
100 (defconst hm--html-menus-package-name "hm--html-menus")
|
|
101
|
46
|
102 (defconst hm--html-menus-package-version "5.5")
|
2
|
103
|
|
104
|
|
105 ;;; Generate the help buffer faces
|
|
106 (hm--html-generate-help-buffer-faces)
|
|
107
|
|
108 ;;; syntax table
|
|
109
|
|
110 (defvar hm--html-mode-syntax-table nil
|
|
111 "Syntax table used while in html mode.")
|
|
112
|
|
113 (if hm--html-mode-syntax-table
|
|
114 ()
|
|
115 (setq hm--html-mode-syntax-table (make-syntax-table))
|
22
|
116 ; (modify-syntax-entry ?\" ". " hm--html-mode-syntax-table)
|
|
117 ; (modify-syntax-entry ?\\ ". " hm--html-mode-syntax-table)
|
|
118 ; (modify-syntax-entry ?' "w " hm--html-mode-syntax-table)
|
|
119 (modify-syntax-entry ?\\ "." hm--html-mode-syntax-table)
|
|
120 (modify-syntax-entry ?' "w" hm--html-mode-syntax-table)
|
|
121 (modify-syntax-entry ?< "(>" hm--html-mode-syntax-table)
|
|
122 (modify-syntax-entry ?> ")<" hm--html-mode-syntax-table)
|
|
123 (modify-syntax-entry ?\" "\"" hm--html-mode-syntax-table)
|
|
124 (modify-syntax-entry ?= "." hm--html-mode-syntax-table))
|
2
|
125
|
|
126
|
|
127 ;;; abbreviation table
|
|
128
|
|
129 (defvar hm--html-mode-abbrev-table nil
|
|
130 "Abbrev table used while in html mode.")
|
|
131
|
|
132 (define-abbrev-table 'hm--html-mode-abbrev-table ())
|
|
133
|
|
134 ;;; the hm--html-mode
|
|
135
|
|
136 (defvar hm--html-mode-name-string "HTML"
|
|
137 "The hm--html-mode name string.")
|
|
138
|
|
139 ;;;###autoload
|
|
140 (defun hm--html-mode ()
|
|
141 "Major mode for editing HTML hypertext documents.
|
|
142 Special commands:\\{hm--html-mode-map}
|
|
143 Turning on hm--html-mode calls the value of the variable hm--html-mode-hook,
|
|
144 if that value is non-nil."
|
|
145 (interactive)
|
|
146 (kill-all-local-variables)
|
|
147 (use-local-map hm--html-mode-map)
|
|
148 (setq mode-name hm--html-mode-name-string)
|
|
149 (setq major-mode 'hm--html-mode)
|
|
150 (setq local-abbrev-table hm--html-mode-abbrev-table)
|
|
151 (set-syntax-table hm--html-mode-syntax-table)
|
22
|
152 (make-local-variable 'comment-start)
|
|
153 (make-local-variable 'comment-end)
|
|
154 (setq comment-start "<!--" comment-end "-->")
|
|
155 (make-local-variable 'sentence-end)
|
|
156 (setq sentence-end "[<>.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*")
|
26
|
157 (make-local-variable 'indent-line-function)
|
22
|
158 (setq indent-line-function 'hm--html-indent-line)
|
2
|
159 (setq idd-actions hm--html-idd-actions)
|
|
160 (hm--install-html-menu hm--html-mode-pulldown-menu-name)
|
|
161 (make-variable-buffer-local 'write-file-hooks)
|
|
162 (add-hook 'write-file-hooks 'hm--html-maybe-new-date-and-changed-comment)
|
22
|
163 (put major-mode 'font-lock-defaults '((hm--html-font-lock-keywords
|
|
164 hm--html-font-lock-keywords-1
|
|
165 hm--html-font-lock-keywords-2)
|
|
166 t
|
|
167 t
|
|
168 nil
|
|
169 nil
|
|
170 ))
|
2
|
171 (run-hooks 'hm--html-mode-hook))
|
|
172
|
|
173 ;;;; Minor Modes
|
|
174
|
|
175 ;;; hm--html-region-mode
|
|
176
|
|
177 (defvar hm--html-region-mode nil
|
|
178 "T, if the region is active in the `hm--html-mode'.")
|
|
179
|
|
180 (make-variable-buffer-local 'hm--html-region-mode)
|
|
181
|
|
182 (add-minor-mode 'hm--html-region-mode " Region" hm--html-region-mode-map)
|
|
183
|
|
184 (if (adapt-xemacsp)
|
|
185
|
|
186 (defun hm--html-region-mode (&optional arg)
|
|
187 "Toggle 'hm--html-region-mode'.
|
|
188 With ARG, turn hm--html-region-mode on iff ARG is positive.
|
|
189
|
|
190 If the `major-mode' isn't the `hm--html-mode' then the minor
|
|
191 mode is switched off, regardless of the ARG and the state
|
|
192 of `hm--html-region-mode'."
|
|
193 (interactive "P")
|
|
194 (setq zmacs-regions-stays t)
|
|
195 (setq hm--html-region-mode
|
|
196 (and (eq major-mode 'hm--html-mode)
|
|
197 (if (null arg) (not hm--html-region-mode)
|
|
198 (> (prefix-numeric-value arg) 0))))
|
|
199 )
|
|
200
|
|
201 (defun hm--html-region-mode (&optional arg)
|
|
202 "Toggle 'hm--html-region-mode'.
|
|
203 With ARG, turn hm--html-region-mode on iff ARG is positive.
|
|
204
|
|
205 If the `major-mode' isn't the `hm--html-mode' then the minor
|
|
206 mode is switched off, regardless of the ARG and the state
|
|
207 of `hm--html-region-mode'."
|
|
208 (interactive "P")
|
|
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 (if hm--html-region-mode
|
|
214 (define-key hm--html-mode-map
|
|
215 hm--html-emacs19-popup-noregion-menu-button
|
|
216 nil)
|
|
217 (if hm--html-expert
|
|
218 (define-key hm--html-mode-map
|
|
219 hm--html-emacs19-popup-noregion-menu-button
|
|
220 hm--html-menu-noregion-expert-map)
|
|
221 (define-key hm--html-mode-map
|
|
222 hm--html-emacs19-popup-noregion-menu-button
|
|
223 hm--html-menu-noregion-novice-map)))
|
|
224 )
|
|
225
|
|
226 )
|
|
227
|
|
228
|
|
229 ;;; hm--html-minor-mode
|
|
230 (make-variable-buffer-local 'hm--html-minor-mode)
|
|
231
|
|
232 (add-minor-mode 'hm--html-minor-mode " HM-HTML" hm--html-minor-mode-map)
|
|
233
|
|
234 ;;;###autoload
|
|
235 (defun hm--html-minor-mode (&optional arg)
|
|
236 "Toggle hm--html-minor-mode.
|
|
237 With arg, turn hm--html-minor-mode on iff arg is positive."
|
|
238 (interactive "P")
|
|
239 (setq hm--html-minor-mode
|
|
240 (if (null arg) (not hm--html-minor-mode)
|
|
241 (> (prefix-numeric-value arg) 0)))
|
|
242 (if hm--html-minor-mode
|
|
243 (hm--install-html-menu hm--html-minor-mode-pulldown-menu-name)
|
|
244 (if (and current-menubar (assoc hm--html-minor-mode-pulldown-menu-name
|
|
245 current-menubar))
|
|
246 (delete-menu-item (list hm--html-minor-mode-pulldown-menu-name))))
|
|
247 )
|
|
248
|
|
249
|
|
250 ;;; hm--html-minor-region-mode
|
|
251
|
|
252 (defvar hm--html-minor-region-mode nil
|
|
253 "Non-nil, if the `hm--html-minor-region-mode' is active.")
|
|
254
|
|
255 (make-variable-buffer-local 'hm--html-minor-region-mode)
|
|
256
|
|
257 (add-minor-mode 'hm--html-minor-region-mode
|
|
258 " Region"
|
|
259 hm--html-minor-region-mode-map)
|
|
260
|
|
261
|
|
262 (if (adapt-xemacsp)
|
|
263
|
|
264 (defun hm--html-minor-region-mode (&optional arg)
|
|
265 "Toggle `hm--html-minor-region-mode'.
|
|
266 With arg, turn `hm--html-minor-region-mode' on iff arg is positive.
|
|
267
|
|
268 But however, if the `hm--html-minor-mode' isn't active, then it
|
|
269 turns `hm--html-minor-region-mode' off."
|
|
270 (interactive "P")
|
|
271 (setq zmacs-regions-stays t)
|
|
272 (setq hm--html-minor-region-mode
|
|
273 (and hm--html-minor-mode
|
|
274 (if (null arg) (not hm--html-minor-region-mode)
|
|
275 (> (prefix-numeric-value arg) 0))))
|
|
276 )
|
|
277
|
|
278 (defun hm--html-minor-region-mode (&optional arg)
|
|
279 "Toggle `hm--html-minor-region-mode'.
|
|
280 With arg, turn `hm--html-minor-region-mode' on iff arg is positive.
|
|
281
|
|
282 But however, if the `hm--html-minor-mode' isn't active, then it
|
|
283 turns `hm--html-minor-region-mode' off."
|
|
284 (interactive "P")
|
|
285 (setq hm--html-minor-region-mode
|
|
286 (and hm--html-minor-mode
|
|
287 (if (null arg) (not hm--html-minor-region-mode)
|
|
288 (> (prefix-numeric-value arg) 0))))
|
|
289 (if hm--html-minor-region-mode
|
|
290 (define-key hm--html-minor-mode-map
|
|
291 hm--html-emacs19-popup-noregion-menu-button
|
|
292 nil)
|
|
293 (if hm--html-expert
|
|
294 (define-key hm--html-minor-mode-map
|
|
295 hm--html-emacs19-popup-noregion-menu-button
|
|
296 hm--html-menu-noregion-expert-map)
|
|
297 (define-key hm--html-minor-mode-map
|
|
298 hm--html-emacs19-popup-noregion-menu-button
|
|
299 hm--html-menu-noregion-novice-map)))
|
|
300 )
|
|
301 )
|
|
302
|
|
303
|
|
304
|
|
305 ;;; Hook function for toggling the region minor modes
|
|
306 (defun hm--html-switch-region-modes-on ()
|
|
307 "Switches the region minor modes of the hm--html-menus package on.
|
|
308 This function should be only be used for the `zmacs-activate-region-hook'
|
|
309 or for the `activate-mark-hook'."
|
|
310 (hm--html-region-mode 1)
|
|
311 (hm--html-minor-region-mode 1))
|
|
312
|
|
313 (defun hm--html-switch-region-modes-off ()
|
|
314 "Switches the region minor modes of the hm--html-menus package on.
|
|
315 This function should be only be used for the `zmacs-deactivate-region-hook'
|
|
316 or for the `deactivate-mark-hook'."
|
|
317 (hm--html-region-mode -1)
|
|
318 (hm--html-minor-region-mode -1))
|
|
319
|
|
320
|
|
321 ;;; Run the load hook
|
|
322 (run-hooks 'hm--html-load-hook)
|
|
323
|
|
324
|
|
325 ;;; Announce the feature hm--html-configuration
|
|
326 (provide 'hm--html-mode)
|