* key-binding values
@ 2005-09-06 15:50 Drew Adams
2005-09-06 16:26 ` Andreas Schwab
0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2005-09-06 15:50 UTC (permalink / raw)
Consider these two definitions:
(defcustom my-key [?\C-\ ] "My key sequence.")
(defcustom my-key "\C- " "My key sequence.")
`C-h v' then gives these values: [67108896] and "^@".
Is this as good as can be expected - is there no way to get something more
readable for [?\C-\ ]? 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.
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. If so, that
makes matters worse in cases like this.
This form is good:
(defcustom my-key [(control ?\ )] "My key sequence.")
`C-h v' then gives [(control 32)], which is even clearer than "^@".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: key-binding values
2005-09-06 15:50 key-binding values Drew Adams
@ 2005-09-06 16:26 ` Andreas Schwab
2005-09-06 17:15 ` Drew Adams
2005-09-07 5:05 ` Richard M. Stallman
0 siblings, 2 replies; 6+ messages in thread
From: Andreas Schwab @ 2005-09-06 16:26 UTC (permalink / raw)
Cc: Emacs-Devel
"Drew Adams" <drew.adams@oracle.com> writes:
> Consider these two definitions:
>
> (defcustom my-key [?\C-\ ] "My key sequence.")
> (defcustom my-key "\C- " "My key sequence.")
>
> `C-h v' then gives these values: [67108896] and "^@".
>
> 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-@"
> 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.
> 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.
> If so, that makes matters worse in cases like this.
>
> This form is good:
>
> (defcustom my-key [(control ?\ )] "My key sequence.")
(key-description [(control ?\ )]) => "C-SPC"
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: key-binding values
2005-09-06 16:26 ` Andreas Schwab
@ 2005-09-06 17:15 ` Drew Adams
2005-09-06 22:14 ` Andreas Schwab
2005-09-07 5:05 ` Richard M. Stallman
1 sibling, 1 reply; 6+ messages in thread
From: Drew Adams @ 2005-09-06 17:15 UTC (permalink / raw)
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: key-binding values
2005-09-06 17:15 ` Drew Adams
@ 2005-09-06 22:14 ` Andreas Schwab
2005-09-06 22:51 ` Edward O'Connor
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2005-09-06 22:14 UTC (permalink / raw)
Cc: Emacs-Devel
"Drew Adams" <drew.adams@oracle.com> writes:
> > 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.
IMHO there is no real preference. The string notation can only represent
a limited set of keys, but is easier to read when it works.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: key-binding values
2005-09-06 22:14 ` Andreas Schwab
@ 2005-09-06 22:51 ` Edward O'Connor
0 siblings, 0 replies; 6+ messages in thread
From: Edward O'Connor @ 2005-09-06 22:51 UTC (permalink / raw)
> IMHO there is no real preference. The string notation can only
> represent a limited set of keys, but is easier to read when it works.
This is why I always use the (kbd "...") notation: represents all keys,
and is more readable than the other options.
Ted
--
Edward O'Connor
hober0@gmail.com
Ense petit placidam sub libertate quietem.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: key-binding values
2005-09-06 16:26 ` Andreas Schwab
2005-09-06 17:15 ` Drew Adams
@ 2005-09-07 5:05 ` Richard M. Stallman
1 sibling, 0 replies; 6+ messages in thread
From: Richard M. Stallman @ 2005-09-07 5:05 UTC (permalink / raw)
Cc: drew.adams, emacs-devel
(key-description [67108896]) => "C-SPC"
(key-description "\C- ") => "C-@"
> 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.
It would be feasible to define a custom type that would
display these vectors or strings of integers in a way
that is convenient when they are really key sequences.
It could be called `key-sequence'.
I don't plan to do this myself.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-09-07 5:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-06 15:50 key-binding values Drew Adams
2005-09-06 16:26 ` Andreas Schwab
2005-09-06 17:15 ` Drew Adams
2005-09-06 22:14 ` Andreas Schwab
2005-09-06 22:51 ` Edward O'Connor
2005-09-07 5:05 ` Richard M. Stallman
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).