From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: Re: [CVS] f7, f8 bound.. Date: Mon, 09 Sep 2002 09:35:14 -0400 Sender: emacs-devel-admin@gnu.org Message-ID: <200209091335.g89DZEO18130@rum.cs.yale.edu> References: <20020903130247.GA6318@gnu.org> <20020903173120.GA29981@gnu.org> <87ptvttnyo.fsf@emacswiki.org> <200209061736.g86HaDi00352@rum.cs.yale.edu> <20020906222113.GC7270@gnu.org> <5xelc662nj.fsf@kfs2.cua.dk> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1031578635 16601 127.0.0.1 (9 Sep 2002 13:37:15 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 9 Sep 2002 13:37:15 +0000 (UTC) Cc: Miles Bader , Stefan Monnier , Per Abrahamsen , emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17oOj3-0004Jd-00 for ; Mon, 09 Sep 2002 15:37:13 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17oPJ0-0002wU-00 for ; Mon, 09 Sep 2002 16:14:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17oOj3-0000Yy-00; Mon, 09 Sep 2002 09:37:13 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17oOhI-0000S6-00 for emacs-devel@gnu.org; Mon, 09 Sep 2002 09:35:24 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17oOhC-0000Rk-00 for emacs-devel@gnu.org; Mon, 09 Sep 2002 09:35:23 -0400 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17oOhA-0000Qy-00; Mon, 09 Sep 2002 09:35:16 -0400 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.11.6/8.11.6) id g89DZEO18130; Mon, 9 Sep 2002 09:35:14 -0400 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: storm@cua.dk (Kim F. Storm) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:7745 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:7745 > But what's does it mean to delete a key binding? Right now, I think we can assume it's "defined" by the definition of global-unset-key (which indeed binds the key to nil). > Or should it restore a default key binding from bindings.el ? Huh? We're talking about "any random keymap", so there's no reason why it should have any relationship with bindings.el. For one, the keymap might never be used directly (see vc-prefix-map for an example which is only ever used after the C-x v prefix). > Or is it a combination of the two - if the current key binding > is set from custom, deleting means: remove the custom binding and > restore the default binding; otherwise, remove the default binding. I think you're thinking about "what if the user drops a change?" (either an addition or a removal). In that case, we might indeed want to reset the binding to what it was before custom started to mess with the map. That's indeed the main difficulty. Per's solution is to either rebuild the whole keymap each time (which requires saving its original value somewhere) or use two maps. The "two maps" approach is a possibility. Basically, the idea is to keep the original map as the parent of the actual map. So when custom changes the map, it does: (let ((orig (keymap-parent map))) (setq map (make-sparse-keymap)) (set-keymap-parent map orig) ...add/remove bindings...) The problem is that any changes made to `map' rather than to its parent are lost without regards to whether the changes were made by custom or not. Stefan