From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lennart Borgman Newsgroups: gmane.emacs.devel 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 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1293648080 11592 80.91.229.12 (29 Dec 2010 18:41:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 29 Dec 2010 18:41:20 +0000 (UTC) Cc: Emacs-Devel devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 29 19:41:16 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PY0wg-0001aA-Oc for ged-emacs-devel@m.gmane.org; Wed, 29 Dec 2010 19:41:10 +0100 Original-Received: from localhost ([127.0.0.1]:45424 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PY0vZ-0001RP-QX for ged-emacs-devel@m.gmane.org; Wed, 29 Dec 2010 13:39:13 -0500 Original-Received: from [140.186.70.92] (port=46800 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PY0vK-00012G-PL for emacs-devel@gnu.org; Wed, 29 Dec 2010 13:39:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PY0vH-0006uW-QA for emacs-devel@gnu.org; Wed, 29 Dec 2010 13:38:56 -0500 Original-Received: from mail-ew0-f41.google.com ([209.85.215.41]:59804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PY0vH-0006pJ-Jp for emacs-devel@gnu.org; Wed, 29 Dec 2010 13:38:55 -0500 Original-Received: by ewy27 with SMTP id 27so5782727ewy.0 for ; Wed, 29 Dec 2010 10:38:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=tWxjL+cxl0gWG7/ELKFnL9+4Mkh1rUBvPpEqRPMxSqk=; b=hQFB6QpHsalt+EBRejnXUNCvy8ma11IFucOfnaMUdedtyk5qgFdwBkAwDMIpk3tD5p T7az4LstbzjR2NwG5d4LDkLKXoxmIKCGudb19Y/pggcysXmPVJij+Medm2SNFg2r1gzm bZEw6cehHHouYCzXdVVL7pUb3FZRg02aMXCbQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=jxk76sCDWMlMvFMCiocFndC5+ZoSXVEqGlNCxm089B9EJ6c5+PMkoS6Dm9f4d5xnF7 si3kXpQoZ4utj1q/0A9ZjXXk0GA4SK14LUmhlZXbruIZ5GYzUpbaP4pVXjaCmu8pAprw K8BB86vq0oZxHpW5MJEAbyrLfOKHVmd84s5MI= Original-Received: by 10.213.112.146 with SMTP id w18mr11908772ebp.84.1293647913253; Wed, 29 Dec 2010 10:38:33 -0800 (PST) Original-Received: by 10.213.20.148 with HTTP; Wed, 29 Dec 2010 10:38:13 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:134038 Archived-At: On Wed, Dec 29, 2010 at 4:43 PM, Stefan Monnier 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: > > =C2=A0 (defvar foo-mode-map > =C2=A0 =C2=A0 (let ((map (make-sparse-keymap))) > =C2=A0 =C2=A0 =C2=A0 (define-key map foo bar) > =C2=A0 =C2=A0 =C2=A0 map)) > > =C2=A0 (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.