From 13a40633cfb5d3b97f26b362c27ffb50846dc1bb Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Thu, 6 Dec 2012 20:37:14 -0800 Subject: [PATCH] Default to mboxrd in Rmail, allow mboxo as an option * lisp/mail/unrmail.el (unrmail-mbox-format): New option. (batch-unrmail, unrmail): Doc fixes. (unrmail): Respect unrmail-mbox-format. * lisp/mail/rmail.el (rmail-mbox-format): New option. (rmail-show-message-1): Respect rmail-mbox-format. * etc/NEWS: Related edits. Fixes: debbugs:6574 --- etc/NEWS | 8 ++++++++ lisp/ChangeLog | 8 ++++++++ lisp/mail/rmail.el | 36 +++++++++++++++++++++++++++++++----- lisp/mail/unrmail.el | 41 ++++++++++++++++++++++++++++++----------- 4 files changed, 77 insertions(+), 16 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 39b04da387c..242b8929fd2 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -58,6 +58,14 @@ amounts of data into the ERC input. ** MH-E has been updated to MH-E version 8.4. See MH-E-NEWS for details. +--- +** The unrmail command converts from BABYL to mboxrd rather than mboxo. +Customize `unrmail-mbox-format' to change this. + +--- +** Similarly, customize `rmail-mbox-format' to influence some minor aspects +of how Rmail displays non-MIME messages. + +++ ** New function `ses-rename-cell' to give SES cells arbitrary names. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 51d2ec6cbd1..940dc62fedf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2012-12-07 Glenn Morris + + * mail/unrmail.el (unrmail-mbox-format): New option. (Bug#6574) + (batch-unrmail, unrmail): Doc fixes. + (unrmail): Respect unrmail-mbox-format. + * mail/rmail.el (rmail-mbox-format): New option. + (rmail-show-message-1): Respect rmail-mbox-format. + 2012-12-07 Stefan Monnier * emacs-lisp/cl-macs.el (cl-tagbody): New macro. diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 372b120046c..b16f501a999 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -2699,6 +2699,27 @@ N defaults to the current message." :group 'rmail :version "23.1") +;; FIXME? +;; rmail-show-mime-function does not unquote >From lines. Should it? +(defcustom rmail-mbox-format 'mboxrd + "The mbox format that your system uses. +There is no way to determine this, so you should set the appropriate value. +The formats quote lines containing \"From \" differently. +The choices are: + `mboxo' : lines that start with \"From \" quoted as \">From \" + `mboxrd': lines that start with \">*From \" quoted with another \">\" +The `mboxo' format is ambiguous, in that one cannot know whether +a line starting with \">From \" originally had a \">\" or not. + +It is not critical to set this to the correct value; it only affects +how Rmail displays lines starting with \">*From \" in non-MIME messages. + +See also `unrmail-mbox-format'." + :type '(choice (const 'mboxrd) + (const 'mboxro)) + :version "24.4" + :group 'rmail) + (defun rmail-show-message-1 (&optional msg) "Show message MSG (default: current message) using `rmail-view-buffer'. Return text to display in the minibuffer if MSG is out of @@ -2791,11 +2812,15 @@ The current mail message becomes the message displayed." ;; Prepare the separator (blank line) before the body. (goto-char (point-min)) (insert "\n") - ;; Unquote quoted From lines - (while (re-search-forward "^>+From " nil t) - (beginning-of-line) - (delete-char 1) - (forward-line)) + ;; Unquote quoted From lines. + (let ((fromline (if (eq 'mboxrd rmail-mbox-format) + "^>+From " + "^>From ")) + case-fold-search) + (while (re-search-forward fromline nil t) + (beginning-of-line) + (delete-char 1) + (forward-line))) (goto-char (point-min))) ;; Copy the headers to the front of the message view buffer. (rmail-copy-headers beg end) @@ -3869,6 +3894,7 @@ see the documentation of `rmail-resend'." (msgnum rmail-current-message) (subject (concat "[" (let ((from (or (mail-fetch-field "From") + ;; FIXME - huh? (mail-fetch-field ">From")))) (if from (concat (mail-strip-quoted-names from) ": ") diff --git a/lisp/mail/unrmail.el b/lisp/mail/unrmail.el index bf7b9abe2c1..23675d90713 100644 --- a/lisp/mail/unrmail.el +++ b/lisp/mail/unrmail.el @@ -1,6 +1,6 @@ -;;; unrmail.el --- convert Rmail Babyl files to mailbox files +;;; unrmail.el --- convert Rmail Babyl files to mbox files -;; Copyright (C) 1992, 2001-2012 Free Software Foundation, Inc. +;; Copyright (C) 1992, 2001-2012 Free Software Foundation, Inc. ;; Maintainer: FSF ;; Keywords: mail @@ -26,7 +26,7 @@ ;;;###autoload (defun batch-unrmail () - "Convert old-style Rmail Babyl files to system inbox format. + "Convert old-style Rmail Babyl files to mbox format. Specify the input Rmail Babyl file names as command line arguments. For each Rmail file, the corresponding output file name is made by adding `.mail' at the end. @@ -45,9 +45,26 @@ For example, invoke `emacs -batch -f batch-unrmail RMAIL'." (declare-function mail-mbox-from "mail-utils" ()) (defvar rmime-magic-string) ; in rmime.el, if you have it +(defcustom unrmail-mbox-format 'mboxrd + "The mbox format that `unrmail' should produce. +These formats separate messages using lines that start with \"From \". +Therefore any lines in the message bodies that start with \"From \" +must be quoted. The `mboxo' format just prepends a \">\" to such lines. +This is not reversible, because given a line starting with \">From \" in +an mboxo file, it is not possible to know whether the original had a \">\" +or not. The `mxbord' format avoids this by also quoting \">From \" as +\">>From \", and so on. For this reason, mboxrd is recommended. + +See also `rmail-mbox-format'." + :type '(choice (const 'mboxrd) + (const 'mboxro)) + :version "24.4" + :group 'rmail) + ;;;###autoload (defun unrmail (file to-file) - "Convert old-style Rmail Babyl file FILE to system inbox format file TO-FILE." + "Convert old-style Rmail Babyl file FILE to mbox format file TO-FILE. +The variable `unrmail-mbox-format' controls which mbox format to use." (interactive "fUnrmail (babyl file): \nFUnrmail into (new mailbox file): ") (with-temp-buffer ;; Read in the old Rmail file with no decoding. @@ -224,13 +241,15 @@ For example, invoke `emacs -batch -f batch-unrmail RMAIL'." (when keywords (insert "X-RMAIL-KEYWORDS: " keywords "\n")) (goto-char (point-min)) - ;; ``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.) - (let ((case-fold-search nil)) - (while (search-forward "\nFrom " nil t) - (forward-char -5) - (insert ?>))) + ;; Convert From to >From, etc. + (let ((case-fold-search nil) + (fromline (if (eq 'mboxrd unrmail-mbox-format) + "^>*From " + "^From "))) + (while (re-search-forward fromline nil t) + (beginning-of-line) + (insert ?>) + (forward-line 1))) (goto-char (point-max)) ;; Add terminator blank line to message. (insert "\n") -- 2.39.5