emacs 根据文件名自动加载内容
1
(setq c-new-buffer-template
'(
; "#include <stdio.h>\n"
; "#include <stdlib.h>\n"
; "\n"
; "int main(void){\n"
; "\n"
; "}\n"
; ))
"/*\n"
" * =====================================================================================\n"
" *\n"
" * Filename: test.c\n"
" *\n"
" * Description:\n"
" *\n"
" * Version: 1.0\n"
" * Created: 07/29/2011 10:37:04 AM\n"
" * Revision: none\n"
" * Compiler: gcc\n"
" *\n"
" * Author: kangle.wang (mn), wangkangluo1@gmail.com\n"
" * Company: APE-TECH\n"
" *\n"
" * =====================================================================================\n"
" */\n"
))
(defun my-c-style ()
"My editing style for .c files."
(c-mode)
(if (zerop (buffer-size))
(tempo-template-c-skeleton)))
(setq auto-mode-alist
(cons '("\\.c\\'" . my-c-style) auto-mode-alist))
(tempo-define-template "c-skeleton" c-new-buffer-template
nil
"Insert a skeleton for a .c document")
(setq js-new-buffer-template
'(
"/*fuckof\n"
))
(defun my-js-style ()
"My editing style for .c files."
(c-mode)
(if (zerop (buffer-size))
(tempo-template-c-skeleton)))
(setq auto-mode-alist
(cons '("\\.js\\'" . my-js-style) auto-mode-alist))
(tempo-define-template "c-skeleton" js-new-buffer-template
nil
"Insert a skeleton for a .c document")
2