Gnus development mailing list
 help / color / mirror / Atom feed
* auto-get new mail
@ 1995-12-19 23:49 Colin Rafferty
  0 siblings, 0 replies; only message in thread
From: Colin Rafferty @ 1995-12-19 23:49 UTC (permalink / raw)


Hi-

The part of VM that I have missed the most is the vm-auto-get-new-mail
variable.  I have duplicated its effect within Gnus.  Everything depends
upon the fact that all your mail groups have a lower level the your
non-mail groups, and that you use a normal mail spool (and that you have
itimers on your flavor of Emacs).

I have stolen the basic itimer setup from Kyle Jones (vm-summary.el).

The remainder of this posting is the code that I have in my .gnus file
that implements everything:

(defvar cor:gnus-new-mail-interval 30
  "*Time in which to automatically get new mail.
0 or non-numeric means don't get new mail.")

(defvar cor:gnus-get-mail-level 2
  "*Level at which the mail groups are.")

(defvar cor:gnus-get-mail-delay 3
  "*Time to sit before we check new mail.")

(defvar cor:gnus-get-mail-hook nil
  "*Hook to run after new mail is automatically gotten.")

(add-hook 'gnus-exit-gnus-hook 'cor:gnus-exit-itimers)
(add-hook 'gnus-group-mode-hook 'cor:gnus-start-itimers-if-needed)

(defun cor:gnus-exit-itimers ()
  (condition-case ()
      (delete-itimer "cor:gnus-new-mail")
    (t)))

(defun cor:gnus-start-itimers-if-needed ()
  (if (or (natnump cor:gnus-new-mail-interval))
      (progn
	(if (null
	     (condition-case nil
		 (progn (require 'itimer) t)
	       (error nil)))
	    (setq cor:gnus-new-mail-interval nil)
	  (and (natnump cor:gnus-new-mail-interval)
	       (not (get-itimer "cor:gnus-new-mail"))
	       (start-itimer "cor:gnus-new-mail"
			     'cor:gnus-get-mail-itimer-function
			     cor:gnus-new-mail-interval nil))))))

;; support for numeric cor:gnus-new-mail-interval
(defun cor:gnus-get-mail-itimer-function ()
  (if (integerp cor:gnus-new-mail-interval)
      (set-itimer-restart current-itimer cor:gnus-new-mail-interval))
  (let ((gnus-group-use-permanent-levels nil))
    (if (and (file-exists-p nnmail-spool-file)
	     ;; file not empty?
	     (< 0 (nth 7 (file-attributes
			  (file-chase-links nnmail-spool-file))))
	     (not (input-pending-p))
	     (or (not (numberp cor:gnus-get-mail-delay))
		 (sit-for cor:gnus-get-mail-delay t)))
	(let ((b-list (buffer-list))
	      (gnus-verbose 0))
	  (while (and (not (input-pending-p)) b-list)
	    (save-excursion
	      (set-buffer (car b-list))
	      (if (eq major-mode 'gnus-group-mode)
		  (progn
		    (gnus-group-get-new-news cor:gnus-get-mail-level)
		    (run-hooks 'cor:gnus-get-mail-hook))))
	    (setq b-list (cdr b-list)))))))

;Colin


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-12-19 23:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-12-19 23:49 auto-get new mail Colin Rafferty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).