aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2009-02-17 02:54:14 +0000
committerGlenn Morris2009-02-17 02:54:14 +0000
commit1640a85f9c5bc25a42cf88e68e8f7e1dd227cf42 (patch)
tree06f346e40a0a5342e2768a841b280859739034d4
parent72e892eb3aea4f3a9e83e743cbaafe4bd932eb8a (diff)
downloademacs-1640a85f9c5bc25a42cf88e68e8f7e1dd227cf42.tar.gz
emacs-1640a85f9c5bc25a42cf88e68e8f7e1dd227cf42.zip
(rmail-mbox-from): New function.
(rmail-output-as-mbox): Use rmail-mbox-from. (rmail-output): Ensure a From line in the not-rmail Babyl case.
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/mail/rmailout.el39
2 files changed, 27 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 735e91e99e3..362f2237839 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -4,6 +4,9 @@
4 (rmail-delete-unwanted-fields): Ignore case. Use line-beg-pos. 4 (rmail-delete-unwanted-fields): Ignore case. Use line-beg-pos.
5 (rmail-output, rmail-output-as-seen): Change the "from-gnus" argument to 5 (rmail-output, rmail-output-as-seen): Change the "from-gnus" argument to
6 "not-rmail", and make it work. Simplify. 6 "not-rmail", and make it work. Simplify.
7 (rmail-mbox-from): New function.
8 (rmail-output-as-mbox): Use rmail-mbox-from.
9 (rmail-output): Ensure a From line in the not-rmail Babyl case.
7 10
8 * mail/rmail.el (rmail-get-attr-names): Give a warning rather than an 11 * mail/rmail.el (rmail-get-attr-names): Give a warning rather than an
9 error if the header is corrupt. 12 error if the header is corrupt.
diff --git a/lisp/mail/rmailout.el b/lisp/mail/rmailout.el
index 8220cd80025..36dfc4c5572 100644
--- a/lisp/mail/rmailout.el
+++ b/lisp/mail/rmailout.el
@@ -308,6 +308,21 @@ Replaces the From line with a \"Mail-from\" header. Adds \"Date\" and
308 "From: \\1\n")) 308 "From: \\1\n"))
309 t))))))) 309 t)))))))
310 310
311;; Note this is duplicated in unrmail.el.
312(defun rmail-mbox-from ()
313 "Return a \"From \" line for the current message.
314The buffer should be narrowed to just the header."
315 (let ((from (or (mail-fetch-field "from")
316 (mail-fetch-field "really-from")
317 (mail-fetch-field "sender")
318 "unknown"))
319 (date (mail-fetch-field "date")))
320 (format "From %s %s\n" (mail-strip-quoted-names from)
321 (or (and date
322 (ignore-errors
323 (current-time-string (date-to-time date))))
324 (current-time-string)))))
325
311(defun rmail-output-as-mbox (file-name nomsg &optional as-seen) 326(defun rmail-output-as-mbox (file-name nomsg &optional as-seen)
312 "Convert the current buffer's text to mbox and output to FILE-NAME. 327 "Convert the current buffer's text to mbox and output to FILE-NAME.
313Alters the current buffer's text, so it should be a temporary buffer. 328Alters the current buffer's text, so it should be a temporary buffer.
@@ -327,20 +342,9 @@ AS-SEEN is non-nil if we are copying the message \"as seen\"."
327 (rmail-delete-unwanted-fields 342 (rmail-delete-unwanted-fields
328 (if rmail-enable-mime "Mail-From" 343 (if rmail-enable-mime "Mail-From"
329 "Mail-From\\|MIME-Version\\|Content-type")) 344 "Mail-From\\|MIME-Version\\|Content-type"))
330 ;; Generate a From line from other header fields if necessary.
331 ;; FIXME this duplicates code from unrmail.el.
332 (goto-char (point-min)) 345 (goto-char (point-min))
333 (unless (looking-at "From ") 346 (or (looking-at "From ")
334 (setq from (or (mail-fetch-field "from") 347 (insert (rmail-mbox-from)))
335 (mail-fetch-field "really-from")
336 (mail-fetch-field "sender")
337 "unknown")
338 date (mail-fetch-field "date")
339 date (or (and date
340 (ignore-errors
341 (current-time-string (date-to-time date))))
342 (current-time-string)))
343 (insert "From " (mail-strip-quoted-names from) " " date "\n"))
344 (widen) 348 (widen)
345 ;; Make sure message ends with blank line. 349 ;; Make sure message ends with blank line.
346 (goto-char (point-max)) 350 (goto-char (point-max))
@@ -439,11 +443,16 @@ from a non-Rmail buffer. In this case, COUNT is ignored."
439 (cur (current-buffer))) 443 (cur (current-buffer)))
440 (if not-rmail ; eg via message-fcc-handler-function 444 (if not-rmail ; eg via message-fcc-handler-function
441 (with-temp-buffer 445 (with-temp-buffer
442 ;; FIXME need to ensure a From line for rmail-convert-to-babyl-format.
443 (insert-buffer-substring cur) 446 (insert-buffer-substring cur)
444 ;; Output in the appropriate format. 447 ;; Output in the appropriate format.
445 (if babyl-format 448 (if babyl-format
446 (rmail-output-as-babyl file-name noattribute) 449 (progn
450 (goto-char (point-min))
451 ;; rmail-convert-to-babyl-format errors if no From line,
452 ;; whereas rmail-output-as-mbox inserts one.
453 (or (looking-at "From ")
454 (insert (rmail-mbox-from)))
455 (rmail-output-as-babyl file-name noattribute))
447 (rmail-output-as-mbox file-name noattribute))) 456 (rmail-output-as-mbox file-name noattribute)))
448 ;; Called from an Rmail buffer. 457 ;; Called from an Rmail buffer.
449 (if rmail-buffer 458 (if rmail-buffer