emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] display-time-mail-icon and directory


From: Kim F. Storm
Subject: Re: [PATCH] display-time-mail-icon and directory
Date: 21 Jan 2002 00:50:12 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

"Eli Zaretskii" <address@hidden> writes:

> > From: address@hidden (Kai =?iso-8859-1?q?Gro=DFjohann?=)
> > Date: Sun, 20 Jan 2002 17:46:14 +0100
> > 
> > With your patch, Emacs can look in one directory and one file.
> > Wouldn't it be cool if Emacs could look in several directories and
> > several files?
> > 
> > I think that's what Eli meant.
> 
> Yes, that's what I meant.  I think I've seen people asking for such a
> feature in the past.

I think it should be able to poll POP3 mailboxes as well.
The following code can be used as a starting point (but it too can only
poll one pop3 mailbox):

(defvar pop3-check-host "...")
(defvar pop3-check-user "...")
;; password is encoded using rmail  (calls rmail-get-pop-password below)

(defconst pop3-check-port 110)
(defconst pop3-check-buffer " *pop3-check*")
(defvar pop3-mail-present nil)

(defun pop3-check-filter (process string)
  "Check POP3 conversation for mailbox status."
  (save-excursion
    (set-buffer (process-buffer process))
    (let (deactivate-mark)
      (goto-char (point-max))
      (insert string)
      (goto-line 4)
      (when (looking-at "\\+\\(OK\\|ERR\\) \\([0-9]+\\) ")
        (setq pop3-mail-present
              (and (string-equal (match-string 1) "OK")
                   (not (string-equal (match-string 2) "0"))))))))

(defun pop3-check-for-mail ()
  "Return TRUE iff mail is waiting in the POP3 mailbox."
  (let ((buffer (get-buffer-create pop3-check-buffer))
        deactivate-mark)
    (save-excursion
      (set-buffer buffer)
      (let (deactivate-mark)
        (erase-buffer)))
    (let ((stream
           (open-network-stream "pop3-check" buffer pop3-check-host 
pop3-check-port)))
      (set-process-filter stream (function pop3-check-filter))
      (process-send-string stream (format "user %s\n" pop3-check-user))
      (process-send-string stream (format "pass %s\n" (rmail-get-pop-password)))
      (process-send-string stream "stat\n")
      (process-send-string stream "quit\n")))
  pop3-mail-present)

;; Customize display-time to show mail icon when pop3-mail-present is t.

-- 
Kim F. Storm <address@hidden> http://www.cua.dk




reply via email to

[Prev in Thread] Current Thread [Next in Thread]