[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where do you add key bindings for a mode made with define-derived-mo

From: Lennart Borgman
Subject: Re: Where do you add key bindings for a mode made with define-derived-mode
Date: Wed, 29 Dec 2010 19:38:13 +0100

On Wed, Dec 29, 2010 at 4:43 PM, Stefan Monnier
<address@hidden> wrote:
>> Do you do that after the defining the major mode (i.e. when loading
>> the library where it is defined) or is there another way?
> The usual way:
>   (defvar foo-mode-map
>     (let ((map (make-sparse-keymap)))
>       (define-key map foo bar)
>       map))
>   (define-derived-mode foo-mode ...)
> Tho, maybe I simply misunderstood your question.

No, you did not but I seem to misunderstand something. Why does that
work? In the code for define-derived-mode there is:

       (defvar ,map (make-sparse-keymap))

Oh, wait! That is what always has surprised me. This statement does
not do anything when the variable is defined...

Hm, thanks, back to the code I wrote long ago. Now I have one thing
less to look at. But I still can't see how (provide 'nxml-mode) can be
passed without nxml-mode-map being defined. I will have to dig a bit.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]