Gnus development mailing list
 help / color / mirror / Atom feed
From: Binjo <binjo.cn@gmail.com>
To: ding@gnus.org
Cc: Yagnesh Raghava Yakkala <yagnesh@live.com>
Subject: Re: gnus fetching same mails again and again (pop)
Date: Fri, 13 Apr 2012 12:17:30 +0800	[thread overview]
Message-ID: <8zty0o8dut.fsf@gmail.com> (raw)
In-Reply-To: <BLU0-SMTP256B9B9330CA83461801364CC3A0@phx.gbl> (Yagnesh Raghava Yakkala's message of "Fri, 13 Apr 2012 03:14:16 +0900")

On 04/13/2012, at 02:14, Yagnesh Raghava Yakkala wrote:

[...]

>
>Unfortunately no. Only pop interface. Thunderbird can keep mails on server, is
>not it possible with gnus.? 
>

IIRC, the `pop3-movemail' retrieves the mail from the 1 to the last mail on the
server, that's why get same mails over and over again.

There's no options for Gnus to get from the latest mail, only if totally rewrite
the `pop3-movemail'. ;)

I once wrote a workaround, which calculate local mails' count, and compare with
the server's, and start retrieving from the latest one. It still may mess up, if
delete/copy local mail though. :(

HTH,

--8<---------------cut here---------------start------------->8---
;;; fuck pop3-movemail
;;; FIXME or get the latest index from "~/Mail/active"  ??
(defun binjo-pop3-latest-index (dir-name)
  "Get latest index to be fetched from DIR-NAME."
  (let ((n 1)
        file-name)
    (mapc (lambda (sub-dir-name)
            (unless (or (string= "." sub-dir-name)
                        (string= ".." sub-dir-name))
              (setq file-name (concat dir-name sub-dir-name "/.overview"))
              (if (file-exists-p file-name)
                  (with-temp-buffer
                    (insert-file-literally file-name)
                    (goto-char (point-max))
                    (forward-line -1)
                    (setq n (+ n (string-to-number
                                  (car (split-string
                                        (thing-at-point 'line))))))))))
          (directory-files dir-name))
    n))

;; TODO stick to the latest pop3-movemail, 20101015
(eval-after-load "pop3"
  '(defun pop3-movemail (&optional crashbox)
     "Transfer contents of a maildrop to the specified CRASHBOX.

A dirty hack to let `pop3-movemail' fetch newest mail if '.overview' exists."
     (or crashbox (setq crashbox (expand-file-name "~/.crashbox")))
     (let* ((process (pop3-open-server pop3-mailhost pop3-port))
            (crashbuf (get-buffer-create " *pop3-retr*"))
            (n 1)
            message-count
            (pop3-password pop3-password))
       (if (file-exists-p "~/Mail/mail/")
           (setq n (binjo-pop3-latest-index "~/Mail/mail/")))
       ;; for debugging only
       (if pop3-debug (switch-to-buffer (process-buffer process)))
       ;; query for password
       (if (and pop3-password-required (not pop3-password))
           (setq pop3-password
                 (read-passwd (format "Password for %s: " pop3-maildrop))))
       (cond ((equal 'apop pop3-authentication-scheme)
              (pop3-apop process pop3-maildrop))
             ((equal 'pass pop3-authentication-scheme)
              (pop3-user process pop3-maildrop)
              (pop3-pass process))
             (t (error "Invalid POP3 authentication scheme")))
       (setq message-count (car (pop3-stat process)))
       (unwind-protect
           (while (<= n message-count)
             (message "Retrieving message %d of %d from %s..."
                      n message-count pop3-mailhost)
             (pop3-retr process n crashbuf)
             (save-excursion
               (set-buffer crashbuf)
               (let ((coding-system-for-write 'binary))
                 (write-region (point-min) (point-max) crashbox t 'nomesg))
               (set-buffer (process-buffer process))
               (while (> (buffer-size) 5000)
                 (goto-char (point-min))
                 (forward-line 50)
                 (delete-region (point-min) (point))))
             (unless pop3-leave-mail-on-server
               (pop3-dele process n))
             (setq n (+ 1 n))
             (pop3-accept-process-output process))
         (when (and pop3-leave-mail-on-server
                    (> n 1))
;;            (message "pop3.el doesn't support UIDL.  Setting `pop3-leave-mail-on-server'
;; to %s might not give the result you'd expect." pop3-leave-mail-on-server)
           (sit-for 1))
         (pop3-quit process))
       (kill-buffer crashbuf))
     t)
)
--8<---------------cut here---------------end--------------->8---



  parent reply	other threads:[~2012-04-13  4:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-12 10:16 Yagnesh Raghava Yakkala
2012-04-12 10:55 ` Alberto Luaces
2012-04-12 16:11   ` Yagnesh Raghava Yakkala
2012-04-12 17:07     ` Andreas Schwab
2012-04-12 18:14       ` Yagnesh Raghava Yakkala
2012-04-12 18:37         ` Lars Magne Ingebrigtsen
2012-04-13  5:45           ` Yagnesh Raghava Yakkala
2012-04-13 10:56             ` Steinar Bang
2012-04-13  2:20         ` XeCycle
2012-04-13  5:35           ` Yagnesh Raghava Yakkala
2012-04-13  6:17             ` XeCycle
2012-04-16  5:19               ` Yagnesh Raghava Yakkala
2012-04-16  6:05                 ` XeCycle
2012-04-16  6:58                   ` Yagnesh Raghava Yakkala
2012-04-16  9:06                     ` Steinar Bang
2012-04-16  9:31                       ` Setting up Dovecot [Was => Re: gnus fetching same mails again and again (pop)] Yagnesh Raghava Yakkala
2012-04-16 13:06                         ` Steinar Bang
2012-04-17  5:33                           ` Yagnesh Raghava Yakkala
2012-04-17  6:28                             ` Steinar Bang
2012-04-16 23:55                         ` Jonas Hörsch
2012-04-17  2:07                           ` Rasmus
2012-04-17  5:43                           ` Yagnesh Raghava Yakkala
2012-04-13  4:17         ` Binjo [this message]
2012-04-13  5:38           ` gnus fetching same mails again and again (pop) Yagnesh Raghava Yakkala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8zty0o8dut.fsf@gmail.com \
    --to=binjo.cn@gmail.com \
    --cc=ding@gnus.org \
    --cc=yagnesh@live.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).