@kindex C-o @r{(Rmail)}
@findex rmail-output-as-seen
The commands @kbd{o} and @kbd{C-o} copy the current message into a
-specified file, adding it at the end. The two commands differ mainly
-in how much to copy: @kbd{o} copies the full message headers, even if
-they are not all visible, while @kbd{C-o} copies exactly the headers
-currently displayed and no more. @xref{Rmail Display}. In addition,
-@kbd{o} converts the message to Babyl format (used by Rmail in Emacs
-version 22 and before) if the file is in Babyl format; @kbd{C-o}
-cannot output to Babyl files at all.
+specified file, adding it at the end. A positive prefix argument
+serves as a repeat count: that many consecutive messages will be
+copied to the specified file, starting with the current one and
+ignoring deleted messages.
+
+The two commands differ mainly in how much to copy: @kbd{o} copies the
+full message headers, even if they are not all visible, while
+@kbd{C-o} copies exactly the headers currently displayed and no more.
+@xref{Rmail Display}. In addition, @kbd{o} converts the message to
+Babyl format (used by Rmail in Emacs version 22 and before) if the
+file is in Babyl format; @kbd{C-o} cannot output to Babyl files at
+all.
@c FIXME remove BABYL mention in some future version?
If the output file is currently visited in an Emacs buffer, the
match the regular expression). If no files match, you cannot select
this menu item.
-@vindex rmail-delete-after-output
Copying a message with @kbd{o} or @kbd{C-o} gives the original copy
of the message the @samp{filed} attribute, so that @samp{filed}
appears in the mode line when such a message is current.
+@vindex rmail-delete-after-output
If you like to keep just a single copy of every mail message, set
the variable @code{rmail-delete-after-output} to @code{t}; then the
@kbd{o}, @kbd{C-o} and @kbd{w} commands delete the original message
after copying it. (You can undelete it afterward if you wish, see
@ref{Rmail Deletion}.)
+@vindex rmail-output-reset-deleted-flag
+ By default, @kbd{o} will leave the deleted status of a message it
+outputs as it was on the original message; thus, a message deleted
+before it was output will appear as deleted in the output file.
+Setting the variable @code{rmail-output-reset-deleted-flag} to a
+non-@code{nil} value countermands that: the copy of the message will
+have its deleted status reset, so the message will appear as undeleted
+in the output file. In addition, when this variable is
+non-@code{nil}, specifying a positive argument to @kbd{o} will not
+ignore deleted messages when looking for consecutive messages to
+output.
+
@vindex rmail-output-file-alist
The variable @code{rmail-output-file-alist} lets you specify
intelligent defaults for the output file, based on the contents of the
regexp)
:group 'rmail-output)
+(defcustom rmail-output-reset-deleted-flag nil
+ "Non-nil means reset the \"deleted\" flag when outputting a message to a file."
+ :type '(choice (const :tag "Output with the \"deleted\" flag reset" t)
+ (const :tag "Output with the \"deleted\" flag intact" nil))
+ :version "27.1"
+ :group 'rmail-output)
+
(defun rmail-output-read-file-name ()
"Read the file name to use for `rmail-output'.
Set `rmail-default-file' to this name as well as returning it.
This command always outputs the complete message header, even if
the header display is currently pruned.
+If `rmail-output-reset-deleted-flag' is non-nil, the message's
+deleted flag is reset in the message appended to the destination
+file. Otherwise, the appended message will remain marked as
+deleted if it was deleted before invoking this command.
+
Optional prefix argument COUNT (default 1) says to output that
many consecutive messages, starting with the current one (ignoring
-deleted messages). If `rmail-delete-after-output' is non-nil, deletes
+deleted messages, unless `rmail-output-reset-deleted-flag' is
+non-nil). If `rmail-delete-after-output' is non-nil, deletes
messages after output.
The optional third argument NOATTRIBUTE, if non-nil, says not to
(if (zerop rmail-total-messages)
(error "No messages to output"))
(let ((orig-count count)
- beg end)
+ beg end delete-attr-reset-p)
(while (> count 0)
- (setq beg (rmail-msgbeg rmail-current-message)
- end (rmail-msgend rmail-current-message))
- ;; All access to the buffer's local variables is now finished...
- (save-excursion
- ;; ... so it is ok to go to a different buffer.
- (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer))
- (setq cur (current-buffer))
- (save-restriction
- (widen)
- (with-temp-buffer
- (insert-buffer-substring cur beg end)
- (if babyl-format
- (rmail-output-as-babyl file-name noattribute)
- (rmail-output-as-mbox file-name noattribute)))))
+ (when (and rmail-output-reset-deleted-flag
+ (rmail-message-deleted-p rmail-current-message))
+ (rmail-set-attribute rmail-deleted-attr-index nil)
+ (setq delete-attr-reset-p t))
+ ;; Make sure we undo our messing with the DELETED attribute.
+ (unwind-protect
+ (progn
+ (setq beg (rmail-msgbeg rmail-current-message)
+ end (rmail-msgend rmail-current-message))
+ ;; All access to the buffer's local variables is now finished...
+ (save-excursion
+ ;; ... so it is ok to go to a different buffer.
+ (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer))
+ (setq cur (current-buffer))
+ (save-restriction
+ (widen)
+ (with-temp-buffer
+ (insert-buffer-substring cur beg end)
+ (if babyl-format
+ (rmail-output-as-babyl file-name noattribute)
+ (rmail-output-as-mbox file-name noattribute))))))
+ (if delete-attr-reset-p
+ (rmail-set-attribute rmail-deleted-attr-index 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))))
+ (if rmail-output-reset-deleted-flag
+ (progn
+ (if rmail-delete-after-output
+ (rmail-delete-message))
+ (if (> count 0)
+ (let ((msgnum rmail-current-message))
+ (rmail-next-message 1)
+ (eq rmail-current-message (1+ msgnum)))))
+ (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