;;; mmm-html-ext.el
;;;
(require 'css-mode)
(mmm-add-classes
'((embedded-css
:submode css-mode
:face mmm-declaration-submode-face
:front "")))
(require 'generic-x)
(mmm-add-classes
'((embedded-javascript
:submode javascript-generic-mode
:face mmm-code-submode-face
:front ""
:back "")))
;;; At the top of a mason component written in the style that I like
;;; to use is:
;;;
;;;
;;;
;;;
;;; The thing is that those should not appear mid-document in the
;;; generated output. It's computationaly cheaper to comment them off
;;; than to filter them out with a <%filter> section. This next block
;;; of code sets things up so that the XML and DOCTYPE declarations
;;; are automatically commented off in the file saved to disk, but not
;;; commented off in the editor buffer, so that the normal mmm-mode
;;; and PSGML mode DTD parsing can take place.
;;;
;;; Copyright (c) 2005
;;; Karl Hegbloom
;;; GPL
;;;
(defun mason-comment-decls (arg)
(interactive "p")
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(cond
((and (< arg 0) (looking-at "%#"))
(progn
(delete-char 2)
(forward-line 1)
(beginning-of-line)
(delete-char 2)))
((and (>= arg 0) (not (looking-at "%#")))
(progn
(insert "%#")
(forward-line 1)
(beginning-of-line)
(insert "%#")))))))
(defvar mason-comment-decls nil)
(make-variable-buffer-local 'mason-comment-decls)
(defun %mason-file-hook (arg)
(when (and mmm-mode
mason-comment-decls)
(mason-comment-decls arg)))
(defun mason-find-file-hook ()
(%mason-file-hook -1)
(set-buffer-modified-p nil))
(defun mason-write-file-hook ()
(%mason-file-hook 1))
(defun mason-after-save-hook ()
(mason-find-file-hook))
(add-hook 'find-file-hooks #'mason-find-file-hook)
(add-hook 'write-file-hooks #'mason-write-file-hook)
(add-hook 'after-save-hook #'mason-after-save-hook)
(require 'php-mode)
(setq auto-mode-alist
(remove-if #'(lambda (elt)
(eq (cdr elt) 'php-mode))
auto-mode-alist))
(let ((ext '("\\.php[345]?\\'" "\\.phtml\\'")))
(while ext
(add-to-list 'auto-mode-alist (cons (car ext) 'html-mode))
(add-to-list 'mmm-mode-ext-classes-alist (list 'html-mode (car ext) 'php))
(setq ext (cdr ext))))
(mmm-add-group
'php
'((php-xml-processing-directive
:submode php-mode
:face mmm-code-submode-face
:front "<[?]php"
:back "[?]>"
:insert ((?p php nil @ "" @))
)
(php-inline=
:submode php-mode
:face mmm-output-submode-face
:front "<[?]="
:back "[?]>"
:insert ((?= php nil @ "= " @ _ @ " ?>" @))
)
(php-inline
:submode php-mode
:face mmm-output-submode-face
:front "<[?]"
:back "[?]>"
:insert ((?\? php nil @ " " @ _ @ " ?>" @))
)
(php-inline-asp=
:submode php-mode
:face mmm-output-submode-face
:front "<%="
:back "%>"
)
(php-inline-asp
:submode php-mode
:face mmm-output-submode-face
:front "<%"
:back "%>"
)
(php-script
:submode php-mode
:face mmm-code-submode-face
:front ""
)
))
(mmm-add-group
'HTML::Template
'((html-template-tag
:submode text-mode
:face mmm-special-submode-face
:front ""
:include-back t
:insert ((?t HTML::Template nil @ @ "" @ @))
)))
(provide 'mmm-html-ext)