emacs-devel
[Top][All Lists]
Advanced

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

RE: key-binding values


From: Drew Adams
Subject: RE: key-binding values
Date: Tue, 6 Sep 2005 10:15:03 -0700

    > Is this as good as can be expected - is there no way to get
    something more
    > readable for [?\C-\ ]?

    (key-description [67108896]) => "C-SPC"
    (key-description "\C- ") => "C-@"

Yes, that's what key-description is for. My question was, "is this as good
as can be expected from C-h v in this case?"  I suppose the answer is "yes",
because there is no way for describe-variable to know that this represents a
key sequence and not an arbitrary string or vector.

    > Emacs users learn quickly to read "^@" as "control @", and they also
    > learn that this is equivalent to "control SPC", but [67108896] is hard
    > to read and digest.

    Keys are just integers in Emacs.  There is nothing that makes
    any integer special wrt to keys.

Characters, not key sequences, are integers. Some key sequences are
characters (integers), but others are more complex events. And none of the
ouput expressions "^@", [67108896], and [(control 32)], or the input
expressions "\C- ", [?\C-\ ], and [(control ?\ )], is an integer.

But this point is valid: There is nothing that makes a vector, string etc.
special wrt a key. There is no way for C-h v to know that a given value is
intended to represent a key sequence.

    > Also, correct me if I'm wrong, but my understanding is that
    the form [?\C- ]
    > is generally preferred over the form "\C- ", for a key binding.

    These two key sequences represent quite different bindings.
    You can't get
    one override the other, it depends on the terminal which key you receive
    on typing C-space.

Whenever either is acceptable, is one of the two preferred in Emacs-Lisp
code, for binding keys? My understanding was that the vector form was
preferred.

    > If so, that makes matters worse in cases like this.
    > This form is good:
    >  (defcustom my-key [(control ?\ )] "My key sequence.")

Given all of the above, I would think that [(control ?\ )] should be the
preferred syntax in code, whenever alternatives are equivalent. Both the
source code and the C-h v output are clearer.






reply via email to

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