From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Subject: Re: strip extraneous CR characters
Date: Mon, 28 Sep 2009 12:49:21 -0500 [thread overview]
Message-ID: <87bpkvez8e.fsf@lifelogs.com> (raw)
In-Reply-To: 83r5trqd2w.fsf@gnu.org
On Mon, 28 Sep 2009 17:54:47 +0200 Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Ted Zlatanov <tzz@lifelogs.com>
>> 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
next prev parent reply other threads:[~2009-09-28 17:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-28 15:01 strip extraneous CR characters Ted Zlatanov
2009-09-28 15:54 ` Eli Zaretskii
2009-09-28 17:49 ` Ted Zlatanov [this message]
2009-09-28 18:10 ` Eli Zaretskii
2009-09-29 0:44 ` Stefan Monnier
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bpkvez8e.fsf@lifelogs.com \
--to=tzz@lifelogs.com \
--cc=emacs-devel@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).