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