[Top][All Lists]

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

Re: Rant: key sequences aren't specified in the elisp manual.

From: Kevin Rodgers
Subject: Re: Rant: key sequences aren't specified in the elisp manual.
Date: Thu, 17 Nov 2005 16:19:39 -0700
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

Alan Mackenzie wrote:
> I've just spent ~ 2 hours trying to figure out from the elisp manual the
> various ways of binding the key sequence "control-C control-backspace".
> This is written in such an abstruse and unclear way in the elisp manual
> (page "Changing Key Bindings") that it's probably easier to try every
> vaguely plausible combination than to try to figure it out from the
> manual.

I think you would have had more luck if you'd started with the Emacs
manual.  The "Init Rebinding" node (aka Rebinding Keys in Your Init
File) says:

|    The simplest method for doing this works for ASCII characters and
| Meta-modified ASCII characters only.  This method uses a string to
| represent the key sequence you want to rebind.  For example, here's how
| to bind `C-z' to `shell':
|      (global-set-key "\C-z" 'shell)


|    When the key sequence includes function keys or mouse button events,
| or non-ASCII characters such as `C-=' or `H-a', you must use the more
| general method of rebinding, which uses a vector to specify the key
| sequence.
|    The way to write a vector in Emacs Lisp is with square brackets
| around the vector elements.  Use spaces to separate the elements.  If an
| element is a symbol, simply write the symbol's name--no other
| delimiters or punctuation are needed.  If a vector element is a
| character, write it as a Lisp character constant: `?' followed by the
| character as it would appear in a string.

followed by several examples.

> In fact, I figured out "[?\C-c \C-backspace]" by just such
> experimentation.  Trouble is, this is rejected by XEmacs, and I want the
> specification to be portable.  So I would like a list of all the ways
> Emacs can do it, so that I can try them one by one in XEmacs.

The "Changing Key Bindings" node of the Emacs Lisp manual says:

|    The key definition and lookup functions accept an alternate syntax
| for event types in a key sequence that is a vector: you can use a list
| containing modifier names plus one base event (a character or function
| key name).  For example, `(control ?a)' is equivalent to `?\C-a' and
| `(hyper control left)' is equivalent to `C-H-left'.  One advantage of
| such lists is that the precise numeric codes for the modifier bits
| don't appear in compiled files.

I don't know why that isn't included in or referenced from the Emacs
manual, or why it doesn't mention that another advantage of the list
syntax is that it's portable to XEmacs.

For your problem, I think the equivalent of "[?\C-c \C-backspace]" is
((control ?c) (control ?\b))


> Where is the list of symbols like `home' that one can use in vectors?
> Would it be too much to expect them either to be listed, or to have an
> @xref to the page where they are listed?  I am confused as to whether
> "backspace" is called "backspace", "del", "BS", "delete", and whether it
> has to be in lower case, upper case, or it doesn't matter.

See the "Function Keys" node (aka Rebinding Function Keys) in the Emacs

> Again, what I would like to see is a "@section Specifying Key Sequences",
> whose meat would look like something like this:

FWIW, I agree.

Kevin Rodgers

reply via email to

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