comparison lisp/mail/rmail.el @ 61223:cf375e6ff77b

(rmail-parse-url): Bugfix. Parse traditional mailbox specifications as well as URLs. (rmail-insert-inbox-text): Remove unused conditional branches.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 02 Apr 2005 11:31:06 +0000
parents e2880855e3d0
children b543e1be9df2 7a3341d65a12
comparison
equal deleted inserted replaced
61222:c7ea442c39c8 61223:cf375e6ff77b
1620 actual version of `movemail', REMOTE is non-nil if MAILBOX-NAME refers to 1620 actual version of `movemail', REMOTE is non-nil if MAILBOX-NAME refers to
1621 a remote mailbox, PASSWORD is the password if it should be 1621 a remote mailbox, PASSWORD is the password if it should be
1622 supplied as a separate argument to `movemail' or nil otherwise, GOT-PASSWORD 1622 supplied as a separate argument to `movemail' or nil otherwise, GOT-PASSWORD
1623 is non-nil if the user has supplied the password interactively. 1623 is non-nil if the user has supplied the password interactively.
1624 " 1624 "
1625 (if (string-match "^\\([^:]+\\)://\\(\\([^:@]+\\)\\(:\\([^@]+\\)\\)?@\\)?.*" file) 1625 (cond
1626 ((string-match "^\\([^:]+\\)://\\(\\([^:@]+\\)\\(:\\([^@]+\\)\\)?@\\)?.*" file)
1626 (let (got-password supplied-password 1627 (let (got-password supplied-password
1627 (proto (match-string 1 file)) 1628 (proto (match-string 1 file))
1628 (user (match-string 3 file)) 1629 (user (match-string 3 file))
1629 (pass (match-string 5 file)) 1630 (pass (match-string 5 file))
1630 (host (substring file (or (match-end 2) 1631 (host (substring file (or (match-end 2)
1631 (+ 3 (match-end 1)))))) 1632 (+ 3 (match-end 1))))))
1633
1632 (if (not pass) 1634 (if (not pass)
1633 (when rmail-remote-password-required 1635 (when rmail-remote-password-required
1634 (setq got-password (not (rmail-have-password))) 1636 (setq got-password (not (rmail-have-password)))
1635 (setq supplied-password (rmail-get-remote-password 1637 (setq supplied-password (rmail-get-remote-password
1636 (string-equal proto "imap"))))) 1638 (string-equal proto "imap")))))
1643 got-password) 1645 got-password)
1644 (error "Emacs movemail does not support %s protocol" proto)) 1646 (error "Emacs movemail does not support %s protocol" proto))
1645 (list file 1647 (list file
1646 (or (string-equal proto "pop") (string-equal proto "imap")) 1648 (or (string-equal proto "pop") (string-equal proto "imap"))
1647 supplied-password 1649 supplied-password
1648 got-password))) 1650 got-password))))
1649 (list file nil nil nil))) 1651
1652 ((string-match "^po:\\([^:]+\\)\\(:\\(.*\\)\\)?" file)
1653 (let (got-password supplied-password
1654 (proto "pop")
1655 (user (match-string 1 file))
1656 (host (match-string 3 file)))
1657
1658 (when rmail-remote-password-required
1659 (setq got-password (not (rmail-have-password)))
1660 (setq supplied-password (rmail-get-remote-password nil)))
1661
1662 (list file "pop" supplied-password got-password)))
1663
1664 (t
1665 (list file nil nil nil))))
1650 1666
1651 (defun rmail-insert-inbox-text (files renamep) 1667 (defun rmail-insert-inbox-text (files renamep)
1652 ;; Detect a locked file now, so that we avoid moving mail 1668 ;; Detect a locked file now, so that we avoid moving mail
1653 ;; out of the real inbox file. (That could scare people.) 1669 ;; out of the real inbox file. (That could scare people.)
1654 (or (memq (file-locked-p buffer-file-name) '(nil t)) 1670 (or (memq (file-locked-p buffer-file-name) '(nil t))
1684 ;; file isn't. 1700 ;; file isn't.
1685 (file-name-directory 1701 (file-name-directory
1686 (expand-file-name buffer-file-name)))) 1702 (expand-file-name buffer-file-name))))
1687 ;; Always use movemail to rename the file, 1703 ;; Always use movemail to rename the file,
1688 ;; since there can be mailboxes in various directories. 1704 ;; since there can be mailboxes in various directories.
1689 (setq movemail t) 1705 (if (not popmail)
1690 ;;; ;; If getting from mail spool directory,
1691 ;;; ;; use movemail to move rather than just renaming,
1692 ;;; ;; so as to interlock with the mailer.
1693 ;;; (setq movemail (string= file
1694 ;;; (file-truename
1695 ;;; (concat rmail-spool-directory
1696 ;;; (file-name-nondirectory file)))))
1697 (if (and movemail (not popmail))
1698 (progn 1706 (progn
1699 ;; On some systems, /usr/spool/mail/foo is a directory 1707 ;; On some systems, /usr/spool/mail/foo is a directory
1700 ;; and the actual inbox is /usr/spool/mail/foo/foo. 1708 ;; and the actual inbox is /usr/spool/mail/foo/foo.
1701 (if (file-directory-p file) 1709 (if (file-directory-p file)
1702 (setq file (expand-file-name (user-login-name) 1710 (setq file (expand-file-name (user-login-name)
1714 (cond ((not renamep) 1722 (cond ((not renamep)
1715 (setq tofile file)) 1723 (setq tofile file))
1716 ((or (file-exists-p tofile) (and (not popmail) 1724 ((or (file-exists-p tofile) (and (not popmail)
1717 (not (file-exists-p file)))) 1725 (not (file-exists-p file))))
1718 nil) 1726 nil)
1719 ((and (not movemail) (not popmail))
1720 ;; Try copying. If that fails (perhaps no space) and
1721 ;; we're allowed to blow away the inbox, rename instead.
1722 (if rmail-preserve-inbox
1723 (copy-file file tofile nil)
1724 (condition-case nil
1725 (copy-file file tofile nil)
1726 (error
1727 ;; Third arg is t so we can replace existing file TOFILE.
1728 (rename-file file tofile t))))
1729 ;; Make the real inbox file empty.
1730 ;; Leaving it deleted could cause lossage
1731 ;; because mailers often won't create the file.
1732 (if (not rmail-preserve-inbox)
1733 (condition-case ()
1734 (write-region (point) (point) file)
1735 (file-error nil))))
1736 (t 1727 (t
1737 (with-temp-buffer 1728 (with-temp-buffer
1738 (let ((errors (current-buffer))) 1729 (let ((errors (current-buffer)))
1739 (buffer-disable-undo errors) 1730 (buffer-disable-undo errors)
1740 (let ((args 1731 (let ((args