unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#2179: 23.0.60; define-key vs define-key-after key syntax
@ 2009-02-03  7:31 Gerard Brunick
  2011-09-11 21:18 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 9+ messages in thread
From: Gerard Brunick @ 2009-02-03  7:31 UTC (permalink / raw)
  To: emacs-pretest-bug

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






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2179: 23.0.60; define-key vs define-key-after key syntax
  2009-02-03  7:31 bug#2179: 23.0.60; define-key vs define-key-after key syntax Gerard Brunick
@ 2011-09-11 21:18 ` Lars Magne Ingebrigtsen
  2011-09-11 21:48   ` Andreas Schwab
  0 siblings, 1 reply; 9+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-11 21:18 UTC (permalink / raw)
  To: Gerard Brunick; +Cc: 2179

Gerard Brunick <gbrunick@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/





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2179: 23.0.60; define-key vs define-key-after key syntax
  2011-09-11 21:18 ` Lars Magne Ingebrigtsen
@ 2011-09-11 21:48   ` Andreas Schwab
  2011-09-11 22:22     ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Schwab @ 2011-09-11 21:48 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 2179, Gerard Brunick

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Gerard Brunick <gbrunick@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@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2179: 23.0.60; define-key vs define-key-after key syntax
  2011-09-11 21:48   ` Andreas Schwab
@ 2011-09-11 22:22     ` Lars Magne Ingebrigtsen
  2011-09-12  7:48       ` Andreas Schwab
  0 siblings, 1 reply; 9+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-11 22:22 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 2179, Gerard Brunick

Andreas Schwab <schwab@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/





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2179: 23.0.60; define-key vs define-key-after key syntax
  2011-09-11 22:22     ` Lars Magne Ingebrigtsen
@ 2011-09-12  7:48       ` Andreas Schwab
  2011-09-12  7:59         ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 9+ messages in thread
From: Andreas Schwab @ 2011-09-12  7:48 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 2179, Gerard Brunick

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2179: 23.0.60; define-key vs define-key-after key syntax
  2011-09-12  7:48       ` Andreas Schwab
@ 2011-09-12  7:59         ` Lars Magne Ingebrigtsen
  2011-09-12  8:14           ` Andreas Schwab
  2011-10-05  5:08           ` Glenn Morris
  0 siblings, 2 replies; 9+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-12  7:59 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 2179, Gerard Brunick

Andreas Schwab <schwab@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/





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2179: 23.0.60; define-key vs define-key-after key syntax
  2011-09-12  7:59         ` Lars Magne Ingebrigtsen
@ 2011-09-12  8:14           ` Andreas Schwab
  2011-10-05  5:08           ` Glenn Morris
  1 sibling, 0 replies; 9+ messages in thread
From: Andreas Schwab @ 2011-09-12  8:14 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 2179, Gerard Brunick

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2179: 23.0.60; define-key vs define-key-after key syntax
  2011-09-12  7:59         ` Lars Magne Ingebrigtsen
  2011-09-12  8:14           ` Andreas Schwab
@ 2011-10-05  5:08           ` Glenn Morris
  2011-10-06 19:16             ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 9+ messages in thread
From: Glenn Morris @ 2011-10-05  5:08 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 2179, Gerard Brunick, Andreas Schwab

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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2179: 23.0.60; define-key vs define-key-after key syntax
  2011-10-05  5:08           ` Glenn Morris
@ 2011-10-06 19:16             ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 9+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-10-06 19:16 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 2179, Gerard Brunick, Andreas Schwab

Glenn Morris <rgm@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/





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-10-06 19:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-03  7:31 bug#2179: 23.0.60; define-key vs define-key-after key syntax Gerard Brunick
2011-09-11 21:18 ` Lars Magne Ingebrigtsen
2011-09-11 21:48   ` Andreas Schwab
2011-09-11 22:22     ` Lars Magne Ingebrigtsen
2011-09-12  7:48       ` Andreas Schwab
2011-09-12  7:59         ` Lars Magne Ingebrigtsen
2011-09-12  8:14           ` Andreas Schwab
2011-10-05  5:08           ` Glenn Morris
2011-10-06 19:16             ` Lars Magne Ingebrigtsen

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