Coder Social home page Coder Social logo

emacsmirror / yatemplate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mineo/yatemplate

0.0 4.0 0.0 69 KB

File templates with yasnippet

Home Page: https://github.com/mineo/yatemplate

License: GNU General Public License v3.0

Emacs Lisp 99.12% Makefile 0.88%

yatemplate's Introduction

MELPA MELPA Stable

YATemplate

Installation

Install this package from MELPA with M-x package-install RET yatemplate RET.

Description

This package bridges the gap between YASnippet and auto-insert-mode. By populating auto-insert-alist with filenames and automatically expanding their content after insertion by auto-insert-mode, it's an easy way to create dynamic file templates. Simply call yatemplate-fill-alist somewhere in your Emacs initialization file to populate auto-insert-alist with filenames from yatemplate-dir.

Each filename will be turned into a new element to push onto auto-insert-alist. To guarantee a particular order, filenames must contain one colon (":"). After collecting all the filenames in yatemplate-dir, their names will be sorted with string<, then split on the colon. The first substring will be discarded, which means it can be used to establish an ordering. The second substring will be used as a regexp as the CONDITION of the element to push onto auto-insert-alist. The ACTION will be a vector of actions that first insert the content of the template file and then expand the content of the buffer with yatemplate-expand-yas-buffer, which simply calls yas-expand-snippet, so you can use everything YASnippet offers in the template.

Note that a dollar sign $ will be added to the end of the regular expression automatically because most of the template filenames will very likely be of the form filename.extension. If you want to specify a template filename where the last letters are not the extension, add .* at the end.

This means that if yatemplate-dir looks like this:

.emacs.d/templates
├── 00:test_.*.py
└── 01:.*.py

yatemplate-fill-alist will first push (".*.py$" . ACTION) onto auto-insert-alist and then ("test_.*.py$" . ACTION).

Of course, you will need to enable auto-insert-mode to have the snippet inserted and expanded into new files.

yatemplate's People

Contributors

conao3 avatar emayej avatar mineo avatar mjgpy3 avatar rubikitch avatar syohex avatar terlar avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.