### Example ~/.gnus.el configuration Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Example-Setup.html A basic Gnus configuration for a standard setup. It sets the news method to NNTP, mail sources to POP, secondary select methods to nnml, and includes commented-out lines for enabling the agent (now default). Place this in ~/.gnus.el and edit to suit your needs. ```emacs-lisp ;; Define how Gnus is to fetch news. We do this over NNTP ;; from your ISP’s server. (setq gnus-select-method '(nntp "news.your-isp.com")) ;; Define how Gnus is to read your mail. We read mail from ;; your ISP’s POP server. (setq mail-sources '((pop :server "pop.your-isp.com"))) ;; Say how Gnus is to store the mail. We use nnml groups. (setq gnus-secondary-select-methods '((nnml ""))) ;; Make Gnus into an offline newsreader. ;; (gnus-agentize) ; The obsolete setting. ;; (setq gnus-agent t) ; Now the default. ``` -------------------------------- ### Example .mairixrc configuration file Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Setting-up-mairix.html A complete example of a .mairixrc file showing base directory, folder paths, format, omissions, and database location. ```text base=~/Maildir maildir=.personal:.work:.logcheck:.sent mh=../Mail/nnml/*... mbox=../mboxmail/mailarchive_year* mformat=maildir omit=zz_mairix-* database=~/.mairixdatabase ``` -------------------------------- ### Example nnimap method for Gmail Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Customizing-the-IMAP-Connection.html An example method that connects to imap.gmail.com with TLS, sets the inbox to INBOX, uses default split methods, expunges immediately, and uses TLS stream. ```lisp (nnimap "imap.gmail.com" (nnimap-inbox "INBOX") (nnimap-split-methods default) (nnimap-expunge t) (nnimap-stream tls)) ``` -------------------------------- ### Example Score File Structure Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Score-File-Format.html A comprehensive example of a score file demonstrating various elements like header matching, scoring adjustments, and local variable settings. ```emacs-lisp (("from" ("Lars Ingebrigtsen" -10000) ("Per Abrahamsen") ("larsi\\|lmi" -50000 nil R)) ("subject" ("Ding is Badd" nil 728373)) ("xref" ("alt.politics" -1000 728372 s)) ("lines" (2 -100 nil <)) (mark 0) (expunge -1000) (mark-and-expunge -10) (read-only nil) (orphan -10) (adapt t) (files "/home/larsi/News/gnu.SCORE") (exclude-files "all.SCORE") (local (gnus-newsgroup-auto-expire t) (gnus-summary-make-false-root empty)) (eval (ding))) ``` -------------------------------- ### Set gnus-button-*-level in gnus-parameters Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Article-Button-Levels.html Example configuration that increases button levels for groups matching specific regexps. Set gnus-parameters to a list of (regexp . parameter-alist) pairs; here, groups matching emacs or gnus get gnus-button-emacs-level 10, unix gets gnus-button-man-level 10, and tex gets gnus-button-tex-level 10. ```emacs-lisp ;; increase gnus-button-*-level in some groups: (setq gnus-parameters '(("\<\(emacs\|gnus\)\>" (gnus-button-emacs-level 10)) ("\" (gnus-button-man-level 10)) ("\" (gnus-button-tex-level 10)))) ``` -------------------------------- ### Group parameters for ham classification with SpamOracle Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/SpamOracle.html Example group parameters for a ham group, installing `spam-use-spamoracle` for both ham and spam processing. Spam-marked messages are sent to SpamOracle as new spam samples. ```emacs-lisp ((spam-contents gnus-group-spam-classification-ham) (spam-process ((ham spam-use-spamoracle) (spam spam-use-spamoracle)))) ``` -------------------------------- ### nnvirtual method regexp for Andrea Dworkin newsgroups Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Combined-Groups.html Example nnvirtual method that collects all Andrea Dworkin newsgroups into one group. The regexp matches group names starting with 'alt.fan.andrea-dworkin' or 'rec.dworkin'. ```lisp (nnvirtual "^alt\\.fan\\.andrea-dworkin$\\|^rec\\.dworkin.*") ``` -------------------------------- ### Configure horizontal tree layout in ~/.gnus.el Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Tree-Display.html Example configuration to enable horizontal trees and set up a side-by-side window layout. ```elisp (setq gnus-use-trees t gnus-generate-tree-function 'gnus-generate-horizontal-tree gnus-tree-minimize-window nil) (gnus-add-configuration '(article (vertical 1.0 (horizontal 0.25 (summary 0.75 point) (tree 1.0)) (article 1.0)))) ``` -------------------------------- ### Set message-default-news-headers with a valid From address Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Anti_002dSpam-Basics.html Sets the From header for all news articles to a valid email address. The example uses 'larsi@trym.ifi.uio.no', but suggests using an address with a keyword like 'larsi+usenet@ifi.uio.no' if supported by the sendmail installation. ```lisp (setq message-default-news-headers "From: Lars Magne Ingebrigtsen \n") ``` -------------------------------- ### Example ~/.authinfo file Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/NNTP.html Shows the format of the ~/.authinfo file with token/value pairs. The first line supplies login and password for news.uio.no; the second line only supplies login for nntp.ifi.uio.no and includes the 'force' tag, which sends authinfo upon connection. The default is to not send authinfo until requested. ```text machine news.uio.no login larsi password geheimnis machine nntp.ifi.uio.no login larsi force yes ``` -------------------------------- ### Configure INN overview.fmt Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/To-From-Newsgroups.html Instruction for news server administrators to add support for extra headers in the overview.fmt file. ```text Newsgroups:full ``` -------------------------------- ### Old procmail configuration for Gnus 5.8 Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Pterodactyl-Gnus.html Example of the old procmail-based mail fetching configuration that was used before Gnus 5.8. This setup uses nnmail-use-procmail, nnmail-spool-file, nnmail-procmail-directory, and nnmail-procmail-suffix variables. It is no longer valid in Gnus 5.8. ```emacs-lisp (setq nnmail-use-procmail t) (setq nnmail-spool-file 'procmail) (setq nnmail-procmail-directory "~/mail/incoming/") (setq nnmail-procmail-suffix "\.in") ``` -------------------------------- ### Configure Gnus Window Layouts Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Window-Layout.html Example configuration for a narrow left-hand group buffer with the right-hand side split between the summary and article buffers. ```elisp (gnus-add-configuration '(article (horizontal 1.0 (vertical 25 (group 1.0)) (vertical 1.0 (summary 0.16 point) (article 1.0))))) (gnus-add-configuration '(summary (horizontal 1.0 (vertical 25 (group 1.0)) (vertical 1.0 (summary 1.0 point))))) ``` -------------------------------- ### Fancy split rule with gnus-registry-split-fancy-with-parent Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Fancy-splitting-to-parent.html Add this rule to your fancy split setup to route followups to the parent message's group. The registry must be enabled and gnus-registry-register-all defaults to non-nil for all messages. Other rules like spam-split and a default mailbox are shown as examples. ```emacs-lisp (setq nnimap-my-split-fancy '(| ;; split to parent: you need this (: gnus-registry-split-fancy-with-parent) ;; other rules, as an example (: spam-split) ;; default mailbox "mail") ``` -------------------------------- ### Full nndir back end implementation example Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Writing-New-Back-Ends.html A shortened version of the nndir back end demonstrating the use of nnoo macros. ```elisp ;;; nndir.el — single directory newsgroup access for Gnus ;; Copyright (C) 1995,1996 Free Software Foundation, Inc. ;;; Code: (require 'nnheader) (require 'nnmh) (require 'nnml) (require 'nnoo) (eval-when-compile (require 'cl)) (nnoo-declare nndir nnml nnmh) (defvoo nndir-directory nil "Where nndir will look for groups." nnml-current-directory nnmh-current-directory) (defvoo nndir-nov-is-evil nil "Non-nil means that nndir will never retrieve NOV headers." nnml-nov-is-evil) (defvoo nndir-current-group "" nil nnml-current-group nnmh-current-group) (defvoo nndir-top-directory nil nil nnml-directory nnmh-directory) (defvoo nndir-get-new-mail nil nil nnml-get-new-mail nnmh-get-new-mail) (defvoo nndir-status-string "" nil nnmh-status-string) ;;; Interface functions. (nnoo-define-basics nndir) (deffoo nndir-open-server (server &optional defs) (setq nndir-directory (or (cadr (assq 'nndir-directory defs)) server)) (unless (assq 'nndir-directory defs) (push `(nndir-directory ,server) defs)) (push `(nndir-current-group ,(file-name-nondirectory (directory-file-name nndir-directory))) defs) (push `(nndir-top-directory ,(file-name-directory (directory-file-name nndir-directory))) defs) (nnoo-change-server 'nndir server defs)) (nnoo-map-functions nndir (nnml-retrieve-headers 0 nndir-current-group 0 0) (nnmh-request-article 0 nndir-current-group 0 0) (nnmh-request-group nndir-current-group 0 0) (nnmh-close-group nndir-current-group 0)) (nnoo-import nndir (nnmh nnmh-status-message nnmh-request-list nnmh-request-newgroups)) (provide 'nndir) ``` -------------------------------- ### Configure gnus-post-method with nngateway and default settings Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Mail_002dTo_002dNews-Gateways.html Simple configuration for using the nngateway back end with the default header transformation. ```lisp (setq gnus-post-method '(nngateway "GATEWAY.ADDRESS")) ``` -------------------------------- ### Example news group identifier Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Group-Parameters.html An example of a news group name used in Gnus. ```text nntp+news.gnus.org:gmane.text.docbook.apps ``` -------------------------------- ### Lines Header Predicate Example Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Score-File-Format.html An example of how an advanced match for the 'lines' header is evaluated as a Lisp form. ```emacs-lisp (< header-value 4) ``` -------------------------------- ### Configure gnus-face-properties-alist for image appearance Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/X_002dFace.html Examples for setting image properties like ascent or relief for Face and X-Face images. ```elisp ;; Specify the altitude of Face and X-Face images in the From header. (setq gnus-face-properties-alist '((pbm . (:face gnus-x-face :ascent 80)) (png . (:ascent 80)))) ;; Show Face and X-Face images as pressed buttons. (setq gnus-face-properties-alist '((pbm . (:face gnus-x-face :relief -2)) (png . (:relief -2)))) ``` -------------------------------- ### Directory mail source example Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Mail-Source-Specifiers.html An example of a directory mail source specifying a path and a file suffix. ```elisp (directory :path "/home/user-name/procmail-dir/" :suffix ".prcml") ``` -------------------------------- ### Configure nnregistry refer method Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Registry-Article-Refer-Method.html Sets the registry entry limit, initializes the registry, and updates the gnus-refer-article-method to include nnregistry as a lookup source. ```elisp ;; Keep enough entries to have a good hit rate when referring to an ;; article using the registry. Use long group names so that Gnus ;; knows where the article is. (setq gnus-registry-max-entries 2500) (gnus-registry-initialize) (setq gnus-refer-article-method '(current (nnregistry) (nnweb "google" (nnweb-type google)))) ``` -------------------------------- ### Example Newsgroups header Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Mail_002dTo_002dNews-Gateways.html Shows an example Newsgroups header that will be transformed by the default header transformation function. ```text Newsgroups: alt.religion.emacs ``` -------------------------------- ### Disable backup creation for Gnus startup files Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Startup-Files.html This example defines a function to inhibit backups and adds it to the hooks for saving the .newsrc.eld and .newsrc files. ```elisp (defun turn-off-backup () (set (make-local-variable 'backup-inhibited) t)) (add-hook 'gnus-save-quick-newsrc-hook 'turn-off-backup) (add-hook 'gnus-save-standard-newsrc-hook 'turn-off-backup) ``` -------------------------------- ### Initialize the Spam package with spam-initialize Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Spam-Package-Introduction.html Run this function to autoload `spam.el` and install the hooks needed for the Spam package to work. Must be called before using the package. ```emacs-lisp (spam-initialize) ``` -------------------------------- ### Set gnus-thread-hide-subtree with predicate Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/More-Threading.html Example of setting gnus-thread-hide-subtree to a predicate specifier that hides threads containing unread or unseen articles. The example uses 'or' with gnus-article-unread-p and gnus-article-unseen-p. Note that the example is nonsensical because all unseen articles are also unread. ```lisp (setq gnus-thread-hide-subtree '(or gnus-article-unread-p gnus-article-unseen-p)) ``` -------------------------------- ### Example getmail script Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Mail-Source-Specifiers.html A shell script example for moving mail from a spool to stdout, used with the :prescript keyword. ```bash #!/bin/sh # getmail - move mail from spool to stdout # flu@iki.fi MOVEMAIL=/usr/lib/emacs/20.3/i386-redhat-linux/movemail TMP=$HOME/Mail/tmp rm -f $TMP; $MOVEMAIL $MAIL $TMP >/dev/null && cat $TMP ``` -------------------------------- ### gnus-posting-styles configuration example Source: https://www.gnu.org/software/emacs/manual/html_node/gnus/Posting-Styles.html Defines a list of posting style rules. Each rule matches a condition and applies attributes like signature, name, headers, and body. Conditions can be regexps, forms, function symbols, or value symbols. The example includes rules for newsgroups, mail, and specific headers. ```lisp (setq gnus-posting-styles '((".*" (signature-file "~/.signature") (name "User Name") (x-face-file "~/.xface") (x-url (getenv "WWW_HOME")) (organization "People's Front Against MWM")) ("^rec.humor" (signature my-funny-signature-randomizer)) ((equal (system-name) "gnarly") ;; A form (signature my-quote-randomizer)) (message-news-p ;; A function symbol (signature my-news-signature)) (window-system ;; A value symbol ("X-Window-System" (format "%s" window-system))) ;; If I’m replying to Larsi, set the Organization header. ((header "from" "larsi.*org") (Organization "Somewhere, Inc.")) ;; Reply to a message from the same subaddress the message ;; was sent to. ((header "x-original-to" "me\\(\\+.+\\)@example.org") (address "me\\1@example.org")) ((posting-from-work-p) ;; A user defined function (signature-file "~/.work-signature") (address "user@bar.foo") (body "You are fired.\n\nSincerely, your boss.") ("X-Message-SMTP-Method" "smtp smtp.example.org 587") (organization "Important Work, Inc")) ("nnml:.*" (From (with-current-buffer gnus-article-buffer (message-fetch-field "to")))) ("^nn.+:" (signature-file "~/.mail-signature")))) ```