Function: rmail-output-as-seen

rmail-output-as-seen is an autoloaded, interactive and byte-compiled function defined in rmailout.el.gz.

Signature

(rmail-output-as-seen FILE-NAME &optional COUNT NOATTRIBUTE NOT-RMAIL)

Documentation

Append this message to mbox file named FILE-NAME.

The details are as for rmail-output, except that:
  i) the header is output as currently seen
 ii) this function cannot write to Babyl files
iii) an Rmail buffer cannot be visiting FILE-NAME

Note that if NOT-RMAIL is non-nil, there is no difference between this function and rmail-output. This argument may be removed in future, so you should call rmail-output directly in that case.

View in manual

Probably introduced at or before Emacs version 23.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmailout.el.gz
;; FIXME nothing outside uses this, so NOT-RMAIL could be dropped.
;; FIXME this duplicates code from rmail-output.
;;;###autoload
(defun rmail-output-as-seen (file-name &optional count noattribute not-rmail)
  "Append this message to mbox file named FILE-NAME.
The details are as for `rmail-output', except that:
  i) the header is output as currently seen
 ii) this function cannot write to Babyl files
iii) an Rmail buffer cannot be visiting FILE-NAME

Note that if NOT-RMAIL is non-nil, there is no difference between this
function and `rmail-output'.  This argument may be removed in future,
so you should call `rmail-output' directly in that case."
  (interactive
   (list (rmail-output-read-file-name)
	 (prefix-numeric-value current-prefix-arg)))
  (if not-rmail
      (rmail-output file-name count noattribute not-rmail)
    (or count (setq count 1))
    (setq file-name
	  (expand-file-name file-name
			    (and rmail-default-file
				 (file-name-directory rmail-default-file))))
    ;; Warn about creating new file.
    (or (find-buffer-visiting file-name)
	(file-exists-p file-name)
	(yes-or-no-p (concat "\"" file-name "\" does not exist, create it? "))
	(error "Output file does not exist"))
    ;; FIXME why not?
    (if (and (file-readable-p file-name) (mail-file-babyl-p file-name))
	(error "Cannot output `as seen' to a Babyl file"))
    (if noattribute (setq noattribute 'nomsg))
    (if rmail-buffer
	(set-buffer rmail-buffer)
      (error "There is no Rmail buffer"))
    (if (zerop rmail-total-messages)
	(error "No messages to output"))
    (let ((orig-count count)
	  (cur (current-buffer)))
      (while (> count 0)
	(let (beg end)
	  ;; If operating from whole-mbox buffer, get message bounds.
	  (or (rmail-buffers-swapped-p)
	      (setq beg (rmail-msgbeg rmail-current-message)
		    end (rmail-msgend rmail-current-message)))
	  (save-restriction
	    (widen)
	    ;; If operating from the view buffer, get the bounds.
	    (or beg
		(setq beg (point-min)
		      end (point-max)))
	    (with-temp-buffer
	      (insert-buffer-substring cur beg end)
	      (rmail-output-as-mbox file-name noattribute t))))
	(or noattribute		; mark message as "filed"
	    (rmail-set-attribute rmail-filed-attr-index t))
	(setq count (1- count))
	(let ((next-message-p
	       (if rmail-delete-after-output
		   (rmail-delete-forward)
		 (if (> count 0)
		     (rmail-next-undeleted-message 1))))
	      (num-appended (- orig-count count)))
	  (if (and (> count 0) (not next-message-p))
	      (error "Only %d message%s appended" num-appended
		     (if (= num-appended 1) "" "s"))))))))