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