smart-snippet


Textmate-like Emacs template extension with smarter behavior

Please migrate to YASnippet

Please migrate to YASnippet. YASnippet is a totally rewritten from scratch after I evaluated the feedbacks from smart-snippet. It support more features and works better. Also it is more convenient to configure. The homepage is at here: http://code.google.com/p/yasnippet/ .

Pete Kazmier's snippet.el is a Textmate-like template extension for Emacs. smart-snippet.el enhances snippet.el so that you can now have more control over the expansion of perticular abbrev. You can have the same abbrev expanding into different snippet under different circumstance.

For example, if you know ruby(or perl, similarly), its if has two use if condition statement end and statement if condition

now you can see if will expand into the first version if it occurs at the beginning of a line(ignoring spaces), the second version if not. Oh, wait, you may also wish not to expand if when typing in comment. OK, just define these smart-snippets: (require 'ruby-mode) (smart-snippet-with-abbrev-table 'ruby-mode-abbrev-table ('if' 'if $${condition} $.' '(not in-comment?)) ('if' 'if $${condition}\n$>$.\nend$>\n' 'bol?))

A screencast can be found here.

You can download smart-snippet.el from here. It NO LONGER requires the separate file snippet.el written by Pete Kazmier.

By default abbrev can't trigger non-word(like skeleton to expand [' to.md'). However, smart-snippet comes with an mechanism to bind key to snippet expansion. Now, you can bind the '[' key to the snippet expand to '.md'. That's not very intresting, isn't it? But this is smart-snippet! Now I can make '' to expand into '' if in normal state, and expand to\'' if in a string. Also, I can make <' to expand into<>' if I'm writing a template, or just `<' if not. Wonderful! For an example of commented config example, please refer to this.

Here is an introduction to smart-snippet, and why I write this extension, which is a Chinese article. I'm sorry there isn't an English version currently, but you can refer to the google translater translated page, though maybe not very impressed.

If you have any problem, feel free to Contact me ( pluskid AT gmail DOT com ).

Project Information

Labels:
Emacs snippet template smart skeleton