help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Any way to make Alt key like X-windows in UTF-8 terminal?


From: David Mazieres expires 2013-11-25 PST
Subject: Any way to make Alt key like X-windows in UTF-8 terminal?
Date: Tue, 27 Aug 2013 14:57:35 -0700
User-agent: SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.8 Emacs/24.3 (x86_64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO)

I've been trying to find a way to get the Alt key to work the same in
UTF-8 terminals as it does in X windows.  By UTF-8 terminal, I mean
one in which the alt key works, adds 128 to the value of whatever key
was typed, and then translates the corresponding unicode code point
(which lies between 128 and 255) into a two byte UTF-8 sequence.  In
particular, this behavior is what you get from xterm if you set the
following X resources:

        XTerm*eightBitInput: true
        XTerm*utf8: true

Now the behavior I get in X windows, which I like, is that Alt behaves
like meta.  In other words, when I type Alt-x, it gets interpreted as
M-x, which is bound to execute-extended-command.  On the other hand,
if I type Control-q followed by Alt-x, I get unicode code point 0xf8,
"LATIN SMALL LETTER O WITH STROKE".

Unfortunately, I can't figure out any easy way to make this happen in
"emacs -nw".  Basically unicode character 0xf8 is always interpreted
as LATIN SMALL LETTER O WITH STROKE, and never as M-x.

In the particular case of xterm, I can set the xterm resource
altSendsEscape to true, but this does not work very well with viper,
which interprets the ESC character differently.  Moreover, for other
applications I run in the terminal, I don't want Alt sending the
escape key.  Hence, I would very much like to make Alt work with the
exact X resources that I listed above in this message.

The best I've been able to come up with so far is:

        XTerm*eightBitInput: true
        XTerm*utf8: false

Then if I run emacs -nw with LC_TYPE=C, I get the appropriate
behavior.  However, now xterm and emacs don't display unicode
characters properly, which I live with okay for years, but now other
applications in my xterm really want to send unicode.  Effectively
what I want is to use different locales for input and output, which is
not possible.  However, I could get something equivalent if emacs
compensated by mapping code points 128-255 to meta keys.

It's also possible that I'm thinking about the problem in entirely the
wrong way, so higher-level advice would be welcome, too.  At a high
level, the problem is just getting viper in "emacs -nw" to work the
way it does in X windows.  Oh, and I guess I have one more constraint,
which is that if I don't hard-code:

        (defun viper-translate-all-ESC-keysequences () nil)

then I get horrible behavior over slow ssh connections and the like or
when I type commands quickly after ESC.  Given my typing, there just
doesn't seem to be any timing heuristic that reliably differentiates
ESC from Meta, and this drove me nuts for years until I enabled a
proper meta key.

Thanks for any help.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]