do not edit — generated by btf.
git.druid.rocksindexdruid520radiumradium-autoinsert.el

radium-autoinsert.el


;;; radium-autoinsert.el, "program init": auto-populate new files in my style -*- lexical-binding: t; -*-
;;
;; only fires on genuinely new/empty files (autoinsert.el's own rule),
;; never touches existing content.
 
(require 'autoinsert)
(setq auto-insert-query nil)
(auto-insert-mode 1)
 
(defun radium-insert-template (text)
  "i insert TEXT, then move point to the \"@!@\" sentinel inside it (and
delete the sentinel), or to the end if there isn't one."
  (let ((start (point)))
    (insert text)
    (goto-char start)
    (if (search-forward "@!@" nil t)
        (replace-match "")
      (goto-char (point-max)))))
 
(define-auto-insert '("\\.c\\'" . "c89 main")
  (lambda ()
    (radium-insert-template
     "#include <stdio.h>\n#include <stdlib.h>\n\nint main(int argc, char** argv);\n\nint\nmain(int argc, char** argv)\n{\n\t@!@\n\treturn 0;\n}\n")))
 
(define-auto-insert '("\\.h\\'" . "header guard")
  (lambda ()
    (radium-insert-template
     (format "#ifndef %s\n#define %s\n\n@!@\n\n#endif\n"
             (radium-header-guard-name) (radium-header-guard-name)))))
 
(define-auto-insert '("\\.pl\\'" . "perl script")
  (lambda ()
    (radium-insert-template "#!/usr/bin/env perl\nuse v5.16;\nuse strict;\nuse warnings FATAL => 'all';\n\n@!@\n")))
 
(define-auto-insert '("\\.sh\\'" . "posix sh script")
  (lambda ()
    (radium-insert-template "#!/usr/bin/env sh\nset -e\n\n@!@\n")))
 
(define-auto-insert '("\\.s\\'" . "at&t asm")
  (lambda ()
    (radium-insert-template
     ".section .text\n.globl _start\n.type _start, @function\n_start:\n\t@!@\n")))
 
(define-auto-insert '("\\.adb\\'" . "ada body")
  (lambda ()
    (let ((name (file-name-base (or (buffer-file-name) "Main"))))
      (radium-insert-template
       (format "procedure %s is\nbegin\n\t@!@\nend %s;\n" name name)))))
(define-auto-insert '("\\.ads\\'" . "ada spec")
  (lambda ()
    (let ((name (file-name-base (or (buffer-file-name) "Main"))))
      (radium-insert-template
       (format "package %s is\n\n\t@!@\n\nend %s;\n" name name)))))
 
(define-auto-insert '("\\.k\\(s\\)?\\'" . "kona script")
  (lambda ()
    (radium-insert-template "@!@")))
 
(define-auto-insert '("\\.fth\\'" . "forth word")
  (lambda ()
    (let ((name (file-name-base (or (buffer-file-name) "main"))))
      (radium-insert-template
       (format ": %s ( -- )\n\t@!@\n;\n" name)))))
 
(define-auto-insert '("\\.scm\\'" . "scheme define")
  (lambda ()
    (radium-insert-template "(define (main)\n\t@!@)\n")))
 
(define-auto-insert '("\\.el\\'" . "elisp file")
  (lambda ()
    (let ((name (file-name-base (or (buffer-file-name) "x"))))
      (radium-insert-template
       (format ";;; %s.el, @!@ -*- lexical-binding: t; -*-\n\n(provide '%s)\n"
               name name)))))
 
(provide 'radium-autoinsert)
powered by btf.