bor.borygmus

A programming weblog by Hao Lian. • A long walk through an angry forest. • A series of memory leaks brought on by senility.

Update: I am currently unable to get any of this to work on the yasnippet 0.6.x release series. Setting yas/trigger-key seems to not do anything or throws an integer-or-marker-p error, and then even when I leave that out, yas/expand hangs for half a second before declaring that it cannot find any snippets. This grumble was written with yasnippet 0.5.5 installed. If anyone knows what’s happening, drop a comment.

You can stick this in your yasnippet (Emacs templating) pipe and chew on it for a while: "cls" "class ${class}(${object}):$0".

In full (the env is a bonus from you to me),

(yas/define-snippets
 'python-mode
 '(("env" "#!/usr/bin/env python\n")
   ("cls" "class ${class}(${object}):$0")))

You can now type “cls” in python-mode and then press your trigger key in order to declare pre-3.0 classes. I got tired of typing object all the time, and 3.0 keeps trying to change me, so here we are.

The default yasnippet trigger key is TAB, but that’s not the smartest choice. Emacs already has a great expander key, Alt-/, which does dynamic abbreviation. By the way, if your “friends” don’t understand why you use Emacs, you can link them to the dynamic abbreviations page.

And, after that, I’ll look the other way if you get a little physical. This—this is what friends do.

After pressing the trigger key, you can press TAB and Shift-TAB to move back and forth between the ${} fields. You are welcome. Actually, you should thank pluskid, the creator.

[(February 13, 2009) .]

Abandon your ideas.

Use Markdown+, but not HTML. In code blocks, beware angle brackets.