Function: mail-source-movemail
mail-source-movemail is a byte-compiled function defined in
mail-source.el.gz.
Signature
(mail-source-movemail FROM TO)
Documentation
Move FROM to TO using movemail.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/mail-source.el.gz
(defun mail-source-movemail (from to)
"Move FROM to TO using movemail."
(if (not (file-writable-p to))
(error "Can't write to crash box %s. Not moving mail" to)
(let ((to (file-truename (expand-file-name to)))
errors result)
(setq to (file-truename to)
from (file-truename from))
;; Set TO if have not already done so, and rename or copy
;; the file FROM to TO if and as appropriate.
(cond
((file-exists-p to)
;; The crash box exists already.
t)
((not (file-exists-p from))
;; There is no inbox.
(setq to nil))
((zerop (file-attribute-size (file-attributes from)))
;; Empty file.
(setq to nil))
(t
;; If getting from mail spool directory, use movemail to move
;; rather than just renaming, so as to interlock with the
;; mailer.
(save-excursion
(setq errors (generate-new-buffer " *mail source loss*"))
(let ((default-directory "/"))
(setq result
;; call-process looks in exec-path, which
;; contains exec-directory, so will find
;; Mailutils movemail if it exists, else it will
;; find "our" movemail in exec-directory.
;; Bug#31737
(apply
#'call-process
(append
(list
mail-source-movemail-program
nil errors nil from to)))))
(when (file-exists-p to)
(set-file-modes to mail-source-default-file-modes 'nofollow))
(if (and (or (not (buffer-modified-p errors))
(zerop (buffer-size errors)))
(and (numberp result)
(zerop result)))
;; No output => movemail won.
t
(set-buffer errors)
;; There may be a warning about older revisions. We
;; ignore that.
(goto-char (point-min))
(if (search-forward "older revision" nil t)
t
;; Probably a real error.
(subst-char-in-region (point-min) (point-max) ?\n ?\ )
(goto-char (point-max))
(skip-chars-backward " \t")
(delete-region (point) (point-max))
(goto-char (point-min))
(when (looking-at "movemail: ")
(delete-region (point-min) (match-end 0)))
;; Result may be a signal description string.
(unless (yes-or-no-p
(format "movemail: %s (%s return). Continue? "
(buffer-string) result))
(error "%s" (buffer-string)))
(setq to nil))))))
(when (buffer-live-p errors)
(kill-buffer errors))
;; Return whether we moved successfully or not.
to)))