all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "David J. Biesack" <David.Biesack@sas.com>
To: bug-gnu-emacs@gnu.org
Subject: bug#4076: 23.1; RMAIL splitting mbox at text starting with 'From ' (patch)
Date: Fri, 07 Aug 2009 14:41:45 -0400	[thread overview]
Message-ID: <ytb8whvxy8m.fsf@sas.com> (raw)

Content-Transfer-Encoding: 7bit
Send a plain text email with the text between the ==== lines below.

The lines beginning with "From " start at the beginning
of the line; there is no leading whitespace or > there
(which might get added by sending this message)
i.e. the message text contains "\n\nFrom " twice.

=====================
This message contains a new paragraph starting with "From " but nit is not a new message

From the beginning, RMAIL/Babyl did not have a problem with this type of message. Now, RMAIl/mbox format does.

this text will show up as a second message; RMAIL will not show any headers.

From where I sit, this is really annoying.

this text will show up as a third message; RMAIL will not show any headers.
=====================

Using RMAIL where the RMAIL file has been converted to mbox format (23.1),
this mail message gets split up into three separate "messages".
The first has the correct mail headers; the other two have no
header information. The lines beginning with "From " are seen
as new mbox messages.

Attached is a patch to rmail to use rmail-unix-mail-delimiter 
instead of simply searching for or looking-at "From ".

I'm not sure if rmail-unix-mail-delimiter is needed in each place,
but this patch works for me.

David J. Biesack, SAS
SAS Campus Dr. Cary, NC 27513
www.sas.com    (919) 531-7771


In GNU Emacs 23.1.1 (i386-mingw-nt5.1.2600)
 of 2009-07-30 on SOFT-MJASON
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.4)'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  display-time-mode: t
  shell-dirtrack-mode: t
  delete-selection-mode: t
  pc-selection-mode: t
  show-paren-mode: t
  iswitchb-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t
  hs-minor-mode: t

Recent input:
k SPC C-x o C-x C-f r m C-g C-g M-x r m <return> r 
C-g C-g C-x b o r i g <return> M-x r m <return> r m 
a i l . e l . o r SPC <return> M-x r e n a m e - f 
SPC <return> r m SPC . e l SPC . SPC e o <backspace> 
<backspace> o SPC <return> r m a i l . e l . o r g 
<return> C-x p M-p M-b M-b C-b M-b C-b | <return> <down-mouse-1> 
<mouse-1> <backspace> ! <return> <down-mouse-1> <mouse-1> 
<down-mouse-1> <mouse-1> <backspace> <backspace> > 
! <backspace> | <backspace> C-e <return> M-\ M-\ <backspace> 
<return> M-p M-b M-b M-b C-b ! <return> r m SPC <M-wheel-down> 
<M-down-mouse-2> <M-mouse-2> <backspace> <return> M-p 
M-p M-b M-b M-b C-b = <backspace> <backspace> <backspace> 
! <backspace> > <return> <help-echo> <down-mouse-1> 
<mouse-1> C-x C-w r m a i l . e l . o r SPC SPC <return> 
y C-x C-w r m a SPC . e l SPC . o r i SPC <backspace> 
<return> C-x p r m r m <backspace> <backspace> SPC 
r m a i l . e l . o r g <return> M-p <backspace> <backspace> 
* C-a C-d C-d l l <return> r m SPC r m a i l * <M-backspace> 
<M-backspace> C-p C-p C-p C-p C-p C-p C-p C-e <return> 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p <return> C-p 
C-p C-p C-e <return> <down-mouse-3> <mouse-3> C-x k 
SPC C-p C-p <return> C-p C-p C-e M-b M-b M-b M-b C-b 
M-d M-b M-b C-b C-y C-e <return> <down-mouse-3> <mouse-3> 
<down-mouse-1> <mouse-1> <down-mouse-1> <mouse-1> M-x 
r e p o r t - e m a c s - b u f SPC g <backspace> <backspace> 
g SPC <return>

Recent messages:
rmail.el.patch
Fontifying rmail.el.patch... (regexps................)
rmail.el.patch
Kill buffer rmail.el.patch? (y or n) 
Mark set
rmail.el.patch [2 times]
Fontifying rmail.el.patch... (regexps................)
rmail.el.patch
Fontifying rmail.el.patch... (regexps................)
rmail.el.patch

patch below


