Gnus development mailing list
 help / color / mirror / Atom feed
* pop3.el: Display the size of the message being fetched (POP3 LIST command)
@ 2009-02-06 14:34 Bojan Petrovic
  2009-02-06 20:44 ` Ted Zlatanov
  0 siblings, 1 reply; 19+ messages in thread
From: Bojan Petrovic @ 2009-02-06 14:34 UTC (permalink / raw)
  To: ding

Hello everyone!

I hope someone finds this patch useful, in spite of the pop3.el blurb
(maybe some poor soul on a dial-up connection).  It implements the
POP3 LIST command and, if `pop3-display-message-size-flag'
customization option is non-nil, displays the size of the message that
is currently being fetched.


Best regards,

Bojan

(Sorry for sending the patch in the body, I am somehow
unable to subscribe to this list from my usual email address)


Index: pop3.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/gnus/pop3.el,v
retrieving revision 1.50
diff -u -r1.50 pop3.el
--- pop3.el	9 Jan 2009 03:01:52 -0000	1.50
+++ pop3.el	6 Feb 2009 14:01:26 -0000
@@ -98,6 +98,12 @@
   :type 'boolean
   :group 'pop3)
 
+(defcustom pop3-display-message-size-flag t
+  "*If non-nil, display the size of the message that is being fetched."
+  :version "22.1" ;; Oort Gnus
+  :type 'boolean
+  :group 'pop3) 
+
 (defvar pop3-timestamp nil
   "Timestamp returned when initially connected to the POP server.
 Used for APOP authentication.")
@@ -135,6 +141,7 @@
 	 (crashbuf (get-buffer-create " *pop3-retr*"))
 	 (n 1)
 	 message-count
+	 message-sizes
 	 (pop3-password pop3-password))
     ;; for debugging only
     (if pop3-debug (switch-to-buffer (process-buffer process)))
@@ -149,10 +156,18 @@
 	   (pop3-pass process))
 	  (t (error "Invalid POP3 authentication scheme")))
     (setq message-count (car (pop3-stat process)))
