;;; rmailout.el --- "RMAIL" mail reader for Emacs: output message to a file
-;; Copyright (C) 1985, 1987, 1993, 1994, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1993, 1994, 2001, 2002, 2003, 2004,
+;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: mail
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
(let ((read-file
(expand-file-name
(read-file-name
- (concat "Output message to Rmail file: (default "
+ (concat "Output message to Rmail file (default "
(file-name-nondirectory default-file)
- ") ")
+ "): ")
(file-name-directory default-file)
(abbreviate-file-name default-file))
(file-name-directory default-file))))
(let ((read-file
(expand-file-name
(read-file-name
- (concat "Output message to Unix mail file: (default "
+ (concat "Output message to Unix mail file (default "
(file-name-nondirectory default-file)
- ") ")
+ "): ")
(file-name-directory default-file)
(abbreviate-file-name default-file))
(file-name-directory default-file))))
(or read-file (file-name-nondirectory default-file))
(file-name-directory default-file)))))))
+(declare-function rmail-update-summary "rmailsum" (&rest ignore))
+
;;; There are functions elsewhere in Emacs that use this function;
;;; look at them before you change the calling method.
;;;###autoload
The default file name comes from `rmail-default-rmail-file',
which is updated to the name you use in this command.
-A prefix argument N says to output N consecutive messages
+A prefix argument COUNT says to output that many consecutive messages,
starting with the current one. Deleted messages are skipped and don't count.
-If optional argument STAY is non-nil, then leave the last filed
-mesasge up instead of moving forward to the next non-deleted message."
+If the optional argument STAY is non-nil, then leave the last filed
+message up instead of moving forward to the next non-deleted message."
(interactive
(list (rmail-output-read-rmail-file-name)
(prefix-numeric-value current-prefix-arg)))
(if redelete (rmail-set-attribute "deleted" t))))
(setq count (1- count))
(if rmail-delete-after-output
- (unless
+ (unless
(if (and (= count 0) stay)
(rmail-delete-message)
(rmail-delete-forward))
(setq count 0))
(if (> count 0)
- (unless
+ (unless
(if (not stay) (rmail-next-undeleted-message 1))
(setq count 0)))))))
;; NOT-RMAIL if t means this buffer does not have the full header
;; and *** EOOH *** that a message in an Rmail file has.
(defun rmail-delete-unwanted-fields (&optional not-rmail)
- (if rmail-fields-not-to-output
+ (if rmail-fields-not-to-output
(save-excursion
(goto-char (point-min))
;; Find the end of the header.
;;;###autoload
(defun rmail-output (file-name &optional count noattribute from-gnus)
"Append this message to system-inbox-format mail file named FILE-NAME.
-A prefix argument N says to output N consecutive messages
+A prefix argument COUNT says to output that many consecutive messages,
starting with the current one. Deleted messages are skipped and don't count.
-When called from lisp code, N may be omitted.
+When called from lisp code, COUNT may be omitted and defaults to 1.
If the pruned message header is shown on the current message, then
messages will be appended with pruned headers; otherwise, messages
(tembuf (get-buffer-create " rmail-output"))
(original-headers-p
(and (not from-gnus)
- (save-excursion
+ (save-excursion
(save-restriction
(narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
(goto-char (point-min))
(forward-line 1)
(= (following-char) ?0)))))
header-beginning
- mail-from mime-version)
+ mail-from mime-version content-type)
(while (> count 0)
;; Preserve the Mail-From and MIME-Version fields
;; even if they have been pruned.
(setq header-beginning (point))
(search-forward "\n*** EOOH ***\n")
(narrow-to-region header-beginning (point))
- (setq mail-from
- (mail-fetch-field "Mail-From")
- mime-version
- (unless rmail-enable-mime
- (mail-fetch-field "MIME-Version"))))))
+ (setq mail-from (mail-fetch-field "Mail-From"))
+ (unless rmail-enable-mime
+ (setq mime-version (mail-fetch-field "MIME-Version")
+ content-type (mail-fetch-field "Content-type"))))))
(save-excursion
(set-buffer tembuf)
(erase-buffer)
(mail-fetch-field "sender")
"unknown"))
" " (current-time-string) "\n"))
- (if mime-version
- (insert "MIME-Version: " mime-version "\n"))
+ (when mime-version
+ (insert "MIME-Version: " mime-version)
+ ;; Some malformed MIME messages set content-type to nil.
+ (when content-type
+ (insert "\nContent-type: " content-type "\n")))
;; ``Quote'' "\nFrom " as "\n>From "
;; (note that this isn't really quoting, as there is no requirement
;; that "\n[>]+From " be quoted in the same transparent way.)
(if (and next-message-p original-headers-p)
(rmail-toggle-header))
(if (and (> count 0) (not next-message-p))
- (progn
- (error
+ (progn
+ (error "%s"
(save-excursion
(set-buffer rmailbuf)
(format "Only %d message%s appended" num-appended
(goto-char (point-min))
(search-forward "\n\n")
(and (file-exists-p file-name)
- (not (y-or-n-p (message "File %s exists; overwrite? " 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 (equal major-mode 'rmail-mode)
(if rmail-delete-after-output
(rmail-delete-forward)))
+;; arch-tag: 447117c6-1a9a-4b88-aa43-3101b043e3a4
;;; rmailout.el ends here