I've been experimenting with emacs tempo mode and it seems likely to save me lots of typing (always a good thing), but I haven't gotten it to work exactly the way I want it. On the wiki, there is an example for elisp similar to what I want to do which works as expected. Here is the complete .emacs that I tested it on:
(require 'tempo)
(setq tempo-interactive t)
(tempo-define-template "lambda"
'(> "(lambda (" p ")" n> r> ")">)
nil
"Insert a template for an anonymous procedure")
(define-abbrev lisp-mode-abbrev-table "lambda" "" 'tempo-template-lambda)
This allows me to type "lambda" followed by a space and have it automatically insert
(lambda ( )
)
In my buffer with the point on the first closing parenthesis.
However, replacing the last two sexp's with the following code (stolen from Joachim Baumann via Sebastien Varrette and modified by me):
(tempo-define-template "c-include"
'("#include <" r ".h>" > n)
nil
"Insert a #include <> statement")
(define-abbrev c-mode-abbrev-table "c-include" "" 'tempo-template-lambda)
Will not cause the template to be inserted after typing "c-include" followed by a space. This is on emacs 22.2.1 running under Ubuntu 9.04. Does anybody have any idea why this might be the case before I go digging deeper into the tempo code and/or (god forbid) the C-mode code?