1 ;;; nxhtml-mumamo.el --- Multi major modes using nxhtml
3 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
4 ;; Created: 2008-03-10T19:04:20+0100 Mon
5 (defconst nxhtml-mumamo:version "0.5")
6 ;; Last-Updated: 2009-01-06 Tue
11 ;; Features that might be required by this library:
13 ;; `backquote', `bytecomp', `mumamo', `mumamo-fun'.
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 ;; This program is free software; you can redistribute it and/or
29 ;; modify it under the terms of the GNU General Public License as
30 ;; published by the Free Software Foundation; either version 2, or
31 ;; (at your option) any later version.
33 ;; This program is distributed in the hope that it will be useful,
34 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
35 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36 ;; General Public License for more details.
38 ;; You should have received a copy of the GNU General Public License
39 ;; along with this program; see the file COPYING. If not, write to
40 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
41 ;; Floor, Boston, MA 02110-1301, USA.
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47 (eval-when-compile (require 'cl))
48 (eval-when-compile (require 'nxhtml nil t))
49 (eval-when-compile (require 'nxhtml-base))
50 (eval-when-compile (require 'nxhtml-mode))
51 (eval-when-compile (require 'mumamo))
52 (eval-and-compile (require 'mumamo-fun))
53 (eval-when-compile (require 'rng-valid nil t))
54 ;;(mumamo-fun-require)
56 ;; (defgroup nxhtml-auto-val-head nil
57 ;; "Automatic turn on of XHTML validation headers."
60 ;; (defmacro define-fictive-validation-header-toggle (fun-sym default-value)
61 ;; (let* ((fun-name (symbol-name fun-sym))
62 ;; (custom-sym (intern (concat fun-name "-auto-val-head")))
63 ;; (hook-sym (intern-soft (concat fun-name "-hook")))
65 ;; (concat "Automatic XHTML validation header for `" fun-name "'.
68 ;; `(defcustom ,custom-sym ,default-value
71 ;; :set (lambda (sym val)
72 ;; (set-default sym val)
74 ;; (add-hook ',hook-sym 'nxhtml-turn-on-validation-header-mode)
75 ;; (remove-hook ',hook-sym 'nxhtml-turn-on-validation-header-mode)))
76 ;; :group 'nxhtml-auto-val-head)
79 ;; Fix-me: add chunk type attr string as last alternative. This will
80 ;; allow things like myattr="<?php echo ?>".
83 (define-mumamo-multi-major-mode nxhtml-mumamo-mode
84 "Turn on multiple major modes for (X)HTML with main mode `nxhtml-mode'.
85 This covers inlined style and javascript and PHP.
87 See also `mumamo-alt-php-tags-mode'."
88 ("nXhtml Family" nxhtml-mode
91 mumamo-chunk-inlined-style
92 mumamo-chunk-inlined-script
96 (add-hook 'nxhtml-mumamo-mode-hook 'mumamo-define-html-file-wide-keys)
97 ;;(define-fictive-validation-header-toggle nxhtml-mumamo-mode t)
100 (define-mumamo-multi-major-mode embperl-nxhtml-mumamo-mode
101 "Turn on multiple major modes for Embperl files with main mode `nxhtml-mode'.
102 This also covers inlined style and javascript."
103 ("Embperl nXhtml Family" nxhtml-mode
104 (mumamo-chunk-embperl-<-
105 mumamo-chunk-embperl-<+
106 mumamo-chunk-embperl-<!
107 mumamo-chunk-embperl-<$
108 mumamo-chunk-inlined-style
109 mumamo-chunk-inlined-script
115 (define-mumamo-multi-major-mode django-nxhtml-mumamo-mode
116 "Turn on multiple major modes for Django with main mode `nxhtml-mode'.
117 This also covers inlined style and javascript."
118 ("Django nXhtml Family" nxhtml-mode
119 (mumamo-chunk-django4
123 mumamo-chunk-inlined-style
124 mumamo-chunk-inlined-script
130 (define-mumamo-multi-major-mode mason-nxhtml-mumamo-mode
131 "Turn on multiple major modes for Mason using main mode `nxhtml-mode'.
132 This covers inlined style and javascript."
133 ("Mason nxhtml Family" nxhtml-mode
135 mumamo-chunk-mason-perl-line
136 mumamo-chunk-mason-perl-single
137 mumamo-chunk-mason-perl-block
138 mumamo-chunk-mason-perl-init
139 mumamo-chunk-mason-perl-once
140 mumamo-chunk-mason-perl-cleanup
141 mumamo-chunk-mason-perl-shared
142 mumamo-chunk-mason-simple-comp
143 mumamo-chunk-mason-compcont
144 mumamo-chunk-mason-args
145 mumamo-chunk-mason-doc
146 mumamo-chunk-mason-text
147 mumamo-chunk-inlined-style
148 mumamo-chunk-inlined-script
152 (add-hook 'mason-nxhtml-mumamo-mode-hook 'mumamo-define-html-file-wide-keys)
153 ;;(mumamo-inherit-sub-chunk-family-locally 'mason-nxhtml-mumamo-mode 'mason-nxhtml-mumamo-mode)
155 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
158 (define-derived-mode nxhtml-genshi-mode nxhtml-mode "gXhtml"
159 "Like `nxhtml-mode' but with Genshi rnc.
160 You should not use this! This is just a part of
161 `genshi-nxhtml-mumamo-mode', use that instead."
162 (let* ((schema-dir (expand-file-name "etc/schema/" nxhtml-install-dir))
163 (genshi-rnc (expand-file-name "qtmstr-xhtml.rnc" schema-dir)))
164 ;;(message "nxhtml-src-dir =%s" nxhtml-src-dir)
165 (message "schema-dir =%s" schema-dir)
166 (when (or (not rng-current-schema-file-name)
167 (string= "xhtml.rnc" (file-name-nondirectory rng-current-schema-file-name)))
170 (rng-set-schema-file-1 genshi-rnc)
172 ;;(rng-save-schema-location-1 t)
174 (nxml-file-parse-error
175 (nxml-display-file-parse-error err)))
176 (when rng-validate-mode
177 (rng-validate-mode -1)
178 (rng-validate-mode 1)))))
181 (define-mumamo-multi-major-mode genshi-nxhtml-mumamo-mode
182 "Turn on multiple major modes for Genshi with main mode `nxhtml-mode'.
183 This also covers inlined style and javascript."
184 ("Genshi HTML Family" nxhtml-genshi-mode
185 (;;mumamo-chunk-genshi%
188 mumamo-chunk-py:match
190 ;;mumamo-chunk-alt-php
191 mumamo-chunk-inlined-style
192 mumamo-chunk-inlined-script
197 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
200 ;; MJT is run in the browser. Some new tags and attributes are used.
202 (define-derived-mode nxhtml-mjt-mode nxhtml-mode "mjtXhtml"
203 "Like `nxhtml-mode' but with genshi rnc.
204 You should not use this! This is just a part of
205 `mjt-nxhtml-mumamo-mode', use that instead."
206 (let* ((schema-dir (expand-file-name "etc/schema/" nxhtml-install-dir))
207 (genshi-rnc (expand-file-name "mjt.rnc" schema-dir)))
208 ;;(message "nxhtml-src-dir =%s" nxhtml-src-dir)
209 (message "schema-dir =%s" schema-dir)
210 (when (or (not rng-current-schema-file-name)
211 (string= "xhtml.rnc" (file-name-nondirectory rng-current-schema-file-name)))
214 (rng-set-schema-file-1 genshi-rnc)
216 ;;(rng-save-schema-location-1 t)
218 (nxml-file-parse-error
219 (nxml-display-file-parse-error err)))
220 (when rng-validate-mode
221 (rng-validate-mode -1)
222 (rng-validate-mode 1)))))
225 (define-mumamo-multi-major-mode mjt-nxhtml-mumamo-mode
226 "Turn on multiple major modes for MJT with main mode `nxhtml-mode'.
227 This also covers inlined style and javascript."
228 ("MJT nXhtml Family" nxhtml-mjt-mode
232 mumamo-chunk-inlined-style
233 mumamo-chunk-inlined-script
238 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
242 (define-mumamo-multi-major-mode smarty-nxhtml-mumamo-mode
243 "Turn on multiple major modes for Smarty with main mode `nxhtml-mode'.
244 This also covers inlined style and javascript."
245 ("Smarty nXhtml Family" nxhtml-mode
249 ;;mumamo-chunk-inlined-style
250 ;;mumamo-chunk-inlined-script
251 mumamo-chunk-smarty-literal
252 mumamo-chunk-smarty-t
253 mumamo-chunk-smarty-comment
257 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
261 (define-mumamo-multi-major-mode gsp-nxhtml-mumamo-mode
262 "Turn on multiple major modes for GSP with main mode `nxhtml-mode'.
263 This also covers inlined style and javascript."
264 ("GSP nXhtml Family" nxhtml-mode
266 mumamo-chunk-inlined-style
267 mumamo-chunk-inlined-script
272 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
276 (define-mumamo-multi-major-mode jsp-nxhtml-mumamo-mode
277 "Turn on multiple major modes for JSP with main mode `nxhtml-mode'.
278 This also covers inlined style and javascript."
279 ("JSP nXhtml Family" nxhtml-mode
281 mumamo-chunk-inlined-style
282 mumamo-chunk-inlined-script
287 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
291 (define-mumamo-multi-major-mode eruby-nxhtml-mumamo-mode
292 "Turn on multiple major modes for eRuby with main mode `nxhtml-mode'.
293 This also covers inlined style and javascript."
294 ("eRuby nXhtml Family" nxhtml-mode
296 mumamo-chunk-inlined-style
297 mumamo-chunk-inlined-script
302 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
306 (define-mumamo-multi-major-mode asp-nxhtml-mumamo-mode
307 "Turn on multiple major modes for ASP with main mode `nxhtml-mode'.
308 This also covers inlined style and javascript."
309 ("ASP nXhtml Family" nxhtml-mode
311 mumamo-asp-chunk-inlined-script
312 mumamo-chunk-inlined-script
317 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
321 (define-mumamo-multi-major-mode mako-nxhtml-mumamo-mode
322 "Turn on multiple major modes for Mako with main mode `nxhtml-mode'.
323 This also covers inlined style and javascript."
326 ;; Fix-me: Add chunks for the tags, but make sure these are made
327 ;; invisible to nxml-mode parser.
329 ;; Fix-me: Maybe finally add that indentation support for one-line chunks?
330 ("Mako nXhtml Family" nxhtml-mode
332 mumamo-chunk-mako-one-line-comment
333 mumamo-chunk-mako-<%doc
334 mumamo-chunk-mako-<%include
335 mumamo-chunk-mako-<%inherit
336 mumamo-chunk-mako-<%namespace
337 mumamo-chunk-mako-<%page
339 ;;mumamo-chunk-mako-<%def
340 ;;mumamo-chunk-mako-<%call
341 ;;mumamo-chunk-mako-<%text
348 mumamo-chunk-inlined-style
349 mumamo-chunk-inlined-script
354 ;; Fix-me: This caused mumamo to loop during fontification since
355 ;; fmode-replace-default-mode was not defined. Mumamo tried to load
356 ;; the function in mumamo-fetch-major-mode-setup in (funcall major)
357 ;; where major mode is php-mode.
359 ;;(eval-after-load 'php-mode '(fmode-replace-default-mode 'php-mode 'nxhtml-mumamo-mode))
363 (provide 'nxhtml-mumamo)
364 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
365 ;;; nxhtml-mumamo.el ends here