How can I make boilerplate text to use with Emacs Gnus email responses?

  • Can you elaborate? – Trey Jackson Jul 31 '09 at 16:21
  • I would like to save three or four common responses, choose one, make small edits, and post or email the result. – Richard Hoskins Jul 31 '09 at 17:21

AbbrevMode works in Gnus.

From that link (with some edits):

Defining Abbrevs

Type the word you want to use as expansion, and then type ‘C-x a g’ and the abbreviation for it. Example:

This is the text of an opening paragraph.Esc h Ctrl-u 0 Ctrl-x a gopenReturn

Me: That's a zero after the C-u. Together they make the abbrev definition C-x a g apply to the selected region, which is a paragraph, in this case, which the M-h (Esc-h or Alt-h) selected. The abbrev definition can be made to apply only to the current major mode instead of globally by using C-x a l (that's an "ell" instead of the "g").

Saving Abbrevs

Use ‘M-x write-abbrev-file’ and just hit RET when asked for a filename. The default is “~/.abbrev_defs”. In the future, Emacs should save the abbrevs automatically when you quit Emacs.

Also, if you want abbreviations to be saved whenever you save files (C-x s) or quit emacs, add the following to your .emacs:

(setq save-abbrevs t)

Restoring Abbrevs

Use ‘M-x read-abbrev-file’ to read the abbrevs, or better yet, add the following to your ~/.emacs file:


This will read the definitions from the default file, “~/.abbrev_defs”.

Using Abbrevs

‘M-x abbrev-mode’ toggles Abbrev mode. You can also put the following in your ~/.emacs file if you want it always on:

(abbrev-mode 1) Actually, you may have to do:

(setq default-abbrev-mode t) I’m not really sure why.

me again: Once abbrev-mode is on, typing an abbreviation followed by white space causes it to be immediately expanded. However, if you don't want that to happen you can leave it turned off and expand them manually like this:

openCtrl-x a e


This is the text of an opening paragraph.


You could also try YASnippet which would allow you to tab complete parts of boiler plate text where required.


Gnus uses Message-Mode for creating messages, so maybe that one has some specific functions for it.

I would use a custom hook in message-setup-hook for that (which asks me what I want to be asked and create a template). Note that this hook is called for both email and usenet news, both new messages and replies. But it should be easy to distinguish these cases from the buffer content.


At its simplest, you can do something like this:

(setq my-F3-keymap (make-sparse-keymap))
(global-set-key [(f3)] my-F3-keymap)

(define-key my-F3-keymap [(n)]
   (lambda ()
     "insert now is..."
     (insert "Now is the time for all good men to come to the aid of their country."))))

(define-key my-F3-keymap [(N)]
   (lambda ()
     "insert now is... with newlines"
     (insert "Now is the time\nfor all good men\nto come to the aid\nof their country."))))

(define-key my-F3-keymap [(f)]
   (lambda ()
     "insert external file contents"
     (insert-file "c:/temp/foo.html"))))

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.