Gnus Manual. Node: Posting Styles

PREVArchived Messages UPComposing Messages NEXTDrafts

5.6: Posting Styles

All them variables, they make my head swim.

So what if you want a different Organization and signature based on what groups you post to? And you post both from your home machine and your work machine, and you want different From lines, and so on?

One way to do stuff like that is to write clever hooks that change the variables you need to have changed. That's a bit boring, so somebody came up with the bright idea of letting the user specify these things in a handy alist. Here's an example of a gnus-posting-styles variable:

  (signature "Peace and happiness")
  (organization "What me?"))
  (signature "Death to everybody"))
  (organization "Emacs is it")))

As you might surmise from this example, this alist consists of several styles. Each style will be applicable if the first element ``matches'', in some form or other. The entire alist will be iterated over, from the beginning towards the end, and each match will be applied, which means that attributes in later styles that match override the same attributes in earlier matching styles. So `comp.programming.literate' will have the `Death to everybody' signature and the `What me?' Organization header.

The first element in each style is called the match. If it's a string, then Gnus will try to regexp match it against the group name. If it's a function symbol, that function will be called with no arguments. If it's a variable symbol, then the variable will be referenced. If it's a list, then that list will be evaled. In any case, if this returns a non-nil value, then the style is said to match.

Each style may contain a arbitrary amount of attributes. Each attribute consists of a (name . value) pair. The attribute name can be one of signature, signature-file, organization, address, name or body. The attribute name can also be a string. In that case, this will be used as a header name, and the value will be inserted in the headers of the article.

The attribute value can be a string (used verbatim), a function (the return value will be used), a variable (its value will be used) or a list (it will be evaled and the return value will be used).

If you wish to check whether the message you are about to compose is meant to be a news article or a mail message, you can check the values of the two dynamically bound variables message-this-is-news and message-this-is-mail.

So here's a new example:

(setq gnus-posting-styles
         (signature-file "~/.signature")
         (name "User Name")
         ("X-Home-Page" (getenv "WWW_HOME"))
         (organization "People's Front Against MWM"))
         (signature my-funny-signature-randomizer))
        ((equal (system-name) "gnarly")
         (signature my-quote-randomizer))
         (signature my-news-signature))
         (signature-file "~/.work-signature")
         (address "")
         (body "You are fired.\n\nSincerely, your boss.")
         (organization "Important Work, Inc"))
         (signature-file "~/.mail-signature"))))
PREVArchived Messages UPComposing Messages NEXTDrafts