1 ;;; mmm-mason.el --- MMM submode class for Mason components
3 ;; Copyright (C) 2000 by Michael Abraham Shulman
5 ;; Author: Michael Abraham Shulman <viritrilbia@users.sourceforge.net>
6 ;; Version: $Id: mmm-mason.el,v 1.13 2003/03/09 17:04:03 viritrilbia Exp $
10 ;; This file 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 2, or (at your option)
15 ;; This file 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.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 ;; This file contains the definition of an MMM Mode submode class for
30 ;; editing Mason components. See the file README.Mason for more
41 (defvar mmm-mason-perl-tags
42 '("perl" "init" "cleanup" "once" "filter" "shared"
43 "perl_init" "perl_cleanup" "perl_once" "perl_filter"))
45 (defvar mmm-mason-pseudo-perl-tags
46 '("args" "perl_args" "attr" "flags"))
48 (defvar mmm-mason-non-perl-tags
49 '("doc" "perl_doc" "text" "perl_text" "def" "perl_def" "method"))
51 (defvar mmm-mason-perl-tags-regexp
52 (concat "<%" (mmm-regexp-opt mmm-mason-perl-tags t) ">")
53 "Matches tags beginning Mason sections containing Perl code.
54 Saves the name of the tag matched.")
56 (defvar mmm-mason-pseudo-perl-tags-regexp
57 (concat "<%" (mmm-regexp-opt mmm-mason-pseudo-perl-tags t) ">")
58 "Match tags beginning Mason sections that look like Perl but aren't.
59 Saves the name of the tag matched.")
61 (defvar mmm-mason-tag-names-regexp
62 (regexp-opt (append mmm-mason-perl-tags mmm-mason-non-perl-tags) t)
63 "Matches any Mason tag name after the \"<%\". Used to verify that a
64 \"<%\" sequence starts an inline section.")
66 (defun mmm-mason-verify-inline ()
67 (not (looking-at mmm-mason-tag-names-regexp)))
78 :insert ((?t mason-<%text> nil @ "<%text>" @ "\n"
79 _ "\n" @ "</%text>" @)))
82 :face mmm-comment-submode-face
86 :insert ((?d mason-<%doc> nil @ "<%doc>" @ "\n"
87 _ "\n" @ "</%doc>" @)))
90 :match-face (("<%perl>" . mmm-code-submode-face)
91 ("<%init>" . mmm-init-submode-face)
92 ("<%cleanup>" . mmm-cleanup-submode-face)
93 ("<%once>" . mmm-init-submode-face)
94 ("<%filter>" . mmm-special-submode-face)
95 ("<%shared>" . mmm-init-submode-face))
96 :front ,mmm-mason-perl-tags-regexp
101 :insert ((?, mason-<%TAG> "Perl section: " @ "<%" str ">" @
102 ";\n" _ "\n" @ "</%" str ">" @)
103 (?< mason-<%TAG> ?, . nil)
104 (?p mason-<%perl> ?, . "perl")
105 (?i mason-<%init> ?, . "init")
106 (?c mason-<%cleanup> ?, . "cleanup")
107 (?o mason-<%once> ?, . "once")
108 (?l mason-<%filter> ?, . "filter")
109 (?s mason-<%shared> ?, . "shared")))
112 :face mmm-declaration-submode-face
113 :front ,mmm-mason-pseudo-perl-tags-regexp
116 :insert ((?. mason-pseudo-<%TAG> "Pseudo-perl section: " @ "<%" str ">" @
117 "\n" _ "\n" @ "</%" str ">" @)
118 (?> mason-pseudo-<%TAG> ?, . nil)
119 (?a mason-<%args> ?. . "args")
120 (?f mason-<%flags> ?. . "flags")
121 (?r mason-<%attr> ?. . "attr")))
124 :face mmm-output-submode-face
126 :front-verify mmm-mason-verify-inline
128 :insert ((?% mason-<%-%> nil @ "<%" @ " " _ " " @ "%>" @)
129 (?5 mason-<%-%> ?% . nil)))
132 :face mmm-special-submode-face
135 :insert ((?& mason-<&-&> nil @ "<&" @ " " _ " " @ "&>" @)
136 (?7 mason-<&-&> ?% . nil)))
137 (mason-one-line-comment
139 :face mmm-comment-submode-face
142 :insert ((?# mason-%-comment nil (mmm-mason-start-line)
143 @ "%" @ "# " _ @ '(mmm-mason-end-line) "\n" @)
144 (?3 mason-%-comment ?# . nil)))
147 :face mmm-code-submode-face
150 :insert ((return mason-%-line nil (mmm-mason-start-line)
151 @ "%" @ " " _ @ '(mmm-mason-end-line) "\n" @)))))
154 ;;{{{ One-line Sections
156 (defun mmm-mason-start-line ()
161 (defun mmm-mason-end-line ()
168 (defun mmm-mason-set-mode-line ()
169 (setq mmm-buffer-mode-display-name "Mason"))
170 (add-hook 'mmm-mason-class-hook 'mmm-mason-set-mode-line)
176 ;;; mmm-mason.el ends here