From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ken manheimer Newsgroups: gmane.emacs.devel Subject: Re: bizarre problem with minor mode defined using define-minor-mode Date: Sun, 16 Jan 2011 01:15:33 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1295158567 24611 80.91.229.12 (16 Jan 2011 06:16:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 16 Jan 2011 06:16:07 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 16 07:16:03 2011 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 1PeLuD-0005Qi-DY for ged-emacs-devel@m.gmane.org; Sun, 16 Jan 2011 07:16:01 +0100 Original-Received: from localhost ([127.0.0.1]:57491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PeLuC-0000Vj-Kq for ged-emacs-devel@m.gmane.org; Sun, 16 Jan 2011 01:16:00 -0500 Original-Received: from [140.186.70.92] (port=57409 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PeLu4-0000Va-7x for emacs-devel@gnu.org; Sun, 16 Jan 2011 01:15:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PeLu1-0006IX-AG for emacs-devel@gnu.org; Sun, 16 Jan 2011 01:15:52 -0500 Original-Received: from mail-ww0-f49.google.com ([74.125.82.49]:34291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PeLu1-0006IL-57 for emacs-devel@gnu.org; Sun, 16 Jan 2011 01:15:49 -0500 Original-Received: by wwb17 with SMTP id 17so4216613wwb.30 for ; Sat, 15 Jan 2011 22:15:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=rOTqoQH5bepunlLNsXuLt/ZbObrHS7oRQXCYsBeFQ78=; b=qg+q7LMjfe3Qanno2IT+1vlg6702D+6Cm/Yl3+PFkZXOCDF4x4oOsJLD9FRCfUHrRb iF9SJmtnqHmsZrieEcgpQlC9uiD/vQHVONepIEiBHligZd1ukJ9m0RNxrTKChg7ynzTe b0SluXeHsXx3Ko4GrNzBZhy95ap6pH8r9AQds= 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=uWbHsHtNtvXO13upOnMP8VuWLGgBPfcQ9vTayLMTG+qVue4YbCAfB7VBBE1EhbpuYb ecgY2GXEjPtv5KzQbh/tqKuCRzV7xiLm50BKkai05Xmf0TencfKbu9XXP/2egG3oImRV zb9oS3GBtT6k2rLy0B6G8biLym36gfPTYyrfc= Original-Received: by 10.216.87.131 with SMTP id y3mr1263289wee.3.1295158548305; Sat, 15 Jan 2011 22:15:48 -0800 (PST) Original-Received: by 10.216.71.14 with HTTP; Sat, 15 Jan 2011 22:15:33 -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:134593 Archived-At: On Sat, Jan 15, 2011 at 11:48 PM, Stefan Monnier wrote: >> i agree that the code is painfully complicated. =A0however, the fset >> actually is effective and necessary to impose the minor-mode keymap >> adjustments allout does. > > I really can't understand who it could be effective. =A0My reading of the > code tells me that function binding is never used. (elisp)Format of Keymaps: "A symbol whose function definition is a keymap is also a keymap." minor-mode-map-alist entries of the form `(allout-mode . allout-mode-map)' apparently tells the emacs key resolution facility to look in the function value of the symbol in the cdr. that's why the fset i do works. >> in fact, removing the fset leads to the same problems with the >> regular, defun'ed allout-mode that i have been seeing with the >> byte-compiled define-minor-mode defined allout mode. > > That's what I would expect, since I think this fset is a no-op. it's not a no-op! as i said before, removing the fset changed behavior. as i describe above, there's an explanation. >> the problem with switching to define-minor-mode is that >> define-minor-mode apparently associates the mode name with the keymap >> value, itself, on minor-mode-map-alist. > > That's because that's what you told it: > > =A0:keymap > > says to use the value of as the keymap, so ":keymap > allout-mode-map" says to use the value of the variable as the keymap. > If you want to use a symbol, then you need to quote it. alas, that's apparently not so: (defvar example-mode-map (make-sparse-keymap)) =3D> example-mode-map (define-key example-mode-map "\C-cv" 'emacs-version) =3D> emacs-version (assq 'example-mode minor-mode-map-alist) =3D> nil (define-minor-mode example-mode "example-mode docstring." :keymap 'example-mode-map nil) =3D> (keymap (3 keymap (118 . emacs-version))) (assq 'example-mode minor-mode-map-alist) =3D> (example-mode keymap (3 keymap (118 . emacs-version))) (it's helpful to discover that just executing the define-minor-mode establishes the keymap in minor-mode-map-alist. i didn't expect that. actually activating the mode doesn't change the situation.) > This said, you can modify a keymap after the fact: as long as you don't > do a (setq allout-mode-map ), you can modify allout-mode-map on > the fly and those changes will take effect immediately without having to > use an indirection through the allout-mode-map symbol. are you suggesting doing a rplacd on the minor-mode-map-alist cell? i guess that's better than the fset approach, since for the latter, in addition to doing the obscure fset, i also have to do surgery to remove the keymap that define-minor-mode puts on minor-mode-map-alist (whether i provide :keymap with a keymap or a symbol). > =A0 =A0 =A0 =A0Stefan