unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: Rant: key sequences aren't specified in the elisp manual.
Date: Thu, 17 Nov 2005 16:19:39 -0700	[thread overview]
Message-ID: <dlj36f$qqm$1@sea.gmane.org> (raw)
In-Reply-To: <Pine.LNX.3.96.1051117222258.317B-100000@acm.acm>

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)

and

|    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
manual.

 > 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

  parent reply	other threads:[~2005-11-17 23:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-17 22:29 Rant: key sequences aren't specified in the elisp manual Alan Mackenzie
2005-11-17 23:17 ` Edward O'Connor
2005-11-19 15:48   ` Portable key sequences [was: key sequences aren't specified...] Stephen J. Turnbull
2005-11-20 17:07     ` Portable key sequences Stefan Monnier
2005-11-17 23:19 ` Rant: key sequences aren't specified in the elisp manual Lennart Borgman
2005-11-17 23:19 ` Kevin Rodgers [this message]
2005-11-17 23:30   ` Drew Adams
2005-11-19 23:26 ` Richard M. Stallman
2005-11-27  0:31 ` Richard Stallman
2005-12-11  5:03 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='dlj36f$qqm$1@sea.gmane.org' \
    --to=ihs_4664@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).