X-Git-Url: https://git.distorted.org.uk/~mdw/skel/blobdiff_plain/6d349e29736243c07a523dd546afc0d70dd1da22..e37dd246bdc763df5bfa57459de449aca1da0ecc:/skelrc diff --git a/skelrc b/skelrc index 3248571..67ffd1a 100644 --- a/skelrc +++ b/skelrc @@ -1,5 +1,13 @@ ;;; -*-emacs-lisp-*- +(defun skelrc-dribble (msg &rest args) + "Write MSG (a `format'-style string, with ARGS) to the debug buffer." + (let ((buffer (get-buffer "*skel-debug*"))) + (and buffer + (with-current-buffer buffer + (goto-char (point-max)) + (insert (apply #'format msg args) "\n"))))) + (defun skelrc-strip-trailing-whitespace (string) "Return STRING, but with trailing whitespace removed. @@ -54,6 +62,23 @@ its chosen major-mode before calling `skel-include'." (let ((val (assq key alist))) (and val (cdr val)))) +(defun skelrc-expand-text (text) + "Return the result of expanding TEXT in the current context. + +The context is extended with any new associations formed during +the expansion." + (let* ((alist skel-alist) + (expanded (with-temp-buffer + (let ((skel-alist alist)) + (insert text) + (goto-char (point-min)) + (skelrc-dribble "before: alist = `%s'" skel-alist) + (skel-do-fill-in) + (setq alist skel-alist) + (buffer-string))))) + (setq skel-alist alist) + expanded)) + (defun skelrc-prefix-lines (prefix lines) "Return LINES, each with PREFIX prepended to the beginning. @@ -70,6 +95,28 @@ the PREFIX is removed." (forward-line)) (buffer-string))) +(defun skelrc-prefix-and-reflow (prefix text) + "Return LINES, reflowed to `fill-column', with PREFIX at the start." + (let ((expanded-prefix (skelrc-expand-text prefix)) + (expanded-text (skelrc-expand-text text)) + (col (string-to-number (skel-lookup 'fill-column)))) + (with-temp-buffer + (let* ((fill-prefix expanded-prefix) + (paragraph-start (concat (skelrc-strip-trailing-whitespace + (regexp-quote expanded-prefix)) + "[ \t\f]*$")) + (paragraph-separate paragraph-start) + (fill-column col)) + + (insert (skelrc-prefix-lines expanded-prefix expanded-text)) + + (goto-char (point-min)) + (while (< (point) (point-max)) + (fill-paragraph) + (forward-paragraph)) + + (buffer-string))))) + (defun skelrc-component () "Return a suitable a `This file is part of ...' line." (if (assq 'full-title skel-alist) @@ -125,6 +172,21 @@ License along with [[library-name]]; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.")) +(setq skelrc-agpl (skelrc-prefix-lines "[[cont-comment]] " +"[[Program-name]] is free software; you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation; either version 3 of the +License, or (at your option) any later version. + +\[[Program-name]] 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 Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public +License along with [[program-name]]; if not, see +.")) + (setq skelrc-bsd (skelrc-prefix-lines "[[cont-comment]] " "Copyright (c) [[year]] [[author]] All rights reserved. @@ -167,11 +229,15 @@ option) any later version.")) (setq skel-alist (append - '((emacs-mode . (skelrc-decode-major-mode)) + `((first-line . "[[new-comment]] -*-[[emacs-mode]]-*-") + (emacs-mode . (skelrc-decode-major-mode)) (year . (substring (current-time-string) 20 24)) (header . "[[licence]][[preamble]]") (basename . (skel-basename)) - (licence . "[[licence-banner]]\n[[cont-comment]]\n[[component]][[licence-text]][[block-end]]\n\n") + (licence . ,(concat "[[licence-banner]]\n" + "[[cont-comment]]\n" + "[[component]][[licence-text]]" + "[[block-end]]\n\n")) (licence-banner . (skelrc-banner "Licensing notice" t)) (component . (skelrc-component)) (licence-text . "[[gpl]]") @@ -191,8 +257,12 @@ option) any later version.")) (gpl . skelrc-gpl) (wide-gpl . skelrc-wide-gpl) (lgpl . skelrc-lgpl) + (agpl . skelrc-agpl) (bsd . skelrc-bsd) - (revisions . "[[revision-banner]]\n[[cont-comment]]\n[[cont-comment]] $Log$[[block-end]]\n\n") + (revisions . ,(concat "[[revision-banner]]\n" + "[[cont-comment]]\n" + "[[cont-comment]] $Log$" + "[[block-end]]\n\n")) (revision-banner . (skelrc-banner "Revision history" t)) (preamble . "") (trailer . "[[tag-line]]\n[[postamble]]")