From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: multiple POP support for RMAIL Date: Sat, 21 Feb 2004 22:56:37 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: Reply-To: ttn@glug.org NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1077400120 23373 80.91.224.253 (21 Feb 2004 21:48:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 21 Feb 2004 21:48:40 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat Feb 21 22:48:30 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Auez8-00080Y-00 for ; Sat, 21 Feb 2004 22:48:30 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Auez8-0001Vv-00 for ; Sat, 21 Feb 2004 22:48:30 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1Auewa-0003M2-1l for emacs-devel@quimby.gnus.org; Sat, 21 Feb 2004 16:45:52 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1Auevv-0003KZ-FC for emacs-devel@gnu.org; Sat, 21 Feb 2004 16:45:11 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1AuevP-00031S-Bo for emacs-devel@gnu.org; Sat, 21 Feb 2004 16:45:10 -0500 Original-Received: from [151.38.70.208] (helo=surf.glug.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1AuevO-0002yi-0C for emacs-devel@gnu.org; Sat, 21 Feb 2004 16:44:38 -0500 Original-Received: from ttn by surf.glug.org with local (Exim 3.35 #1 (Debian)) id 1Auf6y-0002gy-00 for ; Sat, 21 Feb 2004 22:56:36 +0100 Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:20101 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:20101 RMS asks in message: http://mail.gnu.org/archive/html/emacs-devel/2003-04/msg00216.html if anyone wants to implement multiple POP support for RMAIL. please find below a diff against cvs HEAD rmail.el that does the job, w/ the design constraint of being backward compatible w/ the user command `rmail-set-pop-password'. if this constraint can be avoided, it should be possible to come up w/ a cleaner design, but IMHO it's not worth it. (put enough design effort to RMAIL pop support and you wind up w/ Gnus and/or the question of "why not use Gnus?".) this has been tested (by an interested non-programmer emacs user -- i don't use POP mail personally so i don't have a way to test it w/ cvs HEAD) by back porting the change to 21.3 rmail.el. here is a small blurb that can be massaged into the docs: If you wish to receive mail from more than one POP account, you must set @code{rmail-pop-password} to nil, @code{rmail-pop-password-required} non-nil, and include appropriate @code{po:USER:HOSTNAME} entries in @code{rmail-primary-inbox-list}. This causes Emacs to prompt you for each account's password once per session; there is currently no way to specify multiple passwords non-interactively. that last part sticks in my craw a bit, but fwiw the tester doesn't seem to mind the extra interaction w/ emacs in exchange for the new support. thi Index: rmail.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/mail/rmail.el,v retrieving revision 1.385 diff -c -p -w -c -r1.385 rmail.el *** rmail.el 17 Feb 2004 19:54:49 -0000 1.385 --- rmail.el 19 Feb 2004 08:43:13 -0000 *************** unknown user name or bad password" *** 122,127 **** --- 122,129 ---- If you get an incorrect-password error that this expression does not match, please report it with \\[report-emacs-bug].") + ;; Alist associating pop server w/ password. If there is only one pop server + ;; specified in `rmail-primary-inbox-list', key `t' is used for that. (defvar rmail-encoded-pop-password nil) (defcustom rmail-preserve-inbox nil *************** It returns t if it got any new messages. *** 1518,1524 **** (or (memq (file-locked-p buffer-file-name) '(nil t)) (error "RMAIL file %s is locked" (file-name-nondirectory buffer-file-name))) ! (let (file tofile delete-files movemail popmail got-password password) (while files ;; Handle POP mailbox names specially; don't expand as filenames ;; in case the userid contains a directory separator. --- 1520,1532 ---- (or (memq (file-locked-p buffer-file-name) '(nil t)) (error "RMAIL file %s is locked" (file-name-nondirectory buffer-file-name))) ! (let (file tofile delete-files movemail popmail got-password password ! ;; wasteful --ttn ! (popcount (apply '+ (mapcar (function ! (lambda (file) ! (if (string-match "^po:" file) ! 1 0))) ! files)))) (while files ;; Handle POP mailbox names specially; don't expand as filenames ;; in case the userid contains a directory separator. *************** It returns t if it got any new messages. *** 1557,1564 **** file))))) (cond (popmail (if rmail-pop-password-required ! (progn (setq got-password (not (rmail-have-password))) ! (setq password (rmail-get-pop-password)))) (if (memq system-type '(windows-nt cygwin)) ;; cannot have "po:" in file name (setq tofile --- 1565,1575 ---- file))))) (cond (popmail (if rmail-pop-password-required ! (let ((host (unless (= 1 popcount) ! (string-match ".+:" file) ! (substring file (match-end 0))))) ! (setq got-password (not (rmail-have-password host))) ! (setq password (rmail-get-pop-password host)))) (if (memq system-type '(windows-nt cygwin)) ;; cannot have "po:" in file name (setq tofile *************** TEXT and INDENT are not used." *** 3824,3850 **** ; nor is it meant to be. ;;;###autoload ! (defun rmail-set-pop-password (password) "Set PASSWORD to be used for retrieving mail from a POP server." (interactive "sPassword: ") (if password (setq rmail-encoded-pop-password ! (rmail-encode-string password (emacs-pid))) (setq rmail-pop-password nil) (setq rmail-encoded-pop-password nil))) ! (defun rmail-get-pop-password () "Get the password for retrieving mail from a POP server. If none ! has been set, then prompt the user for one." ! (if (not rmail-encoded-pop-password) ! (progn (if (not rmail-pop-password) ! (setq rmail-pop-password (read-passwd "POP password: "))) ! (rmail-set-pop-password rmail-pop-password) ! (setq rmail-pop-password nil))) ! (rmail-encode-string rmail-encoded-pop-password (emacs-pid))) ! ! (defun rmail-have-password () ! (or rmail-pop-password rmail-encoded-pop-password)) (defun rmail-encode-string (string mask) "Encode STRING with integer MASK, by taking the exclusive OR of the --- 3835,3871 ---- ; nor is it meant to be. ;;;###autoload ! (defun rmail-set-pop-password (password &optional host) "Set PASSWORD to be used for retrieving mail from a POP server." (interactive "sPassword: ") (if password (setq rmail-encoded-pop-password ! (cons (cons (or host t) (rmail-encode-string password (emacs-pid))) ! rmail-encoded-pop-password)) (setq rmail-pop-password nil) (setq rmail-encoded-pop-password nil))) ! (defun rmail-get-pop-password (&optional host) "Get the password for retrieving mail from a POP server. If none ! has been set, then prompt the user for one. Optional arg HOST means ! this password is to be used for HOST only." ! (when (or (not rmail-encoded-pop-password) ! (and host (not (assoc host rmail-encoded-pop-password)))) ! (when (not rmail-pop-password) ! (setq rmail-pop-password ! (read-passwd (format "POP password%s: " ! (if (stringp host) ! (concat " for " host) ! ""))))) ! (rmail-set-pop-password rmail-pop-password host) ! (setq rmail-pop-password nil)) ! (rmail-encode-string (cdr (assoc (or host t) rmail-encoded-pop-password)) ! (emacs-pid))) ! ! (defun rmail-have-password (&optional host) ! (or rmail-pop-password ! (and rmail-encoded-pop-password ! (assoc (or host t) rmail-encoded-pop-password)))) (defun rmail-encode-string (string mask) "Encode STRING with integer MASK, by taking the exclusive OR of the