Hello,

  Lately, I've started to slowly migrate my environment to
UTF-8. Since I don't feel ready to do a complete switch yet, as the
environment doesn't seem to be mature enough, I like to have a
"transition period", when I can run applications in either a UTF-8 or
a non-UTF-8 locale, as needed. More specifically, I want to be able to
constantly switch back and forth between el_GR.ISO8859-7 and
el_GR.UTF-8.

  Most programs don't need any particular setup for this. Emacs [0],
however, is a notable exception. In its default setup, it doesn't
completely support a UTF-8 environment, the main problem being that it
doesn't recognise UTF-8 keyboard input. So I set out to discover the
minimum configuration possible, so that it would fully support the
UTF-8 locale, without creating any problems at the ISO8859-7 locale at
the same time. In addition, it would have to work both in X11 and
terminal mode, and in the latter, both on the Linux console and inside
an xterm. The result isn't the most obvious setup, so I thought I'd
post it here, in the hope that others find it useful as well
(esp. Emacs developers).

  First of all, I wanted to make sure that Emacs automatically sets
the language environment to "Greek" in all cases, without actually
configuring it to be the default. This is accomplished with the
following line in .emacs:

(setq locale-language-names (cdr locale-language-names))

  The variable locale-language-names is a list of patters that match
locale names to names of language environments. In my version of
Emacs, the first entry inhibits all UTF-8 locales from setting any
language environment. In my case, this seems to cause more harm than
good, so I eliminate that entry with the above command.

  In addition, I want to set the various coding systems for each
locale to sane values. This is achieved with the following piece of
code:

(setq locale-preferred-coding-systems
      (cons (cons ".*\\.utf-8" 'utf-8) locale-preferred-coding-systems))
((lambda (cs)
   (set-keyboard-coding-system cs)
   (if cs (set-terminal-coding-system cs)))
 (set-locale-environment nil))

  This makes UTF-8 the preferred coding system for UTF-8 locales, and
sets the various coding systems according to the current locale
settings. Now Emacs behaves just like most other applications: assumes
an 8-bit, ISO8859-7 environment under the el_GR.ISO8859-7 locale, and
a multi-byte, UTF-8 environment when run under el_GR.UTF-8.


[0] I use GNU Emacs 21.2-5, the latest version in Debian unstable.

-- 
Vasilis Vasaitis
[EMAIL PROTECTED]
+30976604701


--
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/linux-utf8/

Reply via email to