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