Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: xterm meta and bindkey



On Mon, Nov 10, 2008 at 05:06:58PM +0900, lord_fleg@xxxxxxxxxxxx wrote:
[...]
> bindkey '\C-g' describe-key-briefly
> 
> then hit CTRL-g and then when it prompts me hit META-d
> the response is "\M-C" is capitalize-word.
> 
> if i hit CTRL-g and META-<any key at all> i get the same (\M-C) response.
> 
> if i type 'read' and META-d i get the 8 bit character i expect echo'd.
> 
> if i type 'bash' and hit META-d i get the 8 bit character i expect echo'd.
> 
> i'm confused.  anyone got any ideas?
[...]

What do you get if you run

od -tx1

then type <Meta-d> and then <Ctrl-D><Ctrl-D>

What do the "locale" and "locale charmap" commands output for
you?

What do you get if you type: <Meta-d> after having run
strace -p $$ &

My suspicion is that upon <Meta-d>, your terminal doesn't send
the <Meta-d> byte (d | 0x80 == 0xc4) but the utf8 sequence that
corresponds to the unicode character <Meta-d>.

~$ echo -n '\xc4' | recode ..u8 | od -tx1
0000000 c3 84
0000002

And c3 being the <Meta-c> byte.

I wouldn't use Meta this way. I would tell xterm to send <Esc>x
upon <Meta-x> instead of sending the character <meta-x> (or its
utf8 representation). <Meta-i> is the é character in the
iso8859-1 charset but in utf8 does not correspond to any valid
character by itself which is probably why xterm chose to send
the utf8 sequence.

I suspect newer versions of zsh with multibyte charset support
would decode that c3 84 correctly into the <Meta-i> character as
long as you tell it that your terminal talks utf8 (by making
sure locale charmap returns utf8). So it may work as you expect
in newer zsh versions.

-- 
Stéphane



Messages sorted by: Reverse Date, Date, Thread, Author