FAQ 5-4

Question 5.4

Can I set things like From, Signature etc group based on the group I post too?

Answer

That’s the strength of posting styles. Before, we used ".*" to set the default for all groups. You can use a regexp like "^gmane" and the following settings are only applied to postings you send to the gmane hierarchy, use ".*binaries" instead and they will be applied to postings send to groups containing the string binaries in their name etc.

You can instead of specifying a regexp specify a function which is evaluated, only if it returns true, the corresponding settings take effect. Two interesting candidates for this are message-news-p which returns t if the current Group is a newsgroup and the corresponding message-mail-p.

Note that all forms that match are applied, that means in the example below, when I post to gmane.mail.spam.spamassassin.general, the settings under ".*" are applied and the settings under message-news-p and those under "^gmane" and those under "^gmane\\.mail\\.spam\\.spamassassin\\.general$". Because of this put general settings at the top and specific ones at the bottom.

(setq gnus-posting-styles
      '((".*" ;;default
         (name "Frank Schmitt")
         (organization "Hamme net, kren mer och nimmi")
         (signature-file "~/.signature"))
        ((message-news-p) ;;Usenet news?
         (address "mySpamTrap@Frank-Schmitt.invalid")
         (reply-to "hereRealRepliesOnlyPlease@Frank-Schmitt.invalid"))
        ((message-mail-p) ;;mail?
         (address "usedForMails@Frank-Schmitt.invalid"))
        ("^gmane" ;;this is mail, too in fact
         (address "usedForMails@Frank-Schmitt.invalid")
         (reply-to nil))
        ("^gmane\\.mail\\.spam\\.spamassassin\\.general$"
         (eval (set (make-local-variable 'message-sendmail-envelope-from)
                    "Azzrael@rz-online.de")))))