(setq gnus-novice-user nil
      gnus-expert-user t)

(require 'info)
(require 'gnus-spec)
(require 'gnus-demon)
(require 'gnus-mh)
(require 'starttls)
(require 'smtpmail)
(require 'gnus-kill)

(defun exal-mailto (url)
  (setq url (url-unhex-string url))
  (browse-url-mail url)
(if (string-match (regexp-quote "?") url)
       (let* ((start (match-end 0))
              (args (url-parse-query-string
                     (substring url start nil)))
              (body (cadr (assoc-string "body" args t))))
         (when body
           (switch-to-buffer (car (message-buffers)))
           (save-excursion
             (message-goto-body)
             (insert body))))))


;(if (fboundp 'xterm-mouse-mode)   ; Enable use of the mouse inside XTerms
;    (xterm-mouse-mode t))


(setq gnus-treat-display-smileys t)

  (setq Info-default-directory-list
        (cons "~/repos/gnus/texi" Info-default-directory-list))

;; load color theme when Gnus start
(add-hook 'gnus-startup-hook 'color-theme-exal-gnus)

;; start the server
(add-hook 'gnus-startup-hook 'server-start)


(setq gnus-keep-backlog 20
      gnus-fetch-old-headers t
      nnmbox-mbox-file "~/caixa"
      nnmbox-get-new-mail t
      gnus-group-jump-to-group-prompt "nnmbox:mail."
     nntp-authinfo-file (expand-file-name "newsauth" exal-emacs-dir)
      gnus-local-organization "The GNU Emacs Church")

(rebuild-mail-abbrevs 
 (expand-file-name "mailalias" exal-emacs-dir))


 (setq gnus-summary-line-format 
       (concat
        "%U%R%z"
        "%("
        "%{%B%} "
        "%[%-18,18f%]"
        "%* %s"
        "%)"
        "\n"))



;; follow up

  (add-hook 'message-sent-hook 'gnus-score-followup-article)
  (add-hook 'message-sent-hook 'gnus-score-followup-thread)


(setq gnus-auto-mail-to-author nil)


;; spam defence
;;; (if (string-equal gnus-nntp-server "news-17.escomposlinux.org")
;;;     (progn
;;;       (gnus-kill "Subject" "MI5\\|Persecution")
;;;       (gnus-kill "Subject" "CONSEJOS\\|newgroup\\|rmgroup" "d")
;;;       (gnus-expunge "X")))
;;;

(require 'slb-gnus-bogofilter)
 (setq slb/gnus-spam-group "nnmbox:fuck.spam")


(setq gnus-apply-kill-hook
      '(lambda ()
         (cond ((string-match "gnu\\|es" gnus-newsgroup-name)
                (gnus-kill "Subject" "MI5\\|CONSEJOS")
                (gnus-expunge "X")))))

          (setq  nnmail-expiry-wait 40
                 nnmail-expiry-wait-function #'(lambda (group)
                                                 (cond ((or (string-match "fuck.spam" group)
                                                            (string-match "spambox" group)
                                                            (string-match "spambox-verified" group))
                                                        'immediate)
                                                       (t 7))))

(setq nnml-marks-is-evil t
      nntp-marks-is-evil t)


(add-hook 'message-mode-hook
      (lambda ()
           (setq fill-column 72)
           (turn-on-auto-fill)))

(gnus-start-date-timer)
(setq mm-text-html-renderer 'lynx)

;(setq browse-url-browser-function 'browse-url-firefox
;          browse-url-new-window-flag  t
;          browse-url-firefox-new-window-is-tab t)

(setq message-dont-reply-to-names "Exal")
(add-to-list 'message-header-synonyms '(Original-To))
(setq gnus-add-timestamp-to-message (if noninteractive t 'log))

;;;;;;;;; start SMTP configuration stuff

;; Sending from local smtp server
;(setq smtpmail-default-smtp-server "localhost")


;;; SMTP configurations

 (setq starttls-gnutls-program "gnutls-cli"
       smtpmail-debug-info t
       smtpmail-debug-verb t)
                


;; function that change between smtp servers

(defun exal-change-smtp ()
  "Change the SMTP server according to the current from line."
  (save-excursion
    (let ((from
           (save-restriction
             (message-narrow-to-headers)
             (message-fetch-field "from"))))
      (message "From is `%s', setting `smtpmail-smtp-server' to `%s'"
               from
               (cond
                ((string-match "exal@gnu.org" from)
                  ;; Use stmp-auth
                  (message "Using smtp-auth for GNU account")
                   ;; Sending mail
                  (setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
                        smtpmail-smtp-server "smtp.gmail.com"
                        smtpmail-default-smtp-server "smtp.gmail.com"
                        send-mail-function 'smtpmail-send-it
                        message-send-mail-function 'smtpmail-send-it
                        smtpmail-smtp-service 587)
                  (setq smtpmail-auth-credentials 
                        (expand-file-name "mailauth-gmail" exal-emacs-dir)))
                ((string-match "exal@softwarelivre.org" from)
                   ;; Use SMTP for softwarelivre account
                 (message "Using SMTP for softwarelivre account")
                 (setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
                       smtpmail-smtp-server "smtp.gmail.com"
                       smtpmail-default-smtp-server "smtp.gmail.com"
                       send-mail-function 'smtpmail-send-it
                       message-send-mail-function 'smtpmail-send-it
                       smtpmail-smtp-service 587)
                 (setq smtpmail-auth-credentials 
                       (expand-file-name "mailauth-gmail-frida" exal-emacs-dir)))
                ((string-match "exal@xtremesolutions.com.mx" from)
                   ;; Use SMTP for xtremesolutions account
                 (message "Using SMTP for Xtreme Solutions account")
                 (setq starttls-use-gnutls t)
                 (setq starttls-extra-arguments nil)
                 (setq smtpmail-local-domain nil
                       send-mail-function 'smtpmail-send-it
                       message-send-mail-function 'smtpmail-send-it
                       message-send-mail-partially-limit nil
                       smtpmail-default-smtp-server "xtremesolutions.com.mx"
                       smtpmail-smtp-server "xtremesolutions.com.mx"
                       smtpmail-auth-credentials (expand-file-name "mailauth-xtreme" exal-emacs-dir)
                       smtpmail-starttls-credentials '(("xtremesolutions.com.mx" 26 nil nil))
                       smtpmail-smtp-service 26
                       smtpmail-smtp-server "xtremesolutions.com.mx" ))
                (t
                 (message 
                  (concat "Sending via nntp... "
                          from))))))))

(add-hook 'message-setup-hook 'exal-change-smtp)


;;;; this is my configuration for GMX smtp server

                 ;;;  ;; Use gmx smtp server
                 ;;;  (message "Using gmx smtp server")
                 ;;; (setq starttls-use-gnutls t)
                 ;;; (setq starttls-gnutls-program "gnutls-cli")
                 ;;; (setq starttls-extra-arguments nil)
                 ;;; (setq smtpmail-local-domain nil
                 ;;;       send-mail-function 'smtpmail-send-it
                 ;;;       message-send-mail-function 'smtpmail-send-it
                 ;;;       message-send-mail-partially-limit nil
                 ;;;       smtpmail-default-smtp-server "mail.gmx.net"
                 ;;;       smtpmail-smtp-server "mail.gmx.net"
                 ;;;       smtpmail-debug-info t
                 ;;;       smtpmail-debug-verb t
                 ;;;       smtpmail-auth-credentials "~/emacs-stuff/mailauth"
                 ;;;       smtpmail-starttls-credentials '(("mail.gmx.net" 25 nil nil))
                 ;;;       smtpmail-smtp-server "mail.gmx.net" ))




;;;;;;;;; end SMTP configuration stuff



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



;;;; Exiting ;;;;
;;;

(setq gnus-interactive-exit nil)

(defun exit-emacs-with-gnus ()
  "Save and exit gnus before exiting Emacs."
  (interactive)
  (if (fboundp 'gnus-group-exit)
      (gnus-group-exit))
  (save-buffers-kill-emacs))


(add-hook 'gnus-group-mode-hook
          (lambda ()
            (local-set-key (kbd "q") 'exit-emacs-with-gnus)
            (local-set-key (kbd "C-c q") 'gnus-group-exit)))

;(global-set-key [(control x) (control c)] 'exit-emacs-with-gnus)


;;;
;; for ispell
;;;

;(add-hook 'message-send-hook 'ispell-message)

;(add-hook 'gnus-select-group-hook
;          (lambda ()
;            (cond
;             ((string-match
;               "^es\\." (gnus-group-real-name gnus-newsgroup-name))
;              (ispell-change-dictionary "castellano8"))
;             (t
;              (ispell-change-dictionary "castellano8")))))

;(setq gnus-check-new-newsgroups t)


;; Time-stamping.
(add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp)

(defun gnus-user-format-function-d (headers)
  "Make a nice format for the group time stamp."
  (let ((time (gnus-group-timestamp gnus-tmp-group)))
    (and time
         (format-time-string "%a %d %b %H:%M" time))))

(setq message-generate-headers-first t)


;;
;;; article faces
;;
;(custom-set-faces
; '(gnus-header-subject-face ((t (:foreground "Blue" :bold t :size 10) t))))


(setq gnus-summary-same-subject ""
      gnus-sum-thread-tree-root ""
      gnus-sum-thread-tree-false-root "< "
      gnus-sum-thread-tree-single-indent ""
      gnus-sum-thread-tree-indent " "
      gnus-sum-thread-tree-leaf-with-other "+-> " 
      gnus-sum-thread-tree-single-leaf "\\-> "
      gnus-sum-thread-tree-vertical "| ")


(setq gnus-large-newsgroup nil
      nnmail-treat-duplicates 'delete)


;;;
;;   Split methods
;;;

(setq nnmail-crosspost nil 
      nnmail-split-methods
      '(("duplicates" "^Gnus-Warning:.*duplicate")
        ("fuck.spam" "^Subject: MI5\\|Persecution\\|CONSEJOS\\|Biglumber")
        ("mail.me" "^From:.*Exal de Jesus Garcia Carrillo")
        ("mail.guata" "^From:.*Bernardita*")
        ("mail.gnu" "^To:.*exal@gnu.org")
        ("mail.softwarelivre" "^To:.*exal@softwarelivre.org")
        ("mail.xtreme" "^To:.*exal@xtremesolutions.com.mx")
        ("mail.fsfla.bobagens" "^List-id:.*bobagens.fsfla.org")
        ("mail.fsfla.team" "^List-id:.*team.fsfla.org")
        ("mail.fsfla.cons" "^List-id:.*cons.fsfla.org")
        ("mail.fsfla.discuss" "^List-id:.*discusion.fsfla.org")
        ("mail.fsfla.trad" "^List-id:.*traductores.fsfla.org")
        ("mail.fsfla.drm" "^List-id:.*anti-drm.fsfla.org")
        ("mail.fsfla.info" "^To:.*info@fsfla.org")
        ("mail.fsfla.info" "^Cc:.*info@fsfla.org")
        ("mail.muse" "^List-id:.*muse-el-discuss.gna.org")
        ("mail.gnu.www" "^List-id:.*www-discuss.gnu.org")
        ("mail.gnu.www-es-general" "^List-id:.*www-es-general.gnu.org")
        ("mail.gnu-mx" "^Subject:\\[Core Team]")
        ("mail.gnu-mx" "^To:.*core-owner@mx.gnu.org")
        ("mail.gnu.www-commits" "^List-id:.*www-commits.gnu.org")
        ("mail.UTFSM" "^List-id:.*linux.listas.inf.utfsm.cl")
        ("mail.PHP" "^List-id:.*php.listas.inf.utfsm.cl")
        ("mail.emacs-es" "^List-id:.*emacs-es.es.gnu.org")
        ("mail.debian-pt" "^List-id:.*debian-user-portuguese.lists.debian.org")
        ("mail.debian-es" "^List-id:.*debian-user-spanish.lists.debian.org")
        ("mail.kubuntu" "^List-id:.*kubuntu-users.lists.ubuntu.com")
        ("mail.stumpwm" "^List-id:.*stumpwm-devel.nongnu.org")
        ("mail.lisp-br" "^List-id:.*users.lists.lisp-br.org")
        ("mail.fisl9" "^List-id:.*webfisl9.listas.softwarelivre.org")
        ("mail.spam" "^From:.*mailings@gmx.net")
        ("mail.spam" "^From:.*mailings@gmx-gmbh.de")
        ("mail.emacs-devel" "^List-id:.*emacs-devel.gnu.org")
        ("mail.emacs-commit" "^List-id:.*emacs-commit.gnu.org")
        ("mail.emacs-erc-commit" "^List-id:.*erc-commit.gnu.org")
        ("mail.emacs-erc-discuss" "^List-id:.*erc-discuss.gnu.org")
        ("mail.emacs-erc-announce" "^List-id:.*erc-announce.gnu.org")
        ("mail.gnu.lists" "^List-id:.*.gnu.org")
        ("mail.other" "")))


;(setq nnmail-expiry-target "stuff.expired")


;; Avoid mark messages read as expired
;(remove-hook 'gnus-mark-article-hook
;             'gnus-summary-mark-read-and-unread-as-read)
;(add-hook 'gnus-mark-article-hook 'gnus-summary-mark-unread-as-read)


;; font

(setq gnus-face-9 'font-lock-warning-face
      gnus-face-10 'shadow)


;;;
;;  News settings
;;;

(setq gnus-nntp-server "nntp.aioe.org" ;"news-17.escomposlinux.org" ;
      nntp-port-number "119")


(setq  gnus-select-method '(nntp "nntp.aioe.org")
       user-full-name "Exal de Jesus Garcia Carrillo"
       nnmail-list-identifiers '("[Rr][Ee]:")
       gnus-secondary-select-methods '((nnmbox "")))


(defun gnus-subscribe-selectively (newsgroup)
     (gnus-subscribe-alphabetically newsgroup)
     (if (not (string-match
               ;; This regexp matches only non-wacky newsgroups.
               ;; Change it to suit your preference.
               "^\\(comp\\|alt\\|soc\\|news\\|es\\)\\."
               newsgroup))
       (gnus-group-unsubscribe-group newsgroup)))

 (setq gnus-subscribe-newsgroup-method 'gnus-subscribe-selectively)


;; for local mail
(setq mail-sources
      '((file :path "/var/mail/exal"
              :suffix ""
              :plugged t)))


;;;
;;  Visible headers
;;;

;; Hide things
(setq gnus-boring-article-headers '(empty followup-to newsgroups
                                          many-to reply-to))

(setq gnus-visible-headers
      '("From:" "^Newsgroups:" "^Subject:" "^Date:" "^Followup-To:"
        "^Reply-To:" "^Organization:" "^Summary:" "^Keywords:" "^To:"
        "^Cc:" "^Posted-To:" "^Mail-Copies-To:" "^Apparently-To:"
        "^Gnus-Warning:" "^Resent-From:" "X-Sent:" "^User-Agent:"
        "^X-Mailer:" "^Newsreader:" "^X-Newsreader:" 
        "^X-Accept-Language" "^Message-Id:"))


;(setq message-default-mail-headers "Fcc: ~/Mail/outbox")     

(setq gnus-outgoing-message-group "nnmbox:mail.outbox"
      gnus-gcc-mark-as-read t)

;; warning replying by mail in newsgroups
(setq gnus-confirm-mail-reply-to-news t)


(setq gnus-signature-separator
      '("^-- $" "^-- *$"
        "^-------*$"
        "^ *--------*$"
        "^________*$"
        "^========*$"))

(setq gnus-signature-limit
      '(200.0 "^---*Forwarded article"))


(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)))

(setq gnus-use-adaptive-scoring t)

;;;
;; Display Face
;;;


;; Don't warn me about multiple Face headers
(add-to-list 'message-syntax-checks
             '(multiple-headers . disabled))



  ;;; (setq message-default-headers
  ;;;       (with-temp-buffer
  ;;;   (insert "Face: ")
  ;;;   (insert-file-contents "~/emacs-stuff/faces/me.face")
  ;;;   (buffer-string)))


(defvar exal-gnus-face-directory  
  (expand-file-name "faces" exal-emacs-dir) 
  "The directory in which store my png face files.")

(defvar exal-gnus-default-face
  (expand-file-name "me.png" exal-gnus-face-directory) 
  "The default face for display in msgs.")

(defun exal-gnus-default-face ()
  "Return default Face header."
  (interactive)
  (save-match-data
    (when (and (not (string= exal-gnus-default-face ""))
               (file-exists-p exal-gnus-default-face))
      (gnus-convert-png-to-face exal-gnus-default-face))))

(defun exal-gnus-random-face ()
  "Return Face header data chosen randomly from
`exal-gnus-face-directory'."
  (interactive)
  (save-match-data
    (when (file-exists-p exal-gnus-face-directory)
      (let* ((files (delete exal-gnus-default-face
                            (directory-files exal-gnus-face-directory
                                             t "\\.png$")))
             (file (nth (random (length files)) files)))
        (when file
          (gnus-convert-png-to-face file))))))

;; Specify headers that I want in every message
(defun exal-message-insert-extra-headers ()
  (goto-char (point-min))
  (insert "Face: " (exal-gnus-default-face) "\n"
          "Face: " (exal-gnus-random-face) "\n"))

(add-hook 'message-header-setup-hook 'exal-message-insert-extra-headers)



(defun exal-emacs-version ()
  "Stringified Emacs version."
  (let* ((lst (if (listp gnus-user-agent)
                    gnus-user-agent
                '(gnus emacs type)))
          (system-v (cond ((memq 'config lst)
                             system-configuration)
                           ((memq 'type lst)
                              (symbol-name system-type))
                            (t nil)))
           codename emacsname)
    (cond ((featurep 'sxemacs)
              (setq emacsname "SXEmacs"
                     codename sxemacs-codename))
            ((featurep 'xemacs)
                (setq emacsname "XEmacs"
                       codename xemacs-codename))
              (t
                  (setq emacsname "Emacs")))
    (cond
     ((not (memq 'emacs lst))
      nil)
    ((string-match "^\\(\\([.0-9]+\\)*\\)" emacs-version)
      ;; Emacs:
     ; ((concat "Emacs/" (substring (emacs-version) 10 19)
       (concat "Emacs/" (match-string 1 emacs-version)
              (if system-v
                          (concat " (" system-v ")")
                      "")))
     ((or (featurep 'sxemacs) (featurep 'xemacs))
      ;; XEmacs or SXEmacs:
      (concat emacsname "/" emacs-program-version
                    (let (plst)
                      (when (memq 'codename lst)
                         (push codename plst))
                      (when system-v
                          (push system-v plst))
                      (unless (featurep 'mule)
                          (push "no MULE" plst))
                      (when (> (length plst) 0)
                          (concat
                              " (" (mapconcat 'identity (reverse plst) ", ") ")")))))
     (t emacs-version))))

(defun exal-gnus-version ()
  "Stringified Gnus version and Emacs version.
See the variable `gnus-user-agent'."
  (interactive)
  (if (stringp gnus-user-agent)
      gnus-user-agent
    ;; `gnus-user-agent' is a list:
    (let* ((float-output-format nil)
              (gnus-v
                   (when (memq 'gnus gnus-user-agent)
                           (concat "Gnus/"
                                         (prin1-to-string (gnus-continuum-version gnus-version) t)
                                               " (" gnus-version ")")))
                 (emacs-v (exal-emacs-version)))
      (concat gnus-v (when (and gnus-v emacs-v) " ")
                    emacs-v))))


;;;
;; Posting styles
;;;

     (setq gnus-posting-styles
          '((".*"
             (name user-full-name)
             (address "exal@gnu.org")
             (organization "The GNU Emacs Church")
             ("X-Accept-Language" "es, en, pt")
             ("X-GPG" "0x5251B462")
             ("X-GPG-FINGERPRINT" "B17A 8AD9 8B64 DC6C 7F92  BBF7 A199 B1A1 5251 B462")
             ("X-Home-Page" "http://exal.0x2.org")
             ("User-Agent"  exal-gnus-version)
             (x-face-file 
              (expand-file-name "faces/xface.emacs.txt" exal-emacs-dir)))

             ("gnu"
              (address "exal@gnu.org")
              (organization "GNU Project")
              ("Reply-To" "Exal de Jesus Garcia Carrillo <exal@gnu.org>")
              (signature-file 
               (expand-file-name "signature-gnu" exal-emacs-dir)))
             
             (header "from" "bernardita"
              (address "exal@softwarelivre.org")
              (organization "Associacao Software Livre")
              ("Reply-To" "Exal de Jesus Garcia Carrillo <exal@softwarelivre.org>")
              (signature-file 
               (expand-file-name "signature-sl" exal-emacs-dir)))

             ("fisl9\\|softwarelivre" 
              (address "exal@softwarelivre.org")
              (organization "Associacao Software Livre")
              ("Reply-To" "Exal de Jesus Garcia Carrillo <exal@softwarelivre.org>")
              (signature-file 
               (expand-file-name "signature-sl" exal-emacs-dir)))
             
             ("xtreme"
              (address "exal@xtremesolutions.com.mx")
              (organization "Xtreme Solutions")
              ("Reply-To" "Exal de Jesus Garcia Carrillo <exal@xtremesolutions.com.mx>"))

             (message-news-p
              (address "no-spam@gnu.org")
              (gnus-group-get-parameter gnus-newsgroup-name 'to-address)
             (signature-file 
              (expand-file-name "signature-news" exal-emacs-dir)))))



;; Show all mail groups
(setq gnus-permanently-visible-groups "^nn.*")

;;;
;;  Citation lines
;;;

(setq gnus-ignored-from-addresses
      (regexp-opt '( "exal@gnu.org"
                     "exal@softwarelivre.org"
                     "exal@xtremesolutions.com.mx")))


(defun exal-message-insert-citation-line ()
  "Function that inserts a simple citation line."
  (let* ((components (mail-extract-address-components
                      (mail-header-from message-reply-headers)))
         (name (car components))
         (email (cadr components)))
    (when message-reply-headers
      (cond
       ;; if I wrote the email/news
       ((string-match gnus-ignored-from-addresses email) 
        (insert "Eu " name ", escrevi:") (newline 2))
       
       ;; if is e-mail
       ((string-match "nnmbox:mail" gnus-newsgroup-name)
        (insert "Em " 
                (format-time-string "%A, %e %B %G, "
                                    (gnus-date-get-time
                                     (mail-header-date message-reply-headers)))
                name
                " escreveu:")(newline 2)) 
       
       ;; if is news message
       ((gnus-news-group-p gnus-newsgroup-name)
        (insert  ""
                 name
                 " em "
                 gnus-newsgroup-name
                 " escreveu:")(newline 2))
       ;; any other
       (t
        (insert (mail-header-from message-reply-headers)
                " escreveu:")(newline 2))))))


(setq message-citation-line-function 'exal-message-insert-citation-line)



;;;; Group Buffer

(setq gnus-group-mode-line-format "Gnus: %%b"
      gnus-group-line-format "%M%S%p%P%5y:%B%(%g%)%O\n"
      gnus-topic-line-format "%i[ %{%(%n%)%} (%g/%A) ]%v\n")


(add-hook 'gnus-group-mode-hook 'gnus-topic-mode)



(setq gnus-visual t)
;(setq gnus-visual '(article-highlight menu))

(gnus-add-configuration
 '(article (vertical 1.0
                     (group 5)
                     (summary .25 point)
                     (article 1.0))))
(gnus-add-configuration
 '(summary
   (vertical 1.0
             (group 5)
             (summary 1.0))))

;;;
;; mailcrypting stuff
;;;

(load-library "mailcrypt")
(mc-setversion "gpg")
(autoload 'mc-install-write-mode "mailcrypt" nil t)
(autoload 'mc-install-read-mode "mailcrypt" nil t)
(add-hook 'gnus-summary-mode-hook 'mc-install-read-mode)
(add-hook 'message-mode-hook 'mc-install-write-mode)
(add-hook 'news-reply-mode-hook 'mc-install-write-mode)
;; If you have more than one key, specify the one to use
(setq mc-gpg-user-id user-full-name)
;; Always sign encrypted messages
(setq mc-pgp-always-sign t)
;; How long should mailcrypt remember your passphrase
(setq mc-passwd-timeout 600)
;; Automagically sign all messages
(add-hook 'message-send-hook 'will-you-sign)
(defun will-you-sign ()
        (load-library "mc-toplev")
        (interactive)
        (if (y-or-n-p "Do you want to sign this message? ")
                (mc-sign-message)))

;;;
;;; Get messages automaticaly
;;;


(defun gnus-demon-scan-mail-and-news ()
  "Scan for new mail/news and update the *Group* buffer."
  (when (gnus-alive-p)  
    (save-window-excursion
      (save-excursion
 (set-buffer gnus-group-buffer)
 (gnus-group-get-new-news)))))

(add-hook 'gnus-group-mode-hook 'gnus-demon-init)

;; Sort threads by the date of the root node.
(setq gnus-thread-sort-functions `(gnus-thread-sort-by-date))

;; Initialize the Gnus daemon, check new mail every six minutes.
(gnus-demon-add-handler 'gnus-demon-scan-mail-and-news 6 nil)



;;;;;;;;;;;;;;;; POP3 configuration stuff


(require 'pop3)

(setq tls-hostmismatch nil
      mail-source-ignore-errors t)


(eval-after-load "mail-sources"
  (setq mail-sources `((pop  :server "xtremesolutions.com.mx"
                             :user "exal"
                             :password ,exal-xtreme-passwd)
                       (pop  :server "fencepost.gnu.org"
                             :user "exal"
                             :authentication 'apop
                             :connection ssl
                             :password ,exal-gnu-passwd)
                       (pop  :server "beethoven.softwarelivre.org"
                             :user "exal"
                             :connection ssl
                             :port 995
                             :password ,exal-softwarelivre-passwd))))



;(setq gnus-select-methods 
;      '((nnimap "xtremesolutions.com.mx"
;       (nnimap-authinfo-file "~/emacs-stuff/mailauth-xtreme"))))


;;;;;;;;;;;;End pop3 configuration stuff


(gnus-compile) 

;;; Local Variables:
;;; mode: emacs-lisp
;;; after-save-hook: (gnus-group-read-init-file)
;;; End: