Function: mail-source-report-new-mail

mail-source-report-new-mail is an interactive and byte-compiled function defined in mail-source.el.gz.

Signature

(mail-source-report-new-mail ARG)

Documentation

Toggle whether to report when new mail is available.

This only works when display-time is enabled.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/mail-source.el.gz
(defun mail-source-report-new-mail (arg)
  "Toggle whether to report when new mail is available.
This only works when `display-time' is enabled."
  (interactive "P")
  (if (not mail-source-primary-source)
      (error "Need to set `mail-source-primary-source' to check for new mail"))
  (let ((on (if (null arg)
		(not mail-source-report-new-mail)
	      (> (prefix-numeric-value arg) 0))))
    (setq mail-source-report-new-mail on)
    (and mail-source-report-new-mail-timer
	 (cancel-timer mail-source-report-new-mail-timer))
    (and mail-source-report-new-mail-idle-timer
	 (cancel-timer mail-source-report-new-mail-idle-timer))
    (setq mail-source-report-new-mail-timer nil)
    (setq mail-source-report-new-mail-idle-timer nil)
    (if on
	(progn
	  (require 'time)
	  (setq display-time-mail-function #'mail-source-new-mail-p)
	  ;; Set up the main timer.
	  (setq mail-source-report-new-mail-timer
		(run-at-time
		 (* 60 mail-source-report-new-mail-interval)
		 (* 60 mail-source-report-new-mail-interval)
		 #'mail-source-start-idle-timer))
	  ;; When you get new mail, clear "Mail" from the mode line.
	  (add-hook 'nnmail-post-get-new-mail-hook
		    #'display-time-event-handler)
	  (message "Mail check enabled"))
      (setq display-time-mail-function nil)
      (remove-hook 'nnmail-post-get-new-mail-hook
		   #'display-time-event-handler)
      (message "Mail check disabled"))))