GNU bug report logs - #7803
23.1; Need better definition of vector notation in define-key

Previous Next

Package: emacs;

Reported by: <cppljevans <at> suddenlink.net>

Date: Fri, 7 Jan 2011 21:12:02 UTC

Severity: minor

Found in version 23.1

Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Larry Evans <cppljevans <at> suddenlink.net>
To: bug-gnu-emacs <at> gnu.org
Subject: bug#7803: 23.1; Need better definition of vector notation in define-key
Date: Fri, 07 Jan 2011 21:08:09 -0600
On 01/07/11 19:50, Glenn Morris wrote:
> Larry Evans wrote:
> 
>> Ah, so when it says:
>>
>>   If KEY is `[t]', this sets the default binding in KEYMAP.
>>
>> it means:
> 
> You're overthinking it. It means literally what it says: a vector with
> a single element `t'. Not a vector with any other contents.
> `t' in Emacs documentation always means the special symbol `t', for truth.

Ah. OK.  So if the KEY in

  (define-key KEYMAP KEY BINDING)

is `[t]', then BINDING is ignored, and, I guess, the default binding for
*all* keys in KEYMAP are set to the default binding?  I guess the
"default binding" is self-insert, IOW.

OOPS, now.  I finally went to help, entered define-key, and got:

> define-key is a built-in function in `C source code'.
> 
> (define-key keymap key def)
> 
> In keymap, define key sequence key as def.
> keymap is a keymap.
> 
> key is a string or a vector of symbols and characters meaning a
> sequence of keystrokes and events.  Non-ASCII characters with codes
> above 127 (such as ISO Latin-1) can be included if you use a vector.
> Using [t] for key creates a default definition, which applies to any
> event type that has no other definition in this keymap.

which finally cleared things up.  This tells me that after:

  (define KEYMAP [t] DEFAULT_BINDING)

then any key, KEY, which has *not* occurred in a call:

  (define-key KEYMAP KEY def)

for some value of def, has the DEFAULT_BINDING in KEYMAP.

Is that right?

> 
> Rather than reading the Lispref, the Emacs manual offers a better
> introduction to key bindings for the purposes of user customization.
> 
> (I admit I couldn't see a clear mention of "S-" = "shift" there, though.)
> 

After fishing around the manual, I found it in the info node, "Other
Char Bits" which contains:

  The Lisp syntax for the shift bit is `\S-'; thus, `?\C-\S-o' or
  `?\C-\S-O' represents the shifted-control-o character.

The ? was a bit  mysterious at first, but more fishing showed
me what it meant, but I don't remember where that info node is.








This bug report was last modified 13 years and 311 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.