+    (when (and pop3-display-message-size-flag
+	       (> message-count 0))
+      (setq message-sizes (pop3-list process)))
     (unwind-protect
 	(while (<= n message-count)
-	  (message "Retrieving message %d of %d from %s..."
-		   n message-count pop3-mailhost)
+	  (if pop3-display-message-size-flag
+	      (message "Retrieving message %d of %d from %s... (%.1fk)"
+		       n message-count pop3-mailhost
+		       (/ (cdr (assoc n message-sizes))
+			  1024.0))
+	    (message "Retrieving message %d of %d from %s..."
+		     n message-count pop3-mailhost)) 	  
 	  (pop3-retr process n crashbuf)
 	  (save-excursion
 	    (set-buffer crashbuf)
@@ -451,8 +466,27 @@
     ))
 
 (defun pop3-list (process &optional msg)
-  "Scan listing of available messages.
-This function currently does nothing.")
+  "If MSG is nil, return an alist of (MESSAGE-ID . SIZE) pairs.
+Otherwise, return the size of the message-id MSG"
+  (pop3-send-command process (if msg 
+				 (format "LIST %d" msg)
+			       "LIST"))
+  (let ((response (pop3-read-response process t)))
+    (if msg
+	(string-to-number (nth 2 (split-string response " ")))
+      (let ((start pop3-read-point) end)
+	(save-excursion
+	  (set-buffer (process-buffer process))
+	  (while (not (re-search-forward "^\\.\r\n" nil t))
+	    (pop3-accept-process-output process)
+	    (goto-char start))
+	  (setq pop3-read-point (point-marker))
+	  (goto-char (match-beginning 0))
+	  (setq end (point-marker))
+	  (mapcar #'(lambda (s) (let ((split (split-string s " ")))
+				  (cons (string-to-number (nth 0 split))
+					(string-to-number (nth 1 split)))))
+		  (split-string (buffer-substring start end) "\r\n" t)))))))
 
 (defun pop3-retr (process msg crashbuf)
   "Retrieve message-id MSG to buffer CRASHBUF."







-- 
http://www.fastmail.fm - One of many happy users:
  http://www.fastmail.fm/docs/quotes.html




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-02-06 14:34 pop3.el: Display the size of the message being fetched (POP3 LIST command) Bojan Petrovic
@ 2009-02-06 20:44 ` Ted Zlatanov
  0 siblings, 0 replies; 19+ messages in thread
From: Ted Zlatanov @ 2009-02-06 20:44 UTC (permalink / raw)
  To: ding

On Fri, 06 Feb 2009 15:34:53 +0100 "Bojan Petrovic" <bojan_petrovic@fastmail.fm> wrote: 

BP> I hope someone finds this patch useful, in spite of the pop3.el blurb
BP> (maybe some poor soul on a dial-up connection).  It implements the
BP> POP3 LIST command and, if `pop3-display-message-size-flag'
BP> customization option is non-nil, displays the size of the message that
BP> is currently being fetched.

That looks useful; have you signed papers to contribute?  Also, can you
add a few lines to the manual listing the new variable?

Thanks
Ted




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2010-01-12 17:16                   ` Reiner Steib
@ 2010-03-20 15:21                     ` Ted Zlatanov
  0 siblings, 0 replies; 19+ messages in thread
From: Ted Zlatanov @ 2010-03-20 15:21 UTC (permalink / raw)
  To: ding

I've comitted (finally!) this patch.  Please let me know if it causes
problems.  It's been tested by several people so I think it's fine.

Bojan, thank you for your patience.  It was my fault that it took so
long after you signed papers.

Ted



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2010-01-05 19:40                 ` Ted Zlatanov
@ 2010-01-12 17:16                   ` Reiner Steib
  2010-03-20 15:21                     ` Ted Zlatanov
  0 siblings, 1 reply; 19+ messages in thread
From: Reiner Steib @ 2010-01-12 17:16 UTC (permalink / raw)
  To: ding

On Tue, Jan 05 2010, Ted Zlatanov wrote:

> On Fri, 25 Dec 2009 20:07:02 +0000 (UTC) Bojan Petrovic <bpetrovi@f.bg.ac.rs> wrote: 
>
> BP> Ted Zlatanov <tzz <at> lifelogs.com> writes:
>>> >>> Reiner, do you want me to do the commit?
>>> 
> RS> If someone thinks installing this (or any other non-bugfix path)
> RS> should not wait, please bring the issue up on emacs-devel so that the
> RS> Emacs maintainers can decide.  Thanks.
>>> 
> TZ> I meant "do you want me to do the commit after the feature freeze."
> TZ> Sorry for the confusion.
[...]
> I didn't get a reply from Reiner AFAIK and forgot to ping him back.  I
> am still in favor of installing your patch but will defer to Reiner on
> when it actually happens.

Were basically in the same situation again, as now Emacs is in pretest
for 23.2.

In fact we should probably create a branch for Gnus 5.13 (Emacs 23)
and install non-bugfixes on the trunk.  But that's for Lars to decide.

Bye, Reiner.

[ Resent via mail. Sorry if the posting thru Gmane arrives too. ]
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-12-25 20:07               ` Bojan Petrovic
@ 2010-01-05 19:40                 ` Ted Zlatanov
  2010-01-12 17:16                   ` Reiner Steib
  0 siblings, 1 reply; 19+ messages in thread
From: Ted Zlatanov @ 2010-01-05 19:40 UTC (permalink / raw)
  To: ding

On Fri, 25 Dec 2009 20:07:02 +0000 (UTC) Bojan Petrovic <bpetrovi@f.bg.ac.rs> wrote: 

BP> Ted Zlatanov <tzz <at> lifelogs.com> writes:
>> >>> Reiner, do you want me to do the commit?
>> 
RS> If someone thinks installing this (or any other non-bugfix path)
RS> should not wait, please bring the issue up on emacs-devel so that the
RS> Emacs maintainers can decide.  Thanks.
>> 
TZ> I meant "do you want me to do the commit after the feature freeze."
TZ> Sorry for the confusion.
>> 
>> Reiner, can we commit this patch now?
>> 
>> Thanks
>> Ted

BP> I just wanted to revive this thread, if it died inadvertently.

BP> Does anyone still think that this patch might be useful?

I didn't get a reply from Reiner AFAIK and forgot to ping him back.  I
am still in favor of installing your patch but will defer to Reiner on
when it actually happens.

Ted




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-08-04 14:32             ` Ted Zlatanov
@ 2009-12-25 20:07               ` Bojan Petrovic
  2010-01-05 19:40                 ` Ted Zlatanov
  0 siblings, 1 reply; 19+ messages in thread
From: Bojan Petrovic @ 2009-12-25 20:07 UTC (permalink / raw)
  To: ding

Ted Zlatanov <tzz <at> lifelogs.com> writes:

> >>> Reiner, do you want me to do the commit?
> 
> RS> If someone thinks installing this (or any other non-bugfix path)
> RS> should not wait, please bring the issue up on emacs-devel so that the
> RS> Emacs maintainers can decide.  Thanks.
> 
> TZ> I meant "do you want me to do the commit after the feature freeze."
> TZ> Sorry for the confusion.
> 
> Reiner, can we commit this patch now?
> 
> Thanks
> Ted


Hi,

I just wanted to revive this thread, if it died inadvertently.

Does anyone still think that this patch might be useful?

Regards,

Bojan








^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-04-16 20:08           ` Ted Zlatanov
@ 2009-08-04 14:32             ` Ted Zlatanov
  2009-12-25 20:07               ` Bojan Petrovic
  0 siblings, 1 reply; 19+ messages in thread
From: Ted Zlatanov @ 2009-08-04 14:32 UTC (permalink / raw)
  To: ding

On Thu, 16 Apr 2009 15:08:33 -0500 Ted Zlatanov <tzz@lifelogs.com> wrote: 

TZ> On Thu, 16 Apr 2009 21:06:58 +0200 Reiner Steib <reinersteib+gmane@imap.cc> wrote: 
RS> On Mon, Apr 13 2009, Ted Zlatanov wrote:
>>> Reiner can confirm, but I believe we're in a feature freeze right now so
>>> your patch will be comitted after the Emacs pretest is done.

RS> Yes.

>>> Reiner, do you want me to do the commit?

RS> If someone thinks installing this (or any other non-bugfix path)
RS> should not wait, please bring the issue up on emacs-devel so that the
RS> Emacs maintainers can decide.  Thanks.

TZ> I meant "do you want me to do the commit after the feature freeze."
TZ> Sorry for the confusion.

Reiner, can we commit this patch now?

Thanks
Ted




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-04-16 19:06         ` Reiner Steib
@ 2009-04-16 20:08           ` Ted Zlatanov
  2009-08-04 14:32             ` Ted Zlatanov
  0 siblings, 1 reply; 19+ messages in thread
From: Ted Zlatanov @ 2009-04-16 20:08 UTC (permalink / raw)
  To: ding; +Cc: Bojan Petrovic

On Thu, 16 Apr 2009 21:06:58 +0200 Reiner Steib <reinersteib+gmane@imap.cc> wrote: 

RS> On Mon, Apr 13 2009, Ted Zlatanov wrote:
>> Reiner can confirm, but I believe we're in a feature freeze right now so
>> your patch will be comitted after the Emacs pretest is done.

RS> Yes.

>> Reiner, do you want me to do the commit?

RS> If someone thinks installing this (or any other non-bugfix path)
RS> should not wait, please bring the issue up on emacs-devel so that the
RS> Emacs maintainers can decide.  Thanks.

I meant "do you want me to do the commit after the feature freeze."
Sorry for the confusion.

Thanks
Ted



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-04-13 15:54       ` Ted Zlatanov
@ 2009-04-16 19:06         ` Reiner Steib
  2009-04-16 20:08           ` Ted Zlatanov
  0 siblings, 1 reply; 19+ messages in thread
From: Reiner Steib @ 2009-04-16 19:06 UTC (permalink / raw)
  To: ding; +Cc: Bojan Petrovic

On Mon, Apr 13 2009, Ted Zlatanov wrote:

> On Wed, 01 Apr 2009 Bojan Petrovic <bpetrovi@f.bg.ac.rs> wrote: 
> BP> I have signed the papers and recieved the signed pdf (#410945).
>
> Reiner can confirm, but I believe we're in a feature freeze right now so
> your patch will be comitted after the Emacs pretest is done.

Yes.

> Reiner, do you want me to do the commit?

If someone thinks installing this (or any other non-bugfix path)
should not wait, please bring the issue up on emacs-devel so that the
Emacs maintainers can decide.  Thanks.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-04-01 21:21     ` Bojan Petrovic
@ 2009-04-13 15:54       ` Ted Zlatanov
  2009-04-16 19:06         ` Reiner Steib
  0 siblings, 1 reply; 19+ messages in thread
From: Ted Zlatanov @ 2009-04-13 15:54 UTC (permalink / raw)
  To: ding

On Wed, 01 Apr 2009 21:21:08 +0000 Bojan Petrovic <bpetrovi@f.bg.ac.rs> wrote: 

BP> Reiner Steib <reinersteib+gmane@imap.cc> writes:
BP> I'd be glad to sign them, 
>> 
>> Thanks!

BP> I have signed the papers and recieved the signed pdf (#410945).

Reiner can confirm, but I believe we're in a feature freeze right now so
your patch will be comitted after the Emacs pretest is done.

Reiner, do you want me to do the commit?

Thank you
Ted





^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-02-09 22:48   ` Reiner Steib
  2009-02-09 23:07     ` Katsumi Yamaoka
@ 2009-04-01 21:21     ` Bojan Petrovic
  2009-04-13 15:54       ` Ted Zlatanov
  1 sibling, 1 reply; 19+ messages in thread
From: Bojan Petrovic @ 2009-04-01 21:21 UTC (permalink / raw)
  To: ding

Reiner Steib <reinersteib+gmane@imap.cc> writes:

>> BP> I'd be glad to sign them, 
>
> Thanks!

I have signed the papers and recieved the signed pdf (#410945).



Regards,

Bojan.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-02-10 22:18         ` Reiner Steib
@ 2009-02-11  1:08           ` Bojan Petrovic
  0 siblings, 0 replies; 19+ messages in thread
From: Bojan Petrovic @ 2009-02-11  1:08 UTC (permalink / raw)
  To: ding

Reiner Steib <reinersteib+gmane@imap.cc> writes:

>> In addition, "*-size" would imply it customizes a size at first glance.
>
> Not really.  `pop3-display-message-size' is clear IMHO.

Naming it `pop3-show-message-size' could remove the (possible)
ambiguity, but the term `show` seems to be more frequently used when
talking about pictures or some elements of the UI.

`print'? `echo'? They are similar to `display'...

I'm OK with `pop3-display-message-size'.



Regards,

Bojan.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-02-10 14:44       ` Ted Zlatanov
@ 2009-02-10 22:18         ` Reiner Steib
  2009-02-11  1:08           ` Bojan Petrovic
  0 siblings, 1 reply; 19+ messages in thread
From: Reiner Steib @ 2009-02-10 22:18 UTC (permalink / raw)
  To: ding

[ The following message is a courtesy copy of an article that has
  been posted to news:gmane.emacs.gnus.general as well. ]

On Tue, Feb 10 2009, Ted Zlatanov wrote:

> "Bojan Petrovic" <bojan_petrovic@fastmail.fm> wrote: 
> BP> Katsumi Yamaoka <yamaoka@jpl.org> said:
>>> BTW, isn't `pop3-display-message-size', the name of the option,
>>> enough rather than `pop3-display-message-size-flag'?
>
> BP> Yes, the name is really long, but I followed (and possibly 
> BP> misapplied) the advice from Emacs "Coding Conventions":
>
> BP> * If a user option variable records a true-or-false condition, give
> BP>      it a name that ends in `-flag'.

At least one of the current Emacs maintainers (Stefan) disagrees with
this convention.  I don't like it as well, since boolean options often
are extended to allow other values.  The the option would have to be
renamed.  

In Gnus, we never really followed this convention:

,----
| -*- mode: grep; default-directory: "gnus/trunk/lisp/" -*-
| Grep started at Tue Feb 10 23:16:09
| 
| grep -nH -e '^(def.*-flag\>' *.el
| gnus-bookmark.el:91:(defcustom gnus-bookmark-sort-flag t
| imap.el:1756:(defun imap-message-flag-permanent-p (flag &optional mailbox buffer)
| imap.el:2689:(defun imap-parse-flag-list ()
| nnimap.el:1702:(defconst nnimap-mark-to-flag-alist
| nnimap.el:1715:(defun nnimap-mark-to-flag-1 (preds)
| nnimap.el:1721:(defun nnimap-mark-to-flag (preds &optional always-list make-string)
| spam.el:589:(defcustom spam-spamassassin-spam-flag-header "X-Spam-Flag"
| spam.el:594:(defcustom spam-spamassassin-positive-spam-flag-header "YES"
| 
| Grep finished (matches found) at Tue Feb 10 23:16:10
`----

> In addition, "*-size" would imply it customizes a size at first glance.

Not really.  `pop3-display-message-size' is clear IMHO.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-02-09 23:07     ` Katsumi Yamaoka
  2009-02-09 23:38       ` Bojan Petrovic
@ 2009-02-10 14:44       ` Ted Zlatanov
  2009-02-10 22:18         ` Reiner Steib
  1 sibling, 1 reply; 19+ messages in thread
From: Ted Zlatanov @ 2009-02-10 14:44 UTC (permalink / raw)
  To: ding

On Tue, 10 Feb 2009 08:07:58 +0900 Katsumi Yamaoka <yamaoka@jpl.org> wrote: 

>>>>>> Reiner Steib wrote:
>> Please don't install it before the paper work is complete.  Also, as
>> it's not a bug fix, it should not be installed now.

KY> I agree.

I wouldn't dream of it :)

On Tue, 10 Feb 2009 00:38:27 +0100 "Bojan Petrovic" <bojan_petrovic@fastmail.fm> wrote: 

BP> Katsumi Yamaoka <yamaoka@jpl.org> said:
>> BTW, isn't `pop3-display-message-size', the name of the option,
>> enough rather than `pop3-display-message-size-flag'?

BP> Yes, the name is really long, but I followed (and possibly 
BP> misapplied) the advice from Emacs "Coding Conventions":

BP> * If a user option variable records a true-or-false condition, give
BP>      it a name that ends in `-flag'.

In addition, "*-size" would imply it customizes a size at first glance.
So I like the p-d-m-s-flag name better too.

Ted




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-02-09 23:07     ` Katsumi Yamaoka
@ 2009-02-09 23:38       ` Bojan Petrovic
  2009-02-10 14:44       ` Ted Zlatanov
  1 sibling, 0 replies; 19+ messages in thread
From: Bojan Petrovic @ 2009-02-09 23:38 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: ding

Katsumi Yamaoka <yamaoka@jpl.org> said:
> BTW, isn't `pop3-display-message-size', the name of the option,
> enough rather than `pop3-display-message-size-flag'?

Yes, the name is really long, but I followed (and possibly 
misapplied) the advice from Emacs "Coding Conventions":

* If a user option variable records a true-or-false condition, give
     it a name that ends in `-flag'.



Regards,

Bojan


-- 
http://www.fastmail.fm - One of many happy users:
  http://www.fastmail.fm/docs/quotes.html




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-02-09 22:48   ` Reiner Steib
@ 2009-02-09 23:07     ` Katsumi Yamaoka
  2009-02-09 23:38       ` Bojan Petrovic
  2009-02-10 14:44       ` Ted Zlatanov
  2009-04-01 21:21     ` Bojan Petrovic
  1 sibling, 2 replies; 19+ messages in thread
From: Katsumi Yamaoka @ 2009-02-09 23:07 UTC (permalink / raw)
  To: bojan_petrovic; +Cc: ding

>>>>> Reiner Steib wrote:
> On Mon, Feb 09 2009, Ted Zlatanov wrote:
>> The code looks OK to me, but I don't use POP3 so I can't test it.  If no
>> one else can test it, I'll set up a POP3 server.

With the "Microsoft Exchange Server 2007 POP3 server" I've tested
Bojan's patch.  Works fine.

nnml: Reading incoming mail from pop...
Retrieving message 1 of 2 from pop.jp.example.com... (2.8k)
Retrieving message 2 of 2 from pop.jp.example.com... (3.9k)

BTW, isn't `pop3-display-message-size', the name of the option,
enough rather than `pop3-display-message-size-flag'?

> Please don't install it before the paper work is complete.  Also, as
> it's not a bug fix, it should not be installed now.

I agree.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-02-09 20:11 ` Ted Zlatanov
@ 2009-02-09 22:48   ` Reiner Steib
  2009-02-09 23:07     ` Katsumi Yamaoka
  2009-04-01 21:21     ` Bojan Petrovic
  0 siblings, 2 replies; 19+ messages in thread
From: Reiner Steib @ 2009-02-09 22:48 UTC (permalink / raw)
  To: Bojan Petrovic; +Cc: ding

On Mon, Feb 09 2009, Ted Zlatanov wrote:

> On Sun, 08 Feb 2009 00:35:54 +0100 "Bojan Petrovic" <bojan_petrovic@fastmail.fm> wrote: 
>
>>> That looks useful; have you signed papers to contribute?  Also, can you
>>> add a few lines to the manual listing the new variable?
>
> BP> I'd be glad to sign them, 

Thanks!

> BP> but I am not familiar with procedure.
>
> Reiner Steib has done it in the past, I believe.  

-> personal mail to Bojan and Ted.

> BP> I'm sending the changelog, the texinfo patch, and a slightly revised 
> BP> previous patch: I've changed the commentary to reflect the addition of 
> BP> pop3-list, the docstring of pop3-list and the version number in 
> BP> defcustom (23.1).
>
> The code looks OK to me, but I don't use POP3 so I can't test it.  If no
> one else can test it, I'll set up a POP3 server.

Please don't install it before the paper work is complete.  Also, as
it's not a bug fix, it should not be installed now.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
  2009-02-07 23:35 Bojan Petrovic
@ 2009-02-09 20:11 ` Ted Zlatanov
  2009-02-09 22:48   ` Reiner Steib
  0 siblings, 1 reply; 19+ messages in thread
From: Ted Zlatanov @ 2009-02-09 20:11 UTC (permalink / raw)
  To: ding

On Sun, 08 Feb 2009 00:35:54 +0100 "Bojan Petrovic" <bojan_petrovic@fastmail.fm> wrote: 

>> That looks useful; have you signed papers to contribute?  Also, can you
>> add a few lines to the manual listing the new variable?

BP> I'd be glad to sign them, but I am not familiar with procedure.

Reiner Steib has done it in the past, I believe.  I usually check
http://www.gnu.org/prep/maintain/html_node/Copyright-Papers.html for the
info but you may want to look through
http://www.gnu.org/prep/maintain/html_node/Legal-Matters.html in general
if you're interested, to understand why the assignment is necessary and
what it means.

BP> I'm sending the changelog, the texinfo patch, and a slightly revised 
BP> previous patch: I've changed the commentary to reflect the addition of 
BP> pop3-list, the docstring of pop3-list and the version number in 
BP> defcustom (23.1).

The code looks OK to me, but I don't use POP3 so I can't test it.  If no
one else can test it, I'll set up a POP3 server.

Ted




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: pop3.el: Display the size of the message being fetched (POP3 LIST command)
@ 2009-02-07 23:35 Bojan Petrovic
  2009-02-09 20:11 ` Ted Zlatanov
  0 siblings, 1 reply; 19+ messages in thread
From: Bojan Petrovic @ 2009-02-07 23:35 UTC (permalink / raw)
  To: ding

> That looks useful; have you signed papers to contribute?  Also, can you
> add a few lines to the manual listing the new variable?

I'd be glad to sign them, but I am not familiar with procedure.

I'm sending the changelog, the texinfo patch, and a slightly revised 
previous patch: I've changed the commentary to reflect the addition of 
pop3-list, the docstring of pop3-list and the version number in 
defcustom (23.1).

Please tell me if any changes are needed.



Regards,

Bojan




--snip----------------------------------------------------

2009-02-07  Bojan Petrovic  <bpetrovi@f.bg.ac.rs>

	* gnus.texi (Mail Source Specifiers): Describe
	`pop3-display-message-size-flag' and add it to the index.


2009-02-07  Bojan Petrovic  <bpetrovi@f.bg.ac.rs>

	* pop3.el (pop3-list): Implement the POP3 LIST command.
	(global): Change the commentary to reflect the above change.
	(pop3-movemail): Optionally display the size of the message that
	is being fetched.
	(pop3-display-message-size-flag): New variable.




--snip----------------------------------------------------

Index: gnus.texi
===================================================================
RCS file: /sources/emacs/emacs/doc/misc/gnus.texi,v
retrieving revision 1.40
diff -u -r1.40 gnus.texi
--- gnus.texi	19 Jan 2009 01:06:25 -0000	1.40
+++ gnus.texi	7 Feb 2009 21:57:47 -0000
@@ -15224,6 +15224,11 @@
 do not, then you may get duplicate mails or the whole thing can fall
 apart and leave you with a corrupt mailbox.
 
+@vindex pop3-display-message-size-flag
+If @code{pop3-display-message-size-flag} is non-@code{nil}, the size
+in kilobytes of the message that is being fetched will be displayed in
+the echo area.
+
 Here are some examples for getting mail from a @acronym{POP} server.
 Fetch from the default @acronym{POP} server, using the default user
 name, and default fetcher:



--snip----------------------------------------------------

Index: pop3.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/gnus/pop3.el,v
retrieving revision 1.50
diff -u -r1.50 pop3.el
--- pop3.el	9 Jan 2009 03:01:52 -0000	1.50
+++ pop3.el	7 Feb 2009 21:51:15 -0000
@@ -24,9 +24,8 @@
 
 ;;; Commentary:
 
-;; Most of the standard Post Office Protocol version 3 (RFC 1460) commands
-;; are implemented.  The LIST command has not been implemented due to lack
-;; of actual usefulness.
+;; The entire Post Office Protocol version 3 (RFC 1460) minimal
+;; command set and the optional APOP command are implemented.
 ;; The optional POP3 command TOP has not been implemented.
 
 ;; This program was inspired by Kyle E. Jones's vm-pop program.
@@ -98,6 +97,12 @@
   :type 'boolean
   :group 'pop3)
 
+(defcustom pop3-display-message-size-flag t
+  "*If non-nil, display the size of the message that is being fetched."
+  :version "23.1" ;; No Gnus
+  :type 'boolean
+  :group 'pop3)
+
 (defvar pop3-timestamp nil
   "Timestamp returned when initially connected to the POP server.
 Used for APOP authentication.")
@@ -135,6 +140,7 @@
 	 (crashbuf (get-buffer-create " *pop3-retr*"))
 	 (n 1)
 	 message-count
+	 message-sizes
 	 (pop3-password pop3-password))
     ;; for debugging only
     (if pop3-debug (switch-to-buffer (process-buffer process)))
@@ -149,10 +155,18 @@
 	   (pop3-pass process))
 	  (t (error "Invalid POP3 authentication scheme")))
     (setq message-count (car (pop3-stat process)))
+    (when (and pop3-display-message-size-flag
+	       (> message-count 0))
+      (setq message-sizes (pop3-list process)))
     (unwind-protect
 	(while (<= n message-count)
-	  (message "Retrieving message %d of %d from %s..."
-		   n message-count pop3-mailhost)
+	  (if pop3-display-message-size-flag
+	      (message "Retrieving message %d of %d from %s... (%.1fk)"
+		       n message-count pop3-mailhost
+		       (/ (cdr (assoc n message-sizes))
+			  1024.0))
+	    (message "Retrieving message %d of %d from %s..."
+		     n message-count pop3-mailhost))
 	  (pop3-retr process n crashbuf)
 	  (save-excursion
 	    (set-buffer crashbuf)
@@ -451,8 +465,27 @@
     ))
 
 (defun pop3-list (process &optional msg)
-  "Scan listing of available messages.
-This function currently does nothing.")
+  "Return an alist of (MESSAGE-ID . SIZE) pairs.
+If MSG is supplied, return the size of the message-id MSG"
+  (pop3-send-command process (if msg
+				 (format "LIST %d" msg)
+			       "LIST"))
+  (let ((response (pop3-read-response process t)))
+    (if msg
+	(string-to-number (nth 2 (split-string response " ")))
+      (let ((start pop3-read-point) end)
+	(save-excursion
+	  (set-buffer (process-buffer process))
+	  (while (not (re-search-forward "^\\.\r\n" nil t))
+	    (pop3-accept-process-output process)
+	    (goto-char start))
+	  (setq pop3-read-point (point-marker))
+	  (goto-char (match-beginning 0))
+	  (setq end (point-marker))
+	  (mapcar #'(lambda (s) (let ((split (split-string s " ")))
+				  (cons (string-to-number (nth 0 split))
+					(string-to-number (nth 1 split)))))
+		  (split-string (buffer-substring start end) "\r\n" t)))))))
 
 (defun pop3-retr (process msg crashbuf)
   "Retrieve message-id MSG to buffer CRASHBUF."



-- 
http://www.fastmail.fm - The professional email service




^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-03-20 15:21 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-06 14:34 pop3.el: Display the size of the message being fetched (POP3 LIST command) Bojan Petrovic
2009-02-06 20:44 ` Ted Zlatanov
2009-02-07 23:35 Bojan Petrovic
2009-02-09 20:11 ` Ted Zlatanov
2009-02-09 22:48   ` Reiner Steib
2009-02-09 23:07     ` Katsumi Yamaoka
2009-02-09 23:38       ` Bojan Petrovic
2009-02-10 14:44       ` Ted Zlatanov
2009-02-10 22:18         ` Reiner Steib
2009-02-11  1:08           ` Bojan Petrovic
2009-04-01 21:21     ` Bojan Petrovic
2009-04-13 15:54       ` Ted Zlatanov
2009-04-16 19:06         ` Reiner Steib
2009-04-16 20:08           ` Ted Zlatanov
2009-08-04 14:32             ` Ted Zlatanov
2009-12-25 20:07               ` Bojan Petrovic
2010-01-05 19:40                 ` Ted Zlatanov
2010-01-12 17:16                   ` Reiner Steib
2010-03-20 15:21                     ` Ted Zlatanov

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).