From 79b00f3c656e09463680785556692cb598935819 Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 13 Mar 2022 00:42:38 +0000 Subject: skels: provide/require jao-skel-prefixed --- lib/skels/jao-skel-asdf.el | 10 +-- lib/skels/jao-skel-caml.el | 8 +-- lib/skels/jao-skel-common.el | 152 ---------------------------------------- lib/skels/jao-skel-cpp.el | 13 ++-- lib/skels/jao-skel-cppunit.el | 9 ++- lib/skels/jao-skel-geiser.el | 10 +-- lib/skels/jao-skel-haskell.el | 10 +-- lib/skels/jao-skel-latex.el | 7 +- lib/skels/jao-skel-lisp.el | 12 ++-- lib/skels/jao-skel-make.el | 7 +- lib/skels/jao-skel-perl.el | 9 ++- lib/skels/jao-skel-python.el | 9 ++- lib/skels/jao-skel-readme.el | 7 +- lib/skels/jao-skel-texinfo.el | 13 ++-- lib/skels/jao-skel.el | 157 ++++++++++++++++++++++++++++++++++++++++++ 15 files changed, 214 insertions(+), 219 deletions(-) delete mode 100644 lib/skels/jao-skel-common.el create mode 100644 lib/skels/jao-skel.el (limited to 'lib/skels') diff --git a/lib/skels/jao-skel-asdf.el b/lib/skels/jao-skel-asdf.el index 939eb8d..cb5761e 100644 --- a/lib/skels/jao-skel-asdf.el +++ b/lib/skels/jao-skel-asdf.el @@ -1,6 +1,6 @@ -;;; asdf-skel.el --- Skels for ASDF system definition files +;;; jao-skel-asdf.el --- Skels for ASDF system definition files -;; Copyright (C) 2007 Jose Antonio Ortega Ruiz +;; Copyright (C) 2007, 2022 Jose Antonio Ortega Ruiz ;; Author: Jose Antonio Ortega Ruiz ;; Keywords: lisp @@ -22,7 +22,7 @@ ;;; Code: -(require 'common-skel) +(require 'jao-skel) (define-skeleton jao-skel-asdf-file "ASDF file header" @@ -48,5 +48,5 @@ (add-to-list 'auto-insert-alist '("\\.asd\\'" . jao-skel-asdf-file)) -(provide 'asdf-skel) -;;; asdf-skel.el ends here +(provide 'jao-skel-asdf) +;;; jao-skel-asdf.el ends here diff --git a/lib/skels/jao-skel-caml.el b/lib/skels/jao-skel-caml.el index 65a5db2..bbe6b17 100644 --- a/lib/skels/jao-skel-caml.el +++ b/lib/skels/jao-skel-caml.el @@ -1,4 +1,4 @@ -;; Copyright (C) 2004, 2005, 2009 Jose Antonio Ortega Ruiz +;; Copyright (C) 2004, 2005, 2009, 2022 Jose Antonio Ortega Ruiz ;; Author: Jose A Ortega Ruiz ;; Keywords: tools @@ -24,7 +24,7 @@ ;;; Code: -(require 'common-skel) +(require 'jao-skel) (define-skeleton jao-skel-caml-file "OCaml file header" @@ -38,5 +38,5 @@ (jao-provide-skel "\\.ml[i]?" 'jao-skel-caml-file) -(provide 'caml-skel) - +(provide 'jao-skel-caml) +;;; jao-skel-caml ends here diff --git a/lib/skels/jao-skel-common.el b/lib/skels/jao-skel-common.el deleted file mode 100644 index 977e7ea..0000000 --- a/lib/skels/jao-skel-common.el +++ /dev/null @@ -1,152 +0,0 @@ -;; common definitions and functions - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Jose Antonio Ortega Ruiz - -;; Author: Jose A Ortega Ruiz -;; Keywords: tools - -;; This file 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 3, or (at your option) -;; any later version. - -;; This file 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 GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; Aux functions used in other skeletons - -;;; Code: - -(require 'skeleton) -(require 'autoinsert) - -(defvar jao-company-name nil - "Company name used in copyright notice") - -(defvar jao-copyright-file ".copyright" - "Basename of the raw (uncommented) copyright file") - -(defvar jao-skels-default-scm nil - "Default SCM system") - -(defun jao-prefix (pref) (or pref (concat comment-start " "))) -(defun jao-suffix (suff) (or suff (concat " " comment-end))) - -(defun jao-copyright-line (prefix &optional suffix omit-cpy) - "Create a brief copyright notice with given PREFIX and SUFFIX" - (concat (jao-prefix prefix) - (if omit-cpy "" "Copyright ") - "(c) " (format-time-string "%Y") " " - (or jao-company-name (user-full-name)) - (jao-suffix suffix) "\n")) - -(defun jao-date-line (prefix &optional suffix) - "Create a start date line" - (concat (jao-prefix prefix) - "Start date: " (format-time-string "%a %b %d, %Y %H:%M") - (jao-suffix suffix) "\n")) - -(defun jao-author-line (prefix &optional suffix) - "Create an author date line" - (concat (jao-prefix prefix) - "Author: " (user-full-name) " <" user-mail-address "> " - (jao-suffix suffix) "\n")) - -(defun jao-cvs-line (prefix &optional suffix) - "Create a CVS ID line" - (concat (jao-prefix prefix) "$" "Id$" (jao-suffix suffix) "\n")) - -(defun jao-svn-line (prefix &optional suffix) - "Create a SVN ID line" - (concat (jao-prefix prefix) "X-SVN: $" "Id$" (jao-suffix suffix) "\n")) - -(defun jao-arch-line (&optional prefix suffix) - "Create an arch-tag line" - (let ((uuid (shell-command-to-string "uuidgen"))) - (concat (jao-prefix prefix) "arch-tag: " uuid (jao-suffix suffix) "\n"))) - -(defun jao-insert-arch-line () - (interactive) - (insert (jao-arch-line))) - -(defun jao-scm-line (prefix &optional suffix) - "Create an scm line" - (let* ((formats '(("arch" . jao-arch-line) - ("svn" . jao-svn-line) - ("cvs" . jao-cvs-line) - ("none" . (lambda (p f) "")))) - (names (mapcar 'car formats)) - (prompt (concat "SCM (" (mapconcat 'identity names ", ") "): ")) - (sel (or jao-skels-default-scm - (completing-read prompt formats nil 1))) - (fun (cdr (assoc sel formats)))) - (when fun (concat (funcall fun prefix suffix))))) - -(defun jao-c&co-line (&optional prefix suffix) - (concat (jao-scm-line prefix suffix) "\n" - (jao-co-line prefix suffix))) - -(defun jao-co-line (&optional prefix suffix) - (concat (jao-copyright-line prefix suffix) "\n" - (jao-author-line prefix suffix) - (jao-date-line prefix suffix))) - -;; aux functions --------------------------------------------------------- -(defun jao-basename () - "Get buffer file name without dir nor extension" - (file-name-sans-extension (file-name-nondirectory (buffer-file-name)))) - -(defun jao-basedir () - "Base directory" - (file-name-nondirectory - (substring (file-name-directory (buffer-file-name)) 0 -1))) - -(defun jao-dir-level (l) - (let ((elems (split-string - (file-name-sans-extension (buffer-file-name)) "/"))) - (mapconcat 'identity (nthcdr (- (length elems) (+ 1 l)) elems) "/"))) - -(defun jao-extension () - "Find the extension of the currently visited file" - (let ((elems (split-string (file-name-nondirectory (buffer-file-name)) - "\\."))) - (nth (- (length elems) 1) elems))) - -(defun jao-other-file-name (ext1 ext2) - "Find the complimentary file name of header/source file" - (let ((extension (jao-extension)) - (basename (jao-basename))) - (if (string= extension ext1) (concat basename "." ext2) - (concat basename "." ext1)))) - -(defun jao-insert-commented-file (file-name) - (let* ((start (point)) - (end (+ start (cadr (insert-file-contents file-name))))) - (goto-char end) - (comment-region start (point)))) - -(defun jao-insert-copyright-file () - (let ((dir (locate-dominating-file (buffer-file-name) jao-copyright-file))) - (when dir - (let ((file (expand-file-name jao-copyright-file dir))) - (when (file-exists-p file) - (jao-insert-commented-file file)))))) - -(defun jao-provide-skel (regexp skel) - (let ((ex (assoc regexp auto-insert-alist))) - (if ex (setf (cdr ex) skel) - (add-to-list 'auto-insert-alist (cons regexp skel))))) - -(defsubst jao-skel-provide (lst) - (mapc (lambda (x) (apply #'jao-provide-skel x)) lst)) - -(provide 'common-skel) diff --git a/lib/skels/jao-skel-cpp.el b/lib/skels/jao-skel-cpp.el index 806f1df..b9bd8a2 100644 --- a/lib/skels/jao-skel-cpp.el +++ b/lib/skels/jao-skel-cpp.el @@ -1,6 +1,6 @@ -;;; cpp-skel.el +;;; jao-skel-cpp.el -;; Copyright (C) 2004, 2005, 2008, 2009 Jose Antonio Ortega Ruiz +;; Copyright (C) 2004, 2005, 2008, 2009, 2022 Jose Antonio Ortega Ruiz ;; Author: Jose A Ortega Ruiz ;; Keywords: tools @@ -22,11 +22,11 @@ ;;; Commentary: -;; C++ skeletons. +;; C/C++ skeletons. ;;; Code: -(require 'common-skel) +(require 'jao-skel) (require 'thingatpt) ;;; Variables @@ -250,6 +250,5 @@ ("\\.c$" jao-skel-c-source-header) ("\\.h$" jao-skel-c-header))) -(provide 'cpp-skel) - -;;; cpp-skel.el ends here +(provide 'jao-skel-cpp) +;;; jao-skel-cpp.el ends here diff --git a/lib/skels/jao-skel-cppunit.el b/lib/skels/jao-skel-cppunit.el index 729f392..947f1e5 100644 --- a/lib/skels/jao-skel-cppunit.el +++ b/lib/skels/jao-skel-cppunit.el @@ -1,6 +1,6 @@ -;;; cppunit-skel.el +;;; jao-skel-cppunit.el -;; Copyright (C) 2004, 2005 Jose Antonio Ortega Ruiz +;; Copyright (C) 2004, 2005, 2022 Jose Antonio Ortega Ruiz ;; Author: Jose A Ortega Ruiz ;; Keywords: tools @@ -26,7 +26,7 @@ ;;; Code: -(require 'common-skel) +(require 'jao-skel) (define-skeleton jao-cppunit-main "Insert CPPUNIT main function" @@ -87,5 +87,4 @@ "}" > \n) -(provide 'cppunit-skel) - +(provide 'jao-skel-cppunit) diff --git a/lib/skels/jao-skel-geiser.el b/lib/skels/jao-skel-geiser.el index 3c9181a..a622336 100644 --- a/lib/skels/jao-skel-geiser.el +++ b/lib/skels/jao-skel-geiser.el @@ -1,11 +1,11 @@ -;; geiser-skel.el -- geiser skeletons +;; jao-geiser-fuel.el -- geiser skeletons -;; Copyright (C) 2009 Jose Antonio Ortega Ruiz +;; Copyright (C) 2009, 2022 Jose Antonio Ortega Ruiz ;; Author: Jose Antonio Ortega Ruiz ;; Start date: Fri Sep 11, 2009 00:31 -(require 'common-skel) +(require 'jao-skel) (defconst jao-skel-geiser--bsd ";; This program is free software; you can redistribute it and/or @@ -46,5 +46,5 @@ -(provide 'geiser-skel) -;;; geiser-skel.el ends here +(provide 'jao-geiser-fuel) +;;; jao-geiser-fuel.el ends here diff --git a/lib/skels/jao-skel-haskell.el b/lib/skels/jao-skel-haskell.el index 8ea0301..08b12e1 100644 --- a/lib/skels/jao-skel-haskell.el +++ b/lib/skels/jao-skel-haskell.el @@ -1,5 +1,5 @@ -;;; haskell-skel.el --- skeleton for haskell source files -;; Copyright (C) 2003, 2004, 2005, 2009, 2010, 2012 Jose A Ortega Ruiz +;;; jao-skel-haskell.el --- skeleton for haskell source files +;; Copyright (C) 2003, 2004, 2005, 2009, 2010, 2012, 2022 Jose A Ortega Ruiz ;; Author: Jose A Ortega Ruiz ;; Keywords: languages @@ -25,7 +25,7 @@ ;;; Code: -(require 'common-skel) +(require 'jao-skel) (require 'jao-dominating-file) ;;; Auxiliar @@ -65,6 +65,6 @@ (jao-provide-skel "\\.hs\\'" 'jao-skel-haskell-file) ;; (jao-provide-skel "\\.lhs\\'" 'jao-skel-lit-haskell-file) -(provide 'haskell-skel) +(provide 'jao-skel-haskell) -;;; haskell-skel.el ends here +;;; jao-skel-haskell.el ends here diff --git a/lib/skels/jao-skel-latex.el b/lib/skels/jao-skel-latex.el index 330be22..a1c84e0 100644 --- a/lib/skels/jao-skel-latex.el +++ b/lib/skels/jao-skel-latex.el @@ -1,6 +1,6 @@ ;; latex skeletons -;; Copyright (C) 2004, 2005, 2009 Jose Antonio Ortega Ruiz +;; Copyright (C) 2004, 2005, 2009, 2022 Jose Antonio Ortega Ruiz ;; Author: Jose A Ortega Ruiz ;; Keywords: tools @@ -26,7 +26,7 @@ ;;; Code: -(require 'common-skel) +(require 'jao-skel) (define-skeleton jao-skel-latex "Latex standard header" @@ -48,5 +48,4 @@ (jao-provide-skel "\\.tex$\\|\\.sty$\\|\\.cls$" 'jao-skel-latex) -(provide 'latex-skel) - +(provide 'jao-skel-latex) diff --git a/lib/skels/jao-skel-lisp.el b/lib/skels/jao-skel-lisp.el index e5bb91a..501b34f 100644 --- a/lib/skels/jao-skel-lisp.el +++ b/lib/skels/jao-skel-lisp.el @@ -1,6 +1,6 @@ -;;; lisp-skel.el --- skeleton for lisp-like languages +;;; jao-skel-lisp.el --- skeleton for lisp-like languages -;; Copyright (C) 2003, 2004, 2005, 2008, 2009 Jose A Ortega Ruiz +;; Copyright (C) 2003, 2004, 2005, 2008, 2009, 2022 Jose A Ortega Ruiz ;; Author: Jose A Ortega Ruiz ;; Keywords: lisp @@ -26,7 +26,7 @@ ;;; Code: -(require 'common-skel) +(require 'jao-skel) (define-skeleton jao-skel-lisp-file "Lisp file header" @@ -44,7 +44,7 @@ \n \n) -(jao-provide-skel "\\.\\(scm\\|ss\\|lisp\\|cl\\|el\\)\\'" 'jao-skel-lisp-file) +(jao-provide-skel "\\.\\(scm\\|ss\\|lisp\\|cl)\\'" 'jao-skel-lisp-file) -(provide 'lisp-skel) -;;; lisp-skel.el ends here +(provide 'jao-skel-lisp) +;;; jao-skel-lisp.el ends here diff --git a/lib/skels/jao-skel-make.el b/lib/skels/jao-skel-make.el index 5607dbe..343c3f9 100644 --- a/lib/skels/jao-skel-make.el +++ b/lib/skels/jao-skel-make.el @@ -1,6 +1,6 @@ ;; makefile skeletons -;; Copyright (C) 2004, 2005, 2009 Jose Antonio Ortega Ruiz +;; Copyright (C) 2004, 2005, 2009, 2022 Jose Antonio Ortega Ruiz ;; Author: Jose A Ortega Ruiz ;; Keywords: tools @@ -26,7 +26,7 @@ ;;; Code: -(require 'common-skel) +(require 'jao-skel) (define-skeleton jao-skel-makefile "Makefile standard header" @@ -49,5 +49,4 @@ (jao-provide-skel "\\.mk$\\|Makefile\\(\\.am\\)?\\|configure\\.in" 'jao-skel-makefile) -(provide 'make-skel) - +(provide 'jao-skel-make) diff --git a/lib/skels/jao-skel-perl.el b/lib/skels/jao-skel-perl.el index a5b5bb4..80c2b8f 100644 --- a/lib/skels/jao-skel-perl.el +++ b/lib/skels/jao-skel-perl.el @@ -1,6 +1,6 @@ -;;; perl-skel.el +;;; jao-skel-perl.el -;; Copyright (C) 2004, 2005, 2009 Jose Antonio Ortega Ruiz +;; Copyright (C) 2004, 2005, 2009, 2022 Jose Antonio Ortega Ruiz ;; Author: Jose A Ortega Ruiz ;; Keywords: tools @@ -26,7 +26,7 @@ ;;; Code: -(require 'common-skel) +(require 'jao-skel) (define-skeleton jao-skel-perl-script "Standard perl script header" @@ -74,5 +74,4 @@ (jao-provide-skel "\\.pl$" 'jao-skel-perl-script) (jao-provide-skel "\\.pm$" 'jao-skel-perl-module) -(provide 'perl-skel) - +(provide 'jao-skel-perl) diff --git a/lib/skels/jao-skel-python.el b/lib/skels/jao-skel-python.el index 536f825..73b0634 100644 --- a/lib/skels/jao-skel-python.el +++ b/lib/skels/jao-skel-python.el @@ -1,6 +1,6 @@ -;;; python-skel.el +;;; jao-skel-python.el -;; Copyright (C) 2004, 2005, 2009 Aleix Conchillo Flaque +;; Copyright (C) 2004, 2005, 2009, 2022 Aleix Conchillo Flaque ;; Author: Aleix Conchillo Flaque ;; Keywords: tools @@ -26,7 +26,7 @@ ;;; Code: -(require 'common-skel) +(require 'jao-skel) (define-skeleton jao-skel-python-module "Standard python module header" @@ -49,5 +49,4 @@ (jao-provide-skel "\\.py$" 'jao-skel-python-module) -(provide 'python-skel) - +(provide 'jao-skel-python) diff --git a/lib/skels/jao-skel-readme.el b/lib/skels/jao-skel-readme.el index 9c22cce..31f92b7 100644 --- a/lib/skels/jao-skel-readme.el +++ b/lib/skels/jao-skel-readme.el @@ -1,4 +1,4 @@ -;; Copyright (C) 2004, 2005 Jose Antonio Ortega Ruiz +;; Copyright (C) 2004, 2005, 2022 Jose Antonio Ortega Ruiz ;; Author: Jose A Ortega Ruiz ;; Keywords: tools @@ -24,7 +24,7 @@ ;;; Code: -(require 'common-skel) +(require 'jao-skel) (define-skeleton jao-skel-readme-file "README file header" @@ -40,5 +40,4 @@ (add-to-list 'auto-insert-alist '("README" . jao-skel-readme-file)) -(provide 'readme-skel) - +(provide 'jao-skel-readme) diff --git a/lib/skels/jao-skel-texinfo.el b/lib/skels/jao-skel-texinfo.el index dc73835..d9f2830 100644 --- a/lib/skels/jao-skel-texinfo.el +++ b/lib/skels/jao-skel-texinfo.el @@ -1,4 +1,4 @@ -;;; texinfo-skel.el --- skeletons for texinfo files +;;; jao-skel-texinfo.el --- skeletons for texinfo files ;; Author: Jose Antonio Ortega Ruiz ;; Keywords: languages @@ -24,7 +24,7 @@ ;;; Code: -(require 'common-skel) +(require 'jao-skel) (defun jao-dir-entry () "Read dir file entry" @@ -122,10 +122,7 @@ (jao-skel-child-texinfo)) _) -(add-to-list 'auto-insert-alist '("\\.texi$" . jao-texinfo-skel)) +(add-to-list 'auto-insert-alist '("\\.texi$" . jao-skel-texinfo)) - -(provide 'texinfo-skel) - - -;;; texinfo-skel.el ends here +(provide 'jao-skel-texinfo) +;;; jao-skel-texinfo.el ends here diff --git a/lib/skels/jao-skel.el b/lib/skels/jao-skel.el new file mode 100644 index 0000000..afcd3b3 --- /dev/null +++ b/lib/skels/jao-skel.el @@ -0,0 +1,157 @@ +;; jao-skel.el: common definitions and functions + +;; Copyright (C) 2004-2012, 2022 Jose Antonio Ortega Ruiz + +;; Author: Jose A Ortega Ruiz +;; Keywords: tools + +;; This file 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 3, or (at your option) +;; any later version. + +;; This file 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 GNU Emacs; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Aux functions used in other skeletons + +;;; Code: + +(require 'skeleton) +(require 'autoinsert) + +(defvar jao-company-name nil + "Company name used in copyright notice") + +(defvar jao-copyright-file ".copyright" + "Basename of the raw (uncommented) copyright file") + +(defvar jao-skels-default-scm nil + "Default SCM system") + +(defun jao-prefix (pref) (or pref (concat comment-start " "))) +(defun jao-suffix (suff) (or suff (concat " " comment-end))) + +(defun jao-copyright-line (prefix &optional suffix omit-cpy) + "Create a brief copyright notice with given PREFIX and SUFFIX" + (concat (jao-prefix prefix) + (if omit-cpy "" "Copyright ") + "(c) " (format-time-string "%Y") " " + (or jao-company-name (user-full-name)) + (jao-suffix suffix) "\n")) + +(defun jao-date-line (prefix &optional suffix) + "Create a start date line" + (concat (jao-prefix prefix) + "Start date: " (format-time-string "%a %b %d, %Y %H:%M") + (jao-suffix suffix) "\n")) + +(defun jao-author-line (prefix &optional suffix) + "Create an author date line" + (concat (jao-prefix prefix) + "Author: " (user-full-name) " <" user-mail-address "> " + (jao-suffix suffix) "\n")) + +(defun jao-cvs-line (prefix &optional suffix) + "Create a CVS ID line" + (concat (jao-prefix prefix) "$" "Id$" (jao-suffix suffix) "\n")) + +(defun jao-svn-line (prefix &optional suffix) + "Create a SVN ID line" + (concat (jao-prefix prefix) "X-SVN: $" "Id$" (jao-suffix suffix) "\n")) + +(defun jao-arch-line (&optional prefix suffix) + "Create an arch-tag line" + (let ((uuid (shell-command-to-string "uuidgen"))) + (concat (jao-prefix prefix) "arch-tag: " uuid (jao-suffix suffix) "\n"))) + +(defun jao-insert-arch-line () + (interactive) + (insert (jao-arch-line))) + +(defun jao-scm-line (prefix &optional suffix) + "Create an scm line" + (let* ((formats '(("arch" . jao-arch-line) + ("svn" . jao-svn-line) + ("cvs" . jao-cvs-line) + ("none" . (lambda (p f) "")))) + (names (mapcar 'car formats)) + (prompt (concat "SCM (" (mapconcat 'identity names ", ") "): ")) + (sel (or jao-skels-default-scm + (completing-read prompt formats nil 1))) + (fun (cdr (assoc sel formats)))) + (when fun (concat (funcall fun prefix suffix))))) + +(defun jao-c&co-line (&optional prefix suffix) + (concat (jao-scm-line prefix suffix) "\n" + (jao-co-line prefix suffix))) + +(defun jao-co-line (&optional prefix suffix) + (concat (jao-copyright-line prefix suffix) "\n" + (jao-author-line prefix suffix) + (jao-date-line prefix suffix))) + +;; aux functions --------------------------------------------------------- +(defun jao-basename () + "Get buffer file name without dir nor extension" + (file-name-sans-extension (file-name-nondirectory (buffer-file-name)))) + +(defun jao-basedir () + "Base directory" + (file-name-nondirectory + (substring (file-name-directory (buffer-file-name)) 0 -1))) + +(defun jao-dir-level (l) + (let ((elems (split-string + (file-name-sans-extension (buffer-file-name)) "/"))) + (mapconcat 'identity (nthcdr (- (length elems) (+ 1 l)) elems) "/"))) + +(defun jao-extension () + "Find the extension of the currently visited file" + (let ((elems (split-string (file-name-nondirectory (buffer-file-name)) + "\\."))) + (nth (- (length elems) 1) elems))) + +(defun jao-other-file-name (ext1 ext2) + "Find the complimentary file name of header/source file" + (let ((extension (jao-extension)) + (basename (jao-basename))) + (if (string= extension ext1) (concat basename "." ext2) + (concat basename "." ext1)))) + +(defun jao-insert-commented-file (file-name) + (let* ((start (point)) + (end (+ start (cadr (insert-file-contents file-name))))) + (goto-char end) + (comment-region start (point)))) + +(defun jao-insert-copyright-file () + (let ((dir (locate-dominating-file (buffer-file-name) jao-copyright-file))) + (when dir + (let ((file (expand-file-name jao-copyright-file dir))) + (when (file-exists-p file) + (jao-insert-commented-file file)))))) + +(defun jao-provide-skel (regexp skel) + (let ((ex (assoc regexp auto-insert-alist))) + (if ex (setf (cdr ex) skel) + (add-to-list 'auto-insert-alist (cons regexp skel))))) + +(defsubst jao-skel-provide (lst) + (mapc (lambda (x) (apply #'jao-provide-skel x)) lst)) + +(setq auto-insert t) +(add-hook 'find-file-hooks 'auto-insert) +(setq auto-insert-directory "~/.autoinsert/") +(setq auto-insert-query t) + +(provide 'jao-skel) -- cgit v1.2.3