(setq user-full-name "Guillaume CONNAN"
      user-mail-address "gconnan@free.fr"
      mail-user-agent (quote message-user-agent))

;; mes autre adresses : en répondant à un message permet de réutiliser l'adresse du To:/From:/CC: de ce message
(setq message-alternative-emails 
      (regexp-opt (cons user-mail-address

;; Def charset
;(setq ;gnus-default-charset (quote iso-8859-15)
 ;     gnus-default-posting-charset (quote iso-8859-15))

(message "gnus.el: BASIC IDENTITY initialized")

;; pour poster en latin-1 ou latin-0 ou utf-8
(setq mm-coding-system-priorities
      '(iso-latin-9 iso-latin-1 mule-utf-8)) 

;; afficher les noms des destinataires à la place du mien pour les messages que j'ai envoyés
(setq gnus-ignored-from-addresses "Guillaume CONNAN") ;; 

; pour bidouiller l'adresse pour les NEWS, voir le champ From: dans les posting styles
(setq message-user-organization "Aucune.")

(setq gnus-posting-styles
        ((message-news-p)               ;".*"
         (From    "Guillaume Connan <gconnan.no@spam.free.fr.invalid>")
         (Reply-To "Guillaume Connan <gconnan@free.fr>"))
        ((message-mail-p)               ;".*"
         (From    "Guillaume Connan <gconnan.no@spam.free.fr.invalid>")
         (Reply-To "Guillaume Connan <gconnan@free.fr>"))

;;pour eviter les textes en html

(setq mm-discouraged-alternatives
      '("text/html" "text/richtext")
      (remove "text/html" mm-automatic-display))

;; Def charset
(setq gnus-default-charset (quote iso-8859-15)
      gnus-default-posting-charset (quote iso-8859-15)
      mm-body-charset-encoding-alist '((iso-8859-1 . 8bit)
                                       (iso-8859-15 . 8bit)))

;;Ca, c'est pour gerer les accents mal encodés des autres ... 

(add-to-list 'mm-charset-synonym-alist '(iso8859-15 . iso-8859-15))
(add-to-list 'mm-charset-synonym-alist '(iso885915 . iso-8859-15))

;; We choose nnml: everybody says it's the fastest backend on earth.
(setq gnus-select-method '(nnml ""))
;;(setq gnus-secondary-select-method '(nnml ""))
;;(setq gnus-secondary-select-methods '((nntp "news.free.fr")))
;;(setq gnus-secondary-select-methods '((nnmbox "")))

(setq gnus-secondary-select-methods '((nnimap "imap.free.fr"
                                             ; (remove-prefix "INBOX.")
                                  (nnimap-address "imap.free.fr")
                                  (nnimap-authentificator "gconnan")
                                  (nnimap-authinfo-file "/home/moi/.authinfo")

;;(setq gnus-summary-charset (quote iso-8859-15))


;; In mail-source, procmail store files that
;; We store mails here - this is also defined in my .emacs,
;; it's the only way I found to avoid apparition of ~/Mail/.
(setq gnus-directory "~/.News/")
(setq message-directory "~/.Mail/")

;; fetchmail previously downloaded.
(setq mail-sources
      (list '(directory
              :path "~/.mail-gnus/"
              :suffix ""

;(eval-after-load "mail-source"
 ; '(add-to-list 'mail-sources '(directory :path "/home/moi/.mail-gnus/"
  ;                                        :suffix "")))

;; ;;serveur news principal
;;  (setq gnus-secondary-select-method 
;;        '(
;;                nntp "news.free.fr"
;;                (nntp-authinfo-user "Guillaume")
;;   ;; (nntp-authinfo-password " ")
;;     ))

 (setq gnus-default-subscribed-newsgroups
          '( "fr.comp.text.tex" "fr.comp.applications.emacs"))

;; We trash duplicates mails.
(setq nnmail-treat-duplicates 'delete)

;; We just read mail, no newsgroups.
;(setq gnus-check-new-newsgroups nil)

(message "gnus.el: GETTING MAILS initialized")

;comment envoyer les msg
(setq send-mail-function 'smtpmail-send-it)
(setq message-send-mail-function 'smtpmail-send-it)
(setq smtpmail-smtp-server "smtp.free.fr"
        ;;smtpmail-local-domain "free.fr"
        ;;smtpmail-sendto-domain "free.fr"
        ;;smtpmail-smtp-service 25
        smtpmail-smtp-service "smtp"
        smtpmail-debug-info t           ; only to debug problems
        smtpmail-debug-verb t
        smtpmail-auth-login-username "gconnan"
        smtpmail-auth-credentials '(("smtp.free.fr" 25 "gconnan" "*******"))

;; definition des couleurs de gnus (fenetre "group" et
;; fenetre "summary article"
(set-face-foreground 'gnus-group-mail-3-face "yellow")
(set-face-foreground 'gnus-group-mail-3-empty-face "green")
(set-face-foreground 'message-header-to-face "red")
(set-face-foreground 'message-header-subject-face "yellow")
(set-face-foreground 'gnus-summary-normal-ancient-face "pink")
(set-face-foreground 'gnus-summary-normal-read-face "grey")
(set-face-foreground 'gnus-summary-normal-unread-face "orange")
(set-face-foreground 'gnus-summary-high-unread-face "orange")
(set-face-foreground 'gnus-summary-normal-ticked-face "violet")
(set-face-foreground 'gnus-summary-high-ticked-face "red")
;; Pour les definitions des couleurs dans les mails je suis
;; oblige de creer une fonction qui se raccrochera a la fonction
;; de lecture des mails.

(require 'font-lock)
(defun color-gnus-customization-hook()
(set-face-foreground 'gnus-header-from-face "violet")
(set-face-foreground 'gnus-signature-face "red")
(set-face-foreground 'gnus-header-subject-face "orange")
(set-face-foreground 'gnus-header-content-face "green"))
;(set-face-foreground 'gnus-header-to-face "red"))
;(set-face-foreground 'gnus-header-date-face "blue"))
;(set-face-foreground 'gnus-header-lapsed-face "pink"))
(add-hook 'gnus-visual-mark-article-hook 'color-gnus-customization-hook)

;; Tres pratique, permet de connaitre la derniere fois
;; que l'on a accede a un mailbox ou a un newsgroup
(add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp)
(setq gnus-group-line-format
        "%M\%S\%p\%P\%5y: %(%-40,40g%) %6,6~(cut 2)d\n")

;; MIME Settings for PGnus
(require 'mm-util)
(defun mm-read-charset (prompt)
  "Return a charset."
;(setq gnus-default-posting-charset (quote iso-8859-15))
(setq gnus-article-decode-mime-words t)
(setq gnus-article-decode-charset 1)
(setq gnus-mime-view-all-parts t) ; View all the MIME parts in current article
(setq gnus-ignored-mime-types
(setq gnus-unbuttonized-mime-types nil) ; MIME type -> no buttons when rendered
 ;; Add buttons
 gnus-treat-buttonize t
 ;; Add buttons to the head
 gnus-treat-buttonize-head 'head
 ;; Emphasize text
 gnus-treat-emphasize t
 ;; Fill the article
 gnus-treat-fill-article nil
 ;; Remove carriage returns
 gnus-treat-strip-cr 'last
 ;; Hide headers
 gnus-treat-hide-headers 'head
 ;; Hide boring headers
 gnus-treat-hide-boring-headers 'head
 ;; Hide the signature
 gnus-treat-hide-signature nil
 ;; Hide cited text
 gnus-treat-hide-citation nil
 ;; Strip PGP signatures
 gnus-treat-strip-pgp 'last
 ;; Strip PEM signatures
 gnus-treat-strip-pem 'last
 ;; Highlight the headers
 gnus-treat-highlight-headers 'head
 ;; Highlight cited text
 gnus-treat-highlight-citation 'last
 ;; Highlight the signature
 gnus-treat-highlight-signature 'last
 ;; Display the Date in UT (GMT)
 gnus-treat-date-ut nil
 ;; Display the Date in the local timezone
 gnus-treat-date-local nil
 ;; Display the date in the original timezone
 gnus-treat-date-original nil
 ;; Strip trailing blank lines
 gnus-treat-strip-trailing-blank-lines 'last
 ;; Strip leading blank lines
 gnus-treat-strip-leading-blank-lines 'last
 ;; Strip multiple blank lines
 gnus-treat-strip-multiple-blank-lines 'last
 ;; Strip all blank lines
 ;; gnus-treat-strip-blank-lines nil
 ;; Treat overstrike highlighting
 gnus-treat-overstrike 'last
;;* show the text/plain part before the text/html part in multpart/alternative
(require 'mm-decode)
;;;-- no way do compile with this
;;;--(push "text/plain" mm-alternative-precedence)
;;;--(setq mm-alternative-precedence "text/plain")

(message "gnus.el: MIME initialized")

;; ARCHIVES: one file per month
(setq gnus-message-archive-group
      '((if (message-news-p)
          (concat "mail." (format-time-string
                           "%Y-%m" (current-time)))))

(message "gnus.el: ARCHIVES initialized")

;;************* INTERFACE

;; Here I define how to display subject lines etc...
;; I wanna see thoses groups everytime
(setq gnus-permanently-visible-groups "^nnml\\|^inbox")

;; I like it verbose
(setq gnus-verbose 2000)

;; I wanna be able to access my previous post
(setq gnus-fetch-old-headers t)

;; I wanna keep track of the last time I rode a group
(add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp)

;; *Group* buffer: how to format each group entry.
;;(setq gnus-group-line-format "%M%m %4N/%4t non-lus:      %(%-20,20g%) depuis le %2,2~(cut 6)d/%2,2~(cut 4)d à %2,2~(cut 9)dh%2,2~(cut 11)d\n"
      ;; %var details C-h i
      ;;`M' An asterisk if the group only has marked articles.
      ;;'N' Number of unread articles.
      ;;`t' Estimated total number of articles.
      ;;`G' Group name.
      ;;`D' Newsgroup description.
      ;;`m' `%' (`gnus-new-mail-mark') if there has arrived new mail to the
      ;;    group lately.
      ;;`D' Last time the group as been accessed.
      ;; For the record, a default group line format
      ;;(setq gnus-group-line-format "%M\%S\%p\%P\%5y: %(%-40,40g%) %6,6~(cut 2)d\n")
   ;   )
;; *Summary*: how to format each mail entry.

(setq gnus-topic-line-format "%6v            %5(%5{%7A %}%)%* %5(%5{ ==> %-31n%)%}\n" )

(setq gnus-summary-line-format "%-1R %-1U  %-15,15n | %2,2~(cut 6)o/%2,2~(cut 4)o %2,2~(cut 9)oh%2,2~(cut 11)o | %I%(%0,40s%)\n"
      gnus-summary-same-subject ">>>"
      gnus-summary-mode-line-format "%V: %%b"
      gnus-summary-charset (quote iso-8859-15)
      ;; %var details C-h i
      ;; `s' Subject if the article is the root of the thread or the previous
      ;;     article had a different subject, `gnus-summary-same-subject'
      ;;     otherwise.  (`gnus-summary-same-subject' defaults to `""'.)
      ;; `n' The name (from the `From' header).
      ;; `L' Number of lines in the article.
      ;; `I' Indentation based on thread level (*note Customizing Threading::).
      ;; `>' One space for each thread level.
      ;; `<' Twenty minus thread level spaces.
      ;; `U' Unread.
      ;; `R' This misleadingly named specifier is the "secondary mark".  This
      ;;     mark will say whether the article has been replied to, has been
      ;;     cached, or has been saved.
      ;; `D'  `Date'.
      ;; `d'  The `Date' in `DD-MMM' format.
      ;;`o'     The `Date' in YYYYMMDD`T'HHMMSS format.
      ;; For the record the default string is
      ;; `%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n'.

;; I do not like graphics smileys.
(setq gnus-treat-display-smileys nil)

;; I wanna particular dimensions while reading mails
 gnus-build-sparse-threads 'some
 gnus-use-trees t
 gnus-generate-tree-function 'gnus-generate-horizontal-tree
 gnus-tree-minimize-window nil)

(if  (or (not (getenv "DISPLAY"))
         (string-match ":0" (getenv "DISPLAY")))
         (vertical 1.0
                   (summary 0.40 point)
                   (article 1.0)
       (vertical 1.0
         (summary 0.40 point)
         (article 1.0)
(setq font-lock-maximum-decoration t
      font-lock-maximum-size nil)
(require 'font-lock)
(set-face-foreground 'gnus-summary-normal-ticked-face " violet red")
(set-face-foreground 'gnus-summary-high-ticked-face " violet red")

(message "gnus.el: INTERFACE initialized")

; affichage de la date en relatif
(setq gnus-user-date-format-alist
      '(((gnus-seconds-today) . "     %k:%M")           ;dans la journée =      14:39
        ((+ 86400 (gnus-seconds-today)) . "hier %k:%M") ;hier            = hier 14:39
        ((+ 604800 (gnus-seconds-today)) . "%a  %k:%M") ;dans la semaine = sam  14:39
        ((gnus-seconds-month) . "%a  %d")               ;ce mois         = sam  28
        ((gnus-seconds-year) . "%b %d")                 ;durant l'année  = mai  28
        (t . "%b %d '%y")))                             ;le reste        = mai  28 '05

; Veut plus qu'il me demande si je veut récupérer
; la dernière sauvegarde (auto-save)
(setq gnus-always-read-dribble-file t )

;; corrige les problèmes de mixed latin-1 / latin-9
(setq message-default-charset 'iso-8859-15
      ;; ??? gnus-default-posting-charset (quote iso-8859-15)
      mm-body-charset-encoding-alist '((iso-8859-1 . 8bit)
                                       (iso-8859-15 . 8bit)))
(add-to-list 'mm-charset-synonym-alist '(iso8859-15 . iso-8859-15))
(add-to-list 'mm-charset-synonym-alist '(iso885915 . iso-8859-15))

;; (autoload 'trivial-cite "tc" t t)
;;  (add-hook 'mail-citation-hook 'trivial-cite) 
; Hey, please remove my address from To: and Ccc: while I do a
;; wide reply.
;; seen at http://www.gnusfr.org/gen.php3/2002/04/02/36,0,1,0.html
(setq message-dont-reply-to-names

;; header des réponses

;;              ; "ième jour après Epoch,\n"
;;             ))
;;             (let* ((email (mail-header-from message-reply-headers))
;;                    (data (mail-extract-address-components email))
;;                    (name (car data))
;;                    (net (car (cdr data))))
;;               (or name net email))
;;             " écrivait brillamment :\n\n")))

;; make it the default citation line for Gnus' message mode
;;(setq message-citation-line-function 'epoch-citation-line)

;;   (setq message-citation-line-function 'my-citation-line)
;; (defun my-citation-line ()
;;   "Function that inserts svengo a cool citation line."
;;   (when message-reply-headers
;;     (insert"\n Le " (mail-header-date message-reply-headers) "\n,  " (mail-header-from message-reply-headers) " s'est librement exprimé(e) ainsi :\n")
;;     )
;;   )

;; I want my replies to begin with something like " writes:"
;;   (defun message-insert-citation-line ()
;;     "La fonction qui insere une ligne aux reponses"
;; ;;    (let (                         ;(style (random 4))
;; ;;    (date (cdr (assoc "date" tc-strings-list)))
;; ;;    (email (cdr (assoc "email-addr" tc-strings-list)))
;; ;;    (name (cdr (assoc "real-name" tc-strings-list)))))
;;       (when message-reply-headers
;; ;;     ;; In savannah-hackers group, we talk english
;; ;;     (if (string-equal gnus-newsgroup-name "savannah-hackers")
;; ;;     (insert (mail-header-from message-reply-headers) " said:\n\n")
;;        (insert  " a particulièrement retenu mon attention par le texte suivant  :\n\n")))
;;            ; " vient  d'envoyer ce message :\n\n ")
;; ;       ););)

 ;; header des réponses
 (autoload 'trivial-cite "tc" t t)
(add-hook 'mail-citation-hook 'trivial-cite) 
 (setq tc-debug-level 1
       mail-extr-ignore-single-names nil
       mail-extr-ignore-realname-equals-mailbox-name nil
       tc-normal-citemarks  ">|:"
       tc-fill-long-lines   't
       tc-time-format "%e %B %Y à %H:%m"
       tc-make-attribution 'GC-tc-attribution

(defun gc-tc-attribution ()
  "tc-simple-attribution makes an attribution from email address and date."
  (let ((date (assoc "date" tc-strings-list))
        (name (assoc "email-addr" tc-strings-list)))
    (if (null name)
        "Une personne qui a préféré rester anonyme a écrit :\n\n"
      (if (null date)
          (concat (cdr name) " a écrit :\n\n")
        (concat "Le  " (cdr date) ", " (cdr name) " écrivait brillamment:\n\n")

 ;      tc-make-attribution 'tc-fancy-attribution
 ;     tc-groups-functions '(("alt.sysadmin.recovery" . nix-tc-bofh-group-attribution)
 ;                           ("bofh." . nix-tc-bofh-group-attribution))

;;    (setq message-citation-line-function 'my-citation-line)
;;  (defun my-citation-line ()
;;    "Function that inserts svengo a cool citation line."
;;    (when message-reply-headers
;;      (insert"\n Le " (mail-header-date message-reply-headers) "\n,  " (mail-header-from message-reply-headers) " s'est librement exprimé(e) ainsi :\n")
;;      )
;;    )

;; (setq message-citation-line-function 'sk-tc-attribution-fr)

 (defun GC-tc-attribution ()
   "Générer l'attribution."
   (let ((style (random 5))
         (date (cdr (assoc "date" tc-strings-list)))
         (email (cdr (assoc "email-addr" tc-strings-list)))
         (name (cdr (assoc "real-name" tc-strings-list))))
     (cond ((= style 0)
            (concat "Le " date ", " (or name email) " s'est librement exprimé ainsi :\n\n"))
           ((= style 1)
            (concat "Le " date ", " (or name email) "  a particulièrement retenu mon attention par le texte suivant  :\n\n"))
           ((= style 2)
            (concat "Le " date ", " (or name email) " m'a sorti de ma torpeur en écrivant ceci :\n\n"))
           ((= style 3)
            (concat "Le " date ", " (or name email) "  a formulé dans un style qui lui est propre l'idée suivante  :\n\n"))
           ((= style 4)
            (concat "Le " date ", " (or name email) " vraute ze foloving massage :\n\n")))))

;; (defun sk-tc-attribution-fr ()
;;    "Générer l'attribution."
;;    (let ((style (random 4))
;;          (date (cdr (assoc "date" tc-strings-list)))
;;          (email (cdr (assoc "email-addr" tc-strings-list)))
;;          (name (cdr (assoc "real-name" tc-strings-list))))
;;      (cond ((= style 0)
;;             (insert (mail-header-from message-reply-headers)  (concat "Le " date ", " (or name email) " s'est librement exprimé ainsi :\n\n")))
;;            ((= style 1)
;;             (concat "Le " date ", " (or name email) " a particulièrement retenu mon attention par le texte suivant  :\n\n"))
;;           ((= style 2)
;;             (concat "Le " date ", " (or name email) " m'a sorti de ma torpeur en écrivant ceci :\n\n"))
;;            ((= style 3)
;;             (concat "Le " date ", " (or name email) " a formulé dans un style qui lui est propre l'idée suivante :\n\n"))
;;            (t
;;             (concat "Le " date ", " (or name email) " vraute ze foloving sentence :\n\n")))))

; Lorsqu'on 'kill' un thread, celui-ci est caché
(setq gnus-thread-hide-killed t)

;;===== Quotage (de goret)===================================
; [Format] Snip des messages (W-W-c)
; Format disponible dans le chapitre 3.16.3 du manuel Gnus
(setq gnus-cited-closed-text-button-line-format
      "\[ Snip %n lines (%l Characters) \]\n")

; Couper les lignes trop longues
; (setq-default gnus-treat-fill-long-lines t)
(setq gnus-article-strip-blank-lines t)

; Mise en couleur de la signature
(setq gnus-treat-highlight-signature 'last)

; Veut pas des gorets !
;(add-hook 'gnus-part-display-hook 'gnus-article-hide-citation-maybe)

; Remplacer la date par X-Sent
(setq gnus-treat-date-lapsed 'head)
; Ne pas afficher les secondes défilées
; Remplace l'header Date:
(setq gnus-article-date-lapsed-new-header t);nil)

;; Ajouter des boutons
(setq gnus-treat-buttonize t)
(setq gnus-treat-buttonize-head 'head)

; Ne pas inclure la signature lors d'une réponse
;(setq message-cite-function 'message-cite-original-without-signature)

; Supprimer les messages en double
(setq gnus-suppress-duplicates t)

;; Nettoyer les messages d'un coup
;; http://my.gnus.org/node/view/94
(defun bhaak-wash-this-article ()
  (gnus-article-fill-cited-article nil '70)
(define-key gnus-summary-mode-map "\C-c\w" 'bhaak-wash-this-article)

;;dictionnaire par défaut
(setq ispell-local-dictionary "francais");plutôt ispell-dictionary ?

;(add-hook 'gnus-article-display-hook 'gnus-article-highlight)
;; cache les cles PGP
;(add-hook 'gnus-article-display-hook 'gnus-article-hide-pgp)
;; cache les headers indésirables
;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
;; marre des gorets
;(add-hook 'gnus-article-display-hook  'gnus-treat-hide-citation-maybe)
;; vire certains headers s'ils sont vides
;(add-hook 'gnus-article-display-hook 'gnus-article-hide-boring-headers)
;; vire le QP
;(add-hook 'gnus-article-display-hook 'gnus-article-de-quoted-unreadable)
;; met en valeur les *machins* et autres _trucs_
;(add-hook 'gnus-article-display-hook 'gnus-article-emphasize)

;; Pour ne pas afficher les tags débiles des ML...
(setq gnus-list-identifiers

;; ne pas scroller le message si le reste n'est que quote+signature
;(setq gnus-article-skip-boring t)

; Mes ch'tits headers
;(setq gnus-ignored-headers ".*")
(setq gnus-visible-headers

; Retirer les headers à dormir debout
(setq gnus-boring-article-headers '(empty many-to newsgroup))
(setq gnus-treat-hide-boring-header 'head)

(message "gnus.el: REPLY initialized")


(require 'gnus-cite) 
(set-face-foreground 'gnus-summary-normal-read-face "Blue")
(set-face-foreground 'gnus-signature-face "steelblue")
(copy-face 'default 'gnus-cite-face-1)
(set-face-foreground 'gnus-cite-face-1 "gray")
(copy-face 'default 'gnus-cite-face-2)
(set-face-foreground 'gnus-cite-face-2 "aquamarine")
(copy-face 'default 'gnus-cite-face-3)
(set-face-foreground 'gnus-cite-face-3 "steelblue")
(copy-face 'default 'gnus-header-content-face)
(set-face-foreground 'gnus-header-content-face "pink")
(copy-face 'default 'gnus-header-from-face)
(set-face-foreground 'gnus-header-from-face "violet")
(copy-face 'default 'gnus-header-name-face)
(set-face-foreground 'gnus-header-name-face "blue")
(copy-face 'italic 'gnus-header-subject-face)
(set-face-foreground 'gnus-header-subject-face "red")
(copy-face 'italic 'gnus-cite-attribution-face)
(set-face-foreground 'gnus-cite-attribution-face "yellow")
(copy-face 'bold 'gnus-emphasis-bold)
(set-face-foreground 'gnus-emphasis-bold "mediumturquoise")
(set-face-foreground 'message-header-other-face "pink")
(set-face-foreground 'message-cited-text-face "violet")

(copy-face 'bold 'gnus-group-news-3-face)
(set-face-foreground 'gnus-group-news-3-face "LightBlue")
(set-face-foreground 'gnus-group-news-3-empty-face "Blue")
(copy-face 'bold 'gnus-group-mail-3-face)
(set-face-foreground 'gnus-group-mail-3-face "lightblue")
(copy-face 'default 'gnus-group-mail-3-empty-face)
(set-face-foreground 'gnus-group-mail-3-empty-face "brown")

(copy-face 'default 'gnus-cite-face-1)
(set-face-foreground 'gnus-cite-face-1 "blue")

;(setq message-cite-function 'message-cite-original-without-signature)

(add-hook 'gnus-startup-hook 
          '(lambda ()
             (set-face-foreground 'bold "pink")

(add-hook 'gnus-article-display-hook
          '(lambda ()
             (gnus-article-date-local)              ; will actually convert timestamp from other timezones to yours

;;SPAM sur nnimap

;; (defun filter-spamassassin ()
;;   (save-excursion
;;     (widen)
;;     (if (eq 1 (call-process-region (point-min) (point-max)
;;                                    "spamc" nil nil nil "-c"))
;;         "spam")))

;; ; on dit quel repertoire on filtre
;; (setq nnimap-split-inbox '(INBOX))

;; ;on dit qu'elle fonction filtre quoi
;; (setq nnimap-split-rule
;;     '(("imap.free.fr" ("INBOX" nnimap-split-fancy))))

;; ; c'est ici qu'on apelle notre fonction
;; (setq nnimap-split-fancy
;; '(|
;;   (: filter-spamassassin)))

;; ; on relie la combinaison de touche C-c R s/h pour apprendre un spam/ham

;; (define-key gnus-summary-mode-map
;;         (read-kbd-macro "C-c R h")
;;         '(lambda () (interactive) (pfm-run-command-on-article "sa-learn --ham --no-rebuild"))
;; )

;; (define-key gnus-summary-mode-map
;;         (read-kbd-macro "C-c R s")
;;         '(lambda () (interactive) (pfm-run-command-on-article "sa-learn --spam --no-rebuild"))
;; )

;; ; apprentissage d'un spam
;; (defun learn-spam-spamassassin ()
;;   (save-excursion
;;     (widen)
;;     (call-process "sa-learn" nil 0 nil "--no-rebuild --spam")))

;; (defun learn-ham-spamassassin ()
;;   (save-excursion
;;     (widen)
;;     (call-process "sa-learn" nil 0 nil "--no-rebuild --ham")))