<<< Date Index >>>     <<< Thread Index >>>

Re: Best way to handle DOS newlines



On 2007-05-07, Ray Van Dolson <rvandolson@xxxxxxxx> wrote:
> I occasionally get emails generated from a web application here at work
> that uses DOS/Windows newlines instead of Unix ones.  All the text
> shows up as one large line interspersed with ^M^M's.  I'd like to
> figure out a good way to:
> 
>   1. Correct this in the pager view of the message.
>   2. Correct this prior to the message being passed to my editor (vim)
>      for quoting.
> 
> Currently I am resolving 1 by using the following message-hook:
> 
>   message-hook '~f ChangeControl.System@xxxxxxxx' 'set display_filter="sed -f 
> ~/bin/fix_m.sed"'
> 
> Where fix_m.sed strips out the ^M's and replaces them with my preferred
> newlines.
> 
> However, if I hit reply to this message, everything shows up in vim in
> the original format -- ie with the ^M's all intact and everything on
> one line.
> 
> I can correct this from wtihin vim, but I'd prefer it all be automated.
> 
> I tried a reply-hook similar to my message-hook above, but had no
> success.
> 
> Any suggestions?

You could use a message-hook (even the same message-hook) to also
set 'editor' to vim with a -c option to execute a vim command to fix
those lines, e.g.,

   message-hook '~A'                               'set editor="vim'
   message-hook '~f ChangeControl.System@xxxxxxxx' 'set editor="vim -c \"%!sed 
-f ~/bin/fix_m.sed\""'

HTH,
Gary

-- 
Gary Johnson                               | Agilent Technologies
garyjohn@xxxxxxxxxxxxxxx                   | Mobile Broadband Division
http://www.spocom.com/users/gjohnson/mutt/ | Spokane, Washington, USA