How can I make boilerplate text to use with Emacs Gnus email responses?
AbbrevMode works in Gnus.
From that link (with some edits):
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
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").
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)
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”.
‘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)] (function (lambda () "insert now is..." (interactive) (insert "Now is the time for all good men to come to the aid of their country.")))) (define-key my-F3-keymap [(N)] (function (lambda () "insert now is... with newlines" (interactive) (insert "Now is the time\nfor all good men\nto come to the aid\nof their country.")))) (define-key my-F3-keymap [(f)] (function (lambda () "insert external file contents" (interactive) (insert-file "c:/temp/foo.html"))))