;;; rmailout.el --- "RMAIL" mail reader for Emacs: output message to a file
;; Copyright (C) 1985, 1987, 1993, 1994, 2001, 2002, 2003, 2004, 2005,
-;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: mail
:type 'boolean
:group 'rmail-output)
+;; FIXME risky?
(defcustom rmail-output-file-alist nil
"Alist matching regexps to suggested output Rmail files.
This is a list of elements of the form (REGEXP . NAME-EXP).
(string :tag "File Name")
sexp)))
:group 'rmail-output)
+;;;###autoload(put 'rmail-output-file-alist 'risky-local-variable t)
(defcustom rmail-fields-not-to-output nil
"Regexp describing fields to exclude when outputting a message to a file.
(save-restriction
(unless (looking-at "^From ")
(error "Invalid mbox message"))
- (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
+ (insert "\^L\n0,,\n*** EOOH ***\n")
(rmail-nuke-pinhead-header)
;; Decode base64 or quoted printable contents, Rmail style.
(let* ((header-end (save-excursion
(widen)
;; Make sure message ends with blank line.
(goto-char (point-max))
- (unless (bolp)
- (insert "\n"))
- (unless (looking-back "\n\n")
- (insert "\n"))
+ (rmail-ensure-blank-line)
(goto-char (point-min))
(let ((buf (find-buffer-visiting file-name))
(tembuf (current-buffer)))
(if (null buf)
(let ((coding-system-for-write 'raw-text-unix))
+ ;; FIXME should ensure existing file ends with a blank line.
(write-region (point-min) (point-max) file-name t nomsg))
(if (eq buf (current-buffer))
(error "Can't output message to same file it's already in"))
display message number MSG."
(save-excursion
(rmail-swap-buffers-maybe)
- ;; Turn on Auto Save mode, if it's off in this
- ;; buffer but enabled by default.
+ (rmail-modify-format)
+ ;; Turn on Auto Save mode, if it's off in this buffer but enabled
+ ;; by default.
(and (not buffer-auto-save-file-name)
auto-save-default
(auto-save-mode t))
(rmail-maybe-set-message-counters)
+ ;; Insert the new message after the last old message.
+ (widen)
+ ;; Make sure the last old message ends with a blank line.
+ (goto-char (point-max))
+ (rmail-ensure-blank-line)
+ ;; Insert the new message at the end.
(narrow-to-region (point-max) (point-max))
(insert-buffer-substring tembuf)
(rmail-count-new-messages t)
+ ;; FIXME should re-use existing windows.
(if (rmail-summary-exists)
(rmail-select-summary (rmail-update-summary)))
(rmail-show-message-1 msg)))
(if noattribute (setq noattribute 'nomsg))
(let ((babyl-format (and (file-readable-p file-name)
(mail-file-babyl-p file-name)))
- (cur (current-buffer)))
+ (cur (current-buffer))
+ (buf (find-buffer-visiting file-name)))
+
+ ;; If a babyl file is visited in a buffer, is it visited as babyl
+ ;; or as mbox?
+ (and babyl-format buf
+ (with-current-buffer buf
+ (save-restriction
+ (widen)
+ (save-excursion
+ (goto-char (point-min))
+ (setq babyl-format
+ (looking-at "BABYL OPTIONS:"))))))
+
(if not-rmail ; eg via message-fcc-handler-function
(with-temp-buffer
(insert-buffer-substring cur)
;; 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: