skelrc.pl, skelrc.pm: New comment convention.
[skel] / skelrc
CommitLineData
7fb0878b 1;;; -*-emacs-lisp-*-
2
7e2d1edc
MW
3(defun skelrc-strip-trailing-whitespace (string)
4 (let ((i (1- (length string))))
5 (while (and (>= i 0) (= (char-syntax (aref string i)) ? ))
6 (setq i (1- i)))
7 (substring string 0 (1+ i))))
8
7fb0878b 9(defun skelrc-banner (title &optional block)
10 (let* ((start (skel-lookup 'block-start))
11 (end (skel-lookup (if block 'block-banner-knob 'block-banner-end)))
12 (barlen (- 77 (length (concat start end " ----- " title)))))
7e2d1edc
MW
13 (skelrc-strip-trailing-whitespace (concat start
14 "----- "
15 title
16 " "
17 (make-string barlen ?-)
18 end))))
7fb0878b 19
20(defvar skelrc-forced-major-mode 0)
21
22(defun skelrc-force-mode (new-mode &optional priority)
23 (or priority (setq priority 1))
24 (if (> priority skelrc-forced-major-mode)
25 (progn
26 (or (eq new-mode major-mode)
27 (let ((old-skel-alist skel-alist))
28 (funcall new-mode)
29 (make-variable-buffer-local 'skel-alist)
30 (setq skel-alist old-skel-alist)))
31 (make-variable-buffer-local 'skelrc-forced-major-mode)
32 (setq skelrc-forced-major-mode priority))))
33
34(defun skelrc-decode-major-mode ()
35 (let* ((name (symbol-name major-mode))
36 (endind (string-match "-mode$" name)))
37 (if endind (substring name 0 endind)
38 (name))))
39
441c920b 40(defun skelrc-assq (key list)
41 (let ((val (assq key list)))
42 (and val (cdr val))))
43
44(defun skelrc-component ()
45 (if (assq 'full-title skel-alist)
7fb0878b 46"[[cont-comment]] This file is part of [[full-title]].
441c920b 47[[cont-comment]]\n"
48 ""))
49
50(setq skelrc-gpl
51"[[cont-comment]] [[Program-name]] is free software; you can redistribute it and/or modify
7fb0878b 52[[cont-comment]] it under the terms of the GNU General Public License as published by
53[[cont-comment]] the Free Software Foundation; either version 2 of the License, or
54[[cont-comment]] (at your option) any later version.
3a2c646e 55[[cont-comment]]
441c920b 56[[cont-comment]] [[Program-name]] is distributed in the hope that it will be useful,
7fb0878b 57[[cont-comment]] but WITHOUT ANY WARRANTY; without even the implied warranty of
58[[cont-comment]] MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
59[[cont-comment]] GNU General Public License for more details.
3a2c646e 60[[cont-comment]]
7fb0878b 61[[cont-comment]] You should have received a copy of the GNU General Public License
441c920b 62[[cont-comment]] along with [[program-name]]; if not, write to the Free Software Foundation,
7fb0878b 63[[cont-comment]] Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.")
64
e7043698 65(setq skelrc-wide-gpl ;Version for wide program names
66"[[cont-comment]] [[Program-name]] is free software; you can redistribute it and/or modify
67[[cont-comment]] it under the terms of the GNU General Public License as published by
68[[cont-comment]] the Free Software Foundation; either version 2 of the License, or
69[[cont-comment]] (at your option) any later version.
3a2c646e 70[[cont-comment]]
e7043698 71[[cont-comment]] [[Program-name]] is distributed in the hope that it will be useful,
72[[cont-comment]] but WITHOUT ANY WARRANTY; without even the implied warranty of
73[[cont-comment]] MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74[[cont-comment]] GNU General Public License for more details.
3a2c646e 75[[cont-comment]]
e7043698 76[[cont-comment]] You should have received a copy of the GNU General Public License
77[[cont-comment]] along with [[program-name]]; if not, write to the Free
78[[cont-comment]] Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
79[[cont-comment]] MA 02111-1307, USA.")
80
7fb0878b 81(setq skelrc-lgpl
441c920b 82"[[cont-comment]] [[Library-name]] is free software; you can redistribute it and/or modify
7fb0878b 83[[cont-comment]] it under the terms of the GNU Library General Public License as
441c920b 84[[cont-comment]] published by the Free Software Foundation; either version 2 of the
7fb0878b 85[[cont-comment]] License, or (at your option) any later version.
3a2c646e 86[[cont-comment]]
441c920b 87[[cont-comment]] [[Library-name]] is distributed in the hope that it will be useful,
7fb0878b 88[[cont-comment]] but WITHOUT ANY WARRANTY; without even the implied warranty of
89[[cont-comment]] MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
90[[cont-comment]] GNU Library General Public License for more details.
3a2c646e 91[[cont-comment]]
7fb0878b 92[[cont-comment]] You should have received a copy of the GNU Library General Public
46f73ec5 93[[cont-comment]] License along with [[library-name]]; if not, write to the Free
94[[cont-comment]] Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
95[[cont-comment]] MA 02111-1307, USA.")
7fb0878b 96
3a2c646e 97(setq skelrc-bsd
0237168a 98"[[cont-comment]] Copyright (c) [[year]] [[author]]
99[[cont-comment]] All rights reserved.
3a2c646e 100[[cont-comment]]
0237168a 101[[cont-comment]] Redistribution and use in source and binary forms, with or without
102[[cont-comment]] modification, are permitted provided that the following conditions are
103[[cont-comment]] met:
3a2c646e 104[[cont-comment]]
0237168a 105[[cont-comment]] 1. Redistributions of source code must retain the above copyright
106[[cont-comment]] notice, this list of conditions and the following disclaimer.
3a2c646e 107[[cont-comment]]
0237168a 108[[cont-comment]] 2, Redistributions in binary form must reproduce the above copyright
109[[cont-comment]] notice, this list of conditions and the following disclaimer in the
110[[cont-comment]] documentation and/or other materials provided with the distribution.
3a2c646e 111[[cont-comment]]
0237168a 112[[cont-comment]] 3. The name of the authors may not be used to endorse or promote
113[[cont-comment]] products derived from this software without specific prior written
114[[cont-comment]] permission.
3a2c646e 115[[cont-comment]]
0237168a 116[[cont-comment]] THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
117[[cont-comment]] WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
118[[cont-comment]] MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
119[[cont-comment]] NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
120[[cont-comment]] INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
121[[cont-comment]] (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
122[[cont-comment]] SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
123[[cont-comment]] HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
124[[cont-comment]] STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
125[[cont-comment]] ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
126[[cont-comment]] POSSIBILITY OF SUCH DAMAGE.
3a2c646e 127[[cont-comment]]
0237168a 128[[cont-comment]] Instead of accepting the above terms, you may redistribute and/or modify
129[[cont-comment]] this software under the terms of either the GNU General Public License,
130[[cont-comment]] or the GNU Library General Public License, published by the Free
131[[cont-comment]] Software Foundation; either version 2 of the License, or (at your
132[[cont-comment]] option) any later version.")
133
7fb0878b 134(defun skel-basename ()
135 (file-name-sans-extension (file-name-nondirectory buffer-file-name)))
136
137(setq skel-alist
138 (append
139 '((emacs-mode . (skelrc-decode-major-mode))
140 (year . (substring (current-time-string) 20 24))
86ec878d 141 (header . "[[licence]][[preamble]]")
7fb0878b 142 (basename . (skel-basename))
441c920b 143 (licence . "[[licence-banner]]\n[[cont-comment]]\n[[component]][[licence-text]][[block-end]]\n\n")
7fb0878b 144 (licence-banner . (skelrc-banner "Licensing notice" t))
441c920b 145 (component . (skelrc-component))
7fb0878b 146 (licence-text . "[[gpl]]")
441c920b 147 (Program-name . (or (skelrc-assq 'Program skel-alist)
148 (skelrc-assq 'program skel-alist)
149 "This program"))
150 (program-name . (or (skelrc-assq 'program skel-alist)
151 "this program"))
152 (Library-name . (or (skelrc-assq 'Library skel-alist)
153 (skelrc-assq 'library skel-alist)
154 (skelrc-assq 'Program skel-alist)
155 (skelrc-assq 'program skel-alist)
156 "This library"))
157 (library-name . (or (skelrc-assq 'library skel-alist)
158 (skelrc-assq 'program skel-alist)
159 "this library"))
7fb0878b 160 (gpl . skelrc-gpl)
e7043698 161 (wide-gpl . skelrc-wide-gpl)
7fb0878b 162 (lgpl . skelrc-lgpl)
0237168a 163 (bsd . skelrc-bsd)
7fb0878b 164 (revisions . "[[revision-banner]]\n[[cont-comment]]\n[[cont-comment]] $Log$[[block-end]]\n\n")
165 (revision-banner . (skelrc-banner "Revision history" t))
166 (preamble . "")
28330371 167 (trailer . "[[tag-line]]\n[[postamble]]")
7fb0878b 168 (postamble . "")
169 (tag-line . (skelrc-banner "That's all, folks"))
170 (block-start . (skel-lookup 'new-comment))
171 (block-banner-knob . "")
172 (block-banner-end . "")
173 (block-end . ""))
174 skel-alist))