Initial Commit
[packages] / xemacs-packages / mmm-mode / mmm-cweb.el
1 ;;; mmm-cweb.el --- MMM submode class for CWeb programs
2
3 ;; Copyright (C) 2001 by Alan Shutko
4
5 ;; Author: Alan Shutko <ats@acm.org>
6 ;; Version: $Id: mmm-cweb.el,v 1.1 2008-12-22 14:02:24 mharnisch Exp $
7
8 ;;{{{ GPL
9
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)
13 ;; any later version.
14
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.
19
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.
24
25 ;;}}}
26
27 ;;; Commentary:
28
29 ;; This file contains the definition of an MMM Mode submode class for
30 ;; editing CWeb programs.
31
32 ;;; Code:
33
34 (require 'mmm-compat)
35 (require 'mmm-vars)
36 (require 'mmm-auto)
37
38 (defvar mmm-cweb-section-tags
39   '("@ " "@*"))
40
41 (defvar mmm-cweb-section-regexp
42   (concat "^" (mmm-regexp-opt mmm-cweb-section-tags t)))
43
44 (defvar mmm-cweb-c-part-tags
45   '("@c" "@>=" "@>+=" "@p"))
46
47 (defvar mmm-cweb-c-part-regexp
48   (concat (mmm-regexp-opt mmm-cweb-c-part-tags t)))
49
50 (defun mmm-cweb-in-limbo (pos)
51   "Check to see if POS is in limbo, ie before any cweb sections."
52   (save-match-data
53     (save-excursion
54       (goto-char pos)
55       (not (re-search-backward mmm-cweb-section-regexp nil t)))))
56
57 (defun mmm-cweb-verify-brief-c ()
58   "Verify function for cweb-brief-c class.
59 Checks whether the match is in limbo."
60   (not (mmm-cweb-in-limbo (match-beginning 0))))
61
62 (mmm-add-group
63  'cweb
64  `(
65    (cweb-c-part
66     :submode c-mode
67     :front ,mmm-cweb-c-part-regexp
68     :back ,mmm-cweb-section-regexp)
69    (cweb-label
70     :submode tex-mode
71     :front "@<"
72     :back "@>"
73     :face mmm-comment-submode-face
74     :insert ((?l cweb-label nil @ "@<" @ "@>")))
75    (cweb-brief-c
76     :submode c-mode
77     :front "[^\\|]\\(|\\)[^|]"
78     :front-match 1
79     :front-verify mmm-cweb-verify-brief-c
80 ;    :front-offset -1
81     :back "[^\\|]\\(|\\)"
82     :back-match 1
83 ;    :back-offset 1
84     :end-not-begin t
85     :insert ((?| cweb-c-in-tex nil "|" @ "|")))
86     (cweb-comment
87      :submode tex-mode
88      :front "/[*]"
89      :back "[*]/"
90      :face mmm-comment-submode-face)
91 ))
92
93 ;; (add-to-list 'mmm-mode-ext-classes-alist
94 ;;                   '(plain-tex-mode "\\.w\\'" cweb))
95 ;; (add-to-list 'mmm-mode-ext-classes-alist
96 ;;                   '(latex-mode "\\.w\\'" cweb))
97 ;; (add-to-list 'auto-mode-alist '("\\.w\\'" . tex-mode))
98
99 (provide 'mmm-cweb)
100
101 ;;; mmm-cweb.el ends here