-
Notifications
You must be signed in to change notification settings - Fork 1
/
yas-template.el
55 lines (42 loc) · 1.67 KB
/
yas-template.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
;;; yas-template --- Insert file templates for new files using Yasnippet
;; Copyright (C) 2011 John Wiegley
;; Author: John Wiegley <jwiegley@gmail.com>
;; Created: 20 Aug 2011
;; Version: 1.0
;; Keywords: snippet template skeleton
;; X-URL: https://github.com/jwiegley/yas-template
;; 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, 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 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:
;; For every major-mode which defines a template named "_header", when
;; creating a new file of that type expand the header template to create its
;; initial contents.
;;
;; Install as follows:
;;
;; (require 'yas-template)
;; (yas-template-install)
(require 'yasnippet)
(defgroup yas-template nil
"Insert file templates for new files using Yasnippet"
:group 'yasnippet)
;;;###autoload
(defun yas-template-insert (&rest ignore)
(when (and (bobp) (eobp))
(insert "_header")
(call-interactively #'yas/expand)))
;;;###autoload
(defun yas-template-install ()
(add-hook 'find-file-hook 'yas-template-insert))
(provide 'yas-template)
;;; yas-template.el ends here