From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/68251 Path: news.gmane.org!not-for-mail From: "Bojan Petrovic" Newsgroups: gmane.emacs.gnus.general Subject: Re: pop3.el: Display the size of the message being fetched (POP3 LIST command) Date: Sun, 08 Feb 2009 00:35:54 +0100 Message-ID: <1234049754.2390.1299107629@webmail.messagingengine.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1234049837 18193 80.91.229.12 (7 Feb 2009 23:37:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 7 Feb 2009 23:37:17 +0000 (UTC) To: ding@lists.math.uh.edu Original-X-From: ding-owner+M16691@lists.math.uh.edu Sun Feb 08 00:38:31 2009 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.50) id 1LVwko-0004hu-4n for ding-account@gmane.org; Sun, 08 Feb 2009 00:38:30 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1LVwiO-0003cX-86; Sat, 07 Feb 2009 17:36:00 -0600 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1LVwiM-0003cI-7J for ding@lists.math.uh.edu; Sat, 07 Feb 2009 17:35:58 -0600 Original-Received: from out4.smtp.messagingengine.com ([66.111.4.28]) by mx2.math.uh.edu with esmtp (Exim 4.69) (envelope-from ) id 1LVwiJ-0000My-0p for ding@lists.math.uh.edu; Sat, 07 Feb 2009 17:35:58 -0600 Original-Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 3975628F4DE for ; Sat, 7 Feb 2009 18:35:54 -0500 (EST) Original-Received: from web6.messagingengine.com ([10.202.2.215]) by compute1.internal (MEProxy); Sat, 07 Feb 2009 18:35:54 -0500 Original-Received: by web6.messagingengine.com (Postfix, from userid 99) id 0E0E981569; Sat, 7 Feb 2009 18:35:54 -0500 (EST) X-Sasl-Enc: dLfoAHeLFPk2uOMts9xvoIwbRuq0RsP0gdITfAiwB30Q 1234049754 Content-Disposition: inline X-Mailer: MessagingEngine.com Webmail Interface X-Spam-Score: -3.2 (---) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:68251 Archived-At: > 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 * gnus.texi (Mail Source Specifiers): Describe `pop3-display-message-size-flag' and add it to the index. 2009-02-07 Bojan Petrovic * 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