From: M G Berberich <berberic@forwiss.uni-passau.de>
To: help-gnu-emacs@gnu.org
Subject: changing encoding of buffer
Date: Mon, 28 May 2007 12:34:47 +0200 [thread overview]
Message-ID: <7rnqi4-vn5.ln1@ID-306968.user.individual.net> (raw)
Hello,
I have a newsreader that conforms to the standard and assumes ansi
encoding if none is declared. Microsoft does'n care about standards so
MS-products produce postings that are encoded in windows-125* without
a declaration. A real problem in non-englisch-speaking countries.
When I reply, my newsreader appends my UTF-8 signature and starts
emacs. Emacs reads the file and sets the coding-system to latin1,
displaying the posting correctly but garbling up my signature and
worse saving it as latin1 while the newsreader expects UTF-8.
I wrote this function to solve the problem:
(defun fix-ms-posting ()
"Fixes newsposting that are garbled up by Microsoft-Software"
(interactive)
(let ((coding-system-for-write 'raw-text)
(coding-system-for-read 'utf-8)
(end (progn (end-of-buffer) (search-backward "\n-- \n"))))
(revert-buffer-with-coding-system 'utf-8)
(set-buffer-file-coding-system 'utf-8)
(shell-command-on-region (point-min) end
"recode windows-1252..utf-8" nil t)))
- Is there realy no other way to change the encoding of the buffer
than doing a revert? Can't this be done in-place?
- revert-buffer-with-coding-system always ask if it should do so, can
this be switched off?
- I moved the search-backward to the variables list of let to make it
fail before harm is done if there is no signature. Is this the way
to do it?
MfG
bmg
--
„Des is völlig wurscht, was heut beschlos- | M G Berberich
sen wird: I bin sowieso dagegn!“ | berberic@fmi.uni-passau.de
(SPD-Stadtrat Kurt Schindler; Regensburg) | www.fmi.uni-passau.de/~berberic
next reply other threads:[~2007-05-28 10:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-28 10:34 M G Berberich [this message]
2007-05-28 20:21 ` changing encoding of buffer Eli Zaretskii
[not found] ` <mailman.1365.1180383723.32220.help-gnu-emacs@gnu.org>
2007-05-29 12:39 ` M G Berberich
2007-05-29 19:52 ` Eli Zaretskii
[not found] ` <mailman.1402.1180468336.32220.help-gnu-emacs@gnu.org>
2007-05-29 21:06 ` M G Berberich
2007-05-30 3:22 ` Eli Zaretskii
[not found] ` <mailman.1416.1180495357.32220.help-gnu-emacs@gnu.org>
2007-05-30 7:35 ` M G Berberich
2007-05-31 18:19 ` Giorgos Keramidas
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=7rnqi4-vn5.ln1@ID-306968.user.individual.net \
--to=berberic@forwiss.uni-passau.de \
--cc=berberic@fmi.uni-passau.de \
--cc=help-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.