From: Kenichi Handa <handa@m17n.org>
To: rms@gnu.org
Cc: per.starback@gmail.com, dak@gnu.org, monnier@iro.umontreal.ca,
emacs-devel@gnu.org
Subject: Re: Displaying bytes (was: Inadequate documentation of silly characters on screen.)
Date: Wed, 25 Nov 2009 10:33:54 +0900 [thread overview]
Message-ID: <E1ND6lW-0006AU-Gx@etlken> (raw)
In-Reply-To: <E1ND4AD-0003Yg-Cc@fencepost.gnu.org> (message from Richard Stallman on Tue, 24 Nov 2009 17:47:13 -0500)
In article <E1ND4AD-0003Yg-Cc@fencepost.gnu.org>, Richard Stallman <rms@gnu.org> writes:
> $ od -c euro.txt
> 0000000 T h a t c o s t s 200 1 7 . \n
> 0000020
> $ emacs euro.txt
> This is really a windows-1252 file and the strange character is
> supposed to be a Euro sign.
> For me, with no particular setup to make Emacs expect windows-1252
> files that shows in emacs as
> "That costs \20017." with raw-text-unix.
> Why doesn't Emacs guess right, in this case?
Because some other coding system of the same coding-category of
windows-1252 (coding-category-charset) has the higher priority and
that coding system doesn't contain code \200.
> Could we make it guess right by changing the coding system
> priorities?
Yes.
> If so, should we change the default priorities?
I'm not sure. As it seems that windows-1252 is a superset of
iso-8859-1, it may be ok to give windows-1252 the higher priority.
How do iso-8859-1 users think?
The better thing is to allow registering multiple coding systems in
one coding-category, but I'm not sure I have a time to work on it.
> It may be that a different set of priorities would cause similar
> problems in some other cases and the current defaults are the best.
> But if we have not looked at the question in several years, it would
> be worth studying it now.
> In that case revert-buffer-with-coding-system. Ideally I'd like Emacs
> to ask directly when opening the file
> in such a case, if it can't determine anything better than raw-bytes.
> Maybe so.
For that, it seems that adding that facility in
after-insert-file-set-coding is good. Here's a sample patch. The
actual change should give more information to a user.
--- mule.el.~1.294.~ 2009-11-17 11:42:45.000000000 +0900
+++ mule.el 2009-11-25 10:17:49.000000000 +0900
@@ -1893,7 +1893,18 @@
coding-system-for-read
(not (eq coding-system-for-read 'auto-save-coding)))
(setq buffer-file-coding-system-explicit
- (cons coding-system-for-read nil)))
+ (cons coding-system-for-read nil))
+ (when (and last-coding-system-used
+ (eq (coding-system-base last-coding-system-used) 'raw-text))
+ ;; Give a chance of decoding by some coding system.
+ (let ((coding-system (read-coding-system "Actual coding system: ")))
+ (if coding-system
+ (save-restriction
+ (narrow-to-region (point) (+ (point) inserted))
+ (let ((modified (buffer-modified-p)))
+ (decode-coding-region (point-min) (point-max) coding-system)
+ (setq inserted (- (point-max) (point-min)))
+ (set-buffer-modified-p modified)))))))
(if last-coding-system-used
(let ((coding-system
(find-new-buffer-file-coding-system last-coding-system-used)))
---
Kenichi Handa
handa@m17n.org
next prev parent reply other threads:[~2009-11-25 1:33 UTC|newest]
Thread overview: 96+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-18 19:12 [acm@muc.de: Re: Inadequate documentation of silly characters on screen.] Alan Mackenzie
2009-11-19 1:27 ` Fwd: Re: Inadequate documentation of silly characters on screen Stefan Monnier
2009-11-19 8:20 ` Alan Mackenzie
2009-11-19 8:50 ` Miles Bader
2009-11-19 10:16 ` Fwd: " Andreas Schwab
2009-11-19 12:21 ` Alan Mackenzie
2009-11-19 13:21 ` Jason Rumney
2009-11-19 13:35 ` Stefan Monnier
2009-11-19 14:18 ` Alan Mackenzie
2009-11-19 14:58 ` Jason Rumney
2009-11-19 15:42 ` Alan Mackenzie
2009-11-19 19:39 ` Eli Zaretskii
2009-11-19 15:30 ` Stefan Monnier
2009-11-19 15:58 ` Alan Mackenzie
2009-11-19 16:06 ` Andreas Schwab
2009-11-19 16:47 ` Aidan Kehoe
2009-11-19 17:29 ` Alan Mackenzie
2009-11-19 18:21 ` Aidan Kehoe
2009-11-20 2:43 ` Stephen J. Turnbull
2009-11-19 19:45 ` Eli Zaretskii
2009-11-19 20:07 ` Eli Zaretskii
2009-11-19 19:55 ` Stefan Monnier
2009-11-20 3:13 ` Stephen J. Turnbull
2009-11-19 16:55 ` David Kastrup
2009-11-19 18:08 ` Alan Mackenzie
2009-11-19 19:25 ` Davis Herring
2009-11-19 21:25 ` Alan Mackenzie
2009-11-19 22:31 ` David Kastrup
2009-11-21 22:52 ` Richard Stallman
2009-11-23 2:08 ` Displaying bytes (was: Inadequate documentation of silly characters on screen.) Stefan Monnier
2009-11-23 20:38 ` Richard Stallman
2009-11-23 21:34 ` Per Starbäck
2009-11-24 22:47 ` Richard Stallman
2009-11-25 1:33 ` Kenichi Handa [this message]
2009-11-25 2:29 ` Displaying bytes (was: Inadequate documentation of silly Stefan Monnier
2009-11-25 2:50 ` Lennart Borgman
2009-11-25 6:25 ` Stephen J. Turnbull
2009-11-25 5:40 ` Displaying bytes (was: Inadequate documentation of silly characters on screen.) Ulrich Mueller
2009-11-26 22:59 ` Displaying bytes Reiner Steib
2009-11-27 0:16 ` Ulrich Mueller
2009-11-27 1:41 ` Stefan Monnier
2009-11-27 4:14 ` Stephen J. Turnbull
2009-11-25 5:59 ` Displaying bytes (was: Inadequate documentation of silly characters on screen.) Stephen J. Turnbull
2009-11-25 8:16 ` Kenichi Handa
2009-11-29 16:01 ` Richard Stallman
2009-11-29 16:31 ` Displaying bytes (was: Inadequate documentation of silly Stefan Monnier
2009-11-29 22:01 ` Juri Linkov
2009-11-30 6:05 ` tomas
2009-11-30 12:09 ` Andreas Schwab
2009-11-30 12:39 ` tomas
2009-11-29 22:19 ` Displaying bytes (was: Inadequate documentation of silly characters on screen.) Kim F. Storm
2009-11-30 1:42 ` Stephen J. Turnbull
2009-11-24 1:28 ` Displaying bytes Stefan Monnier
2009-11-24 22:47 ` Richard Stallman
2009-11-25 2:18 ` Stefan Monnier
2009-11-26 6:24 ` Richard Stallman
2009-11-26 8:59 ` David Kastrup
2009-11-26 14:57 ` Stefan Monnier
2009-11-26 16:28 ` Lennart Borgman
2009-11-27 6:36 ` Richard Stallman
2009-11-24 22:47 ` Richard Stallman
2009-11-20 8:48 ` Fwd: Re: Inadequate documentation of silly characters on screen Eli Zaretskii
2009-11-19 19:52 ` Eli Zaretskii
2009-11-19 20:53 ` Alan Mackenzie
2009-11-19 22:16 ` David Kastrup
2009-11-20 8:55 ` Eli Zaretskii
2009-11-19 20:05 ` Stefan Monnier
2009-11-19 21:27 ` Alan Mackenzie
2009-11-19 19:43 ` Eli Zaretskii
2009-11-19 21:57 ` Alan Mackenzie
2009-11-19 23:10 ` Stefan Monnier
2009-11-19 20:02 ` Stefan Monnier
2009-11-19 14:08 ` Stefan Monnier
2009-11-19 14:50 ` Jason Rumney
2009-11-19 15:27 ` Stefan Monnier
2009-11-19 23:12 ` Miles Bader
2009-11-20 2:16 ` Stefan Monnier
2009-11-20 3:37 ` Stephen J. Turnbull
2009-11-20 4:30 ` Stefan Monnier
2009-11-20 7:18 ` Stephen J. Turnbull
2009-11-20 14:16 ` Stefan Monnier
2009-11-21 4:13 ` Stephen J. Turnbull
2009-11-21 5:24 ` Stefan Monnier
2009-11-21 6:42 ` Stephen J. Turnbull
2009-11-21 6:49 ` Stefan Monnier
2009-11-21 7:27 ` Stephen J. Turnbull
2009-11-23 1:58 ` Stefan Monnier
2009-11-21 12:33 ` David Kastrup
2009-11-21 13:55 ` Stephen J. Turnbull
2009-11-21 14:36 ` David Kastrup
2009-11-21 17:53 ` Stephen J. Turnbull
2009-11-21 23:30 ` David Kastrup
2009-11-22 1:27 ` Sebastian Rose
2009-11-22 8:06 ` David Kastrup
2009-11-22 23:52 ` Sebastian Rose
2009-11-19 17:08 ` Fwd: " Alan Mackenzie
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=E1ND6lW-0006AU-Gx@etlken \
--to=handa@m17n.org \
--cc=dak@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=per.starback@gmail.com \
--cc=rms@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.