| 1 | ;;; -*-emacs-lisp-*- |
| 2 | |
| 3 | (defun skelrc-banner (title &optional block) |
| 4 | (let* ((start (skel-lookup 'block-start)) |
| 5 | (end (skel-lookup (if block 'block-banner-knob 'block-banner-end))) |
| 6 | (barlen (- 77 (length (concat start end " ----- " title))))) |
| 7 | (concat start "----- " title " " (make-string barlen ?-) end))) |
| 8 | |
| 9 | (defvar skelrc-forced-major-mode 0) |
| 10 | |
| 11 | (defun skelrc-force-mode (new-mode &optional priority) |
| 12 | (or priority (setq priority 1)) |
| 13 | (if (> priority skelrc-forced-major-mode) |
| 14 | (progn |
| 15 | (or (eq new-mode major-mode) |
| 16 | (let ((old-skel-alist skel-alist)) |
| 17 | (funcall new-mode) |
| 18 | (make-variable-buffer-local 'skel-alist) |
| 19 | (setq skel-alist old-skel-alist))) |
| 20 | (make-variable-buffer-local 'skelrc-forced-major-mode) |
| 21 | (setq skelrc-forced-major-mode priority)))) |
| 22 | |
| 23 | (defun skelrc-decode-major-mode () |
| 24 | (let* ((name (symbol-name major-mode)) |
| 25 | (endind (string-match "-mode$" name))) |
| 26 | (if endind (substring name 0 endind) |
| 27 | (name)))) |
| 28 | |
| 29 | (setq skelrc-gpl |
| 30 | "[[cont-comment]] This file is part of [[full-title]]. |
| 31 | [[cont-comment]] |
| 32 | [[cont-comment]] [[program]] is free software; you can redistribute it and/or modify |
| 33 | [[cont-comment]] it under the terms of the GNU General Public License as published by |
| 34 | [[cont-comment]] the Free Software Foundation; either version 2 of the License, or |
| 35 | [[cont-comment]] (at your option) any later version. |
| 36 | [[cont-comment]] |
| 37 | [[cont-comment]] [[program]] is distributed in the hope that it will be useful, |
| 38 | [[cont-comment]] but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 39 | [[cont-comment]] MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 40 | [[cont-comment]] GNU General Public License for more details. |
| 41 | [[cont-comment]] |
| 42 | [[cont-comment]] You should have received a copy of the GNU General Public License |
| 43 | [[cont-comment]] along with [[program]]; if not, write to the Free Software Foundation, |
| 44 | [[cont-comment]] Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.") |
| 45 | |
| 46 | (setq skelrc-lgpl |
| 47 | "[[cont-comment]] This file is part of [[full-title]]. |
| 48 | [[cont-comment]] |
| 49 | [[cont-comment]] [[program]] is free software; you can redistribute it and/or modify |
| 50 | [[cont-comment]] it under the terms of the GNU Library General Public License as |
| 51 | [[cont-comment]] published by the Free Software Foundation; either version 2 of the |
| 52 | [[cont-comment]] License, or (at your option) any later version. |
| 53 | [[cont-comment]] |
| 54 | [[cont-comment]] [[program]] is distributed in the hope that it will be useful, |
| 55 | [[cont-comment]] but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 56 | [[cont-comment]] MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 57 | [[cont-comment]] GNU Library General Public License for more details. |
| 58 | [[cont-comment]] |
| 59 | [[cont-comment]] You should have received a copy of the GNU Library General Public |
| 60 | [[cont-comment]] License along with [[program]]; if not, write to the Free Software |
| 61 | [[cont-comment]] Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.") |
| 62 | |
| 63 | (defun skel-basename () |
| 64 | (file-name-sans-extension (file-name-nondirectory buffer-file-name))) |
| 65 | |
| 66 | (setq skel-alist |
| 67 | (append |
| 68 | '((emacs-mode . (skelrc-decode-major-mode)) |
| 69 | (year . (substring (current-time-string) 20 24)) |
| 70 | (header . "[[licence]][[revisions]][[preamble]]") |
| 71 | (basename . (skel-basename)) |
| 72 | (licence . "[[licence-banner]]\n[[cont-comment]]\n[[licence-text]][[block-end]]\n\n") |
| 73 | (licence-banner . (skelrc-banner "Licensing notice" t)) |
| 74 | (licence-text . "[[gpl]]") |
| 75 | (gpl . skelrc-gpl) |
| 76 | (lgpl . skelrc-lgpl) |
| 77 | (revisions . "[[revision-banner]]\n[[cont-comment]]\n[[cont-comment]] $Log$[[block-end]]\n\n") |
| 78 | (revision-banner . (skelrc-banner "Revision history" t)) |
| 79 | (preamble . "") |
| 80 | (trailer . "[[tag-line]][[postamble]]\n") |
| 81 | (postamble . "") |
| 82 | (tag-line . (skelrc-banner "That's all, folks")) |
| 83 | (block-start . (skel-lookup 'new-comment)) |
| 84 | (block-banner-knob . "") |
| 85 | (block-banner-end . "") |
| 86 | (block-end . "")) |
| 87 | skel-alist)) |