aboutsummaryrefslogtreecommitdiffhomepage
path: root/contrib/mmm/mmm-rpm.el
blob: 0661e1ad13cc3239642ccb23575406a00aac0587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
;;; mmm-rpm.el --- MMM submode class for RPM spec files

;; Copyright (C) 2000 by Marcus Harnisch <Marcus.Harnisch@gmx.net>

;; Author:  Marcus Harnisch <Marcus.Harnisch@gmx.net>
;; Version: $Id$

;;{{{ GPL

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;}}}

;;; Commentary:

;; This file contains the definition of an MMM Mode submode class for
;; editing shell script sections within RPM (Redhat Package Manager)
;; spec files. I recommend to use it in combination with
;; rpm-spec-mode.el by Stig Bjørlykke <stigb@tihlde.hist.no> and Steve
;; Sanbeg <sanbeg@dset.com> (http://www.xemacs.org/~stigb/rpm-spec-mode.el)

;;; Installation:

;; 1. Copy this file where Emacs can find it.
;;
;; 2. Add the following lines to one of your startup files (e.g. ~/.emacs):
;;
;;   (add-to-list 'mmm-mode-ext-classes-alist
;;                '(rpm-spec-mode "\\.spec\\'" rpm-sh))

;;; Code:

(require 'mmm-auto)

(defconst mmm-rpm-sh-start-tags
  '("prep" "build" "install" "clean" "preun" "postun" "pre"
    "post" "triggerin" "triggerun" "triggerpostun")
  "List containing RPM tags that start a shell-script section in a spec file")

(defvar mmm-rpm-sh-end-tags
  (append '("files" "description" "package") mmm-rpm-sh-start-tags)
  "List containing RPM tags that end a shell-script section in a spec file")

(defvar mmm-rpm-sh-start-regexp
  (concat "^%" (mmm-regexp-opt mmm-rpm-sh-start-tags t) "\\b.*$")
  "Regexp matching RPM tags that start a shell-script section in a spec file")

(defvar mmm-rpm-sh-end-regexp
  (concat "\\'\\|^%" (mmm-regexp-opt mmm-rpm-sh-end-tags t) "\\b.*$")
  "Regexp matching RPM tags that end a shell-script section in a spec file")

(mmm-add-group
 'rpm
 `((rpm-sh
    :submode sh-mode
    :face mmm-code-submode-face
    ;; match tags that starts sh-script region
    :front ,mmm-rpm-sh-start-regexp
    ;; match end of buffer or next tag that ends sh-script region
    :back ,mmm-rpm-sh-end-regexp
    :front-offset 1
    :back-offset 0
    :save-matches 0
    )))

(provide 'mmm-rpm)

;;; mmm-rpm.el ends here