emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strip extraneous CR characters


From: Ted Zlatanov
Subject: Re: strip extraneous CR characters
Date: Mon, 28 Sep 2009 12:49:21 -0500
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.50 (gnu/linux)

On Mon, 28 Sep 2009 17:54:47 +0200 Eli Zaretskii <address@hidden> wrote: 

>> From: Ted Zlatanov <address@hidden>
>> Date: Mon, 28 Sep 2009 10:01:24 -0500
>> 
>> ;; from nnheader.el
>> (defsubst imap-hash-remove-cr-followed-by-lf ()
>> (goto-char (point-max))
>> (while (search-backward "\r\n" nil t)
>> (delete-char 1)))
>> 
>> ;; from nnheader.el
>> (defun imap-hash-ms-strip-cr (&optional string)
>> "Strip ^M from the end of all lines in current buffer or STRING."
>> (if string
>> (with-temp-buffer
>> (insert string)
>> (imap-hash-remove-cr-followed-by-lf)
>> (buffer-string))
>> (save-excursion
>> (imap-hash-remove-cr-followed-by-lf))))
>> 
>> I wonder if it makes sense to define these functions globally?  They are
>> not trivial, though the implementation is short.

EZ> Why are these needed, when we have the EOL decoding as part of
EZ> inserting text into the buffer since a long time ago?  And if the
EZ> initial decode somehow didn't DTRT, either fix that or decode it
EZ> again.

EZ> When will this paradigm not work?

IMAP has CR characters explicitly in the standard.  imap.el passes those
down in every message body and in the headers.  I don't know why imap.el
doesn't use automatic EOL decoding (perhaps to preserve every aspect of
the original data).  I don't need the original CR characters for my
purposes so probably it's better to do the decoding in imap-hash.el
instead of imap.el, which is used by many other packages.

Where can I find an example of this EOL decoding from DOS, to ensure I
am doing it correctly?

Thanks
Ted





reply via email to

[Prev in Thread] Current Thread [Next in Thread]