* Defining key onto copied global map problem
@ 2009-02-24 9:19 Tomohiro MATSUYAMA
2009-02-24 22:14 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Tomohiro MATSUYAMA @ 2009-02-24 9:19 UTC (permalink / raw)
To: emacs-devel
Hi, all
I faced a problem when I define a key onto the copied global map.
After executing following code:
(define-key (copy-keymap (current-global-map)) (kbd "M-c") 'ignore)
"M-c" won't work and just ignores.
I expected that "M-c" just works as defined in (current-global-map).
I'm using:
GNU Emacs 23.0.60.1 (i386-apple-darwin9.6.0, NS apple-appkit-949.43)
of 2009-01-27 on macbook.local
Regards,
MATSUYAMA Tomohiro
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Defining key onto copied global map problem
2009-02-24 9:19 Defining key onto copied global map problem Tomohiro MATSUYAMA
@ 2009-02-24 22:14 ` Stefan Monnier
2009-02-24 22:39 ` David Reitter
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2009-02-24 22:14 UTC (permalink / raw)
To: Tomohiro MATSUYAMA; +Cc: emacs-devel
> (define-key (copy-keymap (current-global-map)) (kbd "M-c") 'ignore)
This creates a new keymap (of same content as the global map), modifies
it and then throws it away.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Defining key onto copied global map problem
2009-02-24 22:14 ` Stefan Monnier
@ 2009-02-24 22:39 ` David Reitter
2009-02-25 0:11 ` Miles Bader
0 siblings, 1 reply; 5+ messages in thread
From: David Reitter @ 2009-02-24 22:39 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Tomohiro MATSUYAMA, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 877 bytes --]
On 24 Feb 2009, at 17:14, Stefan Monnier wrote:
>> (define-key (copy-keymap (current-global-map)) (kbd "M-c")
>> 'ignore)
>
> This creates a new keymap (of same content as the global map),
> modifies
> it and then throws it away.
Which is why changing the copy of the keymap should have no effect -
but it does. I reproduce on Emacs 22.
Note that
(define-key (copy-keymap (current-global-map)) (kbd "x") 'ignore)
works as expected, i.e. it does nothing.
"x" is in my global key-map, while M-c isn't bound there.
I also tried something like
(setcdr (copy-keymap (current-global-map)) '(foo))
which doesn't do anything to the global keymap either, so failing to
copy the tail isn't the problem.
Further, note that the M-c binding doesn't show up in the original
global map after the define-key call above; however, the binding
becomes effective.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2193 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Defining key onto copied global map problem
2009-02-24 22:39 ` David Reitter
@ 2009-02-25 0:11 ` Miles Bader
2009-02-25 4:54 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Miles Bader @ 2009-02-25 0:11 UTC (permalink / raw)
To: emacs-devel
David Reitter <david.reitter@gmail.com> writes:
>>> (define-key (copy-keymap (current-global-map)) (kbd "M-c") 'ignore)
>
> Which is why changing the copy of the keymap should have no effect -
> but it does. I reproduce on Emacs 22.
>
> Note that
> (define-key (copy-keymap (current-global-map)) (kbd "x") 'ignore)
> works as expected, i.e. it does nothing.
I think the reason is that global meta bindings are looked up in the
ESC-prefix map, which is referenced in the top-level keymap using a
symbolic reference, not as an embedded keymap.
Even if copy-keymap recursively copies embedded keymaps, it does not
seem to recursively copy such symbolic references (which makes sense I
suppose).
(lookup-key (current-global-map) "\e") => ESC-prefix
-Miles
--
Patience, n. A minor form of despair, disguised as a virtue.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Defining key onto copied global map problem
2009-02-25 0:11 ` Miles Bader
@ 2009-02-25 4:54 ` Stefan Monnier
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2009-02-25 4:54 UTC (permalink / raw)
To: Miles Bader; +Cc: emacs-devel
> Even if copy-keymap recursively copies embedded keymaps, it does not
> seem to recursively copy such symbolic references (which makes sense I
> suppose).
> (lookup-key (current-global-map) "\e") => ESC-prefix
Indeed.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-02-25 4:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-24 9:19 Defining key onto copied global map problem Tomohiro MATSUYAMA
2009-02-24 22:14 ` Stefan Monnier
2009-02-24 22:39 ` David Reitter
2009-02-25 0:11 ` Miles Bader
2009-02-25 4:54 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.