1 ;;; hm--html-mode --- Major mode for editing HTML documents for the WWW
3 ;; Copyright (C) 1996 - 1998 Heiko Muenkel
5 ;; Author: Heiko Muenkel <muenkel@tnt.uni-hannover.de>
6 ;; Keywords: hypermedia languages help docs wp
8 ;; $Id: hm--html-mode.el,v 6.20 1998-12-03 17:18:29 muenkel Exp $
10 ;; This file is part of XEmacs.
12 ;; XEmacs is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your
15 ;; option) any later version.
17 ;; This program is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with XEmacs; See the file COPYING. if not, write to the Free
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 ;;; Synched up with: Not part of Emacs.
33 ;; This file defines the hm--html-mode, a mode for editing html
34 ;; files. It is the main file of the package hm--html-menus.
35 ;; Previous releases had used the file html-mode.el from Marc
36 ;; Andreessen. In that times the mode was called html-mode. I've
37 ;; changed the name of the mode to distinquish it from other
38 ;; html modes. But feel free to set a
39 ;; (defalias 'hm--html-mode 'html-mode)
40 ;; to get back the old name of the mode.
42 ;; In the earlier releases of the package the main file was
43 ;; hm--html-menu.el. This has been changed to hm--html-mode.el.
48 ;; Put this file and all the other files of the package
49 ;; in one of your load path directories and the
50 ;; following lines in your .emacs:
52 ;; (autoload 'hm--html-mode "hm--html-mode" "HTML major mode." t)
54 ;; (or (assoc "\\.html$" auto-mode-alist)
55 ;; (setq auto-mode-alist (cons '("\\.html$" . hm--html-mode)
57 ;; If there is already another html-mode (like psgml in the XEmacs
58 ;; 19.14, then you must put the following instead of the last form
60 ;; (setq auto-mode-alist (cons '("\\.html$" . hm--html-mode)
63 ;; But you can also use the hm--html-minor-mode as an addition to
64 ;; the psgml html modes. For that you've to put the following line in
66 ;; (add-hook 'html-mode-hook 'hm--html-minor-mode)
68 ;; Note: This works only in an XEmacs version greater than 19.14 and
69 ;; also not in the XEmacs 20.0.
71 ;; Look at the file hm--html-configuration for further installation
81 ;(require 'hm--html-not-standard)
84 (require 'hm--html-configuration))
86 (hm--html-load-config-files)
87 (require 'hm--html-indentation)
89 (defvar hm--html-minor-mode nil
90 "Non-nil, if the `hm--html-minor-mode' is active.")
92 (require 'hm--html-menu)
94 (require 'hm--html-keys)
96 ;(defvar hm--html-minor-mode nil
97 ; "Non-nil, if the `hm--html-minor-mode' is active.")
99 ;(require 'hm--html-menu)
100 (require 'hm--html-drag-and-drop)
103 ;;; The package version
104 (defconst hm--html-menus-package-maintainer "muenkel@tnt.uni-hannover.de")
106 (defconst hm--html-menus-package-name "hm--html-menus")
108 (defconst hm--html-menus-package-version "5.9")
111 ;;; Generate the help buffer faces
112 (hm--html-generate-help-buffer-faces)
116 (defvar hm--html-mode-syntax-table nil
117 "Syntax table used while in html mode.")
119 (if hm--html-mode-syntax-table
121 (setq hm--html-mode-syntax-table (make-syntax-table))
122 ; (modify-syntax-entry ?\" ". " hm--html-mode-syntax-table)
123 ; (modify-syntax-entry ?\\ ". " hm--html-mode-syntax-table)
124 ; (modify-syntax-entry ?' "w " hm--html-mode-syntax-table)
125 (modify-syntax-entry ?\\ "." hm--html-mode-syntax-table)
126 (modify-syntax-entry ?' "w" hm--html-mode-syntax-table)
127 (modify-syntax-entry ?< "(>" hm--html-mode-syntax-table)
128 (modify-syntax-entry ?> ")<" hm--html-mode-syntax-table)
129 (modify-syntax-entry ?\" "\"" hm--html-mode-syntax-table)
130 (modify-syntax-entry ?= "." hm--html-mode-syntax-table))
133 ;;; abbreviation table
135 (defvar hm--html-mode-abbrev-table nil
136 "Abbrev table used while in html mode.")
138 (define-abbrev-table 'hm--html-mode-abbrev-table ())
140 ;;; the hm--html-mode
142 (defvar hm--html-mode-name-string "HTML"
143 "The hm--html-mode name string.")
146 (defun hm--html-mode ()
147 "Major mode for editing HTML hypertext documents.
148 Special commands:\\{hm--html-mode-map}
149 Turning on hm--html-mode calls the value of the variable hm--html-mode-hook,
150 if that value is non-nil."
152 (kill-all-local-variables)
153 (use-local-map hm--html-mode-map)
154 (setq mode-name hm--html-mode-name-string)
155 (setq major-mode 'hm--html-mode)
156 (setq local-abbrev-table hm--html-mode-abbrev-table)
157 (set-syntax-table hm--html-mode-syntax-table)
158 (make-local-variable 'comment-start)
159 (make-local-variable 'comment-end)
160 (setq comment-start "<!--" comment-end "-->")
161 (make-local-variable 'sentence-end)
162 (setq sentence-end "[<>.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*")
163 (make-local-variable 'indent-line-function)
164 (setq indent-line-function 'hm--html-indent-line)
165 (setq idd-actions hm--html-idd-actions)
166 (hm--install-html-menu hm--html-mode-pulldown-menu-name)
167 (make-variable-buffer-local 'write-file-hooks)
168 (add-hook 'write-file-hooks 'hm--html-maybe-new-date-and-changed-comment)
170 (put major-mode 'font-lock-defaults '((hm--html-font-lock-keywords
171 hm--html-font-lock-keywords-1
172 hm--html-font-lock-keywords-2)
177 (make-local-variable 'font-lock-defaults)
178 (setq font-lock-defaults '((hm--html-font-lock-keywords
179 hm--html-font-lock-keywords-1
180 hm--html-font-lock-keywords-2)
185 (run-hooks 'hm--html-mode-hook))
189 ;;; hm--html-region-mode
191 (defvar hm--html-region-mode nil
192 "T, if the region is active in the `hm--html-mode'.")
194 (make-variable-buffer-local 'hm--html-region-mode)
196 (add-minor-mode 'hm--html-region-mode " Region" hm--html-region-mode-map)
200 (defun hm--html-region-mode (&optional arg)
201 "Toggle 'hm--html-region-mode'.
202 With ARG, turn hm--html-region-mode on iff ARG is positive.
204 If the `major-mode' isn't the `hm--html-mode' then the minor
205 mode is switched off, regardless of the ARG and the state
206 of `hm--html-region-mode'."
208 (setq zmacs-regions-stays t)
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))))
216 (defun hm--html-region-mode (&optional arg)
217 "Toggle 'hm--html-region-mode'.
218 With ARG, turn hm--html-region-mode on iff ARG is positive.
220 If the `major-mode' isn't the `hm--html-mode' then the minor
221 mode is switched off, regardless of the ARG and the state
222 of `hm--html-region-mode'."
224 (setq hm--html-region-mode
225 (and (eq major-mode 'hm--html-mode)
226 (if (null arg) (not hm--html-region-mode)
227 (> (prefix-numeric-value arg) 0))))
228 (if hm--html-region-mode
229 (define-key hm--html-mode-map
230 hm--html-emacs19-popup-noregion-menu-button
233 (define-key hm--html-mode-map
234 hm--html-emacs19-popup-noregion-menu-button
235 hm--html-menu-noregion-expert-map)
236 (define-key hm--html-mode-map
237 hm--html-emacs19-popup-noregion-menu-button
238 hm--html-menu-noregion-novice-map)))
244 ;;; hm--html-minor-mode
245 (make-variable-buffer-local 'hm--html-minor-mode)
247 (add-minor-mode 'hm--html-minor-mode " HM-HTML" hm--html-minor-mode-map)
250 (defun hm--html-minor-mode (&optional arg)
251 "Toggle hm--html-minor-mode.
252 With arg, turn hm--html-minor-mode on iff arg is positive."
254 (setq hm--html-minor-mode
255 (if (null arg) (not hm--html-minor-mode)
256 (> (prefix-numeric-value arg) 0)))
257 (if hm--html-minor-mode
259 (hm--install-html-menu hm--html-minor-mode-pulldown-menu-name)
261 ;; In the future it may be a good idea to merge the contents
262 ;; of the idd-actions of the major mode with the one of the
264 (setq idd-actions hm--html-idd-actions)
266 (hm--html-add-major-menu-to-minor-menus)))
267 (when (and (featurep 'menubar)
269 (assoc hm--html-minor-mode-pulldown-menu-name
271 (delete-menu-item (list hm--html-minor-mode-pulldown-menu-name)))
273 (hm--html-remove-major-menu-from-minor-menus)))
278 ;;; hm--html-minor-region-mode
280 (defvar hm--html-minor-region-mode nil
281 "Non-nil, if the `hm--html-minor-region-mode' is active.")
283 (make-variable-buffer-local 'hm--html-minor-region-mode)
285 (add-minor-mode 'hm--html-minor-region-mode
287 hm--html-minor-region-mode-map)
292 (defun hm--html-minor-region-mode (&optional arg)
293 "Toggle `hm--html-minor-region-mode'.
294 With arg, turn `hm--html-minor-region-mode' on iff arg is positive.
296 But however, if the `hm--html-minor-mode' isn't active, then it
297 turns `hm--html-minor-region-mode' off."
299 (setq zmacs-regions-stays t)
300 (setq hm--html-minor-region-mode
301 (and hm--html-minor-mode
302 (if (null arg) (not hm--html-minor-region-mode)
303 (> (prefix-numeric-value arg) 0))))
307 (defun hm--html-minor-region-mode (&optional arg)
308 "Toggle `hm--html-minor-region-mode'.
309 With arg, turn `hm--html-minor-region-mode' on iff arg is positive.
311 But however, if the `hm--html-minor-mode' isn't active, then it
312 turns `hm--html-minor-region-mode' off."
314 (setq hm--html-minor-region-mode
315 (and hm--html-minor-mode
316 (if (null arg) (not hm--html-minor-region-mode)
317 (> (prefix-numeric-value arg) 0))))
318 (if hm--html-minor-region-mode
319 (define-key hm--html-minor-mode-map
320 hm--html-emacs19-popup-noregion-menu-button
323 (define-key hm--html-minor-mode-map
324 hm--html-emacs19-popup-noregion-menu-button
325 hm--html-menu-noregion-expert-map)
326 (define-key hm--html-minor-mode-map
327 hm--html-emacs19-popup-noregion-menu-button
328 hm--html-menu-noregion-novice-map)))
335 ;;; Hook function for toggling the region minor modes
336 (defun hm--html-switch-region-modes-on ()
337 "Switches the region minor modes of the hm--html-menus package on.
338 This function should be only be used for the `zmacs-activate-region-hook'
339 or for the `activate-mark-hook'."
340 (hm--html-region-mode 1)
341 (hm--html-minor-region-mode 1))
343 (defun hm--html-switch-region-modes-off ()
344 "Switches the region minor modes of the hm--html-menus package on.
345 This function should be only be used for the `zmacs-deactivate-region-hook'
346 or for the `deactivate-mark-hook'."
347 (hm--html-region-mode -1)
348 (hm--html-minor-region-mode -1))
351 ;;; Run the load hook
352 (run-hooks 'hm--html-load-hook)
355 ;;; Announce the feature hm--html-configuration
356 (provide 'hm--html-mode)
359 ;;; hm--html-mode.el ends here