Function: gnus-output-to-mail
gnus-output-to-mail is a byte-compiled function defined in
gnus-util.el.gz.
Signature
(gnus-output-to-mail FILENAME &optional ASK)
Documentation
Append the current article to a mail file named FILENAME.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gnus-util.el.gz
(defun gnus-output-to-mail (filename &optional ask)
"Append the current article to a mail file named FILENAME."
(require 'nnmail)
(setq filename (expand-file-name filename))
(let ((artbuf (current-buffer))
(tmpbuf (gnus-get-buffer-create " *Gnus-output*")))
(save-excursion
;; Create the file, if it doesn't exist.
(when (and (not (get-file-buffer filename))
(not (file-exists-p filename)))
(if (or (not ask)
(gnus-y-or-n-p
(concat "\"" filename "\" does not exist, create it? ")))
(let ((file-buffer (create-file-buffer filename)))
(with-current-buffer file-buffer
(let ((require-final-newline nil)
(coding-system-for-write mm-text-coding-system))
(gnus-write-buffer filename)))
(kill-buffer file-buffer))
(error "Output file does not exist")))
(set-buffer tmpbuf)
(erase-buffer)
(insert-buffer-substring artbuf)
(goto-char (point-min))
(if (looking-at "From ")
(forward-line 1)
(insert "From nobody " (current-time-string) "\n"))
(let (case-fold-search)
(while (re-search-forward "^From " nil t)
(beginning-of-line)
(insert ">")))
;; Decide whether to append to a file or to an Emacs buffer.
(let ((outbuf (get-file-buffer filename)))
(if (not outbuf)
(let ((buffer-read-only nil))
(save-excursion
(goto-char (point-max))
(forward-char -2)
(unless (looking-at "\n\n")
(goto-char (point-max))
(unless (bolp)
(insert "\n"))
(insert "\n"))
(goto-char (point-max))
(let ((file-name-coding-system nnmail-pathname-coding-system))
(mm-append-to-file (point-min) (point-max) filename))))
;; File has been visited, in buffer OUTBUF.
(set-buffer outbuf)
(let ((buffer-read-only nil))
(goto-char (point-max))
(unless (eobp)
(insert "\n"))
(insert "\n")
(insert-buffer-substring tmpbuf)))))
(kill-buffer tmpbuf)))