From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/68249 Path: news.gmane.org!not-for-mail From: "Bojan Petrovic" Newsgroups: gmane.emacs.gnus.general Subject: pop3.el: Display the size of the message being fetched (POP3 LIST command) Date: Fri, 06 Feb 2009 15:34:53 +0100 Message-ID: <1233930893.25227.1298908581@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 1233932529 5609 80.91.229.12 (6 Feb 2009 15:02:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Feb 2009 15:02:09 +0000 (UTC) To: ding@lists.math.uh.edu Original-X-From: ding-owner+M16689@lists.math.uh.edu Fri Feb 06 16:03:22 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 1LVSEi-0002Ge-M3 for ding-account@gmane.org; Fri, 06 Feb 2009 16:03:20 +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 1LVSCN-00030I-E5; Fri, 06 Feb 2009 09:00:55 -0600 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1LVRnG-0002tz-28 for ding@lists.math.uh.edu; Fri, 06 Feb 2009 08:34:58 -0600 Original-Received: from out5.smtp.messagingengine.com ([66.111.4.29]) by mx1.math.uh.edu with esmtp (Exim 4.69) (envelope-from ) id 1LVRnC-0003wb-LQ for ding@lists.math.uh.edu; Fri, 06 Feb 2009 08:34:57 -0600 Original-Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 2A61828C739 for ; Fri, 6 Feb 2009 09:34:54 -0500 (EST) Original-Received: from web7.messagingengine.com ([10.202.2.216]) by compute1.internal (MEProxy); Fri, 06 Feb 2009 09:34:54 -0500 Original-Received: by web7.messagingengine.com (Postfix, from userid 99) id F368A999FB; Fri, 6 Feb 2009 09:34:53 -0500 (EST) X-Sasl-Enc: /tMt51jJZfBetUlYlILIcRePrAXcIrDgmX+X+7EF/F4G 1233930893 Content-Disposition: inline X-Mailer: MessagingEngine.com Webmail Interface X-Spam-Score: -2.7 (--) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:68249 Archived-At: 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