Function: rmail-parse-url
rmail-parse-url is a byte-compiled function defined in rmail.el.gz.
Signature
(rmail-parse-url FILE)
Documentation
Parse a mailbox URL string FILE.
Return (MAILBOX-NAME PROTO PASSWORD GOT-PASSWORD), where MAILBOX-NAME is
the name of the mailbox suitable as argument to the actual version of
movemail, PROTO is the movemail protocol (use rmail-remote-proto-p
to see if it refers to a remote mailbox), PASSWORD is the password if it
should be supplied as a separate argument to movemail or nil otherwise,
and GOT-PASSWORD is non-nil if the user has supplied the password
interactively.
Source Code
;; Defined in /usr/src/emacs/lisp/mail/rmail.el.gz
(defun rmail-parse-url (file)
"Parse a mailbox URL string FILE.
Return (MAILBOX-NAME PROTO PASSWORD GOT-PASSWORD), where MAILBOX-NAME is
the name of the mailbox suitable as argument to the actual version of
`movemail', PROTO is the movemail protocol (use `rmail-remote-proto-p'
to see if it refers to a remote mailbox), PASSWORD is the password if it
should be supplied as a separate argument to `movemail' or nil otherwise,
and GOT-PASSWORD is non-nil if the user has supplied the password
interactively."
(cond
((string-match "^\\([^:]+\\)://\\(\\([^:@]+\\)\\(:\\([^@]+\\)\\)?@\\)?.*" file)
(let (got-password supplied-password
(proto (match-string 1 file))
(user (match-string 3 file))
(pass (match-string 5 file))
(host (substring file (or (match-end 2)
(+ 3 (match-end 1))))))
(if (rmail-remote-proto-p proto)
(if (not pass)
(when rmail-remote-password-required
(setq got-password (not (rmail-have-password)))
(setq supplied-password (rmail-get-remote-password
(string-match "^imaps?" proto)
user host)))
;; FIXME
;; The password is embedded. Strip it out since movemail
;; does not really like it, in spite of the movemail spec.
(setq file (concat proto "://" user "@" host))))
(if (rmail-movemail-variant-p 'emacs)
(if (string-equal proto "pop")
(list (concat "po:" user ":" host)
proto
(or pass supplied-password)
got-password)
(error "Emacs movemail does not support %s protocol" proto))
(list file
proto
(or supplied-password pass)
got-password))))
((string-match "^po:\\([^:]+\\)\\(:\\(.*\\)\\)?" file)
(let (got-password supplied-password
(user (match-string 1 file))
(host (match-string 3 file)))
(when rmail-remote-password-required
(setq got-password (not (rmail-have-password)))
(setq supplied-password (rmail-get-remote-password nil user host)))
(list file "pop" supplied-password got-password)))
(t
(list file nil nil nil))))