Build system spring-clean.
[skel] / skelrc
... / ...
CommitLineData
1;;; -*-emacs-lisp-*-
2
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
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)))))
13 (skelrc-strip-trailing-whitespace (concat start
14 "----- "
15 title
16 " "
17 (make-string barlen ?-)
18 end))))
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
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)
46"[[cont-comment]] This file is part of [[full-title]].
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
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.
55[[cont-comment]]
56[[cont-comment]] [[Program-name]] is distributed in the hope that it will be useful,
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.
60[[cont-comment]]
61[[cont-comment]] You should have received a copy of the GNU General Public License
62[[cont-comment]] along with [[program-name]]; if not, write to the Free Software Foundation,
63[[cont-comment]] Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.")
64
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.
70[[cont-comment]]
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.
75[[cont-comment]]
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
81(setq skelrc-lgpl
82"[[cont-comment]] [[Library-name]] is free software; you can redistribute it and/or modify
83[[cont-comment]] it under the terms of the GNU Library General Public License as
84[[cont-comment]] published by the Free Software Foundation; either version 2 of the
85[[cont-comment]] License, or (at your option) any later version.
86[[cont-comment]]
87[[cont-comment]] [[Library-name]] is distributed in the hope that it will be useful,
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.
91[[cont-comment]]
92[[cont-comment]] You should have received a copy of the GNU Library General Public
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.")
96
97(setq skelrc-bsd
98"[[cont-comment]] Copyright (c) [[year]] [[author]]
99[[cont-comment]] All rights reserved.
100[[cont-comment]]
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:
104[[cont-comment]]
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.
107[[cont-comment]]
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.
111[[cont-comment]]
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.
115[[cont-comment]]
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.
127[[cont-comment]]
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
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))
141 (header . "[[licence]][[preamble]]")
142 (basename . (skel-basename))
143 (licence . "[[licence-banner]]\n[[cont-comment]]\n[[component]][[licence-text]][[block-end]]\n\n")
144 (licence-banner . (skelrc-banner "Licensing notice" t))
145 (component . (skelrc-component))
146 (licence-text . "[[gpl]]")
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"))
160 (gpl . skelrc-gpl)
161 (wide-gpl . skelrc-wide-gpl)
162 (lgpl . skelrc-lgpl)
163 (bsd . skelrc-bsd)
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 . "")
167 (trailer . "[[tag-line]]\n[[postamble]]")
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))