all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Stephen J. Turnbull" <stephen@xemacs.org>
Cc: emacs-devel@gnu.org, handa@m17n.org
Subject: Re: per-buffer language environments
Date: Tue, 14 Dec 2010 10:14:49 -0500	[thread overview]
Message-ID: <E1PSWaX-0004Uq-Dj@fencepost.gnu.org> (raw)
In-Reply-To: <87y67sr3cs.fsf@uwakimon.sk.tsukuba.ac.jp> (stephen@xemacs.org)

> From: "Stephen J. Turnbull" <stephen@xemacs.org>
> Cc: Kenichi Handa <handa@m17n.org>,
>     emacs-devel@gnu.org
> Date: Tue, 14 Dec 2010 20:38:43 +0900
> 
> Eli Zaretskii writes:
> 
>  > > * Which coding systems have higher priority when inserting a
>  > >   file in the current buffer.
>  > 
>  > I could understand how the font selection and the default input method
>  > are related to the language, but what do encodings have to do with
>  > that?  The preferred encoding is generally an attribute of a locale,
>  > not of a language.
> 
> Note the word "insert", which implies "read".  It is certainly true
> that a locale may specify an encoding.  However, if the person is
> Japanese, they may specify ja_JP.UTF-8 for their locale and strongly
> prefer that files be written with that encoding, yet still need to
> read files in other encodings.  The locale encoding of UTF-8 is no
> help in distinguishing an EUC-JP file from an ISO-8859-1 file, let
> alone an EUC-CN file.  OTOH, somebody with a Hebrew language
> environment and a locale specifying UTF-8 as the encoding almost
> certainly prefers that a file containing 8-bit-set octets inconsistent
> with UTF-8 be recognized as ISO-8859-8 rather than EUC-JP, no?

Those are all valid concerns, but they are just the tip of an iceberg.
There's an almost infinite number of combinations of a language and
the preferred encoding, and it's impossible to fold them all, or even
their significant fraction, in a reasonably usable user-level
interface.  We shouldn't even try, IMO; we already have
prefer-coding-system, the coding: cookies, the .dir_locals meta-data,
etc. to cover the situations where the user knows what encoding should
be preferred/used, even though her language and locale say otherwise.

set-language-environment accepts a single string, which should be a
language name, as its argument.  (There are some "languages" that we
recognize, such as "Chinese-GB18030", which sneak in the encoding as
well, but that's an anomaly, I think, which goes back to when Emacs
didn't have locale environments to express that.  Now that we do, we
could get rid of that, at least in principle.)  Therefore, a language
environment should set the defaults suitable for the language, and
that doesn't include the encoding, or at least does not have to fit
each minor cultural variant of the language.

>  > The fact that we mix them is because Emacs had
>  > language environments before it had locale environments.
> 
> What's a "locale environment"?

See set-locale-environment.

> AFAIK Emacsen use the locale as a heuristic for determining the
> language environment

There's no heuristic involved, AFAIR.  Emacs has a database of
languages _and_encodings_ suitable for the known locale names.
set-locale-environment uses that database to get the language and the
preferred encoding(s), then calls set-language-environment with the
language, and sets the priorities of the encodings according to the
encoding preferences.



  reply	other threads:[~2010-12-14 15:14 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-11 15:25 per-buffer language environments Werner LEMBERG
2010-12-11 19:00 ` Eli Zaretskii
2010-12-12  6:25   ` Werner LEMBERG
2010-12-13  7:56     ` Kenichi Handa
2010-12-13  9:27       ` Werner LEMBERG
2010-12-13 10:59         ` Kenichi Handa
2010-12-13 12:15           ` Werner LEMBERG
2010-12-13 11:47       ` Eli Zaretskii
2010-12-14 11:38         ` Stephen J. Turnbull
2010-12-14 15:14           ` Eli Zaretskii [this message]
2010-12-15  4:51             ` Stephen J. Turnbull
2010-12-15  6:47               ` Eli Zaretskii
2010-12-15  7:45                 ` Werner LEMBERG
2010-12-16 21:10                 ` Stephen J. Turnbull
2010-12-17 11:51                   ` Eli Zaretskii
2010-12-18  6:29                     ` Werner LEMBERG
2010-12-18  9:30                     ` Stephen J. Turnbull
2010-12-21 18:39                       ` Eli Zaretskii
2010-12-21 21:16                       ` Werner LEMBERG
2010-12-22  6:52                         ` Stephen J. Turnbull
2010-12-22  7:42                           ` Werner LEMBERG
2010-12-17  0:51                 ` Kenichi Handa
2010-12-17  2:48                   ` Stephen J. Turnbull
2010-12-17 11:05                   ` Eli Zaretskii
2010-12-18 17:03       ` Per Starbäck
2010-12-19 13:54         ` Stefan Monnier
2010-12-19 21:05           ` Dimitri Fontaine

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=E1PSWaX-0004Uq-Dj@fencepost.gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=handa@m17n.org \
    --cc=stephen@xemacs.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.