From: mdw Date: Mon, 5 Apr 1999 13:44:58 +0000 (+0000) Subject: Initial revision X-Git-Tag: 1.0.2~21 X-Git-Url: https://git.distorted.org.uk/~mdw/skel/commitdiff_plain/7fb0878b62328fd3bf80e2142a5d68b314105eb1?ds=sidebyside Initial revision --- 7fb0878b62328fd3bf80e2142a5d68b314105eb1 diff --git a/.links b/.links new file mode 100644 index 0000000..264203b --- /dev/null +++ b/.links @@ -0,0 +1,5 @@ +COPYING +elisp-comp +install-sh +missing +mkinstalldirs diff --git a/.skelrc b/.skelrc new file mode 100644 index 0000000..5f8528d --- /dev/null +++ b/.skelrc @@ -0,0 +1,8 @@ +;;; -*-emacs-lisp-*- + +(setq skel-alist + (append + '((author . "Mark Wooding") + (full-title . "Skel") + (program . "Skel")) + skel-alist)) diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..162746f --- /dev/null +++ b/Makefile.am @@ -0,0 +1,61 @@ +## -*-makefile-*- +## +## $Id: Makefile.am,v 1.1 1999/04/05 13:44:59 mdw Exp $ +## +## Makefile for skel +## +## (c) 1998 Mark Wooding +## + +##----- Licensing notice ---------------------------------------------------- +## +## This file is part of Skel. +## +## Skel 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. +## +## Skel 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 Skel; if not, write to the Free Software Foundation, +## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +##----- Revision history ---------------------------------------------------- +## +## $Log: Makefile.am,v $ +## Revision 1.1 1999/04/05 13:44:59 mdw +## Initial revision +## + +## --- Basic automake configuration --- + +AUTOMAKE_OPTIONS = foreign + +## --- Emacs lisp files to build --- + +lisp_LISP = skel.el skel-init.el +ELCFILES = skel.elc + +## --- Other things to install --- + +pkgdata_DATA = \ + skeleton skelrc \ + skelrc.c skelrc.cc skelrc.h skelrc.y \ + skelrc.el \ + skelrc.pm skelrc.pl \ + skelrc.am skelrc.in \ + skeleton.skel skelrc.skel \ + skeleton.texi skelrc.texi + +## --- Things to distribute --- + +EXTRA_DIST = \ + $(pkgdata_DATA) \ + skel-init.el + +##----- That's all, folks --------------------------------------------------- diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..282f23c --- /dev/null +++ b/configure.in @@ -0,0 +1,48 @@ +dnl -*-fundamental-*- +dnl +dnl $Id: configure.in,v 1.1 1999/04/05 13:44:59 mdw Exp $ +dnl +dnl Configuration script for skel +dnl +dnl (c) 1998 Mark Wooding +dnl + +dnl ----- Licensing notice -------------------------------------------------- +dnl +dnl This file is part of Skel. +dnl +dnl Skel is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl Skel is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with Skel; if not, write to the Free Software Foundation, +dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +dnl ----- Revision history -------------------------------------------------- +dnl +dnl $Log: configure.in,v $ +dnl Revision 1.1 1999/04/05 13:44:59 mdw +dnl Initial revision +dnl + +AC_INIT(skel.el.in) +AM_INIT_AUTOMAKE(skel, 1.0) +AM_PATH_LISPDIR +AM_PROG_INSTALL + +mdw_prefix="$prefix" +test "$prefix" = "NONE" && prefix="$ac_default_prefix" +eval "skeldir=\"$datadir/$PACKAGE\"" +prefix="$mdw_prefix" +AC_SUBST(skeldir) + +AC_OUTPUT(Makefile skel.el) + +dnl ----- That's all, folks ------------------------------------------------- diff --git a/skel-init.el b/skel-init.el new file mode 100644 index 0000000..03503ea --- /dev/null +++ b/skel-init.el @@ -0,0 +1,13 @@ +;;; -*-emacs-lisp-*- +;;; +;;; $Id: skel-init.el,v 1.1 1999/04/05 13:44:59 mdw Exp $ +;;; +;;; Initialise skeleton stuff +;;; +;;; (c) 1998 Mark Wooding +;;; + +(autoload 'skel-create-file "skel" nil t) +(autoload 'skel-create-file-other-window "skel" nil t) +(autoload 'skel-create-file-other-frame "skel" nil t) +(provide 'skel-init) diff --git a/skel.el.in b/skel.el.in new file mode 100644 index 0000000..d409011 --- /dev/null +++ b/skel.el.in @@ -0,0 +1,252 @@ +;;; -*-emacs-lisp-*- +;;; +;;; $Id: skel.el.in,v 1.1 1999/04/05 13:44:59 mdw Exp $ +;;; +;;; Filling in skeletons +;;; +;;; (c) 1998 Mark Wooding +;;; + +;;;----- Licensing notice --------------------------------------------------- +;;; +;;; This program 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. +;;; +;;; This program 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 this program; if not, write to the Free Software Foundation, +;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +;;;----- Revision history --------------------------------------------------- +;;; +;;; $Log: skel.el.in,v $ +;;; Revision 1.1 1999/04/05 13:44:59 mdw +;;; Initial revision +;;; + +;;;----- Variables (largely tweakable) -------------------------------------- + +(defvar skel-directory-list '(".skel" "") + "*List of directory names which contain skeleton files.") + +(defvar skel-skeleton-path '("@skeldir@" "~/skel" "~/src/skel") + "*List of directories to search for skeleton data anyway.") + +(defvar skel-skelrc '(".skelrc" "skelrc") + "*File containing skeleton substitution data, looked up using the standard +skeleton search mathod.") + +(defvar skel-alist '() + "Alist of values to substitute into a skeleton. It is filled in by skelrc +files and user interaction. + +The alist's keys are symbols, interned from the placeholder strings in the +skeleton file. The values are forms to be evaluated. In the simplest case, +the form is a string added as a result of user interaction; however, it could +just as easily be a function call or something similarly complicated.") + +;;;----- Finding skeleton files --------------------------------------------- + +(defun skel-do-join (acc jfun ll s) + "Recursive guts of skel-join." + (if ll + (if (car ll) + (skel-do-join (skel-do-join acc jfun (cdr ll) + (funcall jfun s (car (car ll)))) + jfun (cons (cdr (car ll)) (cdr ll)) s) + acc) + (cons s acc))) + +(defun skel-join (jfun base &rest ll) + "Return a list built from joining elements from the given lists in order, +left to right. JFUN is a function of two arguments which can join items +together. BASE is the initial item." + (nreverse (skel-do-join nil jfun ll base))) + +(defun skel-do-parents (dir acc) + "Tail recursive guts of skel-parents" + (setq acc (cons dir acc)) + (setq dir (substring dir 0 (string-match "/[^/]*/?$" dir))) + (if (string= dir "") + (cons "/" acc) + (skel-do-parents dir acc))) + +(defun skel-parents (dir) + "Returns a list of DIR, DIR's parent directory, etc., all the way up to the +root." + (setq dir (expand-file-name dir)) + (nreverse (skel-do-parents dir nil))) + +(defun skel-do-find (l all acc) + (if l + (let ((n (car l))) + (if (and (file-readable-p n) (file-regular-p n)) + (if all + (skel-do-find (cdr l) all (cons (abbreviate-file-name n) acc)) + (abbreviate-file-name n)) + (skel-do-find (cdr l) all acc))) + acc)) + +(defun skel-find-skeleton (name &optional all acc) + "Searches for skeleton files. NAME is the name of the file to find, or +a list of possible names. + +If ALL is nil, or omitted, return only the first matching filename +encountered. Otherwise, return a list of all matching names, most `global' +first. ACC is a base list to which the matching filenames are prepended." + + ;; --- Build one big list of all the possible names --- + + (let ((l (skel-join (lambda (x y) (if (string= y "") + x + (expand-file-name y x))) + nil + (append (skel-parents default-directory) + skel-skeleton-path) + skel-directory-list + (if (listp name) name (cons name nil))))) + + ;; --- Now filter out any which aren't interesting --- + + (skel-do-find l all acc))) + +;;;----- Processing file skeletons ------------------------------------------ + +(defun skel-include (file) + "Includes the skeleton rc FILE." + (let ((rc (skel-find-skeleton file t))) + (while rc + (load (car rc) nil t t) + (setq rc (cdr rc))))) + +(defun skel-lookup (name) + + "Reads the value of symbol NAME in skel-alist. If there is no currrent +value, the user is prompted for one." + + ;; --- Resolve NAME into a symbol --- + + (if (stringp name) + (setq name (intern name))) + + ;; --- Look up the value --- + ;; + ;; Add it to the list if we've not seen it before. Protect ourselves + ;; against functions which do regexp matching. + + (let ((pair (assq name skel-alist)) + value) + (if pair + (save-match-data (setq value (eval (cdr pair)))) + (setq value (read-string (format "Value for %s: " name))) + (setq skel-alist (cons (cons name value) skel-alist))) + value)) + +(defun skel-do-fill-in () + "Does the actual donkey-work of filling in a file. For each fill-in area +in the current buffer, the function looks to see if the item in question has +been entered into ALIST: if so, it is replaced automatically; otherwise the +user is promted to enter a string to substitute into the buffer at this +point." + (if (re-search-forward "\\[\\[\\([^]]*\\)\\]\\]" nil t) + (progn + (replace-match (skel-lookup (match-string 1)) t t nil) + (goto-char (match-beginning 0)) + (skel-do-fill-in)))) + +;;;----- Creating new files from skeletons ---------------------------------- + +(defun skel-do-create-file (name switch &optional skel) + + "Does the main work of creating a file based on a skeleton. The SWITCH +argument is called to display the buffer." + + ;; --- Some local variables --- + ;; + ;; This is a little bit of a hack, but do I look like someone who cares? + + (let (ext rc) + + ;; --- Find out if the file's there already --- + + (if (file-exists-p name) + (or (yes-or-no-p + (format "File %s already exists. Overwrite? " name)) + (error "Aborted!"))) + + ;; --- Fiddle with the filename --- + + (cond ((stringp skel) (let ((extind (string-match "\.[^.]*$" skel))) + (setq ext (and extind (substring skel extind))))) + (skel (progn + (setq ext (read-string "Extension: ")) + (or (string= ext "") (setq ext (concat "." ext))))) + (t (let ((extind (string-match "\.[^.]*$" name))) + (setq ext (and extind (substring name extind)))))) + (setq skel (concat "skeleton" (or ext ""))) + + ;; --- Find the skeleton filename --- + + (setq skel (or (skel-find-skeleton skel) + (skel-find-skeleton "skeleton") + (error "Couldn't find skeleton file %s" skel))) + + ;; --- Visit the file and destroy its contents --- + + (funcall switch (find-file-noselect name)) + (kill-region (point-min) (point-max)) + (insert-file skel) + + ;; --- Mangle the skeleton data in the file --- + + (make-local-variable 'skel-alist) + (setq skel-alist '()) + + ;; --- Read the default values to insert --- + + (let ((rc (append + (skel-find-skeleton skel-skelrc t) + (and ext + (skel-find-skeleton + (if (listp skel-skelrc) + (mapcar (lambda (x) (concat x ext)) skel-skelrc) + (concat skel-skelrc ext)) + t))))) + (while rc + (load (car rc) nil t t) + (setq rc (cdr rc)))) + + ;; --- Now do substitution --- + + (skel-do-fill-in) + (not-modified))) + +;;;----- User commands ------------------------------------------------------ + +(defun skel-create-file (name &optional skel) + "Creates a new file called NAME and visits it. If SKEL is non-`nil', it is +the name of a skeleton file to insert and substitute. Otherwise the skeleton +file's name is derived from NAME by taking NAME's extension and appending it +to `skel'." + (interactive "FSkeleton create file: \nP") + (skel-do-create-file name 'switch-to-buffer skel)) + +(defun skel-create-file-other-window (name &optional skel) + "Like skel-create-file, but in another window." + (interactive "FSkeleton create file in other window: \nP") + (skel-do-create-file name 'switch-to-buffer-other-window skel)) + +(defun skel-create-file-other-frame (name &optional skel) + "Like skel-create-file, but in another frame." + (interactive "FSkeleton create file in other frame: \nP") + (skel-do-create-file name 'switch-to-buffer-other-frame skel)) + +;;;----- Is that all there is? ---------------------------------------------- + +(provide 'skel) diff --git a/skeleton b/skeleton new file mode 100644 index 0000000..c5a058f --- /dev/null +++ b/skeleton @@ -0,0 +1,10 @@ +[[new-comment]] -*-[[emacs-mode]]-*- +[[cont-comment]] +[[cont-comment]] $Id$ +[[cont-comment]] +[[cont-comment]] [[purpose]] +[[cont-comment]] +[[cont-comment]] (c) [[year]] [[author]] +[[end-comment]] + +[[header]][[trailer]] \ No newline at end of file diff --git a/skeleton.skel b/skeleton.skel new file mode 100644 index 0000000..1891473 --- /dev/null +++ b/skeleton.skel @@ -0,0 +1,8 @@ +;;; -*-emacs-lisp-*- + +(skelrc-force-mode '[[target-mode]]) + +(setq skel-alist + (append + '((...)) + skel-alist)) diff --git a/skeleton.texi b/skeleton.texi new file mode 100644 index 0000000..d505a90 --- /dev/null +++ b/skeleton.texi @@ -0,0 +1,118 @@ +\input texinfo @c -*-texinfo-*- +@c +@c $Id$ +@c +@c [[purpose]] +@c +@c (c) [[year]] [[author]] +@c + +[[revisions]]@c ----- Standard boilerplate ----------------------------------------------- + +@c %**start of header +@setfilename [[basename]].info +@settitle [[title]] +@setchapternewpage odd +@footnotestyle end +@paragraphindent 0 +@iftex +@input texinice +@afourpaper +@end iftex +@c %**end of header + +@c ----- Useful macros ------------------------------------------------------ + +@set version 1.0 + +@c ----- Copyright matters -------------------------------------------------- + +@c --- The `Info' version --- + +@ifinfo + +This file documents [[subject]] version +@value{version}. + +Copyright (c) [[year]] [[author]] + +Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries a copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided also that the +sections entitled `Copying' and `GNU General Public License' are +included exactly as in the original, and provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation +approved by the copyright holder. + +@end ifinfo + +@c --- Printed title page --- + +@titlepage + +@title [[title]] +@subtitle [[subtitle]] +@author [[author]] +@page + +@vskip 0pt plus 1filll + +Copyright @copyright{} [[year]] [[author]] + +Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided also that the +sections entitled `Copying' and `GNU General Public License' are +included exactly as in the original, and provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation +approved by the copyright holder. + +@end titlepage + + +@c -------------------------------------------------------------------------- +@ifinfo +@node Top, Copying, (dir), (dir) +@top [[title]] + +@menu +@end menu + +@end ifinfo + +@c -------------------------------------------------------------------------- +@node Copying, Introduction, Top, Top +@unnumbered The GNU General Public License + +@include gpl.texi + +@c -------------------------------------------------------------------------- +@node Introduction, , Copying, Top +@unnumbered Introduction + +@c -------------------------------------------------------------------------- +@contents +@bye diff --git a/skelrc b/skelrc new file mode 100644 index 0000000..53922de --- /dev/null +++ b/skelrc @@ -0,0 +1,87 @@ +;;; -*-emacs-lisp-*- + +(defun skelrc-banner (title &optional block) + (let* ((start (skel-lookup 'block-start)) + (end (skel-lookup (if block 'block-banner-knob 'block-banner-end))) + (barlen (- 77 (length (concat start end " ----- " title))))) + (concat start "----- " title " " (make-string barlen ?-) end))) + +(defvar skelrc-forced-major-mode 0) + +(defun skelrc-force-mode (new-mode &optional priority) + (or priority (setq priority 1)) + (if (> priority skelrc-forced-major-mode) + (progn + (or (eq new-mode major-mode) + (let ((old-skel-alist skel-alist)) + (funcall new-mode) + (make-variable-buffer-local 'skel-alist) + (setq skel-alist old-skel-alist))) + (make-variable-buffer-local 'skelrc-forced-major-mode) + (setq skelrc-forced-major-mode priority)))) + +(defun skelrc-decode-major-mode () + (let* ((name (symbol-name major-mode)) + (endind (string-match "-mode$" name))) + (if endind (substring name 0 endind) + (name)))) + +(setq skelrc-gpl +"[[cont-comment]] This file is part of [[full-title]]. +[[cont-comment]] +[[cont-comment]] [[program]] is free software; you can redistribute it and/or modify +[[cont-comment]] it under the terms of the GNU General Public License as published by +[[cont-comment]] the Free Software Foundation; either version 2 of the License, or +[[cont-comment]] (at your option) any later version. +[[cont-comment]] +[[cont-comment]] [[program]] is distributed in the hope that it will be useful, +[[cont-comment]] but WITHOUT ANY WARRANTY; without even the implied warranty of +[[cont-comment]] MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +[[cont-comment]] GNU General Public License for more details. +[[cont-comment]] +[[cont-comment]] You should have received a copy of the GNU General Public License +[[cont-comment]] along with [[program]]; if not, write to the Free Software Foundation, +[[cont-comment]] Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.") + +(setq skelrc-lgpl +"[[cont-comment]] This file is part of [[full-title]]. +[[cont-comment]] +[[cont-comment]] [[program]] is free software; you can redistribute it and/or modify +[[cont-comment]] it under the terms of the GNU Library General Public License as +[[cont-comment]] published by the Free Software Foundation; either version 2 of the +[[cont-comment]] License, or (at your option) any later version. +[[cont-comment]] +[[cont-comment]] [[program]] is distributed in the hope that it will be useful, +[[cont-comment]] but WITHOUT ANY WARRANTY; without even the implied warranty of +[[cont-comment]] MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +[[cont-comment]] GNU Library General Public License for more details. +[[cont-comment]] +[[cont-comment]] You should have received a copy of the GNU Library General Public +[[cont-comment]] License along with [[program]]; if not, write to the Free Software +[[cont-comment]] Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.") + +(defun skel-basename () + (file-name-sans-extension (file-name-nondirectory buffer-file-name))) + +(setq skel-alist + (append + '((emacs-mode . (skelrc-decode-major-mode)) + (year . (substring (current-time-string) 20 24)) + (header . "[[licence]][[revisions]][[preamble]]") + (basename . (skel-basename)) + (licence . "[[licence-banner]]\n[[cont-comment]]\n[[licence-text]][[block-end]]\n\n") + (licence-banner . (skelrc-banner "Licensing notice" t)) + (licence-text . "[[gpl]]") + (gpl . skelrc-gpl) + (lgpl . skelrc-lgpl) + (revisions . "[[revision-banner]]\n[[cont-comment]]\n[[cont-comment]] $Log$[[block-end]]\n\n") + (revision-banner . (skelrc-banner "Revision history" t)) + (preamble . "") + (trailer . "[[tag-line]][[postamble]]\n") + (postamble . "") + (tag-line . (skelrc-banner "That's all, folks")) + (block-start . (skel-lookup 'new-comment)) + (block-banner-knob . "") + (block-banner-end . "") + (block-end . "")) + skel-alist)) diff --git a/skelrc.am b/skelrc.am new file mode 100644 index 0000000..1047b25 --- /dev/null +++ b/skelrc.am @@ -0,0 +1,14 @@ +;; -*-emacs-lisp-*- + +(skelrc-force-mode 'makefile-mode) + +(setq skel-alist + (append + '((new-comment . "##") + (cont-comment . "##") + (end-comment . "##") + (block-start . "##") + (block-banner-knob . "") + (block-banner-end . "") + (block-end . "")) + skel-alist)) diff --git a/skelrc.c b/skelrc.c new file mode 100644 index 0000000..864ac49 --- /dev/null +++ b/skelrc.c @@ -0,0 +1,22 @@ +;;; -*-emacs-lisp-*- + +(skelrc-force-mode 'c-mode) + +(setq skel-alist + (append + '((new-comment . "/*") + (cont-comment . " *") + (end-comment . " */") + (block-start . "/*") + (block-banner-knob . "* ") + (block-banner-end . "*/") + (block-end . "\n */") + (preamble . "[[includes]][[structures]][[main-code]]") + (includes . "[[includes-banner]]\n\n[[headers]]") + (includes-banner . (skelrc-banner "Header files")) + (headers . "") + (structures . "[[struct-banner]]\n\n") + (struct-banner . (skelrc-banner "Data structures")) + (main-code . "[[main-code-banner]]\n\n") + (main-code-banner . (skelrc-banner "Main code"))) + skel-alist)) diff --git a/skelrc.cc b/skelrc.cc new file mode 100644 index 0000000..5c1dd3d --- /dev/null +++ b/skelrc.cc @@ -0,0 +1,4 @@ +;;; -*-emacs-lisp-*- + +(skelrc-force-mode 'c++-mode) +(skel-include "skelrc.c") diff --git a/skelrc.el b/skelrc.el new file mode 100644 index 0000000..10a057c --- /dev/null +++ b/skelrc.el @@ -0,0 +1,8 @@ +;;; -*-emacs-lisp-*- + +(setq skel-alist + (append + '((new-comment . ";;;") + (cont-comment . ";;;") + (end-comment . ";;;")) + skel-alist)) diff --git a/skelrc.h b/skelrc.h new file mode 100644 index 0000000..f0309db --- /dev/null +++ b/skelrc.h @@ -0,0 +1,26 @@ +;;; -*-emacs-lisp-*- + +(skel-include "skelrc.c") + +(defun skelrc-c-guard-name () + (if buffer-file-name + (upcase (file-name-sans-extension (file-name-nondirectory + buffer-file-name))) + (skel-lookup 'include-guard-name))) + +(setq skel-alist + (append + '((preamble . "[[guard]][[c++-guard]][[includes]][[structures]][[functions]]") + (guard . "#ifndef [[guard-name]]_H\n#define [[guard-name]]_H\n\n") + (guard-name . (skelrc-c-guard-name)) + (c++-guard . "#ifdef __cplusplus\n extern \"C\" {\n#endif\n\n") + (includes . "[[includes-banner]]\n\n[[headers]]") + (includes-banner . (skelrc-banner "Header files")) + (headers . "") + (structures . "[[struct-banner]]\n\n") + (struct-banner . (skelrc-banner "Data structures")) + (functions . "[[func-banner]]\n\n") + (func-banner . (skelrc-banner "Functions provided")) + (postamble . "\n\n[[c++-unguard]]#endif") + (c++-unguard . "#ifdef __cplusplus\n }\n#endif\n\n")) + skel-alist)) diff --git a/skelrc.in b/skelrc.in new file mode 100644 index 0000000..d1f7bb6 --- /dev/null +++ b/skelrc.in @@ -0,0 +1,14 @@ +;; -*-emacs-lisp-*- + +(skelrc-force-mode 'fundamental-mode) + +(setq skel-alist + (append + '((new-comment . "dnl") + (cont-comment . "dnl") + (end-comment . "dnl") + (block-start . "dnl ") + (block-banner-knob . "") + (block-banner-end . "") + (block-end . "")) + skel-alist)) diff --git a/skelrc.pl b/skelrc.pl new file mode 100644 index 0000000..5f0b123 --- /dev/null +++ b/skelrc.pl @@ -0,0 +1,15 @@ +;;; -*-emacs-lisp-*- + +(skelrc-force-mode 'perl-mode) + +(setq skel-alist + (append + '((new-comment . "#") + (cont-comment . "#") + (end-comment . "#") + (block-start . "#") + (block-banner-knob . "") + (block-banner-end . "") + (block-end . "") + (preamble . "")) + skel-alist)) diff --git a/skelrc.pm b/skelrc.pm new file mode 100644 index 0000000..5f0b123 --- /dev/null +++ b/skelrc.pm @@ -0,0 +1,15 @@ +;;; -*-emacs-lisp-*- + +(skelrc-force-mode 'perl-mode) + +(setq skel-alist + (append + '((new-comment . "#") + (cont-comment . "#") + (end-comment . "#") + (block-start . "#") + (block-banner-knob . "") + (block-banner-end . "") + (block-end . "") + (preamble . "")) + skel-alist)) diff --git a/skelrc.skel b/skelrc.skel new file mode 100644 index 0000000..95ced9b --- /dev/null +++ b/skelrc.skel @@ -0,0 +1,3 @@ +;;; -*-emacs-lisp-*- + +(skelrc-force-mode 'emacs-lisp-mode) diff --git a/skelrc.texi b/skelrc.texi new file mode 100644 index 0000000..f23e0e3 --- /dev/null +++ b/skelrc.texi @@ -0,0 +1,14 @@ +;;; -*-emacs-lisp-*- + +(skelrc-force-mode 'texinfo-mode) + +(setq skel-alist + (append + '((new-comment . "@c") + (cont-comment . "@c") + (end-comment . "@c") + (block-start . "@c ") + (block-banner-knob . "") + (block-banner-end . "") + (block-end . "")) + skel-alist)) diff --git a/skelrc.y b/skelrc.y new file mode 100644 index 0000000..4015573 --- /dev/null +++ b/skelrc.y @@ -0,0 +1,74 @@ +;;; -*-emacs-lisp-*- + +(skelrc-force-mode 'c-mode) + +(setq skel-alist + (append + `((new-comment . "/*") + (cont-comment . " *") + (end-comment . " */") + (block-start . "/*") + (block-banner-knob . "* ") + (block-banner-end . "*/") + (block-end . "\n */") + (preamble . "[[c-stuff]][[yacc-stuff]][[c-code]]") + + ;; --- Heavy-duty C preamble to the parser --- + + (c-stuff . "[[includes]][[macros]][[depends]][[references]]") + (includes . "[[includes-banner]]\n%{\n\n[[headers]]") + (includes-banner . (skelrc-banner "Header files")) + (headers . "") + (macros . "[[macros-banner]]\n\n[[macros-body]]") + (macros-banner . (skelrc-banner "Parser control macros")) + (macros-body . "#define YYDEBUG 1\n#define YYERROR_VERBOSE\n\n") + (depends . "[[deps-banner]]\n\n[[deps-body]]") + (deps-banner . (skelrc-banner "External dependencies")) + (deps-body . "extern int yylex(void);\n\n") + (references . "[[refs-banner]]\n\n[[refs-body]]") + (refs-banner . (skelrc-banner "Forward references")) + (refs-body . "static int yyerror(const char */*e*/);\n\n") + + ;; --- Yacc preamble and main parser --- + + (yacc-stuff . "[[yacc-decls]][[tokens]][[nonterms]][[yacc-parser]]") + + (yacc-decls . "[[decls-banner]]%}\n\n[[decls-body]]") + (decls-banner . (skelrc-banner "Yacc declarations")) + (decls-body . ,(concat "%expect 0\n" + "%start ...\n" + "\n" + "/* --- Stack type --- */\n" + "\n" + "%union {\n" + "}\n" + "\n")) + (tokens . "[[toks-banner]]\n\n") + (toks-banner . (skelrc-banner "Token declarations")) + (nonterms . "[[nonterms-banner]]\n\n") + (nonterms-banner . (skelrc-banner "Nonterminal declarations")) + + (yacc-parser . "[[parser-banner]]\n%%\n\n") + (parser-banner . (skelrc-banner "Grammar rules")) + + ;; --- C code stuck on the end --- + + (c-code . "[[c-code-banner]]\n%%\n\n[[yyerror]]") + (c-code-banner . (skelrc-banner "C code")) + (yyerror . ,(concat "/* --- @yyerror@ --- *\n" + " *\n" + " * Arguments:\t@const char *e@ = " + "error message text\n" + " *\n" + " * Returns:\t---\n" + " *\n" + " * Use:\t\tHandles errors reported by " + "the parser.\n" + " */\n" + "\n" + "static void yyerror(const char *e)\n" + "{\n" + " fprintf(stderr, \"%s\\n\", e);\n" + "}\n" + "\n"))) + skel-alist))