; -*- lisp -*- ;;Byte Compile .gnus.el if it has changed since the last time visited (defun GnusWait! () "If ~/.gnus.el exists and is newer than ~/.gnus, recompile it to ~/.gnus.elc and move the compiled version to ~/.gnus." (cond ((file-newer-than-file-p "~/.gnus.el" "~/.gnus") (let ((mode-line-format "*** PLEASE STANDBY: RECOMPILING .gnus.el **")) (sit-for 0) (byte-compile-file "~/.gnus.el") (message ".gnus recompiled --- reloading ...") (rename-file "~/.gnus.elc" "~/.gnus" t)) (load "~/.gnus" t t t) (message "") ))) (GnusWait!) ;; I don't use any other newsreader. (setq gnus-save-newsrc-file nil gnus-read-newsrc-file nil ) ;(setq gnus-secondary-select-methods '((nnfolder ""))) ;; nnimap is great : I sort my mail with procmail with "| dmail +mailbox" ;; rules, and then can access my mailboxes from anywhere with any ;; mailer and the same folders. (setq gnus-secondary-select-methods '((nnimap "ormelune.imag.fr") (nndiary ""))) ;; Mandatory to use nndiary. (add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp) (setq nndiary-get-new-mail t) (setq gnus-visible-headers '("^From:" "^Newsgroups:" "^Subject:" "^Date:" "^Followup-To:" "^Reply-To:" "^Organization:" "^Summary:" "^Keywords:" "^To:" "^[BGF]?Cc:" "^Posted-To:" "^Mail-Copies-To:" "^Apparently-To:" "^X-Gnus-Warning:" "^Resent-From:" "^X-Sent:" "^X-Mailer:" "^X-Newsreader:" "^X-User-Agent:" "^User-Agent:" "^X-Diary")) ;(setq nnfolder-directory "~/Mail") ;(setq nnmail-split-methods ; '(("ensimag" "^\\(To\\|Cc\\):.*ensi3a@ensi") ; ("dea" "^\\(To\\|Cc\\):.*deaisc@ufrima.imag.fr") ; ("dea" "^\\(To\\|Cc\\):.*all@ufrima.imag.fr") ; ("dea" "^\\(To\\|Cc\\):.*moym@ufrima.imag.fr") ; ("verimag" "^\\(To\\|Cc\\):.*hybride.verimag@imag.fr") ; ("verimag" "^\\(To\\|Cc\\):.*seminaires-verimag@imag.fr") ; ("verimag" "^\\(To\\|Cc\\):.*all.verimag@imag.fr") ; ("perso" "^\\(To\\|Cc\\):.*[Mm]atthieu\\.[Mm]oy@.*imag.fr") ; ("bbdb" "^\\(To\\|Cc\\):.*bbdb-info@lists.sourceforge.net") ; ("ding" "^\\(To\\|Cc\\):.*ding@gnus.org") ; ("default" ""))) ;(rebuild-mail-abbrevs "~/.mailrc") ;(add-hook 'mail-setup-hook 'bbdb-define-all-aliases) (add-hook 'gnus-message-setup-hook 'bbdb-define-all-aliases) (setq bbdb-north-american-phone-numbers-p nil) ;;--------------------------------------------------------------------- ;; moy-bbdb.el : Noticing BBDB records on outgoing mails (add-hook 'message-send-hook 'bbdb/send-hook) (setq ;; Add the notes when noticing messages. bbdb/send-notice-hook '(bbdb/send-auto-notes-hook) ;; Ignore the messages described in bbdb/send-ignore-some-messages-alist bbdb/send-auto-create-p 'bbdb/send-ignore-some-messages-hook ;; Useless with the previous line, but ... bbdb/send-ignore-most-messages-alist '(("Subject" . "yyyyyy")) ;; The only messages to be ignored. bbdb/send-ignore-some-messages-alist '(("Subject" . "xxxxxx")) ;; What to add to the record. bbdb/send-auto-notes-alist '(("Subject" (".*test.*" . "I sent him a test.") (".*" last-sent 0 t))) ;; Notice only messages addressed to me. bbdb-ignore-most-messages-alist '(("to" . "matthieu\\.moy@.*\\.imag\\.fr")) bbdb-notice-hook '(bbdb-auto-notes-hook) bbdb-offer-save 'savenoprompt bbdb/mail-auto-create-p 'bbdb-ignore-most-messages-hook bbdb/news-auto-create-p 'bbdb-ignore-most-messages-hook bbdb/prompt-for-create-p t ;; This is standard. Keep track of the last message recieved. bbdb-auto-notes-alist '(("Subject" ("test" . "He sent me a test") (".*" last-recieved 0 t)) ("Organization" (".*" company 0))) ) (add-hook 'message-send-hook 'moy-gnus-check-headers) ;;--------------------------------------------------------------------- ;; X-Face : My head as a 48x48 pixmap in the header of mails. ;(defvar gnus-x-face-file (expand-file-name "~/.x-face")) ;(defun message-insert-x-face () ; (save-excursion ; (goto-char (point-min)) ; (search-forward mail-header-separator) ; (beginning-of-line nil) ; (insert "X-Face: ") ; (insert-file gnus-x-face-file))) ;(add-hook 'message-send-hook 'message-insert-x-face) ;;--------------------------------------------------------------------- ;; X-face colors (require 'gnus-fun) (set-face-background 'gnus-x-face (face-foreground 'default)) (set-face-foreground 'gnus-x-face (face-background 'default)) ;;--------------------------------------------------------------------- ;; Posting style (defun moy-gnus-group-group-name () (if (string-match ":\\([^:]*\\)$" gnus-newsgroup-name) (match-string 1 gnus-newsgroup-name)) ) (setq nndiary-pers '("nndiary:.*" (signature nil) (address "Matthieu.Moy@imag.fr") ("X-Diary-Minute" "*") ("X-Diary-Hour" "*") ("X-Diary-Dom" "*") ("X-Diary-Month" "*") ("X-Diary-Year" "*") ("X-Diary-Dow" "*") ("X-Diary-Time-Zone" "*") )) (setq gnus-posting-styles `((".*" (signature "Matthieu MOY") (name "Matthieu Moy") (address "Matthieu.Moy@imag.fr") ("X-Gnus-To-Folder" moy-gnus-group-group-name) ) ("^nn.+:ensimag" (signature-file "~/.signature-ensimag") (address "Matthieu.Moy@ensimag.imag.fr")) ("^nn.+:verimag" (signature-file "~/.signature-verimag") (address "Matthieu.Moy@imag.fr")) ("^nn.+:perso" ; (signature-file "~/.signature") (signature "Matthieu") ("X-Gnus-To-Folder" "perso")) (message-this-is-news (signature "Matthieu") (address "MatthieuNOSPAM.Moy@imag.fr.invalid") ("X-Gnus-To-Folder" "none")) ,nndiary-pers )) ;;--------------------------------------------------------------------- ;; Gnus-pers. (defun moy-find-in-alist (alist value) (if (not alist) nil (if (eq (caar alist) value) (if (listp (cdar alist)) (cadar alist) (cdar alist)) (moy-find-in-alist (cdr alist) value)))) (defun moy-concat-alist (alist) (cond ((not alist) "") ((stringp (caar alist)) (let ((remainder (moy-concat-alist (cdr alist)))) (concat (caar alist) ": " (if (listp (cdar alist)) (cadar alist) (cdar alist)) (if (not (string= remainder "")) "\n") remainder ))) (t (moy-concat-alist (cdr alist))))) (defun moy-posting-style-to-pers (posting name) (let ((fields (cdr posting))) `(,name ,(moy-find-in-alist fields 'address) ,(moy-concat-alist fields) ,(or (moy-find-in-alist fields 'signature) (moy-find-in-alist fields 'signature-file)) ))) (gnus-personality-init-for-sending) (setq gnus-personality-electric-headers '( (to "[Mm]atthieu.[Mm]oy@imag.fr" "to-myself") )) (setq gnus-personalities `(("default" "" "X-Face: %xEb27l:C~bcH,tGGRk8m'o_}XBMb*NoIbS$sp(:3s+l@PwMH+C*7Vf@Y_]%rP)*/'`Lpt[O9C;jbVo?Qp X-Url: http://www-verimag.imag.fr/~moy/ Mail-Copies-To: never Bcc: Matthieu.Moy@imag.fr Organization: Verimag" ) ("to-myself" "Myself " "" "" ) ("Verimag" "" "" ,(expand-file-name "~/.signature-verimag") ) ,(moy-posting-style-to-pers nndiary-pers "nndiary") )) ;;--------------------------------------------------------------------- ;; nndiary (require 'gnus-diary) (defvar nndiary-default-group-name "diary" "Name of the nndiary group to post to by default") (defun moy-gnus-summary-resend-message-to-diary () "Send current message to the group `nndiary-default-group-name'. Typical example : I recieve a message from a friend, giving me an appointment at 12 o'clock on May 24. While reading the message, I call this function, which opens a new buffer with this message, and all the nndiary headers ready. I give the date and time in the headers, C-c C-c, and the message will go into my diary, and come back to remind me on time." (interactive) (gnus-summary-resend-message-edit) (message-narrow-to-headers) (message-remove-header "^To:\\|^Cc:\\|^Bcc:" t) (insert (concat "Newsgroups: " nndiary-default-group-name "\n")) (insert "X-Diary-Minute: * X-Diary-Hour: * X-Diary-Dom: * X-Diary-Month: * X-Diary-Year: * X-Diary-Dow: * X-Diary-Time-Zone: * ") (re-search-backward "^X-Diary-Minute: ") (end-of-line) (widen) (setq gnus-newsgroup-name (concat "nndiary:" nndiary-default-group-name)) (gnus-setup-message 'message) ) (setq nndiary-reminders '((10 . day) (0 . day) (60 . minute) (7 . minute) (0 . minute))) (require 'gnus-msg) (define-key gnus-send-bounce-map "d" 'moy-gnus-summary-resend-message-to-diary ) ;;--------------------------------------------------------------------- ;; Archiving sent mail. ; I now do this with Bcc: (setq gnus-message-archive-group nil) ; '((if (message-news-p) ; "misc-news" ; (concat "mail." (format-time-string ; "%Y-%m" (current-time)))))) ;;--------------------------------------------------------------------- ;; Topics (add-hook 'gnus-group-mode-hook 'gnus-topic-mode) ;;--------------------------------------------------------------------- ;; Show all mail groups ;(setq gnus-permanently-visible-groups ".*") ;;(setq gnus-permanently-visible-groups "^nn.*") ;;--------------------------------------------------------------------- ;; Mail notification ; Note : minor bugs remaining in the number of messages displayed. (defun gnus-group-number-of-unread-mail (level) "*Returns the number of unread mails in groups of subscription level LEVEL and below." (let ((num-of-unread 0) (newsrc (cdr gnus-newsrc-alist)) info clevel) (while newsrc (setq info (car newsrc) clevel (gnus-info-level info)) (when (<= clevel level) (setq num-of-unread (+ num-of-unread (car (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb))))) (setq newsrc (cdr newsrc))) num-of-unread)) (require 'gnus-demon) (setq level 2) (defun my-notify-message () (if (> number-of-unread last-time-number-of-unread) (progn (if (> number-of-unread 0) (beep)) (message (let ((number-of-new (- number-of-unread last-time-number-of-unread))) (concat "***** " (int-to-string number-of-new) " new mail" (if (> number-of-new 1) "s" "") " recieved *****" (if (> number-of-unread last-time-number-of-unread) (concat " (" (int-to-string last-time-number-of-unread) " old)")) ) ) ) ) (if (= number-of-unread 0) (message "No mail") (message (concat (int-to-string number-of-unread) " old unread mail" (if (> number-of-unread 1) "s" "") )) ) ) ) (defun my-gnus-demon-handler () (message "Checking new mail ...") (save-window-excursion (save-excursion (when (gnus-alive-p) (set-buffer gnus-group-buffer) (gnus-group-get-new-news level)))) (setq last-time-number-of-unread number-of-unread) (setq number-of-unread (gnus-group-number-of-unread-mail level)) (my-notify-message) ) (setq last-time-number-of-unread 0) (setq gnus-demon-timestep 20) (gnus-demon-add-handler 'my-gnus-demon-handler 1 1) (gnus-demon-add-handler 'gnus-group-get-new-news 90 10) (gnus-demon-init) (setq gnus-group-line-format "^%L ?%I !%T %M%S%p%m%P%5y: %(%G %)%O\n") ;;--------------------------------------------------------------------- ;; Gnus summary avec les threads en arbre, ... (setq gnus-summary-line-format "%U%R%z%(%[%4L: %-20,20f%]%)%B %s\n" gnus-summary-same-subject "") (setq gnus-sum-thread-tree-root " >" gnus-sum-thread-tree-single-indent " " gnus-sum-thread-tree-vertical "|" gnus-sum-thread-tree-indent " " gnus-sum-thread-tree-leaf-with-other "+-> " gnus-sum-thread-tree-single-leaf "`-> ") ;(setq gnus-use-trees t ; gnus-generate-tree-function 'gnus-generate-horizontal-tree ; gnus-tree-minimize-window nil) ;;--------------------------------------------------------------------- ;; Window configuration. ; Slightly inspired from Netscape. (if (eq window-system 'x) (progn (gnus-add-configuration '(article (vertical 1.0 (horizontal 0.25 ("*BBDB*" 0.4) (summary 1.0 point)) (horizontal 1.0 (group 0.3) (article 1.0))))) (gnus-add-configuration '(summary (horizontal 1.0 (vertical 0.3 ("*BBDB*" 0.25) (group 1.0)) (summary 1.0) ))) (gnus-add-configuration '(reply (vertical 1.0 (article 0.3) (message 1.0 point)))) ) ) ;;--------------------------------------------------------------------- ;; A little bit faster at startup : ;(setq gnus-check-new-newsgroups nil) ;;grab older messages in the thread (setq gnus-fetch-old-headers 100) ;;View all the MIME parts in the current article (setq gnus-mime-view-all-parts t gnus-buttonized-mime-types nil gnus-unbuttonized-mime-types '("text/plain") ) (require 'message-x) ;; Lorsque l'on écrit un message, effectue la completion, y ;; compris avec les alias definis dans ~/.mailrc ;; ;(autoload 'bbdb-define-all-aliases ; "bbdb-com" "Hook mail alias feature of BBDB into message-mode." t) ;(add-hook 'message-setup-hook 'bbdb-define-all-aliases) ;;--------------------------------------------------------------------- ;; To force bbdb to cite the name *and* address of people when ;; completing address. ;; Expl : Matthieu Moy (setq bbdb-dwim-net-address-allow-redundancy t) (defadvice bbdb-complete-name (after bbdb-complete-name-default-domain activate) (let* ((completed ad-return-value)) (if (null completed) (expand-abbrev) ) ) ) ;(require 'mail-abbrevs) (require 'gnus-msg) ; This will be useless with Ognus 0.06. (The code is now included in it) (require 'moy-gnus) (setq message-ignored-resent-headers "^Content-Transfer-Encoding:\\|^X-Gnus\\|^Received:\\|^X-") ; When pressing 'd' in the summary buffer, the current article is ; marked as expirable. If there is another unread article in the ; group, then jump to this article. Else, jump to the next article. (define-key gnus-summary-mode-map "d" '(lambda (n) (interactive "p") (if (= (gnus-summary-mark-as-expirable n) 1) (next-line 1)))) (define-key gnus-summary-mode-map "D" '(lambda (n) (interactive "p") (if (= (gnus-summary-mark-as-read-forward n) 1) (next-line 1)))) (setq message-dont-reply-to-names "Matthieu\\(NOSPAM\\)?.Moy@.*imag.fr\\(.invalid\\)?\\|moym@ufrima.imag.fr" bbdb-user-mail-names message-dont-reply-to-names gnus-ignored-from-addresses message-dont-reply-to-names) ;;--------------------------------------------------------------------- ;; Avoid posting Quoted Printable, and preferably post latin-1. (setq gnus-default-posting-charset (quote iso-8859-1) mm-body-charset-encoding-alist '((iso-8859-1 . 8bit) (iso-8859-15 . 8bit))) ;;--------------------------------------------------------------------- ;; See plain text preferably. (add-to-list 'mm-discouraged-alternatives "text/html") ;; But view it with lynx if necessary. ;(setq mm-inline-text-html-renderer 'lynx) ;;; Word wrap articles (W Q) ;(add-hook 'gnus-select-article-hook ; '(lambda () ; (gnus-article-fill-long-lines))) (add-hook 'gnus-article-prepare-hook 'gnus-article-highlight-signature) (setq message-cite-function 'message-cite-original-without-signature gnus-thread-sort-functions 'gnus-thread-sort-by-score gnus-summary-thread-gathering-function 'gnus-gather-threads-by-references) (add-hook 'message-sent-hook '(lambda () (gnus-score-followup-thread 500))) ;;; This is simply GREAT ! EXCELLENT !! WONDERFULL !!! :-) (setq gnus-use-adaptive-scoring t) ;;--------------------------------------------------------------------- ;; Archives are marked as read when I send a message. (setq gnus-gcc-mark-as-read t) (defun gnus-group-news (&optional arg) "Start composing a news. If ARG, use the group under point. If ARG is 1, prompt for a group name. This function prepares a news even when using mail groups. This is useful for posting messages to mail groups without actually sending them over the network. The corresponding backend must have a 'request-post method." (interactive "P") (let ((group gnus-newsgroup-name) (buffer (current-buffer))) (unwind-protect (progn (setq gnus-newsgroup-name (if arg (if (= 1 (prefix-numeric-value arg)) (completing-read "Use group: " gnus-active-hashtb nil (gnus-read-active-file-p)) (gnus-group-group-name)) "")) (gnus-setup-message 'message (message-news (gnus-group-real-name gnus-newsgroup-name)))) (save-excursion (set-buffer buffer) (setq gnus-newsgroup-name group))))) (define-key gnus-group-mode-map "w" 'gnus-group-news) (setq message-shoot-gnksa-feet '(empty-article)) (require 'gnus-outlook-deuglify) ;(define-key gnus-summary-wash-map "k" 'gnus-article-outlook-deuglify-article) (setq message-subscribed-address-functions '(gnus-find-subscribed-addresses)) (add-to-list 'gnus-parameters '("" (subscribed . t))) (setq gnus-auto-select-first nil) (setq gnus-auto-select-subject 'best) (setq message-forward-ignored-headers "^Content-Transfer-Encoding:\\|^X-Gnus\\|^Received:\\|^X-MIME-Autoconverted:" message-forward-before-signature nil message-make-forward-subject-function 'message-forward-subject-fwd)