emailemacsgnus

How to make Emacs Gnus to get new mails automatically?


I try to fetch new mails with Gnus, but it doesn't work. I tried following options in my .emacs file:

;(setq gnus-demon-timestep 10)
(gnus-demon-add-handler 'gnus-group-get-new-news 1 nil)
;(gnus-demon-add-handler 'gnus-demon-scan-mail 1 nil)
;(gnus-demon-add-handler 'gnus-demon-scan-news 1 nil)
(gnus-demon-init)

I tried to add each of the 3 handlers, and put t instead of nil, but it didn't work. If I press g or run M-x gnus-group-get-new-news manually Gnus does fetchs new mails. I checked gnus-demon-handlers and it indeed says: gnus-demon-handlers's value is ((gnus-group-get-new-news 1 nil)) but it doesn't fetch mails automatically.


Solution

  • Try moving (gnus-demon-init) above the rest. The functions don't exist until that the demon is initialized.

    e.g.

    (add-hook 'gnus-startup-hook
      '(lambda ()
         (gnus-demon-init)
         (setq gnus-demon-timestep 60)  ;; each timestep is 60 seconds
         ;; Check for new mail every 1 timestep (1 minute)
         (gnus-demon-add-handler 'gnus-demon-scan-news 1 t)
    
         ;; Don't crash gnus if disconnected
         (defadvice gnus-demon-scan-news (around gnus-demon-timeout activate)
           "Timeout for Gnus."
           (with-timeout
           (120 (message "Gnus timed out."))
         ad-do-it))))