From: "Bojan Petrovic" <bojan_petrovic@fastmail.fm>
To: ding@lists.math.uh.edu
Subject: pop3.el: Display the size of the message being fetched (POP3 LIST command)
Date: Fri, 06 Feb 2009 15:34:53 +0100 [thread overview]
Message-ID: <1233930893.25227.1298908581@webmail.messagingengine.com> (raw)
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
next reply other threads:[~2009-02-06 14:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-06 14:34 Bojan Petrovic [this message]
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
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=1233930893.25227.1298908581@webmail.messagingengine.com \
--to=bojan_petrovic@fastmail.fm \
--cc=ding@lists.math.uh.edu \
/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).