3c20a65ff4
The sample `00:test_*.py` should read `00:test_.*.py`, as per https://github.com/mineo/yatemplate#description
64 lines
2.3 KiB
Org Mode
64 lines
2.3 KiB
Org Mode
#+TITLE: Templates layer
|
|
|
|
* Table of Contents :TOC_4_gh:noexport:
|
|
- [[#description][Description]]
|
|
- [[#features][Features:]]
|
|
- [[#install][Install]]
|
|
- [[#configuration][Configuration]]
|
|
- [[#default-insertions][Default insertions]]
|
|
- [[#querying][Querying]]
|
|
|
|
* Description
|
|
This layer provides templates to Spacemacs. A template consists of text that is
|
|
automatically inserted into a new file when it is opened. This is done via
|
|
[[https://github.com/mineo/yatemplate][yatemplate]], which leverages [[https://github.com/joaotavora/yasnippet][yasnippet]].
|
|
|
|
** Features:
|
|
- Auto-insert snippets when creating specific new files.
|
|
|
|
* Install
|
|
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
|
add =templates= to the existing =dotspacemacs-configuration-layers= list in this
|
|
file.
|
|
|
|
* Configuration
|
|
Drop your templates in =~/.emacs.d/private/templates= or
|
|
=~/.spacemacs.d/templates= depending on which method you are using.
|
|
|
|
You can also specify a different location with =templates-private-directory=:
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(setq-default dotspacemacs-configuration-layers
|
|
'((templates :variables templates-private-directory "~/mytemplates")))
|
|
#+END_SRC
|
|
|
|
Each file in this directory must be of the form =XXX:regexp= where =regexp= is a
|
|
regular expression that will be matched against filenames. The prefix =XXX= can
|
|
be used to enforce an ordering (templates that come first will have priority).
|
|
It is not part of the final regexp. Therefore, more specific templates should
|
|
come first. For example,
|
|
|
|
#+BEGIN_EXAMPLE
|
|
00:test_.*.py
|
|
01:.*.py
|
|
#+END_EXAMPLE
|
|
|
|
See the [[https://github.com/mineo/yatemplate][yatemplate]] documentation for specifics. Full yasnippet syntax is
|
|
supported, so consult the [[http://joaotavora.github.io/yasnippet/snippet-development.html][yasnippet]] documentation for details.
|
|
|
|
** Default insertions
|
|
Note that Emacs ships with some default templates. If these are not to your
|
|
liking, set the layer variable =templates-use-defaults= to =nil=.
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(setq-default dotspacemacs-configuration-layers
|
|
'((templates :variables templates-use-defaults nil)))
|
|
#+END_SRC
|
|
|
|
** Querying
|
|
To disable the automatic querying each time a new file is opened, set
|
|
=auto-insert-query= to =nil=.
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(setq auto-insert-query nil)
|
|
#+END_SRC
|