X-Git-Url: https://git.distorted.org.uk/~mdw/skel/blobdiff_plain/da3134ee428238075d12295d6f184694e9cca36c..0aece27bb1a3cc43d22fbcbb702595f6f2fc89f3:/skelrc diff --git a/skelrc b/skelrc index ef8c93b..00b4412 100644 --- a/skelrc +++ b/skelrc @@ -62,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. @@ -78,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 (length expanded-prefix)))) + + (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) @@ -85,68 +124,23 @@ the PREFIX is removed." \[[cont-comment]]\n" "")) -(setq skelrc-gpl (skelrc-prefix-lines "[[cont-comment]] " -"[[Program-name]] 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 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with [[program-name]]; if not, write to the Free Software Foundation, -Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.")) - -(setq skelrc-wide-gpl (skelrc-prefix-lines "[[cont-comment]] " -;;Version for wide program names -"[[Program-name]] 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 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with [[program-name]]; if not, write to the Free -Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA.")) - -(setq skelrc-lgpl (skelrc-prefix-lines "[[cont-comment]] " -"[[Library-name]] is free software; you can redistribute it and/or modify -it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. - -\[[Library-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 Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -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. +(defun skelrc-generic-gpl (&rest params) + (setq skel-alist (append params skel-alist)) + (skelrc-prefix-and-reflow "[[cont-comment]] " +"[[Short-name]] is free software: you can redistribute it and/or +modify it under the terms of the GNU \[[gpl-qualifiers]]General +Public License as published by the Free Software Foundation; +either version [[gpl-version]] of the License, or (at your +option) any later version. -\[[Program-name]] is distributed in the hope that it will be useful, +\[[Short-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. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +\[[gpl-qualifiers]]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 -.")) +You should have received a copy of the GNU +\[[gpl-qualifiers]]General Public License along with +\[[short-name]]. If not, [[gpl-find-licence]]")) (setq skelrc-bsd (skelrc-prefix-lines "[[cont-comment]] " "Copyright (c) [[year]] [[author]] @@ -202,23 +196,55 @@ option) any later version.")) (licence-banner . (skelrc-banner "Licensing notice" t)) (component . (skelrc-component)) (licence-text . "[[gpl]]") - (Program-name . (or (skelrc-assq 'Program skel-alist) - (skelrc-assq 'program skel-alist) - "This program")) - (program-name . (or (skelrc-assq 'program skel-alist) - "this program")) - (Library-name . (or (skelrc-assq 'Library skel-alist) - (skelrc-assq 'library skel-alist) - (skelrc-assq 'Program skel-alist) - (skelrc-assq 'program skel-alist) - "This library")) - (library-name . (or (skelrc-assq 'library skel-alist) - (skelrc-assq 'program skel-alist) - "this library")) - (gpl . skelrc-gpl) - (wide-gpl . skelrc-wide-gpl) - (lgpl . skelrc-lgpl) - (agpl . skelrc-agpl) + (fill-column . "70") + (Short-name . (or (skelrc-assq 'Library skel-alist) + (skelrc-assq 'library skel-alist) + (skelrc-assq 'Program skel-alist) + (skelrc-assq 'program skel-alist) + "This [[thing]]")) + (short-name . (or (skelrc-assq 'library skel-alist) + (skelrc-assq 'program skel-alist) + "this [[thing]]")) + (generic-gpl . (skelrc-generic-gpl)) + (gnu-temple-place . (concat "write to the " + "Free Software Foundation, Inc., " + "59 Temple Place - Suite 330, " + "Boston, MA 02111-1307, USA.")) + (gnu-website . "see .") + (gpl-2 . (skelrc-generic-gpl '(gpl-version . "2") + '(gpl-qualifiers . "") + '(gpl-find-licence + . "[[gnu-temple-place]]") + '(thing . "program"))) + (gpl-3 . (skelrc-generic-gpl '(gpl-version . "3") + '(gpl-qualifiers . "") + '(gpl-find-licence + . "[[gnu-website]]") + '(thing . "program"))) + (lgpl-2 . (skelrc-generic-gpl '(gpl-version . "2") + '(gpl-qualifiers . "Library ") + '(gpl-find-licence + . "[[gnu-temple-place]]") + '(thing . "library"))) + (lgpl-2.1 . (skelrc-generic-gpl '(gpl-version . "2.1") + '(gpl-qualifiers . "Lesser ") + '(gpl-find-licence + . "[[gnu-temple-place]]") + '(thing . "library"))) + (lgpl-3 . (skelrc-generic-gpl '(gpl-version . "3") + '(gpl-qualifiers . "Lesser ") + '(gpl-find-licence + . "[[gnu-website]]") + '(thing . "library"))) + (agpl-3 . (skelrc-generic-gpl '(gpl-version . "3") + '(gpl-qualifiers . "Affero ") + '(gpl-find-licence + . "[[gnu-website]]") + '(thing . "program"))) + (gpl . "[[gpl-2]]") + (wide-gpl . "[[gpl-2]]") + (lgpl . "[[lgpl-2]]") + (agpl . "[[agpl-3]]") (bsd . skelrc-bsd) (revisions . ,(concat "[[revision-banner]]\n" "[[cont-comment]]\n"