*** rmail.el.orig       Fri Aug  7 14:26:34 2009
--- rmail.el    Fri Aug  7 14:24:07 2009
***************
*** 772,777 ****
--- 772,784 ----
  this expression, you must change the code in `rmail-nuke-pinhead-header'
  that knows the exact ordering of the \\( \\) subexpressions.")
  
+ ; fix broken rmail-add-mbox-headers in rmail.el 
+ ; which originally breaks messages at any text starting with "^From " instead of rmail-unix-mail-delimiter
+ ; David.Biesack@sas.com 07Aug09
+ (defvar rmail-unix-mail-delimiter-nn (concat "\n\n" rmail-unix-mail-delimiter)
+       "Like rmail-unix-mail-delimiter but with \n\n prepended.")
+ 
+ 
  ;; FIXME the rmail-header-name headers ought to be customizable.
  ;; It seems a bit arbitrary, for example, that all of the Date: line
  ;; gets highlighted.
***************
*** 2059,2064 ****
--- 2066,2072 ----
    (unless (looking-back "\n\n")
      (insert "\n")))
  
+ ;; patched to use rmail-unix-mail-delimiter instead of "From " David.Biesack@sas.com 07Aug09
  (defun rmail-add-mbox-headers ()
    "Validate the RFC2822 format for the new messages.
  Point should be at the first new message.
***************
*** 2077,2083 ****
        (unless (= start (point-max))
          ;; Scan the new messages to establish a count and to ensure that
          ;; an attribute header is present.
!         (while (looking-at "From ")
            ;; Determine if a new attribute header needs to be added to
            ;; the message.
            (if (search-forward "\n\n" nil t)
--- 2085,2091 ----
        (unless (= start (point-max))
          ;; Scan the new messages to establish a count and to ensure that
          ;; an attribute header is present.
!         (while (looking-at rmail-unix-mail-delimiter) ;; was : (looking-at "From ") sasdjb 07Aug09
            ;; Determine if a new attribute header needs to be added to
            ;; the message.
            (if (search-forward "\n\n" nil t)
***************
*** 2090,2099 ****
                  (widen))
              (rmail-error-bad-format))
            ;; Move to the next message.
!           (if (search-forward "\n\nFrom " nil 'move)
                (forward-char -5))
            (setq start (point))))
        count))))
  \f
  (defun rmail-get-header-1 (name)
    "Subroutine of `rmail-get-header'.
--- 2098,2109 ----
                  (widen))
              (rmail-error-bad-format))
            ;; Move to the next message.
!           (if (search-forward rmail-unix-mail-delimiter-nn nil 'move)
                (forward-char -5))
            (setq start (point))))
        count))))
+ 
+ 
  \f
  (defun rmail-get-header-1 (name)
    "Subroutine of `rmail-get-header'.
***************
*** 2475,2497 ****
                    ?D
                  ?\s) deleted-head))))
  
  (defun rmail-set-message-counters-counter (&optional stop)
    ;; Collect the start position for each message into 'messages-head.
    (let ((start (point)))
      (while (search-backward "\n\nFrom " stop t)
        (forward-char 2)
!       (rmail-collect-deleted start)
!       (setq messages-head (cons (point-marker) messages-head)
!           total-messages (1+ total-messages)
!           start (point))
!       ;; Show progress after every 20 messages or so.
!       (if (zerop (% total-messages 20))
!         (message "Counting messages...%d" total-messages)))
      ;; Handle the first message, maybe.
      (if stop
        (goto-char stop)
        (goto-char (point-min)))
!     (unless (not (looking-at "From "))
        (rmail-collect-deleted start)
        (setq messages-head (cons (point-marker) messages-head)
            total-messages (1+ total-messages)))))
--- 2485,2510 ----
                    ?D
                  ?\s) deleted-head))))
  
+ ;; patched to use rmail-unix-mail-delimiter instead of "From "; David.Biesack@sas.com 07Aug09
  (defun rmail-set-message-counters-counter (&optional stop)
    ;; Collect the start position for each message into 'messages-head.
    (let ((start (point)))
      (while (search-backward "\n\nFrom " stop t)
        (forward-char 2)
!       (cond ((looking-at rmail-unix-mail-delimiter)
!              (rmail-collect-deleted start)
!              (setq messages-head (cons (point-marker) messages-head)
!                    total-messages (1+ total-messages)
!                    start (point))
!              ;; Show progress after every 20 messages or so.
!              (if (zerop (% total-messages 20))
!                  (message "Counting messages...%d" total-messages))))
!       )
      ;; Handle the first message, maybe.
      (if stop
        (goto-char stop)
        (goto-char (point-min)))
!     (unless (not (looking-at rmail-unix-mail-delimiter))
        (rmail-collect-deleted start)
        (setq messages-head (cons (point-marker) messages-head)
            total-messages (1+ total-messages)))))






             reply	other threads:[~2009-08-07 18:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <83bpmqmx33.fsf@gnu.org>
2009-08-07 18:41 ` David J. Biesack [this message]
2009-08-08 10:20   ` bug#4076: marked as done (23.1; RMAIL splitting mbox at text starting with 'From ' (patch)) Emacs bug Tracking System

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ytb8whvxy8m.fsf@sas.com \
    --to=david.biesack@sas.com \
    --cc=4076@emacsbugs.donarmstrong.com \
    --cc=bug-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.