From: Thien-Thi Nguyen <ttn@surf.glug.org>
Subject: multiple POP support for RMAIL
Date: Sat, 21 Feb 2004 22:56:37 +0100 [thread overview]
Message-ID: <E1Auf6y-0002gy-00@surf.glug.org> (raw)
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
next reply other threads:[~2004-02-21 21:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-21 21:56 Thien-Thi Nguyen [this message]
2004-02-22 0:05 ` multiple POP support for RMAIL Robert J. Chassell
2004-02-22 11:14 ` Thien-Thi Nguyen
2004-02-22 13:43 ` Robert J. Chassell
2004-03-06 22:31 ` Thien-Thi Nguyen
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1Auf6y-0002gy-00@surf.glug.org \
--to=ttn@surf.glug.org \
--cc=ttn@glug.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).