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