unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* multiple POP support for RMAIL
@ 2004-02-21 21:56 Thien-Thi Nguyen
  2004-02-22  0:05 ` Robert J. Chassell
  0 siblings, 1 reply; 5+ messages in thread
From: Thien-Thi Nguyen @ 2004-02-21 21:56 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-03-06 22:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-21 21:56 multiple POP support for RMAIL Thien-Thi Nguyen
2004-02-22  0:05 ` 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

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).