Function: rmail-output-body-to-file

rmail-output-body-to-file is an autoloaded, interactive and byte-compiled function defined in rmailout.el.gz.

Signature

(rmail-output-body-to-file FILE-NAME)

Documentation

Write this message body to the file FILE-NAME.

Interactively, the default file name comes from either the message
"Subject" header, or from rmail-default-body-file. Updates the value
of rmail-default-body-file accordingly. In all uses, if FILE-NAME is not absolute, it is expanded with the directory part of rmail-default-body-file.

Note that this overwrites FILE-NAME (after confirmation), rather than appending to it. Deletes the message after writing if rmail-delete-after-output is non-nil.

Probably introduced at or before Emacs version 20.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmailout.el.gz
;;;###autoload
(defun rmail-output-body-to-file (file-name)
  "Write this message body to the file FILE-NAME.
Interactively, the default file name comes from either the message
\"Subject\" header, or from `rmail-default-body-file'.  Updates the value
of `rmail-default-body-file' accordingly.  In all uses, if FILE-NAME
is not absolute, it is expanded with the directory part of
`rmail-default-body-file'.

Note that this overwrites FILE-NAME (after confirmation), rather
than appending to it.  Deletes the message after writing if
`rmail-delete-after-output' is non-nil."
  (interactive
   (let ((default-file
	   (or (mail-fetch-field "Subject")
	       rmail-default-body-file)))
     (setq default-file
	   (string-replace ":" "-" default-file))
     (setq default-file
	   (string-replace " " "-" default-file))
     (list (setq rmail-default-body-file
		 (read-file-name
		  "Output message body to file: "
		  (and default-file (file-name-directory default-file))
		  default-file
		  nil default-file)))))
  (setq file-name
	(expand-file-name file-name
			  (and rmail-default-body-file
			       (file-name-directory rmail-default-body-file))))
  (if (zerop rmail-current-message)
      (error "No message to output"))
  (save-excursion
    (goto-char (point-min))
    (search-forward "\n\n")
    (and (file-exists-p file-name)
	 (not (y-or-n-p (format "File %s exists; overwrite? " file-name)))
	 (error "Operation aborted"))
    (write-region (point) (point-max) file-name))
  (if rmail-delete-after-output
      (rmail-delete-forward)))