Emacs includes an abbreviation package that allows you to type a shortcut e.g. oc which it will expand it to (say) oversight committee.
And a good thing too. I’ve had to type rel="nofollow" a few too many times in the past few days. I’d much rather type, for example "rnf" which I can add using (define-abbrev ...)
.
Another advantage is that I can include my inline styles in abbreviations which is very handy when wordpress.com makes it a little bit inconvenient to fix the master css.
(define-abbrev global-abbrev-table "rnf" "rel=\"nofollow\"") (define-abbrev global-abbrev-table "stcod" "style=\"font-size: 130%; background: #eee; padding: 3px;\"") (define-abbrev global-abbrev-table "stsrc" (concat "<pre style=\"font-size: 130%; border: 1px solid #bbb;" "background: #eee; margin: 15px 5px; padding: 5px;\">"))
Then add a hook to enable abbrev mode and you are good to go.
(add-hook 'text-mode-hook (lambda () (abbrev-mode 1)))
Look at yasnippet. ๐
Hi Alexander,
I have heard about yasnippet and it is on my list of things to try but I thought it was a competitor for Tempo mode or Skeleton mode rather than abbrev mode.
abbrev-mode and yasnippet are indeed complementary. I use both quite a lot. There are times when a certain shortcut could go in either, and there are some that I have actually defined in both, but in most cases it’s clear when you’d use one or the other.
Hm, I just use yasnippet for any abbreviations or templates. ๐
Okay Alexander, you’ve piqued my interest. ๐ I’ll take a look.
I am also using yasnippet for abbreviations.
It is really nice and easy to extend.