emacs-devel
[Top][All Lists]
Advanced

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

Re: kbd vs read-key-sequence


From: Stefan Monnier
Subject: Re: kbd vs read-key-sequence
Date: Mon, 05 Mar 2007 12:10:00 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.93 (gnu/linux)

>     On the other side of the problem we have code written in the .emacs
>     file which tries to bind something to this key.  To work, this has to
>     satisfy the condition that when Emacs loads the .emacs file, the key
>     it finds in the define-key call corresponds to the form of the event
>     after key-translation-map (but before unibyte-char-to-multibyte if
>     applicable).

> Except for the case of unibyte characters, that is the same as the
> character that gets inserted in the buffer if you type the character,
> right?  So it should be possible to type in the character code that
> C-x = shows you, right?

Almost:
1 - the unibyte case is very common, so the "exception" is important.
2 - there's also translation-table-for-input.  I had suggested to apply this
    directly in read-char but it was rejected, so it's still applied much
    later, in self-insert-command (and a few other commands).

> And you should also be able to insert that character in .emacs,
> then save it in whichever coding system.  Why won't that work?

Off the top of my head:
- saving may change the char thanks to unify-8859-on-encoding
  (e.g. you copy a iso-8859-15 char to your .emacs which you then save in
  iso-8859-1).
- the coding-system may not be properly detected, especially if you
  configure your auto-dtection in your .emacs: the configuration will apply
  to all files you open but not to the loading of .emacs

>     And if you want it to work with modifiers, it's yet a bit more
>     interesting because the base-event is not always decoded
> I don't understand that.  What does it mean to "decode the base-event"?

Turn ?\M-<encoded-é> into ?\M-é.

> Anyway, if you want to bind a character with modifiers, you can just use
> a construct in .emacs that applies the modifier to the desired base
> character, such as \M- in a string, or (meta CHAR).

> Is there a case where that doesn't work?

Because the way the event is decoded through read-key-sequence is not
necessarily the same.  E.g. while ?<encoded-é> may get turned into ?é, it
may be the case that ?\M-<encoded-é> stays unchanged.


        Stefan




reply via email to

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