From: Dmitriyi Paduchikh <paduch@mail.ru>
To: bug-gnu-emacs@gnu.org
Subject: Problem with auto-coding-functions
Date: Sat, 16 Jun 2007 18:53:04 +0600 [thread overview]
Message-ID: <87y7ikvz67.fsf@dvp.imm.uran.ru> (raw)
[-- Attachment #1: Type: text/plain, Size: 2438 bytes --]
Dear Emacs developers,
I am using Debian package emacs-snapshot 20070608-1 of Romain Francoise. It
is a snapshot of Emacs 22 branch.
I wrote a function for auto-coding-functions hook which would run a program
called Enca[1] as a subprocess to determine encoding of the text. Function
runs enca by calling call-process-region. See attachment for full source.
This worked OK when opening a file, however if I tried to save file with C-x
C-m c utf-8, Emacs asked:
Selected encoding no-conversion disagrees with iso-8859-5-unix specified
by file contents. Really save (else edit coding cookies and try again)?
(yes or no)
I think that iso-8859-5-unix comes from Enca. Enca incorrectly determines
Cyrillic text in emacs-mule as ISO-8859-5. But no-conversion was very
confusing. As it appears (see backtrace in the attachment) it is due to
select-safe-coding-system being called recursively via call-process-region.
I solved this by binding auto-coding-functions to nil inside my function.
However some problems remain.
First, auto-coding-functions get executed via select-safe-coding-system on
decoded text whereas documentation of auto-coding-functions promises that
functions will be called on undecoded text. Clearly there is a bug here. If
functions need to be called on both decoded and undecoded text this should
be mentioned in the documentation, and some method of distinguishing wether
the text is decoded or not should be provided.
Second, when saving with C-x C-m c utf-8, Emacs still asks
Selected encoding utf-8-unix disagrees with iso-8859-5-unix specified by
file contents. Really save (else edit coding cookies and try again)? (yes
or no)
which is somewhat annoying. I would rather prefer that Emacs just silently
saved file with coding system given via C-x C-m c (utf-8 in my case) despite
whatever coding system auto-coding-functions suggest.
Third, if I set coding system by C-x C-m f, Emacs silently saves file with
the coding system returned by auto-coding-functions (iso-8859-5 in my case)
no matter what coding system was specified with C-x C-m f. This looks wrong
to me. IMHO it would be better if Emacs respected the explicit user choice
and at least asked him.
Note. My language environment is Russian using koi8-r if this matters.
Footnotes:
[1] Extremely Naive Charset Analyser. Available as Debian package, or else
look for it at http://packages.debian.org/unstable/source/enca
[-- Attachment #2: auto-enca.el --]
[-- Type: application/emacs-lisp, Size: 688 bytes --]
[-- Attachment #3: The backtrace --]
[-- Type: application/octet-stream, Size: 14711 bytes --]
[-- Attachment #4: Type: text/plain, Size: 149 bytes --]
_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs
reply other threads:[~2007-06-16 12:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=87y7ikvz67.fsf@dvp.imm.uran.ru \
--to=paduch@mail.ru \
--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 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).