]> code.delx.au - gnu-emacs/commitdiff
Default to mboxrd in Rmail, allow mboxo as an option
authorGlenn Morris <rgm@gnu.org>
Fri, 7 Dec 2012 04:37:14 +0000 (20:37 -0800)
committerGlenn Morris <rgm@gnu.org>
Fri, 7 Dec 2012 04:37:14 +0000 (20:37 -0800)
* 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
lisp/ChangeLog
lisp/mail/rmail.el
lisp/mail/unrmail.el

index 39b04da387c19cc54cef9b0300ad5a18f14730bd..242b8929fd238410a2a31d1f3d797f3a92ee1954 100644 (file)
--- 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.
 
index 51d2ec6cbd1aa76b35504019a2fee71f07aa9172..940dc62fedff3dbbaccfd3eb6e7e5ba64f056a2d 100644 (file)
@@ -1,3 +1,11 @@
+2012-12-07  Glenn Morris  <rgm@gnu.org>
+
+       * 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  <monnier@iro.umontreal.ca>
 
        * emacs-lisp/cl-macs.el (cl-tagbody): New macro.
index 372b120046c5c1380ec00a97693e20c81f4a1839..b16f501a99944419a0394eb04c112b72f239a167 100644 (file)
@@ -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) ": ")
index bf7b9abe2c16874e4d68bdd35c584edae77b4c39..23675d90713f753bff5c9f8f56319f4088eb55ec 100644 (file)
@@ -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")