Initial Commit
[packages] / xemacs-packages / mmm-mode / mmm-univ.el
1 ;;; mmm-univ.el --- The "Universal" Submode Class
2
3 ;; Copyright (C) 2000 by Free Software Foundation, Inc.
4
5 ;; Author: Michael Abraham Shulman <mas@kurukshetra.cjb.net>
6
7 ;;{{{ GPL
8
9 ;; This file is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; This file is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to
21 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;}}}
25
26 ;;; Commentary:
27
28 ;; This file defines the "universal" submode class, the default value
29 ;; of `mmm-global-classes', which specifies a standard way to indicate
30 ;; that part of a buffer should be in a different mode--for example,
31 ;; in an email message.
32
33 ;;; Code:
34
35 (require 'mmm-auto)
36 (require 'mmm-vars)
37
38 (defun mmm-univ-get-mode (string)
39   (string-match "[a-zA-Z-]+" string)
40   (setq string (match-string 0 string))
41   (let ((modestr (intern (if (string-match "mode\\'" string)
42                              string
43                            (concat string "-mode")))))
44     (or (mmm-ensure-modename modestr)
45         (signal 'mmm-no-matching-submode nil))))
46
47 (mmm-add-classes
48  `((universal
49     :front "{%\\([a-zA-Z-]+\\)%}"
50     :back "{%/~1%}"
51     :insert ((?/ universal "Submode: " @ "{%" str "%}" @ "\n" _ "\n"
52                  @ "{%/" str "%}" @))
53     :match-submode mmm-univ-get-mode
54     :save-matches 1
55     )))
56
57 (provide 'mmm-univ)
58
59 \f
60 ;;; Local Variables:
61 ;;; mmm-global-classes: nil
62 ;;; End:
63
64 ;;; mmm-univ.el ends here