;;;; new-files.el -- set up auto-insert to suit me ;;; Time-stamp: <2006-11-14 17:32:25 jcgs> (require 'autoinsert) (defun insert-file-variables () "Make a file variables entry in the current buffer." (interactive) (save-excursion (goto-char (point-max)) (insert "\n" comment-start " Local" " variables: " comment-end "\n" comment-start " : " comment-end "\n" comment-start " End: " comment-end "\n"))) (defun remove-auto-insert (condition) "Remove the current actions for CONDITION." ;; unfortunately this is not provided in autoinsert.el ;; it seems that only the first match for a condition is meant to be used, ;; but it didn't look like that in practice (let ((x auto-insert-alist)) (while x (let ((x-cond (caar x))) (if (or (equal (caadr x) condition) (and (consp x-cond) (eq (car x-cond) condition))) (rplacd x (cddr x)) (setq x (cdr x)))))) (if (equal (caar auto-insert-alist) condition) (setq auto-insert-alist (cdr auto-insert-alist)))) ;; (setq auto-insert-directory "/nfs/vivaldi/u/ldisk5/john/insert/") last changed 95-06! (setq auto-insert-directory "~/common/insert/") ;; (setq auto-insert-alist ;; (append '(("\\.lisp" . "lisp-insert.lisp") ;; ("\\.el" . "el-insert.el") ;; ("\\.sh" . "sh-insert.sh") ;; ("\\.ps" . "ps-insert.ps") ;; ("\\.sml" . "sml-insert.sml") ;; ; ("\\.html" . "html-insert.html") ;; ) ;; auto-insert-alist)) (defvar gpl-string " ;; 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 ") (remove-auto-insert 'emacs-lisp-mode) (define-auto-insert 'emacs-lisp-mode '("Emacs lisp mode" ";;;; " (file-name-nondirectory (buffer-file-name)) " -- " (read-string "Description: ") "\n;;; Time-stamp: <>\n" (if (yes-or-no-p "Include GPL? ") gpl-string) "\n" _ "\n\n(provide '" (let* ((name (file-name-nondirectory (buffer-file-name))) (el-pos (string-match "\\.el" name))) (substring name 0 el-pos)) ")\n" "\n" ";;; end of " (file-name-nondirectory (buffer-file-name)) "\n")) (remove-auto-insert 'latex-mode) (define-auto-insert 'latex-mode '( ;; should try to offer completing read for these "options, RET: " "\\documentclass[" str & ?\] | -1 ?{ (read-string "class: ") "}\n" ("package, %s: " "\\usepackage[" (read-string "options, RET: ") & ?\] | -1 ?{ str "}\n") "\\title{" (read-string "Title: ") "}\n" "\\author{" (read-string "Author: " (let* ((name (user-full-name))) (if (string-match "^ *\\([^ ]+\\) *$" name) (match-string 1 name) name))) "}\n" _ "\n\\begin{document}\n" _ "\n\\end{document}\n")) (remove-auto-insert 'xmlex-mode) (define-auto-insert "\\.xmlex$" '("XmLex mode" "\n" "\n" "\n" "\n" _ "\n")) ;;; end of new-files.el