GNU bug report logs - #2179
23.0.60; define-key vs define-key-after key syntax

Previous Next

Package: emacs;

Reported by: Gerard Brunick <gbrunick <at> math.utexas.edu>

Date: Tue, 3 Feb 2009 07:40:04 UTC

Severity: minor

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

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 2179 in the body.
You can then email your comments to 2179 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2179; Package emacs. (Tue, 03 Feb 2009 07:40:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gerard Brunick <gbrunick <at> math.utexas.edu>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 03 Feb 2009 07:40:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Gerard Brunick <gbrunick <at> math.utexas.edu>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.0.60; define-key vs define-key-after key syntax
Date: Tue, 03 Feb 2009 01:31:34 -0600
This may or may not be a bug, but it caused me some pain, so I am 
pointing it out.

(define-key my-map [(control l)] 'do-something)

works as expected, but

(define-key-after my-map [(control l)] 'do-something)

does not.  The reason is that define-key does a lot of work to allow
for a wide range of key syntaxes, but define-key-after just does:

(setq key
     (if (<= (length key) 1) (aref key 0) ...

and (control l) must get mapped to ?\C-l = 12 to be useful in a keymap.
As I say, I'm not sure this is a bug, but it was rather
counter-intuitive to me, so maybe a warning to this effect in the
documentation for define-key-after would be sufficient.  The current
documentation says "... This is like `define-key' except that the binding
for KEY is placed just after the binding for the event AFTER ..."

Cheers,
Gerard




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2179; Package emacs. (Sun, 11 Sep 2011 21:32:03 GMT) Full text and rfc822 format available.

Message #8 received at 2179 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Gerard Brunick <gbrunick <at> math.utexas.edu>
Cc: 2179 <at> debbugs.gnu.org
Subject: Re: 23.0.60; define-key vs define-key-after key syntax
Date: Sun, 11 Sep 2011 23:18:20 +0200
Gerard Brunick <gbrunick <at> math.utexas.edu> writes:

> (define-key my-map [(control l)] 'do-something)
>
> works as expected, but
>
> (define-key-after my-map [(control l)] 'do-something)
>
> does not.  The reason is that define-key does a lot of work to allow
> for a wide range of key syntaxes, but define-key-after just does:
>
> (setq key
>      (if (<= (length key) 1) (aref key 0) ...
>
> and (control l) must get mapped to ?\C-l = 12 to be useful in a keymap.

Yes, you'd expect both key's to allow the same syntax.  However, as far
as I can see, all the magic to translate from the `define-key' key
syntax is inside that C function, so that would have to be refactored
out first.  I think.

`define-key-after' should at least document the restricted key syntax it
allows... 

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2179; Package emacs. (Sun, 11 Sep 2011 21:54:01 GMT) Full text and rfc822 format available.

Message #11 received at 2179 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Cc: 2179 <at> debbugs.gnu.org, Gerard Brunick <gbrunick <at> math.utexas.edu>
Subject: Re: bug#2179: 23.0.60; define-key vs define-key-after key syntax
Date: Sun, 11 Sep 2011 23:48:49 +0200
Lars Magne Ingebrigtsen <larsi <at> gnus.org> writes:

> Gerard Brunick <gbrunick <at> math.utexas.edu> writes:
>
>> (define-key my-map [(control l)] 'do-something)
>>
>> works as expected, but
>>
>> (define-key-after my-map [(control l)] 'do-something)
>>
>> does not.  The reason is that define-key does a lot of work to allow
>> for a wide range of key syntaxes, but define-key-after just does:
>>
>> (setq key
>>      (if (<= (length key) 1) (aref key 0) ...
>>
>> and (control l) must get mapped to ?\C-l = 12 to be useful in a keymap.
>
> Yes, you'd expect both key's to allow the same syntax.  However, as far
> as I can see, all the magic to translate from the `define-key' key
> syntax is inside that C function, so that would have to be refactored
> out first.  I think.

Since define-key-after is only useful for menu-bar bindings which don't
use characters in keys this doesn't look like a serious restriction.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2179; Package emacs. (Sun, 11 Sep 2011 22:31:01 GMT) Full text and rfc822 format available.

Message #14 received at 2179 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 2179 <at> debbugs.gnu.org, Gerard Brunick <gbrunick <at> math.utexas.edu>
Subject: Re: bug#2179: 23.0.60; define-key vs define-key-after key syntax
Date: Mon, 12 Sep 2011 00:22:43 +0200
Andreas Schwab <schwab <at> linux-m68k.org> writes:

> Since define-key-after is only useful for menu-bar bindings which don't
> use characters in keys this doesn't look like a serious restriction.

The doc string of `define-key-after' doesn't say that it's only for
menu-bar bindings.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2179; Package emacs. (Mon, 12 Sep 2011 07:54:02 GMT) Full text and rfc822 format available.

Message #17 received at 2179 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Cc: 2179 <at> debbugs.gnu.org, Gerard Brunick <gbrunick <at> math.utexas.edu>
Subject: Re: bug#2179: 23.0.60; define-key vs define-key-after key syntax
Date: Mon, 12 Sep 2011 09:48:50 +0200
Lars Magne Ingebrigtsen <larsi <at> gnus.org> writes:

> Andreas Schwab <schwab <at> linux-m68k.org> writes:
>
>> Since define-key-after is only useful for menu-bar bindings which don't
>> use characters in keys this doesn't look like a serious restriction.
>
> The doc string of `define-key-after' doesn't say that it's only for
> menu-bar bindings.

define-key-after is a compiled Lisp function in `subr.el'.
[...]
The order of bindings in a keymap matters when it is used as a menu.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2179; Package emacs. (Mon, 12 Sep 2011 08:08:02 GMT) Full text and rfc822 format available.

Message #20 received at 2179 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 2179 <at> debbugs.gnu.org, Gerard Brunick <gbrunick <at> math.utexas.edu>
Subject: Re: bug#2179: 23.0.60; define-key vs define-key-after key syntax
Date: Mon, 12 Sep 2011 09:59:10 +0200
Andreas Schwab <schwab <at> linux-m68k.org> writes:

>>> Since define-key-after is only useful for menu-bar bindings which don't
>>> use characters in keys this doesn't look like a serious restriction.
>>
>> The doc string of `define-key-after' doesn't say that it's only for
>> menu-bar bindings.
>
> define-key-after is a compiled Lisp function in `subr.el'.
> [...]
> The order of bindings in a keymap matters when it is used as a menu.

So?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#2179; Package emacs. (Mon, 12 Sep 2011 08:19:02 GMT) Full text and rfc822 format available.

Message #23 received at 2179 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Cc: 2179 <at> debbugs.gnu.org, Gerard Brunick <gbrunick <at> math.utexas.edu>
Subject: Re: bug#2179: 23.0.60; define-key vs define-key-after key syntax
Date: Mon, 12 Sep 2011 10:14:13 +0200
Lars Magne Ingebrigtsen <larsi <at> gnus.org> writes:

> Andreas Schwab <schwab <at> linux-m68k.org> writes:
>
>>>> Since define-key-after is only useful for menu-bar bindings which don't
>>>> use characters in keys this doesn't look like a serious restriction.
>>>
>>> The doc string of `define-key-after' doesn't say that it's only for
>>> menu-bar bindings.
>>
>> define-key-after is a compiled Lisp function in `subr.el'.
>> [...]
>> The order of bindings in a keymap matters when it is used as a menu.
>
> So?

Yes.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2179; Package emacs. (Wed, 05 Oct 2011 05:09:02 GMT) Full text and rfc822 format available.

Message #26 received at 2179 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Cc: 2179 <at> debbugs.gnu.org, Gerard Brunick <gbrunick <at> math.utexas.edu>,
	Andreas Schwab <schwab <at> linux-m68k.org>
Subject: Re: bug#2179: 23.0.60; define-key vs define-key-after key syntax
Date: Wed, 05 Oct 2011 01:08:13 -0400
Lars Magne Ingebrigtsen wrote:

>>> The doc string of `define-key-after' doesn't say that it's only for
>>> menu-bar bindings.
>>
>> define-key-after is a compiled Lisp function in `subr.el'.
>> [...]
>> The order of bindings in a keymap matters when it is used as a menu.
>
> So?

Perhaps the point was supposed to be that the order of the elements in a
keymap ONLY matters in a menu, therefore there is no point to use
define-key-after with anything other then menu entries, therefore
define-key-after does not need to be extended to handle the same range
of key syntax that define-key can, therefore this is just a
documentation bug for define-key-after.




bug closed, send any further explanations to 2179 <at> debbugs.gnu.org and Gerard Brunick <gbrunick <at> math.utexas.edu> Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 06 Oct 2011 19:17:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#2179; Package emacs. (Thu, 06 Oct 2011 19:18:01 GMT) Full text and rfc822 format available.

Message #31 received at 2179 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 2179 <at> debbugs.gnu.org, Gerard Brunick <gbrunick <at> math.utexas.edu>,
	Andreas Schwab <schwab <at> linux-m68k.org>
Subject: Re: bug#2179: 23.0.60; define-key vs define-key-after key syntax
Date: Thu, 06 Oct 2011 21:16:34 +0200
Glenn Morris <rgm <at> gnu.org> writes:

> Perhaps the point was supposed to be that the order of the elements in a
> keymap ONLY matters in a menu, therefore there is no point to use
> define-key-after with anything other then menu entries, therefore
> define-key-after does not need to be extended to handle the same range
> of key syntax that define-key can, therefore this is just a
> documentation bug for define-key-after.

I totally misunderstood what the function was meant to do.  :-) 

I've now just clarified the doc string and am closing the report.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 04 Nov 2011 11:24:04 GMT) Full text and rfc822 format available.

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

Previous Next


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