(autoload 'Electric-pop-up-window "electric")
(defvar biff-check-mail-command-list '("from")
"Command + arguments to execute to find out whether there is new mail.
Mail notification is given if the output from this command matches
(defvar biff-new-mail-re "From \\(.*\\)$"
"*String used to determine whether the output of biff-check-mail-command
indicates that new mail has arrived.")
(defvar biff-notification-string "New mail from %s"
"*String used to notify user of incoming mail.
It is used in conjunction with the first substring matched by
biff-new-mail-re to create a message to display in the minibuffer.
If it's value is nil, no minibuffer message is displayed, but the *Biff*
buffer is displayed for a short time.")
(defvar biff-time-interval 30
"*The time (in seconds) that biff waits before looking for mail")
(defvar biff-new-mail nil
"Non-nil when new mail has arrived.
May be used in the mode-line to signal arival of new mail.")
(defun biff (arg)
"Notify me when new mail arrives by writing a message in the minibuffer
or popping up a buffer (if biff-notification-string is nil). This is
useful when you spend long periods inside emacs so that the normal biff
doesn't help. Kills the current biff, and then starts a new one if ARG is
non-nil. The status of your mailbox is examined every biff-time-interval
seconds (default: 30)"
(interactive (list (y-or-n-p "Run biff? ")))
(let ((old-timer (get-timer "biff")))
(if old-timer (delete-timer old-timer)))
(start-timer "biff" 'biff-check-mail 5 biff-time-interval)))
(defun biff-check-mail ()
"Check for new mail"
(setq biff-new-mail nil)
(apply 'start-process "biff-check-mail" nil
(set-process-filter biff-check-mail-process 'biff-check-mail-filter)))
(defun biff-check-mail-filter (PROC STR)
(set-buffer (get-buffer-create " *Biff*"))
(setq biff-new-mail t)
(if (and (not (search-backward STR nil t))
(string-match biff-new-mail-re STR))
(if (match-beginning 1)
(substring STR (match-beginning 1) (match-end 1))
(substring STR (match-beginning 0) (match-end 0)))))
(message biff-notification-string notification))
(sleep-for 2) (sit-for 30)))))))